projects
/
cparser
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Let panic() print file, line and function.
[cparser]
/
wrappergen
/
write_jna.c
diff --git
a/wrappergen/write_jna.c
b/wrappergen/write_jna.c
index
09ef6aa
..
3e17794
100644
(file)
--- a/
wrappergen/write_jna.c
+++ b/
wrappergen/write_jna.c
@@
-32,7
+32,7
@@
#include "printer.h"
#include "adt/error.h"
#include "adt/xmalloc.h"
#include "printer.h"
#include "adt/error.h"
#include "adt/xmalloc.h"
-#include
<libfirm/adt/pset_new.h>
+#include
"adt/pset_new.h"
typedef struct output_limit {
const char *filename;
typedef struct output_limit {
const char *filename;
@@
-226,7
+226,7
@@
static void write_type(type_t *type)
case TYPE_ERROR:
case TYPE_TYPEOF:
case TYPE_TYPEDEF:
case TYPE_ERROR:
case TYPE_TYPEOF:
case TYPE_TYPEDEF:
- panic("invalid type
found
");
+ panic("invalid type");
case TYPE_ARRAY:
case TYPE_REFERENCE:
case TYPE_FUNCTION:
case TYPE_ARRAY:
case TYPE_REFERENCE:
case TYPE_FUNCTION:
@@
-275,7
+275,7
@@
static void write_unary_expression(const unary_expression_t *expression)
write_expression(expression->value);
return;
default:
write_expression(expression->value);
return;
default:
- panic("unim
eplemented unary expression found
");
+ panic("unim
plemented unary expression
");
}
write_expression(expression->value);
}
}
write_expression(expression->value);
}
@@
-303,18
+303,22
@@
static void write_binary_expression(const binary_expression_t *expression)
fputs(")", out);
}
fputs(")", out);
}
+static void write_integer(const literal_expression_t *literal)
+{
+ for (const char *c = literal->value.begin; c != literal->suffix; ++c) {
+ fputc(*c, out);
+ }
+}
+
static void write_expression(const expression_t *expression)
{
/* TODO */
switch(expression->kind) {
case EXPR_LITERAL_INTEGER:
static void write_expression(const expression_t *expression)
{
/* TODO */
switch(expression->kind) {
case EXPR_LITERAL_INTEGER:
- case EXPR_LITERAL_INTEGER_OCTAL:
- fprintf(out, "%s", expression->literal.value.begin);
+ write_integer(&expression->literal);
break;
break;
- case EXPR_LITERAL_INTEGER_HEXADECIMAL:
- fprintf(out, "0x%s", expression->literal.value.begin);
- break;
- case EXPR_REFERENCE_ENUM_VALUE: {
+
+ case EXPR_ENUM_CONSTANT: {
/* UHOH... hacking */
entity_t *entity = expression->reference.entity;
write_enum_name(& entity->enum_value.enum_type->enumt);
/* UHOH... hacking */
entity_t *entity = expression->reference.entity;
write_enum_name(& entity->enum_value.enum_type->enumt);
@@
-400,7
+404,7
@@
static void write_variable(const entity_t *entity)
static void write_function(const entity_t *entity)
{
static void write_function(const entity_t *entity)
{
- if (entity->function.
statement
!= NULL) {
+ if (entity->function.
body
!= NULL) {
fprintf(stderr, "Warning: can't convert function bodies (at %s)\n",
entity->base.symbol->string);
return;
fprintf(stderr, "Warning: can't convert function bodies (at %s)\n",
entity->base.symbol->string);
return;
@@
-436,8
+440,6
@@
static void write_function(const entity_t *entity)
if(function_type->variadic) {
if(!first) {
fprintf(out, ", ");
if(function_type->variadic) {
if(!first) {
fprintf(out, ", ");
- } else {
- first = 0;
}
fputs("Object ... args", out);
}
}
fputs("Object ... args", out);
}
@@
-520,8
+522,7
@@
void write_jna_decls(FILE *output, const translation_unit_t *unit)
}
#if 0
}
#if 0
- if(type->kind == TYPE_COMPOUND_STRUCT
- || type->kind == TYPE_COMPOUND_UNION) {
+ if (is_type_compound(type)) {
write_compound(entity->base.symbol, &type->compound);
}
#endif
write_compound(entity->base.symbol, &type->compound);
}
#endif