X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=wrappergen%2Fwrite_jna.c;h=78f63090d4f42a01bf2e714dd304a1e188b7dcc3;hb=1c4280092863759931f2fd0753bee70c2f540808;hp=8f438ff129643c38143f6c74f3a0c51898d11307;hpb=943bc48a155169ae3d8357a2aecd405247852426;p=cparser diff --git a/wrappergen/write_jna.c b/wrappergen/write_jna.c index 8f438ff..78f6309 100644 --- a/wrappergen/write_jna.c +++ b/wrappergen/write_jna.c @@ -1,6 +1,6 @@ /* * This file is part of cparser. - * Copyright (C) 2007-2008 Matthias Braun + * Copyright (C) 2007-2009 Matthias Braun * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -72,8 +72,8 @@ static const char *get_atomic_type_string(const atomic_type_kind_t type) case ATOMIC_TYPE_USHORT: return "short"; case ATOMIC_TYPE_INT: return "int"; case ATOMIC_TYPE_UINT: return "int"; - case ATOMIC_TYPE_LONG: return "NativeLong"; - case ATOMIC_TYPE_ULONG: return "NativeLong"; + case ATOMIC_TYPE_LONG: return "com.sun.jna.NativeLong"; + case ATOMIC_TYPE_ULONG: return "com.sun.jna.NativeLong"; case ATOMIC_TYPE_LONGLONG: return "long"; case ATOMIC_TYPE_ULONGLONG: return "long"; case ATOMIC_TYPE_FLOAT: return "float"; @@ -96,6 +96,11 @@ static void write_pointer_type(const pointer_type_t *type) fputs("String", out); return; } + if (is_type_pointer(points_to)) { + /* hack... */ + fputs("Pointer[]", out); + return; + } fputs("Pointer", out); } @@ -438,10 +443,7 @@ void write_jna_decls(FILE *output, const translation_unit_t *unit) type_set_output(out); fprintf(out, "/* WARNING: Automatically generated file */\n"); fputs("import com.sun.jna.Library;\n", out); - fputs("import com.sun.jna.Native;\n", out); - fputs("import com.sun.jna.Platform;\n", out); fputs("import com.sun.jna.Pointer;\n", out); - fputs("import com.sun.jna.NativeLong;\n", out); fputs("\n\n", out); /* TODO: where to get the name from? */ @@ -459,7 +461,9 @@ void write_jna_decls(FILE *output, const translation_unit_t *unit) if (buf[0] == 0) continue; - symbol_t *symbol = symbol_table_insert(buf); + char *str = malloc(len+1); + memcpy(str, buf, len+1); + symbol_t *symbol = symbol_table_insert(str); pset_new_insert(&avoid_symbols, symbol); } fclose(avoid);