[pypy-commit] creflect default: Standardize the location and usage of the .c/.h files
arigo
noreply at buildbot.pypy.org
Sat Nov 29 18:14:35 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r121:f71be8e76e58
Date: 2014-11-29 18:10 +0100
http://bitbucket.org/cffi/creflect/changeset/f71be8e76e58/
Log: Standardize the location and usage of the .c/.h files
diff too long, truncating to 2000 out of 2035 lines
diff --git a/creflect/codegen.py b/creflect/codegen.py
--- a/creflect/codegen.py
+++ b/creflect/codegen.py
@@ -65,16 +65,16 @@
decl.write_declaration(funcblock)
if funcblock.crx_type_vars:
- funcblock.writedecl("crx_type_t %s;" % (
+ funcblock.writedecl("_crx_type_t %s;" % (
', '.join(funcblock.crx_type_vars),))
for d1 in funcblock.crx_field_vars:
- funcblock.writedecl("crx_field_t %s;" % d1)
+ funcblock.writedecl("_crx_field_t %s;" % d1)
static_decl = ""
if static:
static_decl = "static "
- outerblock.writeline('%svoid %s(crx_builder_t *cb)' % (static_decl,
- crx_func_name))
+ outerblock.writeline('%svoid %s(_crx_builder_t *cb)' % (static_decl,
+ crx_func_name))
outerblock.write_subblock(funcblock)
outerblock.writeline('') # for the final \n below
return '\n'.join(outerblock.codelines)
diff --git a/creflect/src/creflect.h b/creflect/creflect.h
rename from creflect/src/creflect.h
rename to creflect/creflect.h
--- a/creflect/src/creflect.h
+++ b/creflect/creflect.h
@@ -1,20 +1,20 @@
-#ifndef _CREFLECT_H_
-#define _CREFLECT_H_
+#ifndef _CRX_H_
+#define _CRX_H_
#include <stddef.h>
#include <string.h>
-typedef struct crx_type_s crx_type_t; /* opaque */
-typedef void (*crx_trampoline0_fn)(void *args[], void *res);
-typedef void (*crx_trampoline1_fn)(void *fn, void *args[], void *res);
+typedef struct _crx_type_s _crx_type_t; /* opaque */
+typedef void (*_crx_trampoline0_fn)(void *args[], void *res);
+typedef void (*_crx_trampoline1_fn)(void *fn, void *args[], void *res);
typedef struct {
const char *name;
- crx_type_t *type;
+ _crx_type_t *type;
size_t offset;
int numbits, bitshift;
-} crx_field_t;
+} _crx_field_t;
typedef union {
int as_int;
@@ -27,52 +27,53 @@
float as_float;
double as_double;
long double as_long_double;
-} crx_num_const_t;
+} _crx_num_const_t;
-#define CRX_SELF struct _crx_builder_s *
+#define _CRX_SELF struct _crx_builder_s *
typedef struct _crx_builder_s {
- crx_type_t *(*get_void_type)(CRX_SELF);
- crx_type_t *(*get_char_type)(CRX_SELF);
- crx_type_t *(*get_bool_type)(CRX_SELF);
- crx_type_t *(*get_signed_type)(CRX_SELF, size_t,
+ _crx_type_t *(*get_void_type)(_CRX_SELF);
+ _crx_type_t *(*get_char_type)(_CRX_SELF);
+ _crx_type_t *(*get_bool_type)(_CRX_SELF);
+ _crx_type_t *(*get_signed_type)(_CRX_SELF, size_t,
+ const char *);
+ _crx_type_t *(*get_unsigned_type)(_CRX_SELF, size_t,
+ const char *);
+ _crx_type_t *(*get_float_type)(_CRX_SELF, size_t,
const char *);
- crx_type_t *(*get_unsigned_type)(CRX_SELF, size_t,
- const char *);
- crx_type_t *(*get_float_type)(CRX_SELF, size_t,
- const char *);
- crx_type_t *(*get_function_type)(CRX_SELF, crx_type_t *,
- crx_type_t *[], int, crx_trampoline1_fn);
- crx_type_t *(*get_ellipsis_function_type)(CRX_SELF, crx_type_t *,
- crx_type_t *[], int);
- crx_type_t *(*get_pointer_type)(CRX_SELF, crx_type_t *);
- crx_type_t *(*get_const_type)(CRX_SELF, crx_type_t *);
- crx_type_t *(*get_array_type)(CRX_SELF, crx_type_t *, size_t);
- crx_type_t *(*get_incomplete_array_type)(CRX_SELF, crx_type_t *);
- crx_type_t *(*get_struct_type)(CRX_SELF, const char *);
- crx_type_t *(*get_union_type)(CRX_SELF, const char *);
- crx_type_t *(*get_enum_type)(CRX_SELF, const char *);
- crx_type_t *(*get_user_type)(CRX_SELF, const char *);
- crx_type_t *(*get_unknown_type)(CRX_SELF, const char *);
- void (*complete)(CRX_SELF, crx_type_t *,
- size_t, size_t, crx_field_t[], int);
- void (*complete_enum)(CRX_SELF, crx_type_t *, crx_type_t *);
- void (*define_type)(CRX_SELF, const char *, crx_type_t *);
- void (*define_var)(CRX_SELF, const char *, crx_type_t *,
+ _crx_type_t *(*get_function_type)(_CRX_SELF, _crx_type_t *,
+ _crx_type_t *[], int,
+ _crx_trampoline1_fn);
+ _crx_type_t *(*get_ellipsis_function_type)(_CRX_SELF, _crx_type_t *,
+ _crx_type_t *[], int);
+ _crx_type_t *(*get_pointer_type)(_CRX_SELF, _crx_type_t *);
+ _crx_type_t *(*get_const_type)(_CRX_SELF, _crx_type_t *);
+ _crx_type_t *(*get_array_type)(_CRX_SELF, _crx_type_t *, size_t);
+ _crx_type_t *(*get_incomplete_array_type)(_CRX_SELF, _crx_type_t *);
+ _crx_type_t *(*get_struct_type)(_CRX_SELF, const char *);
+ _crx_type_t *(*get_union_type)(_CRX_SELF, const char *);
+ _crx_type_t *(*get_enum_type)(_CRX_SELF, const char *);
+ _crx_type_t *(*get_user_type)(_CRX_SELF, const char *);
+ _crx_type_t *(*get_unknown_type)(_CRX_SELF, const char *);
+ void (*complete)(_CRX_SELF, _crx_type_t *,
+ size_t, size_t, _crx_field_t[], int);
+ void (*complete_enum)(_CRX_SELF, _crx_type_t *, _crx_type_t *);
+ void (*define_type)(_CRX_SELF, const char *, _crx_type_t *);
+ void (*define_var)(_CRX_SELF, const char *, _crx_type_t *,
void *);
- void (*define_func)(CRX_SELF, const char *, crx_type_t *,
- crx_type_t *[], int, crx_trampoline0_fn, void *);
- void (*define_num_const)(CRX_SELF, const char *, crx_type_t *,
- crx_num_const_t *);
- void (*error)(CRX_SELF, const char *);
-} crx_builder_t;
-#undef CRX_SELF
+ void (*define_func)(_CRX_SELF, const char *, _crx_type_t *,
+ _crx_type_t *[], int, _crx_trampoline0_fn, void *);
+ void (*define_num_const)(_CRX_SELF, const char *, _crx_type_t *,
+ _crx_num_const_t *);
+ void (*error)(_CRX_SELF, const char *);
+} _crx_builder_t;
+#undef _CRX_SELF
-#define CRX_INT_TYPE(cb, expr, guessname) \
- _creflect__int_type(cb, expr > 0, sizeof(expr), expr == 1, guessname)
+#define _CRX_INT_TYPE(cb, expr, guessname) \
+ _crx_int_type(cb, expr > 0, sizeof(expr), expr == 1, guessname)
-#define CRX_INT_CONST(cb, expr, vp, pn) \
- _creflect__int_const(cb, vp, pn, \
+#define _CRX_INT_CONST(cb, expr, vp, pn) \
+ _crx_int_const(cb, vp, pn, \
"integer constant '" #expr "' is too large", \
!(((expr) * 0 + 4) << (sizeof(int)*8-2)), \
!(((expr) * 0L + 4L) << (sizeof(long)*8-2)), \
@@ -81,19 +82,19 @@
(expr) == (long long)(expr), \
(unsigned long long)(expr))
-#define CRX_CHAR_CONST(cb, expr, vp) \
- _creflect__char_const(cb, vp, \
+#define _CRX_CHAR_CONST(cb, expr, vp) \
+ _crx_char_const(cb, vp, \
"char constant '" #expr "' is too large", \
(expr) == (signed char)(expr) || (expr) == (unsigned char)(expr), \
(char)(expr))
-#define CRX_FLOAT_CONST(cb, expr, vp) \
- _creflect__float_const(cb, vp, sizeof(expr), (long double)(expr))
+#define _CRX_FLOAT_CONST(cb, expr, vp) \
+ _crx_float_const(cb, vp, sizeof(expr), (long double)(expr))
__attribute__((unused))
-static crx_type_t *_creflect__int_type(crx_builder_t *cb, int expr_positive,
- size_t size_of_expr, int expr_equal_one,
- const char *guessname)
+static _crx_type_t *_crx_int_type(_crx_builder_t *cb, int expr_positive,
+ size_t size_of_expr, int expr_equal_one,
+ const char *guessname)
{
if (!expr_positive)
return cb->get_signed_type(cb, size_of_expr, guessname);
@@ -104,12 +105,12 @@
}
__attribute__((unused))
-static crx_type_t *_creflect__int_const(crx_builder_t *cb, crx_num_const_t *vp,
- int preference_number,
- const char *toobig,
- int fits_int, int fits_long,
- int unsign, int fits_ull, int fits_ll,
- unsigned long long value)
+static _crx_type_t *_crx_int_const(_crx_builder_t *cb, _crx_num_const_t *vp,
+ int preference_number,
+ const char *toobig,
+ int fits_int, int fits_long,
+ int unsign, int fits_ull, int fits_ll,
+ unsigned long long value)
{
size_t size;
const char *name;
@@ -170,9 +171,9 @@
}
__attribute__((unused))
-static void _creflect__char_const(crx_builder_t *cb, crx_num_const_t *vp,
- const char *toobig,
- int fits_char, char value)
+static void _crx_char_const(_crx_builder_t *cb, _crx_num_const_t *vp,
+ const char *toobig,
+ int fits_char, char value)
{
if (!fits_char)
cb->error(cb, toobig);
@@ -181,9 +182,9 @@
}
__attribute__((unused))
-static crx_type_t *_creflect__float_const(crx_builder_t *cb,
- crx_num_const_t *vp,
- size_t size, long double value)
+static _crx_type_t *_crx_float_const(_crx_builder_t *cb,
+ _crx_num_const_t *vp,
+ size_t size, long double value)
{
const char *name;
@@ -202,4 +203,4 @@
return cb->get_float_type(cb, size, name);
}
-#endif /* _CREFLECT_H_ */
+#endif /* _CRX_H_ */
diff --git a/creflect/src/c_decl_parser.c b/creflect/creflect_cdecl.c
rename from creflect/src/c_decl_parser.c
rename to creflect/creflect_cdecl.c
--- a/creflect/src/c_decl_parser.c
+++ b/creflect/creflect_cdecl.c
@@ -1,10 +1,10 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
-#include "creflect.h"
+#include "creflect_cdecl.h"
-enum crxp_token_e {
+enum token_e {
TOK_STAR='*',
TOK_OPEN_PAREN='(',
TOK_CLOSE_PAREN=')',
@@ -40,13 +40,13 @@
#define NUM_DELAY_SLOTS 5000
typedef struct {
- enum crxp_token_e kind;
- const char *p;
+ enum token_e kind;
+ const char *p, **error_location;
size_t size;
- crx_builder_t *cb;
+ _crx_builder_t *cb;
intptr_t *delay_slots;
intptr_t all_delay_slots[NUM_DELAY_SLOTS];
-} crxp_token_t;
+} token_t;
static int is_space(char x)
{
@@ -69,7 +69,7 @@
return (is_ident_first(x) || is_digit(x));
}
-static char get_following_char(crxp_token_t *tok)
+static char get_following_char(token_t *tok)
{
const char *p = tok->p + tok->size;
if (tok->kind == TOK_ERROR)
@@ -79,7 +79,7 @@
return *p;
}
-static void next_token(crxp_token_t *tok)
+static void next_token(token_t *tok)
{
const char *p = tok->p + tok->size;
if (tok->kind == TOK_ERROR)
@@ -156,15 +156,18 @@
}
}
-static crx_type_t *parse_error(crxp_token_t *tok, const char *msg)
+static _crx_type_t *parse_error(token_t *tok, const char *msg)
{
- if (tok->kind != TOK_ERROR)
+ if (tok->kind != TOK_ERROR) {
+ tok->kind = TOK_ERROR;
+ if (tok->error_location)
+ *tok->error_location = tok->p;
tok->cb->error(tok->cb, msg);
- tok->kind = TOK_ERROR;
+ }
return NULL;
}
-static intptr_t *alloc_ds(crxp_token_t *tok, size_t num)
+static intptr_t *alloc_ds(token_t *tok, size_t num)
{
intptr_t *result = tok->delay_slots;
if (num > (tok->all_delay_slots + NUM_DELAY_SLOTS - tok->delay_slots)) {
@@ -175,9 +178,9 @@
return result;
}
-static crx_type_t *parse_complete(crxp_token_t *tok);
+static _crx_type_t *parse_complete(token_t *tok);
-static void parse_sequel(crxp_token_t *tok, intptr_t ds_end)
+static void parse_sequel(token_t *tok, intptr_t ds_end)
{
intptr_t *ds;
while (tok->kind == TOK_STAR || tok->kind == TOK_CONST) {
@@ -232,7 +235,7 @@
next_token(tok);
break;
}
- crx_type_t *t1 = parse_complete(tok);
+ _crx_type_t *t1 = parse_complete(tok);
intptr_t *ds_type = alloc_ds(tok, 1);
if (ds_type == NULL)
return;
@@ -300,7 +303,7 @@
}
}
-static crx_type_t *fetch_delay_slots(crxp_token_t *tok, crx_type_t *t1,
+static _crx_type_t *fetch_delay_slots(token_t *tok, _crx_type_t *t1,
intptr_t *delay_slot)
{
if (tok->kind == TOK_ERROR)
@@ -334,7 +337,7 @@
case TOK_DOTDOTDOT: /* function ending with a '...' */
{
intptr_t nbargs = *delay_slot++;
- crx_type_t **argtypes = (crx_type_t **)delay_slot;
+ _crx_type_t **argtypes = (_crx_type_t **)delay_slot;
delay_slot += nbargs;
if (tok_kind == TOK_DOTDOTDOT)
t1 = tok->cb->get_ellipsis_function_type(tok->cb, t1,
@@ -350,9 +353,9 @@
}
}
-static crx_type_t *parse_complete(crxp_token_t *tok)
+static _crx_type_t *parse_complete(token_t *tok)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
int is_const = (tok->kind == TOK_CONST);
if (is_const) {
next_token(tok);
@@ -506,20 +509,27 @@
return fetch_delay_slots(tok, t1, orig);
}
-const char *creflect_decl_parser(crx_builder_t *cb, const char *input,
- crx_type_t **result)
+_crx_type_t *creflect_decl_parser(_crx_builder_t *cb, const char *input,
+ const char **error_location)
{
- crxp_token_t token;
+ _crx_type_t *result;
+ token_t token;
token.kind = TOK_START;
token.cb = cb;
token.p = input;
+ token.error_location = error_location;
token.size = 0;
token.delay_slots = token.all_delay_slots;
next_token(&token);
- *result = parse_complete(&token);
+ result = parse_complete(&token);
- if (token.kind == TOK_END)
+ if (token.kind == TOK_END) {
+ if (error_location)
+ *error_location = NULL;
+ return result;
+ }
+ else {
+ parse_error(&token, "unexpected symbol");
return NULL;
- parse_error(&token, "unexpected symbol");
- return token.p;
+ }
}
diff --git a/creflect/creflect_cdecl.h b/creflect/creflect_cdecl.h
new file mode 100644
--- /dev/null
+++ b/creflect/creflect_cdecl.h
@@ -0,0 +1,11 @@
+#ifndef _CRX_CDECL_H_
+#define _CRX_CDECL_H_
+
+#include "creflect.h"
+
+
+_crx_type_t *creflect_decl_parser(_crx_builder_t *cb, const char *input,
+ const char **error_location);
+
+
+#endif /* _CRX_CDECL_H_ */
diff --git a/creflect/creflect_cdecl_main.c b/creflect/creflect_cdecl_main.c
new file mode 100644
--- /dev/null
+++ b/creflect/creflect_cdecl_main.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <assert.h>
+#include "creflect_cdecl.h"
+#include "creflect_debug_print.h"
+
+int main(int argc, char *argv[])
+{
+ _crx_type_t *t1;
+ const char *error;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s 'c_type_declaration'\n", argv[0]);
+ return 2;
+ }
+ t1 = creflect_decl_parser(&creflect_debug_builder, argv[1], &error);
+ if (error == NULL) {
+ assert(t1 != NULL);
+ printf("%s\n", creflect_type_text(t1));
+ }
+ else {
+ assert(t1 == NULL);
+ printf("%s\n", argv[1]);
+ while (error > argv[1]) {
+ printf(" ");
+ error--;
+ }
+ printf("^\n");
+ }
+ return 0;
+}
diff --git a/creflect/src/creflect_print.h b/creflect/creflect_debug_print.c
rename from creflect/src/creflect_print.h
rename to creflect/creflect_debug_print.c
--- a/creflect/src/creflect_print.h
+++ b/creflect/creflect_debug_print.c
@@ -2,47 +2,53 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+#include "creflect_debug_print.h"
-struct crx_type_s {
+struct _crx_type_s {
char text[1];
};
-static crx_type_t *newtype(const char *a)
+const char *creflect_type_text(_crx_type_t *t1)
+{
+ return t1->text;
+}
+
+static _crx_type_t *newtype(const char *a)
{
size_t la = strlen(a);
- crx_type_t *t = malloc(la + 1);
+ _crx_type_t *t = malloc(la + 1);
strcpy(t->text, a);
return t;
}
-static crx_type_t *newtype2(const char *a, const char *b)
+static _crx_type_t *newtype2(const char *a, const char *b)
{
size_t la = strlen(a);
size_t lb = strlen(b);
- crx_type_t *t = malloc(la + lb + 1);
+ _crx_type_t *t = malloc(la + lb + 1);
strcat(strcpy(t->text, a), b);
return t;
}
-static crx_type_t *tst_get_void_type(crx_builder_t *cb)
+static _crx_type_t *tst_get_void_type(_crx_builder_t *cb)
{
return newtype("void");
}
-static crx_type_t *tst_get_char_type(crx_builder_t *cb)
+static _crx_type_t *tst_get_char_type(_crx_builder_t *cb)
{
return newtype("char");
}
-static crx_type_t *tst_get_bool_type(crx_builder_t *cb)
+static _crx_type_t *tst_get_bool_type(_crx_builder_t *cb)
{
return newtype("_Bool");
}
-static crx_type_t *tst_get_signed_type(crx_builder_t *cb, size_t sz,
- const char *g)
+static _crx_type_t *tst_get_signed_type(_crx_builder_t *cb, size_t sz,
+ const char *g)
{
int skip = 0;
if (sizeof(long) == sizeof(long long))
@@ -63,8 +69,8 @@
abort();
}
-static crx_type_t *tst_get_unsigned_type(crx_builder_t *cb, size_t sz,
- const char *g)
+static _crx_type_t *tst_get_unsigned_type(_crx_builder_t *cb, size_t sz,
+ const char *g)
{
int skip = 0;
if (sizeof(long) == sizeof(long long))
@@ -84,8 +90,8 @@
abort();
}
-static crx_type_t *tst_get_float_type(crx_builder_t *cb, size_t sz,
- const char *g)
+static _crx_type_t *tst_get_float_type(_crx_builder_t *cb, size_t sz,
+ const char *g)
{
int skip = 0;
if (sizeof(double) == sizeof(long double))
@@ -101,9 +107,9 @@
abort();
}
-static crx_type_t *tst_get_function_type(crx_builder_t *cb, crx_type_t *ret,
- crx_type_t *args[], int nargs,
- crx_trampoline1_fn trampl)
+static _crx_type_t *tst_get_function_type(_crx_builder_t *cb, _crx_type_t *ret,
+ _crx_type_t *args[], int nargs,
+ _crx_trampoline1_fn trampl)
{
int i;
const char *prev = "FUNC( ";
@@ -115,66 +121,67 @@
return newtype2(prev, " )");
}
-static crx_type_t *tst_get_ellipsis_function_type(crx_builder_t *cb,
- crx_type_t *ret,
- crx_type_t *args[], int nargs)
+static _crx_type_t *tst_get_ellipsis_function_type(_crx_builder_t *cb,
+ _crx_type_t *ret,
+ _crx_type_t *args[],
+ int nargs)
{
- crx_type_t *dotdotdot = newtype2("... -> ", ret->text);
+ _crx_type_t *dotdotdot = newtype2("... -> ", ret->text);
return tst_get_function_type(cb, dotdotdot, args, nargs, 0);
}
-static crx_type_t *tst_get_pointer_type(crx_builder_t *cb, crx_type_t *t)
+static _crx_type_t *tst_get_pointer_type(_crx_builder_t *cb, _crx_type_t *t)
{
return newtype2("PTR ", t->text);
}
-static crx_type_t *tst_get_const_type(crx_builder_t *cb, crx_type_t *t)
+static _crx_type_t *tst_get_const_type(_crx_builder_t *cb, _crx_type_t *t)
{
return newtype2("CONST ", t->text);
}
-static crx_type_t *tst_get_array_type(crx_builder_t *cb, crx_type_t *t,
- size_t len)
+static _crx_type_t *tst_get_array_type(_crx_builder_t *cb, _crx_type_t *t,
+ size_t len)
{
char c[32];
sprintf(c, "ARRAY[%zd] ", len);
return newtype2(c, t->text);
}
-static crx_type_t *tst_get_incomplete_array_type(crx_builder_t *cb,
- crx_type_t *t)
+static _crx_type_t *tst_get_incomplete_array_type(_crx_builder_t *cb,
+ _crx_type_t *t)
{
return newtype2("ARRAY[] ", t->text);
}
-static crx_type_t *tst_get_struct_type(crx_builder_t *cb, const char *name)
+static _crx_type_t *tst_get_struct_type(_crx_builder_t *cb, const char *name)
{
return newtype2("STRUCT ", name);
}
-static crx_type_t *tst_get_union_type(crx_builder_t *cb, const char *name)
+static _crx_type_t *tst_get_union_type(_crx_builder_t *cb, const char *name)
{
return newtype2("UNION ", name);
}
-static crx_type_t *tst_get_enum_type(crx_builder_t *cb, const char *name)
+static _crx_type_t *tst_get_enum_type(_crx_builder_t *cb, const char *name)
{
return newtype2("ENUM ", name);
}
-static crx_type_t *tst_get_user_type(crx_builder_t *cb, const char *name)
+static _crx_type_t *tst_get_user_type(_crx_builder_t *cb, const char *name)
{
return newtype(name);
}
-static crx_type_t *tst_get_unknown_type(crx_builder_t *cb, const char *name)
+static _crx_type_t *tst_get_unknown_type(_crx_builder_t *cb, const char *name)
{
return newtype2("UNKNOWN ", name);
}
-static void tst_complete(crx_builder_t *cb, crx_type_t *t,
+static void tst_complete(_crx_builder_t *cb, _crx_type_t *t,
size_t sz, size_t align,
- crx_field_t fields[], int nfields)
+ _crx_field_t fields[], int nfields)
{
int i;
printf("%s:\n", t->text);
@@ -183,26 +190,26 @@
}
}
-static void tst_complete_enum(crx_builder_t *cb, crx_type_t *t,
- crx_type_t *inttype)
+static void tst_complete_enum(_crx_builder_t *cb, _crx_type_t *t,
+ _crx_type_t *inttype)
{
abort();
}
-static void tst_define_type(crx_builder_t *cb, const char *name, crx_type_t *t)
+static void tst_define_type(_crx_builder_t *cb, const char *name, _crx_type_t *t)
{
printf("TYPEDEF %s = %s\n", name, t->text);
}
-static void tst_define_var(crx_builder_t *cb, const char *name, crx_type_t *t,
+static void tst_define_var(_crx_builder_t *cb, const char *name, _crx_type_t *t,
void *addr)
{
printf("VAR %s: %s\n", name, t->text);
}
-static void tst_define_func(crx_builder_t *cb, const char *name,
- crx_type_t *ret, crx_type_t *args[], int nargs,
- crx_trampoline0_fn trampl, void *directcall)
+static void tst_define_func(_crx_builder_t *cb, const char *name,
+ _crx_type_t *ret, _crx_type_t *args[], int nargs,
+ _crx_trampoline0_fn trampl, void *directcall)
{
int i;
printf("FUNC %s: ", name);
@@ -211,8 +218,8 @@
printf("%s\n", ret->text);
}
-static void tst_define_num_const(crx_builder_t *cb, const char *name,
- crx_type_t *t, crx_num_const_t *value)
+static void tst_define_num_const(_crx_builder_t *cb, const char *name,
+ _crx_type_t *t, _crx_num_const_t *value)
{
printf("NUMCONST %s = %s ", name, t->text);
if (strcmp(t->text, "int") == 0)
@@ -241,12 +248,12 @@
}
}
-static void tst_error(crx_builder_t *cb, const char *msg)
+static void tst_error(_crx_builder_t *cb, const char *msg)
{
printf("ERROR: %s\n", msg);
}
-static crx_builder_t maincb = {
+_crx_builder_t creflect_debug_builder = {
tst_get_void_type,
tst_get_char_type,
tst_get_bool_type,
diff --git a/creflect/creflect_debug_print.h b/creflect/creflect_debug_print.h
new file mode 100644
--- /dev/null
+++ b/creflect/creflect_debug_print.h
@@ -0,0 +1,11 @@
+#ifndef _CRX_DEBUG_PRINT_H_
+#define _CRX_DEBUG_PRINT_H_
+
+#include "creflect.h"
+
+
+extern _crx_builder_t creflect_debug_builder;
+const char *creflect_type_text(_crx_type_t *);
+
+
+#endif /* _CRX_DEBUG_PRINT_H_ */
diff --git a/creflect/src/creflect_check.c b/creflect/creflect_libcheck.c
rename from creflect/src/creflect_check.c
rename to creflect/creflect_libcheck.c
diff --git a/creflect/driver.py b/creflect/driver.py
--- a/creflect/driver.py
+++ b/creflect/driver.py
@@ -84,7 +84,7 @@
CALL_TEMPLATE1 = '''
/***** CREFLECT main entry point *****/
-void %s(crx_builder_t *cb) {
+void %s(_crx_builder_t *cb) {
%s}
'''
CALL_TEMPLATE2 = '''\
@@ -95,9 +95,9 @@
DEBUG_TEMPLATE = '''\
/***** CREFLECT debug code *****/
-#include "creflect_print.h"
+#include "creflect_debug_print.h"
int main(void) {
- %s(&maincb);
+ %s(&creflect_debug_builder);
return 0;
}
'''
diff --git a/creflect/model.py b/creflect/model.py
--- a/creflect/model.py
+++ b/creflect/model.py
@@ -120,7 +120,7 @@
hint = self.name.split()
if hint[0] in ('signed', 'unsigned'):
hint = hint[1:]
- expr = 'CRX_INT_TYPE(cb, %s, "%s")' % (star_p1, " ".join(hint))
+ expr = '_CRX_INT_TYPE(cb, %s, "%s")' % (star_p1, " ".join(hint))
elif self.is_char_type():
errmsg = "numeric type '%s' is not a char" % (
inspect.get_comment_type(0, False),)
@@ -163,7 +163,7 @@
return block.write_crx_type_var(expr)
def write_num_const_decl(self, block, varname):
- block.writedecl("crx_num_const_t v;")
+ block.writedecl("_crx_num_const_t v;")
comment = "an integer"
op = "<< 1"
if self.is_char_type():
@@ -181,12 +181,12 @@
preference = 2
else:
preference = 1
- expr = "CRX_INT_CONST(cb, %s, &v, %d)" % (varname, preference)
+ expr = "_CRX_INT_CONST(cb, %s, &v, %d)" % (varname, preference)
elif self.is_char_type():
- block.writeline('CRX_CHAR_CONST(cb, %s, &v);' % varname)
+ block.writeline('_CRX_CHAR_CONST(cb, %s, &v);' % varname)
expr = 'cb->get_char_type(cb)'
elif self.is_float_type():
- expr = "CRX_FLOAT_CONST(cb, %s, &v)" % (varname,)
+ expr = "_CRX_FLOAT_CONST(cb, %s, &v)" % (varname,)
else:
raise AssertionError
t1 = block.write_crx_type_var(expr)
diff --git a/test/codegen/001.c b/test/codegen/001.c
--- a/test/codegen/001.c
+++ b/test/codegen/001.c
@@ -2,6 +2,6 @@
# ____________________________________________________________
-void test001(crx_builder_t *cb)
+void test001(_crx_builder_t *cb)
{
}
diff --git a/test/codegen/002.c b/test/codegen/002.c
--- a/test/codegen/002.c
+++ b/test/codegen/002.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test002(crx_builder_t *cb)
+void test002(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
num_t *p1;
char *p2;
diff --git a/test/codegen/002b.c b/test/codegen/002b.c
--- a/test/codegen/002b.c
+++ b/test/codegen/002b.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test002b(crx_builder_t *cb)
+void test002b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3, *t4;
+ _crx_type_t *t1, *t2, *t3, *t4;
{
num_t *p1;
char *p2;
diff --git a/test/codegen/002c.c b/test/codegen/002c.c
--- a/test/codegen/002c.c
+++ b/test/codegen/002c.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test002c(crx_builder_t *cb)
+void test002c(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
+ _crx_type_t *t1, *t2, *t3;
{
num_t *p1;
char *p2;
diff --git a/test/codegen/003.c b/test/codegen/003.c
--- a/test/codegen/003.c
+++ b/test/codegen/003.c
@@ -2,16 +2,16 @@
# ____________________________________________________________
-void test003(crx_builder_t *cb)
+void test003(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
p1 = (void *)b;
(void)(*p1 << 1); /* check that 'num_t' is an integer type */
*p1 = -1; /* check that 'num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, *p1, "int");
+ t1 = _CRX_INT_TYPE(cb, *p1, "int");
cb->define_type(cb, "num_t", t1);
#expect TYPEDEF num_t = int
}
diff --git a/test/codegen/003b.c b/test/codegen/003b.c
--- a/test/codegen/003b.c
+++ b/test/codegen/003b.c
@@ -2,16 +2,16 @@
# ____________________________________________________________
-void test003b(crx_builder_t *cb)
+void test003b(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
p1 = (void *)b;
(void)(*p1 << 1); /* check that 'num_t' is an integer type */
*p1 = -1; /* check that 'num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, *p1, "long");
+ t1 = _CRX_INT_TYPE(cb, *p1, "long");
cb->define_type(cb, "num_t", t1);
#expect TYPEDEF num_t = long
}
diff --git a/test/codegen/003c.c b/test/codegen/003c.c
--- a/test/codegen/003c.c
+++ b/test/codegen/003c.c
@@ -2,16 +2,16 @@
# ____________________________________________________________
-void test003c(crx_builder_t *cb)
+void test003c(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
p1 = (void *)b;
(void)(*p1 << 1); /* check that 'num_t' is an integer type */
*p1 = -1; /* check that 'num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, *p1, "long long");
+ t1 = _CRX_INT_TYPE(cb, *p1, "long long");
cb->define_type(cb, "num_t", t1);
#expect TYPEDEF num_t = long long
}
diff --git a/test/codegen/003d.c b/test/codegen/003d.c
--- a/test/codegen/003d.c
+++ b/test/codegen/003d.c
@@ -2,16 +2,16 @@
# ____________________________________________________________
-void test003d(crx_builder_t *cb)
+void test003d(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
p1 = (void *)b;
(void)(*p1 << 1); /* check that 'num_t' is an integer type */
*p1 = -1; /* check that 'num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, *p1, "char");
+ t1 = _CRX_INT_TYPE(cb, *p1, "char");
cb->define_type(cb, "num_t", t1);
#expect TYPEDEF num_t = signed char
}
diff --git a/test/codegen/003e.c b/test/codegen/003e.c
--- a/test/codegen/003e.c
+++ b/test/codegen/003e.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test003e(crx_builder_t *cb)
+void test003e(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
diff --git a/test/codegen/003f.c b/test/codegen/003f.c
--- a/test/codegen/003f.c
+++ b/test/codegen/003f.c
@@ -2,16 +2,16 @@
# ____________________________________________________________
-void test003f(crx_builder_t *cb)
+void test003f(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
p1 = (void *)b;
(void)(*p1 << 1); /* check that 'num_t' is an integer type */
*p1 = -1; /* check that 'num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, *p1, "long long");
+ t1 = _CRX_INT_TYPE(cb, *p1, "long long");
cb->define_type(cb, "num_t", t1);
#expect TYPEDEF num_t = unsigned long long
}
diff --git a/test/codegen/003g.c b/test/codegen/003g.c
--- a/test/codegen/003g.c
+++ b/test/codegen/003g.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test003g(crx_builder_t *cb)
+void test003g(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
diff --git a/test/codegen/003h.c b/test/codegen/003h.c
--- a/test/codegen/003h.c
+++ b/test/codegen/003h.c
@@ -6,16 +6,16 @@
# ____________________________________________________________
-void test003h(crx_builder_t *cb)
+void test003h(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
p1 = (void *)b;
(void)(*p1 << 1); /* check that 'num_t' is an integer type */
*p1 = -1; /* check that 'num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, *p1, "long long");
+ t1 = _CRX_INT_TYPE(cb, *p1, "long long");
cb->define_type(cb, "num_t", t1);
#expect TYPEDEF num_t = int
}
diff --git a/test/codegen/003i.c b/test/codegen/003i.c
--- a/test/codegen/003i.c
+++ b/test/codegen/003i.c
@@ -2,16 +2,16 @@
# ____________________________________________________________
-void test003i(crx_builder_t *cb)
+void test003i(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
num_t *p1;
char b[sizeof(*p1)];
p1 = (void *)b;
(void)(*p1 << 1); /* check that 'num_t' is an integer type */
*p1 = -1; /* check that 'num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, *p1, "char");
+ t1 = _CRX_INT_TYPE(cb, *p1, "char");
cb->define_type(cb, "num_t", t1);
#expect TYPEDEF num_t = signed char
}
diff --git a/test/codegen/004.c b/test/codegen/004.c
--- a/test/codegen/004.c
+++ b/test/codegen/004.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test004(crx_builder_t *cb)
+void test004(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
num_t *p1;
char *p2;
@@ -13,7 +13,7 @@
*p1 = (void *)b; /* check that 'num_t' is a pointer type */
(void)(**p1 << 1); /* check that '*num_t' is an integer type */
**p1 = -1; /* check that '*num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, **p1, "int");
+ t1 = _CRX_INT_TYPE(cb, **p1, "int");
t2 = cb->get_pointer_type(cb, t1);
cb->define_type(cb, "num_t", t2);
#expect TYPEDEF num_t = PTR int
diff --git a/test/codegen/004b.c b/test/codegen/004b.c
--- a/test/codegen/004b.c
+++ b/test/codegen/004b.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test004b(crx_builder_t *cb)
+void test004b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
+ _crx_type_t *t1, *t2, *t3;
{
num_t *p1;
char *p2;
@@ -15,7 +15,7 @@
**p1 = (void *)b; /* check that '*num_t' is a pointer type */
(void)(***p1 << 1); /* check that '**num_t' is an integer type */
***p1 = -1; /* check that '**num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, ***p1, "int");
+ t1 = _CRX_INT_TYPE(cb, ***p1, "int");
t2 = cb->get_pointer_type(cb, t1);
t3 = cb->get_pointer_type(cb, t2);
cb->define_type(cb, "num_t", t3);
diff --git a/test/codegen/005.c b/test/codegen/005.c
--- a/test/codegen/005.c
+++ b/test/codegen/005.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test005(crx_builder_t *cb)
+void test005(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
foo_t *p1;
char b[sizeof(**p1)]; /* check that 'foo_t[]' is a valid type */
@@ -15,7 +15,7 @@
}
(void)(**p1 << 1); /* check that 'foo_t[]' is an integer type */
**p1 = -1; /* check that 'foo_t[]' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, **p1, "int");
+ t1 = _CRX_INT_TYPE(cb, **p1, "int");
t2 = cb->get_array_type(cb, t1, sizeof(*p1) / sizeof(**p1));
cb->define_type(cb, "foo_t", t2);
#expect TYPEDEF foo_t = ARRAY[27] int
diff --git a/test/codegen/005b.c b/test/codegen/005b.c
--- a/test/codegen/005b.c
+++ b/test/codegen/005b.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test005b(crx_builder_t *cb)
+void test005b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
+ _crx_type_t *t1, *t2, *t3;
{
foo_t *p1;
char *p3;
@@ -17,7 +17,7 @@
**p1 = (void *)b; /* check that 'foo_t[]' is a pointer type */
(void)(***p1 << 1); /* check that '*foo_t[]' is an integer type */
***p1 = -1; /* check that '*foo_t[]' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, ***p1, "int");
+ t1 = _CRX_INT_TYPE(cb, ***p1, "int");
t2 = cb->get_pointer_type(cb, t1);
t3 = cb->get_array_type(cb, t2, sizeof(*p1) / sizeof(**p1));
cb->define_type(cb, "foo_t", t3);
diff --git a/test/codegen/005c.c b/test/codegen/005c.c
--- a/test/codegen/005c.c
+++ b/test/codegen/005c.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test005c(crx_builder_t *cb)
+void test005c(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
+ _crx_type_t *t1, *t2, *t3;
{
foo_t *p1;
char *p2;
@@ -17,7 +17,7 @@
}
(void)(***p1 << 1); /* check that '(*foo_t)[]' is an integer type */
***p1 = -1; /* check that '(*foo_t)[]' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, ***p1, "int");
+ t1 = _CRX_INT_TYPE(cb, ***p1, "int");
t2 = cb->get_array_type(cb, t1, sizeof(**p1) / sizeof(***p1));
t3 = cb->get_pointer_type(cb, t2);
cb->define_type(cb, "foo_t", t3);
diff --git a/test/codegen/005d.c b/test/codegen/005d.c
--- a/test/codegen/005d.c
+++ b/test/codegen/005d.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test005d(crx_builder_t *cb)
+void test005d(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3, *t4, *t5, *t6, *t7, *t8, *t9, *t10;
+ _crx_type_t *t1, *t2, *t3, *t4, *t5, *t6, *t7, *t8, *t9, *t10;
{
foo_t *p1;
char *p4;
@@ -37,7 +37,7 @@
*********p1 = (void *)b; /* check that '*(***foo_t[][])[][]' is a pointer type */
(void)(**********p1 << 1); /* check that '**(***foo_t[][])[][]' is an integer type */
**********p1 = -1; /* check that '**(***foo_t[][])[][]' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, **********p1, "int");
+ t1 = _CRX_INT_TYPE(cb, **********p1, "int");
t2 = cb->get_pointer_type(cb, t1);
t3 = cb->get_pointer_type(cb, t2);
t4 = cb->get_array_type(cb, t3, sizeof(*******p1) / sizeof(********p1));
diff --git a/test/codegen/006.c b/test/codegen/006.c
--- a/test/codegen/006.c
+++ b/test/codegen/006.c
@@ -2,16 +2,16 @@
# ____________________________________________________________
-void test006(crx_builder_t *cb)
+void test006(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
num_t *p1;
char b[sizeof(*p1)];
memset(b, -1, sizeof(b));
p1 = (void *)b;
(void)(*p1 << 1); /* check that 'num_t' is an integer type */
- t1 = CRX_INT_TYPE(cb, *p1, "int");
+ t1 = _CRX_INT_TYPE(cb, *p1, "int");
t2 = cb->get_const_type(cb, t1);
cb->define_type(cb, "num_t", t2);
#expect TYPEDEF num_t = CONST unsigned int
diff --git a/test/codegen/006b.c b/test/codegen/006b.c
--- a/test/codegen/006b.c
+++ b/test/codegen/006b.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test006b(crx_builder_t *cb)
+void test006b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
+ _crx_type_t *t1, *t2, *t3;
{
num_t *p1;
char *p2;
@@ -17,7 +17,7 @@
}
(void)(**p1 << 1); /* check that '*num_t' is an integer type */
**p1 = -1; /* check that '*num_t' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, **p1, "int");
+ t1 = _CRX_INT_TYPE(cb, **p1, "int");
t2 = cb->get_pointer_type(cb, t1);
t3 = cb->get_const_type(cb, t2);
cb->define_type(cb, "num_t", t3);
diff --git a/test/codegen/006c.c b/test/codegen/006c.c
--- a/test/codegen/006c.c
+++ b/test/codegen/006c.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test006c(crx_builder_t *cb)
+void test006c(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3, *t4;
+ _crx_type_t *t1, *t2, *t3, *t4;
{
foo_t *p1;
char *p2;
@@ -21,7 +21,7 @@
}
(void)(***p1 << 1); /* check that '(*foo_t)[]' is an integer type */
***p1 = -1; /* check that '(*foo_t)[]' is not declared 'const' */
- t1 = CRX_INT_TYPE(cb, ***p1, "int");
+ t1 = _CRX_INT_TYPE(cb, ***p1, "int");
t2 = cb->get_array_type(cb, t1, sizeof(**p1) / sizeof(***p1));
t3 = cb->get_pointer_type(cb, t2);
t4 = cb->get_const_type(cb, t3);
diff --git a/test/codegen/007.c b/test/codegen/007.c
--- a/test/codegen/007.c
+++ b/test/codegen/007.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void test007(crx_builder_t *cb)
+void test007(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
t1 = cb->get_unknown_type(cb, "$num_t");
cb->define_type(cb, "num_t", t1);
diff --git a/test/codegen/func-001.c b/test/codegen/func-001.c
--- a/test/codegen/func-001.c
+++ b/test/codegen/func-001.c
@@ -14,9 +14,9 @@
return f();
}
-void testfunc_001(crx_builder_t *cb)
+void testfunc_001(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
t1 = cb->get_signed_type(cb, sizeof(int), "int");
cb->define_func(cb, "f", t1, 0, 0, &testfunc_001__c_f, &testfunc_001__d_f);
diff --git a/test/codegen/func-001b.c b/test/codegen/func-001b.c
--- a/test/codegen/func-001b.c
+++ b/test/codegen/func-001b.c
@@ -34,9 +34,9 @@
return h(a0, a1);
}
-void testfunc_001b(crx_builder_t *cb)
+void testfunc_001b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *a3[1], *t4, *a5[2], *a6[2];
+ _crx_type_t *t1, *t2, *a3[1], *t4, *a5[2], *a6[2];
{
t1 = cb->get_unsigned_type(cb, sizeof(unsigned int), "unsigned int");
t2 = cb->get_signed_type(cb, sizeof(long), "long");
diff --git a/test/codegen/func-001c.c b/test/codegen/func-001c.c
--- a/test/codegen/func-001c.c
+++ b/test/codegen/func-001c.c
@@ -14,9 +14,9 @@
return f(a0);
}
-void testfunc_001c(crx_builder_t *cb)
+void testfunc_001c(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *a3[1];
+ _crx_type_t *t1, *t2, *a3[1];
{
t1 = cb->get_float_type(cb, sizeof(double), "double");
t2 = cb->get_float_type(cb, sizeof(float), "float");
diff --git a/test/codegen/func-002.c b/test/codegen/func-002.c
--- a/test/codegen/func-002.c
+++ b/test/codegen/func-002.c
@@ -7,9 +7,9 @@
# ____________________________________________________________
-void testfunc_002(crx_builder_t *cb)
+void testfunc_002(_crx_builder_t *cb)
{
- crx_type_t *t1, *a2[1], *t3;
+ _crx_type_t *t1, *a2[1], *t3;
{
int (*p1)(int, ...) = &f; /* check that 'f' is a function with exactly the given signature */
(void)p1;
diff --git a/test/codegen/func-003.c b/test/codegen/func-003.c
--- a/test/codegen/func-003.c
+++ b/test/codegen/func-003.c
@@ -7,9 +7,9 @@
*(int *)result = f(*(long *)args[0], *(long *)args[1], *(int *)args[2]);
}
-void testfunc_003(crx_builder_t *cb)
+void testfunc_003(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *a3[3], *t4, *t5;
+ _crx_type_t *t1, *t2, *a3[3], *t4, *t5;
{
func_t *p1;
char *p2;
diff --git a/test/codegen/func-003b.c b/test/codegen/func-003b.c
--- a/test/codegen/func-003b.c
+++ b/test/codegen/func-003b.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void testfunc_003b(crx_builder_t *cb)
+void testfunc_003b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *a3[1], *t4, *t5;
+ _crx_type_t *t1, *t2, *a3[1], *t4, *t5;
{
func_t *p1;
char *p2;
diff --git a/test/codegen/func-004.c b/test/codegen/func-004.c
--- a/test/codegen/func-004.c
+++ b/test/codegen/func-004.c
@@ -7,9 +7,9 @@
*(int *)result = f(*(long *)args[0], *(int *)args[1]);
}
-void testfunc_004(crx_builder_t *cb)
+void testfunc_004(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *a3[2], *t4, *t5, *t6;
+ _crx_type_t *t1, *t2, *a3[2], *t4, *t5, *t6;
{
func_t *p1;
char *p2;
diff --git a/test/codegen/func-005.c b/test/codegen/func-005.c
--- a/test/codegen/func-005.c
+++ b/test/codegen/func-005.c
@@ -19,9 +19,9 @@
*(long *)result = f(*(char *)args[0], *(short *)args[1]);
}
-void testfunc_005(crx_builder_t *cb)
+void testfunc_005(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3, *t4, *t5, *t6, *a7[2], *t8, *t9, *a10[2];
+ _crx_type_t *t1, *t2, *t3, *t4, *t5, *t6, *a7[2], *t8, *t9, *a10[2];
{
t1 = cb->get_void_type(cb);
t2 = cb->get_signed_type(cb, sizeof(int), "int");
diff --git a/test/codegen/glob-001.c b/test/codegen/glob-001.c
--- a/test/codegen/glob-001.c
+++ b/test/codegen/glob-001.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void testglob_001(crx_builder_t *cb)
+void testglob_001(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
void *p1 = someglob; /* check that 'someglob' is a pointer */
if (0) { someglob = p1; } /* check that 'someglob' is a pointer variable, and not an array or a constant */
diff --git a/test/codegen/glob-002.c b/test/codegen/glob-002.c
--- a/test/codegen/glob-002.c
+++ b/test/codegen/glob-002.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void testglob_002(crx_builder_t *cb)
+void testglob_002(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
char (*p1)[] = &someglob; /* check that 'someglob' is of type 'char[]' */
(void)p1;
diff --git a/test/codegen/glob-002b.c b/test/codegen/glob-002b.c
--- a/test/codegen/glob-002b.c
+++ b/test/codegen/glob-002b.c
@@ -4,9 +4,9 @@
# ____________________________________________________________
-void testglob_002b(crx_builder_t *cb)
+void testglob_002b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
int (*p1)[] = &someglob; /* check that 'someglob' is of type 'int[]' */
(void)p1;
diff --git a/test/codegen/glob-002c.c b/test/codegen/glob-002c.c
--- a/test/codegen/glob-002c.c
+++ b/test/codegen/glob-002c.c
@@ -4,9 +4,9 @@
# ____________________________________________________________
-void testglob_002c(crx_builder_t *cb)
+void testglob_002c(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
int *p1 = &someglob; /* check that 'someglob' is of type 'int' */
(void)p1;
diff --git a/test/codegen/glob-002d.c b/test/codegen/glob-002d.c
--- a/test/codegen/glob-002d.c
+++ b/test/codegen/glob-002d.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void testglob_002d(crx_builder_t *cb)
+void testglob_002d(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
int **p1 = &someglob; /* check that 'someglob' is of type 'int *' */
(void)p1;
diff --git a/test/codegen/glob-003.c b/test/codegen/glob-003.c
--- a/test/codegen/glob-003.c
+++ b/test/codegen/glob-003.c
@@ -2,13 +2,13 @@
# ____________________________________________________________
-void testglob_003(crx_builder_t *cb)
+void testglob_003(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) << 1); /* check that 'ab' is an integer */
- t1 = CRX_INT_CONST(cb, ab, &v, 1);
+ t1 = _CRX_INT_CONST(cb, ab, &v, 1);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = int -42
}
diff --git a/test/codegen/glob-003b.c b/test/codegen/glob-003b.c
--- a/test/codegen/glob-003b.c
+++ b/test/codegen/glob-003b.c
@@ -6,13 +6,13 @@
# ____________________________________________________________
-void testglob_003b(crx_builder_t *cb)
+void testglob_003b(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) << 1); /* check that 'ab' is an integer */
- t1 = CRX_INT_CONST(cb, ab, &v, 1);
+ t1 = _CRX_INT_CONST(cb, ab, &v, 1);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = int 42
}
diff --git a/test/codegen/glob-003c.c b/test/codegen/glob-003c.c
--- a/test/codegen/glob-003c.c
+++ b/test/codegen/glob-003c.c
@@ -2,13 +2,13 @@
# ____________________________________________________________
-void testglob_003c(crx_builder_t *cb)
+void testglob_003c(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) << 1); /* check that 'ab' is an integer */
- t1 = CRX_INT_CONST(cb, ab, &v, 1);
+ t1 = _CRX_INT_CONST(cb, ab, &v, 1);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = unsigned int 42
}
diff --git a/test/codegen/glob-003d.c b/test/codegen/glob-003d.c
--- a/test/codegen/glob-003d.c
+++ b/test/codegen/glob-003d.c
@@ -2,13 +2,13 @@
# ____________________________________________________________
-void testglob_003d(crx_builder_t *cb)
+void testglob_003d(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) << 1); /* check that 'ab' is an integer or char */
- CRX_CHAR_CONST(cb, ab, &v);
+ _CRX_CHAR_CONST(cb, ab, &v);
t1 = cb->get_char_type(cb);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = char '*'
diff --git a/test/codegen/glob-003e.c b/test/codegen/glob-003e.c
--- a/test/codegen/glob-003e.c
+++ b/test/codegen/glob-003e.c
@@ -2,13 +2,13 @@
# ____________________________________________________________
-void testglob_003e(crx_builder_t *cb)
+void testglob_003e(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) << 1); /* check that 'ab' is an integer */
- t1 = CRX_INT_CONST(cb, ab, &v, 2);
+ t1 = _CRX_INT_CONST(cb, ab, &v, 2);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = long -42
}
diff --git a/test/codegen/glob-003f.c b/test/codegen/glob-003f.c
--- a/test/codegen/glob-003f.c
+++ b/test/codegen/glob-003f.c
@@ -2,13 +2,13 @@
# ____________________________________________________________
-void testglob_003f(crx_builder_t *cb)
+void testglob_003f(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) << 1); /* check that 'ab' is an integer */
- t1 = CRX_INT_CONST(cb, ab, &v, 3);
+ t1 = _CRX_INT_CONST(cb, ab, &v, 3);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = long long -42
}
diff --git a/test/codegen/glob-003g.c b/test/codegen/glob-003g.c
--- a/test/codegen/glob-003g.c
+++ b/test/codegen/glob-003g.c
@@ -2,13 +2,13 @@
# ____________________________________________________________
-void testglob_003g(crx_builder_t *cb)
+void testglob_003g(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) << 1); /* check that 'ab' is an integer */
- t1 = CRX_INT_CONST(cb, ab, &v, 1);
+ t1 = _CRX_INT_CONST(cb, ab, &v, 1);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = int -42
}
diff --git a/test/codegen/glob-003h.c b/test/codegen/glob-003h.c
--- a/test/codegen/glob-003h.c
+++ b/test/codegen/glob-003h.c
@@ -3,20 +3,20 @@
# ____________________________________________________________
-void testglob_003h(crx_builder_t *cb)
+void testglob_003h(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) / 2.0); /* check that 'ab' is a number */
- t1 = CRX_FLOAT_CONST(cb, ab, &v);
+ t1 = _CRX_FLOAT_CONST(cb, ab, &v);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = float 42.000000
}
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((abd) / 2.0); /* check that 'abd' is a number */
- t2 = CRX_FLOAT_CONST(cb, abd, &v);
+ t2 = _CRX_FLOAT_CONST(cb, abd, &v);
cb->define_num_const(cb, "abd", t2, &v);
#expect NUMCONST abd = double 42.000000
}
diff --git a/test/codegen/glob-003i.c b/test/codegen/glob-003i.c
--- a/test/codegen/glob-003i.c
+++ b/test/codegen/glob-003i.c
@@ -2,13 +2,13 @@
# ____________________________________________________________
-void testglob_003i(crx_builder_t *cb)
+void testglob_003i(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((abl) / 2.0); /* check that 'abl' is a number */
- t1 = CRX_FLOAT_CONST(cb, abl, &v);
+ t1 = _CRX_FLOAT_CONST(cb, abl, &v);
cb->define_num_const(cb, "abl", t1, &v);
#expect NUMCONST abl = long double 42.000000
}
diff --git a/test/codegen/glob-003j.c b/test/codegen/glob-003j.c
--- a/test/codegen/glob-003j.c
+++ b/test/codegen/glob-003j.c
@@ -2,13 +2,13 @@
# ____________________________________________________________
-void testglob_003j(crx_builder_t *cb)
+void testglob_003j(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((ab) << 1); /* check that 'ab' is an integer */
- t1 = CRX_INT_CONST(cb, ab, &v, 1);
+ t1 = _CRX_INT_CONST(cb, ab, &v, 1);
cb->define_num_const(cb, "ab", t1, &v);
#expect NUMCONST ab = int 42
}
diff --git a/test/codegen/glob-004.c b/test/codegen/glob-004.c
--- a/test/codegen/glob-004.c
+++ b/test/codegen/glob-004.c
@@ -7,9 +7,9 @@
*(int *)result = f(*(long *)args[0], *(long *)args[1]);
}
-void testglob_004(crx_builder_t *cb)
+void testglob_004(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *a3[2], *t4, *t5;
+ _crx_type_t *t1, *t2, *a3[2], *t4, *t5;
{
int (**p1)(long, long) = &someglob; /* check that 'someglob' is of type 'int (*)(long, long)' */
(void)p1;
diff --git a/test/codegen/glob-005.c b/test/codegen/glob-005.c
--- a/test/codegen/glob-005.c
+++ b/test/codegen/glob-005.c
@@ -4,9 +4,9 @@
# ____________________________________________________________
-void testglob_005(crx_builder_t *cb)
+void testglob_005(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
+ _crx_type_t *t1, *t2, *t3;
{
mytype_t *p1;
char *p2;
diff --git a/test/codegen/macro-001.c b/test/codegen/macro-001.c
--- a/test/codegen/macro-001.c
+++ b/test/codegen/macro-001.c
@@ -3,20 +3,20 @@
# ____________________________________________________________
-void testmacro_001(crx_builder_t *cb)
+void testmacro_001(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
+ _crx_type_t *t1, *t2;
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((FOO) << 1); /* check that 'FOO' is an integer */
- t1 = CRX_INT_CONST(cb, FOO, &v, 1);
+ t1 = _CRX_INT_CONST(cb, FOO, &v, 1);
cb->define_num_const(cb, "FOO", t1, &v);
#expect NUMCONST FOO = int 42
}
{
- crx_num_const_t v;
+ _crx_num_const_t v;
(void)((BAR) << 1); /* check that 'BAR' is an integer */
- t2 = CRX_INT_CONST(cb, BAR, &v, 1);
+ t2 = _CRX_INT_CONST(cb, BAR, &v, 1);
cb->define_num_const(cb, "BAR", t2, &v);
#expect NUMCONST BAR = unsigned int 42
}
diff --git a/test/codegen/struct-001.c b/test/codegen/struct-001.c
--- a/test/codegen/struct-001.c
+++ b/test/codegen/struct-001.c
@@ -5,10 +5,10 @@
# ____________________________________________________________
-void teststruct_001(crx_builder_t *cb)
+void teststruct_001(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
- crx_field_t d1[2];
+ _crx_type_t *t1, *t2, *t3;
+ _crx_field_t d1[2];
t1 = cb->get_struct_type(cb, "foo_s");
{
struct foo_s *p1;
@@ -17,7 +17,7 @@
p1 = (void *)(((char *)b) - o);
(void)(p1->aa << 1); /* check that 'struct foo_s::aa' is an integer type */
p1->aa = -1; /* check that 'struct foo_s::aa' is not declared 'const' */
- t2 = CRX_INT_TYPE(cb, p1->aa, "int");
+ t2 = _CRX_INT_TYPE(cb, p1->aa, "int");
d1[0].name = "aa";
d1[0].type = t2;
d1[0].offset = o;
@@ -31,7 +31,7 @@
p1 = (void *)(((char *)b) - o);
(void)(p1->bb << 1); /* check that 'struct foo_s::bb' is an integer type */
p1->bb = -1; /* check that 'struct foo_s::bb' is not declared 'const' */
- t3 = CRX_INT_TYPE(cb, p1->bb, "int");
+ t3 = _CRX_INT_TYPE(cb, p1->bb, "int");
d1[1].name = "bb";
d1[1].type = t3;
d1[1].offset = o;
diff --git a/test/codegen/struct-001b.c b/test/codegen/struct-001b.c
--- a/test/codegen/struct-001b.c
+++ b/test/codegen/struct-001b.c
@@ -4,10 +4,10 @@
# ____________________________________________________________
-void teststruct_001b(crx_builder_t *cb)
+void teststruct_001b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
- crx_field_t d1[1];
+ _crx_type_t *t1, *t2, *t3;
+ _crx_field_t d1[1];
t1 = cb->get_struct_type(cb, "foo_s");
{
struct foo_s *p1;
@@ -16,7 +16,7 @@
memset(b, -1, sizeof(b));
p1 = (void *)(((char *)b) - o);
(void)(p1->aa << 1); /* check that 'struct foo_s::aa' is an integer type */
- t2 = CRX_INT_TYPE(cb, p1->aa, "int");
+ t2 = _CRX_INT_TYPE(cb, p1->aa, "int");
t3 = cb->get_const_type(cb, t2);
d1[0].name = "aa";
d1[0].type = t3;
diff --git a/test/codegen/struct-002.c b/test/codegen/struct-002.c
--- a/test/codegen/struct-002.c
+++ b/test/codegen/struct-002.c
@@ -4,10 +4,10 @@
# ____________________________________________________________
-void teststruct_002(crx_builder_t *cb)
+void teststruct_002(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
- crx_field_t d1[1];
+ _crx_type_t *t1, *t2, *t3;
+ _crx_field_t d1[1];
t1 = cb->get_struct_type(cb, "foo_s");
{
struct foo_s *p1;
diff --git a/test/codegen/struct-003.c b/test/codegen/struct-003.c
--- a/test/codegen/struct-003.c
+++ b/test/codegen/struct-003.c
@@ -4,10 +4,10 @@
# ____________________________________________________________
-void teststruct_003(crx_builder_t *cb)
+void teststruct_003(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
- crx_field_t d1[1];
+ _crx_type_t *t1, *t2, *t3;
+ _crx_field_t d1[1];
t1 = cb->get_struct_type(cb, "foo_s");
{
struct foo_s *p1;
@@ -18,7 +18,7 @@
p1->aa = (void *)b; /* check that 'struct foo_s::aa' is a pointer type */
(void)(*p1->aa << 1); /* check that '*struct foo_s::aa' is an integer type */
*p1->aa = -1; /* check that '*struct foo_s::aa' is not declared 'const' */
- t2 = CRX_INT_TYPE(cb, *p1->aa, "int");
+ t2 = _CRX_INT_TYPE(cb, *p1->aa, "int");
t3 = cb->get_pointer_type(cb, t2);
d1[0].name = "aa";
d1[0].type = t3;
diff --git a/test/codegen/struct-004.c b/test/codegen/struct-004.c
--- a/test/codegen/struct-004.c
+++ b/test/codegen/struct-004.c
@@ -4,10 +4,10 @@
# ____________________________________________________________
-void teststruct_004(crx_builder_t *cb)
+void teststruct_004(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
- crx_field_t d1[1];
+ _crx_type_t *t1, *t2, *t3;
+ _crx_field_t d1[1];
t1 = cb->get_struct_type(cb, "foo_s");
{
struct foo_s *p1;
@@ -20,7 +20,7 @@
}
(void)(*p1->aa << 1); /* check that 'struct foo_s::aa[]' is an integer type */
*p1->aa = -1; /* check that 'struct foo_s::aa[]' is not declared 'const' */
- t2 = CRX_INT_TYPE(cb, *p1->aa, "int");
+ t2 = _CRX_INT_TYPE(cb, *p1->aa, "int");
t3 = cb->get_array_type(cb, t2, sizeof(p1->aa) / sizeof(*p1->aa));
d1[0].name = "aa";
d1[0].type = t3;
diff --git a/test/codegen/struct-005.c b/test/codegen/struct-005.c
--- a/test/codegen/struct-005.c
+++ b/test/codegen/struct-005.c
@@ -2,10 +2,10 @@
# ____________________________________________________________
-void teststruct_005(crx_builder_t *cb)
+void teststruct_005(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2;
- crx_field_t d1[1];
+ _crx_type_t *t1, *t2;
+ _crx_field_t d1[1];
t1 = cb->get_struct_type(cb, "$foo_t");
{
foo_t *p1;
@@ -14,7 +14,7 @@
p1 = (void *)(((char *)b) - o);
(void)(p1->aa << 1); /* check that 'foo_t::aa' is an integer type */
p1->aa = -1; /* check that 'foo_t::aa' is not declared 'const' */
- t2 = CRX_INT_TYPE(cb, p1->aa, "int");
+ t2 = _CRX_INT_TYPE(cb, p1->aa, "int");
d1[0].name = "aa";
d1[0].type = t2;
d1[0].offset = o;
diff --git a/test/codegen/struct-005b.c b/test/codegen/struct-005b.c
--- a/test/codegen/struct-005b.c
+++ b/test/codegen/struct-005b.c
@@ -2,10 +2,10 @@
# ____________________________________________________________
-void teststruct_005b(crx_builder_t *cb)
+void teststruct_005b(_crx_builder_t *cb)
{
- crx_type_t *t1, *t2, *t3;
- crx_field_t d1[1];
+ _crx_type_t *t1, *t2, *t3;
+ _crx_field_t d1[1];
t1 = cb->get_struct_type(cb, "$$foo_p");
{
foo_p p1;
@@ -14,7 +14,7 @@
p1 = (void *)(((char *)b) - o);
(void)(p1->aa << 1); /* check that '*foo_p::aa' is an integer type */
p1->aa = -1; /* check that '*foo_p::aa' is not declared 'const' */
- t2 = CRX_INT_TYPE(cb, p1->aa, "int");
+ t2 = _CRX_INT_TYPE(cb, p1->aa, "int");
d1[0].name = "aa";
d1[0].type = t2;
d1[0].offset = o;
diff --git a/test/codegen/struct-006.c b/test/codegen/struct-006.c
--- a/test/codegen/struct-006.c
+++ b/test/codegen/struct-006.c
@@ -2,9 +2,9 @@
# ____________________________________________________________
-void teststruct_006(crx_builder_t *cb)
+void teststruct_006(_crx_builder_t *cb)
{
- crx_type_t *t1;
+ _crx_type_t *t1;
t1 = cb->get_struct_type(cb, "$foo_t");
cb->complete(cb, t1, sizeof(foo_t),
((char *)&((struct{char a; foo_t b;} *)0)->b) - (char *)0,
diff --git a/test/test_c_decl_parser.py b/test/test_c_decl_parser.py
--- a/test/test_c_decl_parser.py
+++ b/test/test_c_decl_parser.py
@@ -2,37 +2,14 @@
from .udir import udir
-TESTER = r"""
-#include "c_decl_parser.c"
-#include "creflect_print.h"
-
-int main(int argc, char *argv[])
-{
- crx_type_t *t1;
- const char *p = creflect_decl_parser(&maincb, argv[1], &t1);
- if (p == NULL) {
- printf("%s\n", t1->text);
- }
- else {
- printf("%s\n", argv[1]);
- while (p > argv[1]) {
- printf(" ");
- p--;
- }
- printf("^\n");
- }
- return 0;
-}
-"""
-
-
def setup_module(mod):
+ creflect_dir = os.path.join(os.path.dirname(__file__), '..', 'creflect')
executable = str(udir.join('c_decl_parser_test'))
- f = open(executable + '.c', 'w')
- f.write(TESTER)
- f.close()
- err = os.system("gcc -g -Werror '%s.c' -o '%s' -I../creflect/src" % (
- executable, executable))
+ err = os.system("gcc -g -Werror -o '%s'"
+ " '%s/creflect_cdecl.c'"
+ " '%s/creflect_debug_print.c'"
+ " '%s/creflect_cdecl_main.c'" % (
+ executable, creflect_dir, creflect_dir, creflect_dir))
assert not err
mod.executable = executable
diff --git a/test/test_cgcompile.py b/test/test_cgcompile.py
--- a/test/test_cgcompile.py
+++ b/test/test_cgcompile.py
@@ -19,27 +19,29 @@
infile = str(udir.join('cg-' + filename))
outfile = str(udir.join('cg-' + basename))
assert infile != outfile
+ creflect_dir = os.path.join(path, '..', '..', 'creflect')
f = open(infile, 'w')
- f.write('#include <stdio.h>\n')
- f.write('#include "%s/../../creflect/src/creflect.h"\n' % path)
- f.write('\n')
+ f.write('''
+#include "creflect.h"
+#include "creflect_debug_print.h"
+''')
for line in inputlines:
if not (line.startswith('# ') or line.startswith('#expect')):
if line.startswith('typedef ...'):
line = 'typedef struct _missing ' + line[11:]
f.write(line)
- f.write('\n')
- f.write('#include "%s/../../creflect/src/creflect_print.h"\n' % path)
f.write('''
int main(void)
{
- test%s(&maincb);
+ test%s(&creflect_debug_builder);
return 0;
}
''' % (basename.replace('-','_'),))
f.close()
#
- err = os.system("gcc -g -Werror -Wall '%s' -o '%s'" % (infile, outfile))
More information about the pypy-commit
mailing list