From 38296e4df55f5b2694a3953f23758e8fed0e9900 Mon Sep 17 00:00:00 2001 From: "jband%netscape.com" Date: Sat, 10 Apr 1999 06:17:49 +0000 Subject: [PATCH] Prepare for not emitting js stubs decls into headers. Emit the macro for GetIID. git-svn-id: svn://10.0.0.236/trunk@26973 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/tools/xpidl/xpidl.c | 11 ++++++--- mozilla/xpcom/tools/xpidl/xpidl.h | 1 + mozilla/xpcom/tools/xpidl/xpidl_header.c | 27 ++++++++++++++-------- mozilla/xpcom/typelib/xpidl/xpidl.c | 11 ++++++--- mozilla/xpcom/typelib/xpidl/xpidl.h | 1 + mozilla/xpcom/typelib/xpidl/xpidl_header.c | 27 ++++++++++++++-------- 6 files changed, 54 insertions(+), 24 deletions(-) diff --git a/mozilla/xpcom/tools/xpidl/xpidl.c b/mozilla/xpcom/tools/xpidl/xpidl.c index 5c5725c617d..615d5f6eed8 100644 --- a/mozilla/xpcom/tools/xpidl/xpidl.c +++ b/mozilla/xpcom/tools/xpidl/xpidl.c @@ -41,9 +41,10 @@ FindMode(char *mode) return NULL; } -gboolean enable_debug = FALSE; -gboolean enable_warnings = FALSE; -gboolean verbose_mode = FALSE; +gboolean enable_debug = FALSE; +gboolean enable_warnings = FALSE; +gboolean verbose_mode = FALSE; +gboolean emit_js_stub_decls = TRUE; /* XXX change default to FALSE */ static char xpidl_usage_str[] = "Usage: %s [-m mode] [-w] [-v] [-I path] [-o basename] filename.idl\n" @@ -51,6 +52,7 @@ static char xpidl_usage_str[] = " -v verbose mode (NYI)\n" " -I add entry to start of include path for ``#include \"nsIThing.idl\"''\n" " -o use basename (e.g. ``/tmp/nsIThing'') for output\n" +" -s emit JS stub declarations in headers for use with -m stub\n" " -m specify output mode:\n"; static void @@ -116,6 +118,9 @@ main(int argc, char *argv[]) case 'v': verbose_mode = TRUE; break; + case 's': + emit_js_stub_decls = TRUE; + break; case 'I': if (i == argc) { fputs("ERROR: missing path after -I\n", stderr); diff --git a/mozilla/xpcom/tools/xpidl/xpidl.h b/mozilla/xpcom/tools/xpidl/xpidl.h index e8af2438e84..bc1ef96ac48 100644 --- a/mozilla/xpcom/tools/xpidl/xpidl.h +++ b/mozilla/xpcom/tools/xpidl/xpidl.h @@ -38,6 +38,7 @@ extern gboolean enable_debug; extern gboolean enable_warnings; extern gboolean verbose_mode; +extern gboolean emit_js_stub_decls; typedef struct TreeState TreeState; diff --git a/mozilla/xpcom/tools/xpidl/xpidl_header.c b/mozilla/xpcom/tools/xpidl/xpidl_header.c index c6ca3dc2bbe..b7132dda9d9 100644 --- a/mozilla/xpcom/tools/xpidl/xpidl_header.c +++ b/mozilla/xpcom/tools/xpidl/xpidl_header.c @@ -61,12 +61,13 @@ pass_1(TreeState *state) fputc('\n', state->file); g_hash_table_foreach(state->includes, write_header, state); } - - fputs("\n" - "#ifdef XPIDL_JS_STUBS\n" - "#include \"jsapi.h\"\n" - "#endif\n", - state->file); + if (emit_js_stub_decls) { + fputs("\n" + "#ifdef XPIDL_JS_STUBS\n" + "#include \"jsapi.h\"\n" + "#endif\n", + state->file); + } } else { fprintf(state->file, "\n#endif /* __gen_%s_h__ */\n", define); } @@ -149,12 +150,19 @@ interface(TreeState *state) fputs(" {\n" " public: \n", state->file); if (iid) { + fputs(" NS_DEFINE_STATIC_IID_ACCESSOR(", state->file); + if (!write_classname_iid_define(state->file, className)) + return FALSE; + fputs(")\n", state->file); +/* XX remove this old code... emitting the macro instead */ +/* fputs(" static const nsIID& GetIID() {\n" " static nsIID iid = ", state->file); if (!write_classname_iid_define(state->file, className)) return FALSE; fputs(";\n return iid;\n }\n", state->file); +*/ } state->tree = IDL_INTERFACE(iface).body; @@ -170,14 +178,15 @@ interface(TreeState *state) * #ifdef), or you lose the vtable invariance upon which so much * of (XP)COM is based. */ - fprintf(state->file, + if (emit_js_stub_decls) { + fprintf(state->file, "\n" "#ifdef XPIDL_JS_STUBS\n" " static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);\n" " static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, %s *priv);\n" "#endif\n", className); - + } fputs("};\n", state->file); return TRUE; @@ -372,7 +381,7 @@ do_const_dcl(TreeState *state) } if(success) { - fprintf(state->file, " enum { %s = %d };\n", + fprintf(state->file, "\n enum { %s = %d };\n", name, (int) IDL_INTEGER(dcl->const_exp).value); } else { IDL_tree_warning(state->tree, IDL_WARNING1, diff --git a/mozilla/xpcom/typelib/xpidl/xpidl.c b/mozilla/xpcom/typelib/xpidl/xpidl.c index 5c5725c617d..615d5f6eed8 100644 --- a/mozilla/xpcom/typelib/xpidl/xpidl.c +++ b/mozilla/xpcom/typelib/xpidl/xpidl.c @@ -41,9 +41,10 @@ FindMode(char *mode) return NULL; } -gboolean enable_debug = FALSE; -gboolean enable_warnings = FALSE; -gboolean verbose_mode = FALSE; +gboolean enable_debug = FALSE; +gboolean enable_warnings = FALSE; +gboolean verbose_mode = FALSE; +gboolean emit_js_stub_decls = TRUE; /* XXX change default to FALSE */ static char xpidl_usage_str[] = "Usage: %s [-m mode] [-w] [-v] [-I path] [-o basename] filename.idl\n" @@ -51,6 +52,7 @@ static char xpidl_usage_str[] = " -v verbose mode (NYI)\n" " -I add entry to start of include path for ``#include \"nsIThing.idl\"''\n" " -o use basename (e.g. ``/tmp/nsIThing'') for output\n" +" -s emit JS stub declarations in headers for use with -m stub\n" " -m specify output mode:\n"; static void @@ -116,6 +118,9 @@ main(int argc, char *argv[]) case 'v': verbose_mode = TRUE; break; + case 's': + emit_js_stub_decls = TRUE; + break; case 'I': if (i == argc) { fputs("ERROR: missing path after -I\n", stderr); diff --git a/mozilla/xpcom/typelib/xpidl/xpidl.h b/mozilla/xpcom/typelib/xpidl/xpidl.h index e8af2438e84..bc1ef96ac48 100644 --- a/mozilla/xpcom/typelib/xpidl/xpidl.h +++ b/mozilla/xpcom/typelib/xpidl/xpidl.h @@ -38,6 +38,7 @@ extern gboolean enable_debug; extern gboolean enable_warnings; extern gboolean verbose_mode; +extern gboolean emit_js_stub_decls; typedef struct TreeState TreeState; diff --git a/mozilla/xpcom/typelib/xpidl/xpidl_header.c b/mozilla/xpcom/typelib/xpidl/xpidl_header.c index c6ca3dc2bbe..b7132dda9d9 100644 --- a/mozilla/xpcom/typelib/xpidl/xpidl_header.c +++ b/mozilla/xpcom/typelib/xpidl/xpidl_header.c @@ -61,12 +61,13 @@ pass_1(TreeState *state) fputc('\n', state->file); g_hash_table_foreach(state->includes, write_header, state); } - - fputs("\n" - "#ifdef XPIDL_JS_STUBS\n" - "#include \"jsapi.h\"\n" - "#endif\n", - state->file); + if (emit_js_stub_decls) { + fputs("\n" + "#ifdef XPIDL_JS_STUBS\n" + "#include \"jsapi.h\"\n" + "#endif\n", + state->file); + } } else { fprintf(state->file, "\n#endif /* __gen_%s_h__ */\n", define); } @@ -149,12 +150,19 @@ interface(TreeState *state) fputs(" {\n" " public: \n", state->file); if (iid) { + fputs(" NS_DEFINE_STATIC_IID_ACCESSOR(", state->file); + if (!write_classname_iid_define(state->file, className)) + return FALSE; + fputs(")\n", state->file); +/* XX remove this old code... emitting the macro instead */ +/* fputs(" static const nsIID& GetIID() {\n" " static nsIID iid = ", state->file); if (!write_classname_iid_define(state->file, className)) return FALSE; fputs(";\n return iid;\n }\n", state->file); +*/ } state->tree = IDL_INTERFACE(iface).body; @@ -170,14 +178,15 @@ interface(TreeState *state) * #ifdef), or you lose the vtable invariance upon which so much * of (XP)COM is based. */ - fprintf(state->file, + if (emit_js_stub_decls) { + fprintf(state->file, "\n" "#ifdef XPIDL_JS_STUBS\n" " static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);\n" " static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, %s *priv);\n" "#endif\n", className); - + } fputs("};\n", state->file); return TRUE; @@ -372,7 +381,7 @@ do_const_dcl(TreeState *state) } if(success) { - fprintf(state->file, " enum { %s = %d };\n", + fprintf(state->file, "\n enum { %s = %d };\n", name, (int) IDL_INTEGER(dcl->const_exp).value); } else { IDL_tree_warning(state->tree, IDL_WARNING1,