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
This commit is contained in:
jband%netscape.com
1999-04-10 06:17:49 +00:00
parent 00b32606ba
commit 38296e4df5
6 changed files with 54 additions and 24 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,