diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2013-10-08 10:36:19 -0700 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-10-08 10:36:19 -0700 |
commit | 283e52486136b4fef22433c037dceb84d1b15637 (patch) | |
tree | 24ea301a5dc6d14f601d9151cc60fc681113d250 | |
parent | d0ce91ccea8e10b35171b627fd46f0838a3ae99c (diff) |
better wl_array supportbetter-array
-rw-r--r-- | src/scanner.c | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/scanner.c b/src/scanner.c index e7ad327..2891668 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -578,6 +578,28 @@ emit_opcodes(struct wl_list *message_list, struct interface *interface) printf("\n"); } +static const char * +get_simple_type_name(enum arg_type type) +{ + switch (type) { + case INT: + case FD: + return "int32_t"; + case NEW_ID: + case UNSIGNED: + return "uint32_t"; + case FIXED: + return "wl_fixed_t"; + break; + case STRING: + case OBJECT: + case ARRAY: + default: + fprintf(stderr, "invalid simple type\n"); + exit(EXIT_FAILURE); + } +} + static void emit_type(struct arg *a) { @@ -585,23 +607,24 @@ emit_type(struct arg *a) default: case INT: case FD: - printf("int32_t "); - break; case NEW_ID: case UNSIGNED: - printf("uint32_t "); - break; case FIXED: - printf("wl_fixed_t "); + printf("%s %s", get_simple_type_name(a->type), a->name); break; case STRING: - printf("const char *"); + printf("const char *%s", a->name); break; case OBJECT: - printf("struct %s *", a->interface_name); + printf("struct %s *%s", a->interface_name, a->name); break; case ARRAY: - printf("struct wl_array *"); + if (0) + printf("struct wl_array *"); + else + printf("%s *%s, int %s_count", + get_simple_type_name(a->element_type), + a->name, a->name); break; } } @@ -686,7 +709,6 @@ emit_stubs(struct wl_list *message_list, struct interface *interface) continue; printf(", "); emit_type(a); - printf("%s", a->name); } printf(")\n" @@ -756,12 +778,11 @@ emit_event_wrappers(struct wl_list *message_list, struct interface *interface) switch (a->type) { case NEW_ID: case OBJECT: - printf("struct wl_resource *"); + printf("struct wl_resource *%s", a->name); break; default: emit_type(a); } - printf("%s", a->name); } printf(")\n" @@ -898,11 +919,10 @@ emit_structs(struct wl_list *message_list, struct interface *interface) printf("void *"); else if (!is_interface && a->type == NEW_ID) - printf("struct %s *", a->interface_name); + printf("struct %s *%s", + a->interface_name, a->name); else emit_type(a); - - printf("%s", a->name); } printf(");\n"); |