diff options
Diffstat (limited to 'src/duk-libdom.c')
-rw-r--r-- | src/duk-libdom.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/duk-libdom.c b/src/duk-libdom.c index 45e7e79..02b41b3 100644 --- a/src/duk-libdom.c +++ b/src/duk-libdom.c @@ -331,26 +331,27 @@ output_prototype_header(struct ir *ir) fprintf(protof, "duk_ret_t %s_%s___proto(duk_context *ctx);\n", DLPFX, interfacee->class_name); - /** \todo 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. Additionally the - * init/fini definition should be made static. + /* 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. */ - - /* finaliser declaration */ - fprintf(protof, - "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(protof, interfacee, init_node); - fprintf(protof, ";\n\n"); + if (interfacee->refcount > 0) { + /* finaliser declaration */ + fprintf(protof, + "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(protof, interfacee, init_node); + fprintf(protof, ";\n\n"); + } + fprintf(protof, "\n"); } close_header(ir, protof, "prototype"); |