summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/duk-libdom-dictionary.c6
-rw-r--r--src/duk-libdom-interface.c7
-rw-r--r--src/duk-libdom.c39
3 files changed, 33 insertions, 19 deletions
diff --git a/src/duk-libdom-dictionary.c b/src/duk-libdom-dictionary.c
index 275855e..6aae0ca 100644
--- a/src/duk-libdom-dictionary.c
+++ b/src/duk-libdom-dictionary.c
@@ -367,6 +367,9 @@ output_dictionary_init_declaration(FILE* outf,
{
struct genbind_node *param_node;
+ if (dictionarye->refcount == 0) {
+ fprintf(outf, "static ");
+ }
fprintf(outf,
"void %s_%s___init(duk_context *ctx, %s_private_t *priv",
DLPFX, dictionarye->class_name, dictionarye->class_name);
@@ -446,6 +449,9 @@ output_dictionary_fini(FILE* outf,
GENBIND_METHOD_TYPE_FINI);
/* finaliser definition */
+ if (dictionarye->refcount == 0) {
+ fprintf(outf, "static ");
+ }
fprintf(outf,
"void %s_%s___fini(duk_context *ctx, %s_private_t *priv)\n",
DLPFX, dictionarye->class_name, dictionarye->class_name);
diff --git a/src/duk-libdom-interface.c b/src/duk-libdom-interface.c
index 7501bea..3ac7d83 100644
--- a/src/duk-libdom-interface.c
+++ b/src/duk-libdom-interface.c
@@ -432,6 +432,9 @@ output_interface_init_declaration(FILE* outf,
{
struct genbind_node *param_node;
+ if (interfacee->refcount == 0) {
+ fprintf(outf, "static ");
+ }
fprintf(outf,
"void %s_%s___init(duk_context *ctx, %s_private_t *priv",
DLPFX, interfacee->class_name, interfacee->class_name);
@@ -510,7 +513,11 @@ output_interface_fini(FILE* outf,
NULL,
GENBIND_METHOD_TYPE_FINI);
+
/* finaliser definition */
+ if (interfacee->refcount == 0) {
+ fprintf(outf, "static ");
+ }
fprintf(outf,
"void %s_%s___fini(duk_context *ctx, %s_private_t *priv)\n",
DLPFX, interfacee->class_name, interfacee->class_name);
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");