diff options
author | Vincent Sanders <vince@kyllikki.org> | 2015-08-30 09:14:38 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-08-30 09:14:38 +0100 |
commit | 83956295f66576becbf5de8cef915cd0d54f409b (patch) | |
tree | b8040d623ed6d0998ddb23224f364cc1b4be2460 /src/duk-libdom-interface.c | |
parent | d6f41574a18866ebfbb8b61f9afcd0a0de2d40cf (diff) | |
download | nsgenbind-83956295f66576becbf5de8cef915cd0d54f409b.tar.gz nsgenbind-83956295f66576becbf5de8cef915cd0d54f409b.tar.bz2 |
Change dictionary generation to produce C accessors.
This generates routines which correctly handle reading a member from a
dictionary and returning it as the correct c type. Currently the types
"any", "user" and "sequence" remain unhandled.
Diffstat (limited to 'src/duk-libdom-interface.c')
-rw-r--r-- | src/duk-libdom-interface.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/duk-libdom-interface.c b/src/duk-libdom-interface.c index 3ac7d83..aa44d38 100644 --- a/src/duk-libdom-interface.c +++ b/src/duk-libdom-interface.c @@ -792,7 +792,7 @@ output_interface_elipsis_operation(FILE* outf, * operation with elipsis should go */ WARN(WARNING_UNIMPLEMENTED, - "Elipsis parameetrs not checked: method %s::%s();", + "Elipsis parameters not checked: method %s::%s();", interfacee->name, operatione->name); output_get_method_private(outf, interfacee->class_name); @@ -1339,3 +1339,46 @@ op_error: return res; } +/* exported function documented in duk-libdom.h */ +int output_interface_declaration(FILE* outf, struct ir_entry *interfacee) +{ + struct genbind_node *init_node; + + /* do not generate prototype declarations for interfaces marked no + * output + */ + if (interfacee->u.interface.noobject) { + return 0; + } + + /* prototype declaration */ + fprintf(outf, "duk_ret_t %s_%s___proto(duk_context *ctx);\n", + DLPFX, interfacee->class_name); + + /* if the interface has no references (no other interface inherits from + * it) there is no reason to export the initalisor/finaliser as no + * other class constructor/destructor should call them. + */ + if (interfacee->refcount < 1) { + fprintf(outf, "\n"); + + return 0; + } + + /* finaliser declaration */ + fprintf(outf, + "void %s_%s___fini(duk_context *ctx, %s_private_t *priv);\n", + DLPFX, interfacee->class_name, interfacee->class_name); + + /* find the initialisor method on the class (if any) */ + init_node = genbind_node_find_method(interfacee->class, + NULL, + GENBIND_METHOD_TYPE_INIT); + + /* initialisor definition */ + output_interface_init_declaration(outf, interfacee, init_node); + + fprintf(outf, ";\n\n"); + + return 0; +} |