зеркало из https://github.com/mozilla/gecko-dev.git
- Use write rather than dump consistently (dump has unfortunate connotations).
- Avoid gratuitous extra newlines in foo.h compiled from foo.idl. - Use do-while, not for or while, guarded by if that tests the loop condition. - Use NS_EXPORT to qualify static InitJSClass and GetJSObject method. - Turn enum declarations within interfaces into JS class constant numbers. - Defend against null return from JS_GetPrivate (prototype and user-constructed objects have no private data).
This commit is contained in:
Родитель
ff14535f6e
Коммит
4a71eaefa6
|
@ -112,9 +112,10 @@ gboolean
|
|||
xpidl_process_node(TreeState *state);
|
||||
|
||||
/*
|
||||
* Dump a comment containing IDL source decompiled from state->tree.
|
||||
* Write a newline folllowed by an indented, one-line comment containing IDL
|
||||
* source decompiled from state->tree.
|
||||
*/
|
||||
void
|
||||
xpidl_dump_comment(TreeState *state, int indent);
|
||||
xpidl_write_comment(TreeState *state, int indent);
|
||||
|
||||
#endif /* __xpidl_h */
|
||||
|
|
|
@ -60,7 +60,6 @@ pass_1(TreeState *state)
|
|||
if (g_hash_table_size(state->includes)) {
|
||||
fputc('\n', state->file);
|
||||
g_hash_table_foreach(state->includes, write_header, state);
|
||||
fputc('\n', state->file);
|
||||
}
|
||||
} else {
|
||||
fprintf(state->file, "\n#endif /* __gen_%s_h__ */\n", define);
|
||||
|
@ -69,7 +68,7 @@ pass_1(TreeState *state)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
output_classname_iid_define(FILE *file, const char *className)
|
||||
write_classname_iid_define(FILE *file, const char *className)
|
||||
{
|
||||
const char *iidName;
|
||||
if (className[0] == 'n' && className[1] == 's') {
|
||||
|
@ -101,10 +100,10 @@ interface(TreeState *state)
|
|||
/* XXX report error */
|
||||
return FALSE;
|
||||
fprintf(state->file, "\n/* {%s} */\n#define ", iid);
|
||||
if (!output_classname_iid_define(state->file, className))
|
||||
if (!write_classname_iid_define(state->file, className))
|
||||
return FALSE;
|
||||
fprintf(state->file, "_STR \"%s\"\n#define ", iid);
|
||||
if (!output_classname_iid_define(state->file, className))
|
||||
if (!write_classname_iid_define(state->file, className))
|
||||
return FALSE;
|
||||
/* This is such a gross hack... */
|
||||
fprintf(state->file, " \\\n {0x%.8s, 0x%.4s, 0x%.4s, \\\n "
|
||||
|
@ -116,12 +115,12 @@ interface(TreeState *state)
|
|||
fprintf(state->file, "class %s", className);
|
||||
if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
|
||||
fputs(" : ", state->file);
|
||||
for (; iter; iter = IDL_LIST(iter).next) {
|
||||
do {
|
||||
fprintf(state->file, "public %s",
|
||||
IDL_IDENT(IDL_LIST(iter).data).str);
|
||||
if (IDL_LIST(iter).next)
|
||||
fputs(", ", state->file);
|
||||
}
|
||||
} while ((iter = IDL_LIST(iter).next));
|
||||
}
|
||||
fputs(" {\n"
|
||||
" public: \n", state->file);
|
||||
|
@ -129,7 +128,7 @@ interface(TreeState *state)
|
|||
fputs(" static const nsIID& IID() {\n"
|
||||
" static nsIID iid = ",
|
||||
state->file);
|
||||
if (!output_classname_iid_define(state->file, className))
|
||||
if (!write_classname_iid_define(state->file, className))
|
||||
return FALSE;
|
||||
fputs(";\n return iid;\n }\n", state->file);
|
||||
}
|
||||
|
@ -142,8 +141,8 @@ interface(TreeState *state)
|
|||
/* XXXbe keep this statement until -m stub dies */
|
||||
fprintf(state->file,
|
||||
"\n"
|
||||
" static JSObject *InitJSClass(JSContext *cx);\n"
|
||||
" static JSObject *GetJSObject(JSContext *cx, %s *priv);\n",
|
||||
" static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);\n"
|
||||
" static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, %s *priv);\n",
|
||||
className);
|
||||
|
||||
fputs("};\n", state->file);
|
||||
|
@ -260,7 +259,7 @@ static gboolean
|
|||
attr_dcl(TreeState *state)
|
||||
{
|
||||
gboolean ro = IDL_ATTR_DCL(state->tree).f_readonly;
|
||||
xpidl_dump_comment(state, 2);
|
||||
xpidl_write_comment(state, 2);
|
||||
return attr_accessor(state, TRUE) && (ro || attr_accessor(state, FALSE));
|
||||
}
|
||||
|
||||
|
@ -273,9 +272,11 @@ do_enum(TreeState *state)
|
|||
IDL_IDENT(IDL_TYPE_ENUM(enumb).ident).str);
|
||||
|
||||
for (iter = IDL_TYPE_ENUM(enumb).enumerator_list;
|
||||
iter; iter = IDL_LIST(iter).next)
|
||||
iter;
|
||||
iter = IDL_LIST(iter).next) {
|
||||
fprintf(state->file, " %s%s\n", IDL_IDENT(IDL_LIST(iter).data).str,
|
||||
IDL_LIST(iter).next ? ",": "");
|
||||
}
|
||||
|
||||
fputs("};\n\n", state->file);
|
||||
return TRUE;
|
||||
|
@ -356,7 +357,7 @@ op_dcl(TreeState *state)
|
|||
struct _IDL_OP_DCL *op = &IDL_OP_DCL(state->tree);
|
||||
IDL_tree iter;
|
||||
|
||||
xpidl_dump_comment(state, 2);
|
||||
xpidl_write_comment(state, 2);
|
||||
|
||||
fprintf(state->file, " NS_IMETHOD %s(", IDL_IDENT(op->ident).str);
|
||||
for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) {
|
||||
|
@ -390,7 +391,7 @@ op_dcl(TreeState *state)
|
|||
}
|
||||
|
||||
static void
|
||||
dump_codefrag_line(gpointer data, gpointer user_data)
|
||||
write_codefrag_line(gpointer data, gpointer user_data)
|
||||
{
|
||||
TreeState *state = (TreeState *)user_data;
|
||||
char *line = (char *)data;
|
||||
|
@ -403,7 +404,7 @@ codefrag(TreeState *state)
|
|||
{
|
||||
if (strcmp(IDL_CODEFRAG(state->tree).desc, "C++"))
|
||||
return TRUE;
|
||||
g_slist_foreach(IDL_CODEFRAG(state->tree).lines, dump_codefrag_line,
|
||||
g_slist_foreach(IDL_CODEFRAG(state->tree).lines, write_codefrag_line,
|
||||
(gpointer)state);
|
||||
fputc('\n', state->file);
|
||||
return TRUE;
|
||||
|
|
|
@ -507,7 +507,7 @@ xpidl_process_idl(char *filename, IncludePathEntry *include_path,
|
|||
}
|
||||
|
||||
void
|
||||
xpidl_dump_comment(TreeState *state, int indent)
|
||||
xpidl_write_comment(TreeState *state, int indent)
|
||||
{
|
||||
fprintf(state->file, "\n%*s/* ", indent, "");
|
||||
IDL_tree_to_IDL(state->tree, state->ns, state->file,
|
||||
|
|
|
@ -27,8 +27,8 @@ struct stub_private {
|
|||
IDL_tree iface;
|
||||
IDL_tree *funcs;
|
||||
unsigned nfuncs;
|
||||
IDL_tree *const_dbls;
|
||||
unsigned nconst_dbls;
|
||||
IDL_tree *enums;
|
||||
unsigned nenums;
|
||||
IDL_tree *props;
|
||||
unsigned nprops;
|
||||
};
|
||||
|
@ -38,8 +38,8 @@ free_stub_private(struct stub_private *priv)
|
|||
{
|
||||
if (priv->funcs)
|
||||
free(priv->funcs);
|
||||
if (priv->const_dbls)
|
||||
free(priv->const_dbls);
|
||||
if (priv->enums)
|
||||
free(priv->enums);
|
||||
if (priv->props)
|
||||
free(priv->props);
|
||||
free(priv);
|
||||
|
@ -149,15 +149,15 @@ js_convert_arguments_format(IDL_tree type)
|
|||
|
||||
static gboolean
|
||||
emit_convert_result(TreeState *state, const char *from, const char *to,
|
||||
const char *extra)
|
||||
const char *extra_space)
|
||||
{
|
||||
switch (IDL_NODE_TYPE(state->tree)) {
|
||||
case IDLN_TYPE_INTEGER:
|
||||
fprintf(state->file,
|
||||
"%s if (!JS_NewNumberValue(cx, (jsdouble) %s, %s))\n"
|
||||
"%s return JS_FALSE;\n",
|
||||
extra, from, to,
|
||||
extra);
|
||||
extra_space, from, to,
|
||||
extra_space);
|
||||
break;
|
||||
case IDLN_TYPE_STRING:
|
||||
/* XXXbe must free 'from' using priv's nsIAllocator iff not weak! */
|
||||
|
@ -166,15 +166,15 @@ emit_convert_result(TreeState *state, const char *from, const char *to,
|
|||
"%s if (!str)\n"
|
||||
"%s return JS_FALSE;\n"
|
||||
"%s *%s = STRING_TO_JSVAL(str);\n",
|
||||
extra, from,
|
||||
extra,
|
||||
extra,
|
||||
extra, to);
|
||||
extra_space, from,
|
||||
extra_space,
|
||||
extra_space,
|
||||
extra_space, to);
|
||||
break;
|
||||
case IDLN_TYPE_BOOLEAN:
|
||||
fprintf(state->file,
|
||||
"%s *%s = BOOLEAN_TO_JSVAL(%s);\n",
|
||||
extra, to, from);
|
||||
extra_space, to, from);
|
||||
break;
|
||||
case IDLN_IDENT:
|
||||
if (IDL_NODE_UP(state->tree) &&
|
||||
|
@ -182,14 +182,14 @@ emit_convert_result(TreeState *state, const char *from, const char *to,
|
|||
/* XXXbe issue warning, method should have been noscript? */
|
||||
fprintf(state->file,
|
||||
"%s *%s = JSVAL_NULL;\n",
|
||||
extra, to);
|
||||
extra_space, to);
|
||||
break;
|
||||
}
|
||||
fprintf(state->file,
|
||||
"%s *%s = OBJECT_TO_JSVAL(%s::GetJSObject(cx, %s));\n"
|
||||
"%s NS_RELEASE(%s);\n",
|
||||
extra, to, IDL_IDENT(state->tree).str, from,
|
||||
extra, from);
|
||||
extra_space, to, IDL_IDENT(state->tree).str, from,
|
||||
extra_space, from);
|
||||
break;
|
||||
default:
|
||||
assert(0); /* XXXbe */
|
||||
|
@ -211,7 +211,7 @@ stub_op_dcl(TreeState *state)
|
|||
return TRUE;
|
||||
|
||||
append_to_vector(&priv->funcs, &priv->nfuncs, method);
|
||||
xpidl_dump_comment(state, 0);
|
||||
xpidl_write_comment(state, 0);
|
||||
|
||||
assert(IDL_NODE_UP(IDL_NODE_UP(method)));
|
||||
iface = IDL_NODE_UP(IDL_NODE_UP(method));
|
||||
|
@ -291,7 +291,9 @@ stub_op_dcl(TreeState *state)
|
|||
static gboolean
|
||||
stub_type_enum(TreeState *state)
|
||||
{
|
||||
fputs("XXXbe type_enum\n", state->file);
|
||||
struct stub_private *priv = state->priv;
|
||||
if (priv)
|
||||
append_to_vector(&priv->enums, &priv->nenums, state->tree);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -309,6 +311,8 @@ emit_property_op(TreeState *state, const char *className, char which)
|
|||
" return JS_TRUE;\n"
|
||||
" nsresult result;\n"
|
||||
" %s *priv = (%s *)JS_GetPrivate(cx, obj);\n"
|
||||
" if (!priv)\n"
|
||||
" return JS_TRUE;\n"
|
||||
" switch (JSVAL_TO_INT(id)) {\n",
|
||||
className, which, className, className);
|
||||
|
||||
|
@ -404,12 +408,22 @@ stub_interface(TreeState *state)
|
|||
fputs(" {0}\n};\n", state->file);
|
||||
}
|
||||
|
||||
if (priv->const_dbls) {
|
||||
if (priv->enums) {
|
||||
fprintf(state->file,
|
||||
"\nstatic JSConstDoubleSpec %s_const_dbls[] = {\n",
|
||||
className);
|
||||
for (i = 0; i < priv->nconst_dbls; i++) {
|
||||
fprintf(state->file, " {%g, \"%s\"},\n", 0., "d'oh!");
|
||||
for (i = 0; i < priv->nenums; i++) {
|
||||
unsigned j = 0;
|
||||
IDL_tree iter;
|
||||
for (iter = IDL_TYPE_ENUM(priv->enums[i]).enumerator_list;
|
||||
iter;
|
||||
iter = IDL_LIST(iter).next) {
|
||||
fprintf(state->file,
|
||||
" {%u, \"%s\"},\n",
|
||||
j,
|
||||
IDL_IDENT(IDL_LIST(iter).data).str);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
fputs(" {0}\n};\n", state->file);
|
||||
|
||||
|
@ -510,7 +524,7 @@ stub_interface(TreeState *state)
|
|||
else
|
||||
fputc('0', state->file);
|
||||
fputs( ", 0, 0);\n", state->file);
|
||||
if (priv->const_dbls) {
|
||||
if (priv->enums) {
|
||||
fprintf(state->file,
|
||||
" if (!proto)\n"
|
||||
" return 0;\n"
|
||||
|
|
|
@ -112,9 +112,10 @@ gboolean
|
|||
xpidl_process_node(TreeState *state);
|
||||
|
||||
/*
|
||||
* Dump a comment containing IDL source decompiled from state->tree.
|
||||
* Write a newline folllowed by an indented, one-line comment containing IDL
|
||||
* source decompiled from state->tree.
|
||||
*/
|
||||
void
|
||||
xpidl_dump_comment(TreeState *state, int indent);
|
||||
xpidl_write_comment(TreeState *state, int indent);
|
||||
|
||||
#endif /* __xpidl_h */
|
||||
|
|
|
@ -60,7 +60,6 @@ pass_1(TreeState *state)
|
|||
if (g_hash_table_size(state->includes)) {
|
||||
fputc('\n', state->file);
|
||||
g_hash_table_foreach(state->includes, write_header, state);
|
||||
fputc('\n', state->file);
|
||||
}
|
||||
} else {
|
||||
fprintf(state->file, "\n#endif /* __gen_%s_h__ */\n", define);
|
||||
|
@ -69,7 +68,7 @@ pass_1(TreeState *state)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
output_classname_iid_define(FILE *file, const char *className)
|
||||
write_classname_iid_define(FILE *file, const char *className)
|
||||
{
|
||||
const char *iidName;
|
||||
if (className[0] == 'n' && className[1] == 's') {
|
||||
|
@ -101,10 +100,10 @@ interface(TreeState *state)
|
|||
/* XXX report error */
|
||||
return FALSE;
|
||||
fprintf(state->file, "\n/* {%s} */\n#define ", iid);
|
||||
if (!output_classname_iid_define(state->file, className))
|
||||
if (!write_classname_iid_define(state->file, className))
|
||||
return FALSE;
|
||||
fprintf(state->file, "_STR \"%s\"\n#define ", iid);
|
||||
if (!output_classname_iid_define(state->file, className))
|
||||
if (!write_classname_iid_define(state->file, className))
|
||||
return FALSE;
|
||||
/* This is such a gross hack... */
|
||||
fprintf(state->file, " \\\n {0x%.8s, 0x%.4s, 0x%.4s, \\\n "
|
||||
|
@ -116,12 +115,12 @@ interface(TreeState *state)
|
|||
fprintf(state->file, "class %s", className);
|
||||
if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
|
||||
fputs(" : ", state->file);
|
||||
for (; iter; iter = IDL_LIST(iter).next) {
|
||||
do {
|
||||
fprintf(state->file, "public %s",
|
||||
IDL_IDENT(IDL_LIST(iter).data).str);
|
||||
if (IDL_LIST(iter).next)
|
||||
fputs(", ", state->file);
|
||||
}
|
||||
} while ((iter = IDL_LIST(iter).next));
|
||||
}
|
||||
fputs(" {\n"
|
||||
" public: \n", state->file);
|
||||
|
@ -129,7 +128,7 @@ interface(TreeState *state)
|
|||
fputs(" static const nsIID& IID() {\n"
|
||||
" static nsIID iid = ",
|
||||
state->file);
|
||||
if (!output_classname_iid_define(state->file, className))
|
||||
if (!write_classname_iid_define(state->file, className))
|
||||
return FALSE;
|
||||
fputs(";\n return iid;\n }\n", state->file);
|
||||
}
|
||||
|
@ -142,8 +141,8 @@ interface(TreeState *state)
|
|||
/* XXXbe keep this statement until -m stub dies */
|
||||
fprintf(state->file,
|
||||
"\n"
|
||||
" static JSObject *InitJSClass(JSContext *cx);\n"
|
||||
" static JSObject *GetJSObject(JSContext *cx, %s *priv);\n",
|
||||
" static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);\n"
|
||||
" static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, %s *priv);\n",
|
||||
className);
|
||||
|
||||
fputs("};\n", state->file);
|
||||
|
@ -260,7 +259,7 @@ static gboolean
|
|||
attr_dcl(TreeState *state)
|
||||
{
|
||||
gboolean ro = IDL_ATTR_DCL(state->tree).f_readonly;
|
||||
xpidl_dump_comment(state, 2);
|
||||
xpidl_write_comment(state, 2);
|
||||
return attr_accessor(state, TRUE) && (ro || attr_accessor(state, FALSE));
|
||||
}
|
||||
|
||||
|
@ -273,9 +272,11 @@ do_enum(TreeState *state)
|
|||
IDL_IDENT(IDL_TYPE_ENUM(enumb).ident).str);
|
||||
|
||||
for (iter = IDL_TYPE_ENUM(enumb).enumerator_list;
|
||||
iter; iter = IDL_LIST(iter).next)
|
||||
iter;
|
||||
iter = IDL_LIST(iter).next) {
|
||||
fprintf(state->file, " %s%s\n", IDL_IDENT(IDL_LIST(iter).data).str,
|
||||
IDL_LIST(iter).next ? ",": "");
|
||||
}
|
||||
|
||||
fputs("};\n\n", state->file);
|
||||
return TRUE;
|
||||
|
@ -356,7 +357,7 @@ op_dcl(TreeState *state)
|
|||
struct _IDL_OP_DCL *op = &IDL_OP_DCL(state->tree);
|
||||
IDL_tree iter;
|
||||
|
||||
xpidl_dump_comment(state, 2);
|
||||
xpidl_write_comment(state, 2);
|
||||
|
||||
fprintf(state->file, " NS_IMETHOD %s(", IDL_IDENT(op->ident).str);
|
||||
for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) {
|
||||
|
@ -390,7 +391,7 @@ op_dcl(TreeState *state)
|
|||
}
|
||||
|
||||
static void
|
||||
dump_codefrag_line(gpointer data, gpointer user_data)
|
||||
write_codefrag_line(gpointer data, gpointer user_data)
|
||||
{
|
||||
TreeState *state = (TreeState *)user_data;
|
||||
char *line = (char *)data;
|
||||
|
@ -403,7 +404,7 @@ codefrag(TreeState *state)
|
|||
{
|
||||
if (strcmp(IDL_CODEFRAG(state->tree).desc, "C++"))
|
||||
return TRUE;
|
||||
g_slist_foreach(IDL_CODEFRAG(state->tree).lines, dump_codefrag_line,
|
||||
g_slist_foreach(IDL_CODEFRAG(state->tree).lines, write_codefrag_line,
|
||||
(gpointer)state);
|
||||
fputc('\n', state->file);
|
||||
return TRUE;
|
||||
|
|
|
@ -507,7 +507,7 @@ xpidl_process_idl(char *filename, IncludePathEntry *include_path,
|
|||
}
|
||||
|
||||
void
|
||||
xpidl_dump_comment(TreeState *state, int indent)
|
||||
xpidl_write_comment(TreeState *state, int indent)
|
||||
{
|
||||
fprintf(state->file, "\n%*s/* ", indent, "");
|
||||
IDL_tree_to_IDL(state->tree, state->ns, state->file,
|
||||
|
|
|
@ -27,8 +27,8 @@ struct stub_private {
|
|||
IDL_tree iface;
|
||||
IDL_tree *funcs;
|
||||
unsigned nfuncs;
|
||||
IDL_tree *const_dbls;
|
||||
unsigned nconst_dbls;
|
||||
IDL_tree *enums;
|
||||
unsigned nenums;
|
||||
IDL_tree *props;
|
||||
unsigned nprops;
|
||||
};
|
||||
|
@ -38,8 +38,8 @@ free_stub_private(struct stub_private *priv)
|
|||
{
|
||||
if (priv->funcs)
|
||||
free(priv->funcs);
|
||||
if (priv->const_dbls)
|
||||
free(priv->const_dbls);
|
||||
if (priv->enums)
|
||||
free(priv->enums);
|
||||
if (priv->props)
|
||||
free(priv->props);
|
||||
free(priv);
|
||||
|
@ -149,15 +149,15 @@ js_convert_arguments_format(IDL_tree type)
|
|||
|
||||
static gboolean
|
||||
emit_convert_result(TreeState *state, const char *from, const char *to,
|
||||
const char *extra)
|
||||
const char *extra_space)
|
||||
{
|
||||
switch (IDL_NODE_TYPE(state->tree)) {
|
||||
case IDLN_TYPE_INTEGER:
|
||||
fprintf(state->file,
|
||||
"%s if (!JS_NewNumberValue(cx, (jsdouble) %s, %s))\n"
|
||||
"%s return JS_FALSE;\n",
|
||||
extra, from, to,
|
||||
extra);
|
||||
extra_space, from, to,
|
||||
extra_space);
|
||||
break;
|
||||
case IDLN_TYPE_STRING:
|
||||
/* XXXbe must free 'from' using priv's nsIAllocator iff not weak! */
|
||||
|
@ -166,15 +166,15 @@ emit_convert_result(TreeState *state, const char *from, const char *to,
|
|||
"%s if (!str)\n"
|
||||
"%s return JS_FALSE;\n"
|
||||
"%s *%s = STRING_TO_JSVAL(str);\n",
|
||||
extra, from,
|
||||
extra,
|
||||
extra,
|
||||
extra, to);
|
||||
extra_space, from,
|
||||
extra_space,
|
||||
extra_space,
|
||||
extra_space, to);
|
||||
break;
|
||||
case IDLN_TYPE_BOOLEAN:
|
||||
fprintf(state->file,
|
||||
"%s *%s = BOOLEAN_TO_JSVAL(%s);\n",
|
||||
extra, to, from);
|
||||
extra_space, to, from);
|
||||
break;
|
||||
case IDLN_IDENT:
|
||||
if (IDL_NODE_UP(state->tree) &&
|
||||
|
@ -182,14 +182,14 @@ emit_convert_result(TreeState *state, const char *from, const char *to,
|
|||
/* XXXbe issue warning, method should have been noscript? */
|
||||
fprintf(state->file,
|
||||
"%s *%s = JSVAL_NULL;\n",
|
||||
extra, to);
|
||||
extra_space, to);
|
||||
break;
|
||||
}
|
||||
fprintf(state->file,
|
||||
"%s *%s = OBJECT_TO_JSVAL(%s::GetJSObject(cx, %s));\n"
|
||||
"%s NS_RELEASE(%s);\n",
|
||||
extra, to, IDL_IDENT(state->tree).str, from,
|
||||
extra, from);
|
||||
extra_space, to, IDL_IDENT(state->tree).str, from,
|
||||
extra_space, from);
|
||||
break;
|
||||
default:
|
||||
assert(0); /* XXXbe */
|
||||
|
@ -211,7 +211,7 @@ stub_op_dcl(TreeState *state)
|
|||
return TRUE;
|
||||
|
||||
append_to_vector(&priv->funcs, &priv->nfuncs, method);
|
||||
xpidl_dump_comment(state, 0);
|
||||
xpidl_write_comment(state, 0);
|
||||
|
||||
assert(IDL_NODE_UP(IDL_NODE_UP(method)));
|
||||
iface = IDL_NODE_UP(IDL_NODE_UP(method));
|
||||
|
@ -291,7 +291,9 @@ stub_op_dcl(TreeState *state)
|
|||
static gboolean
|
||||
stub_type_enum(TreeState *state)
|
||||
{
|
||||
fputs("XXXbe type_enum\n", state->file);
|
||||
struct stub_private *priv = state->priv;
|
||||
if (priv)
|
||||
append_to_vector(&priv->enums, &priv->nenums, state->tree);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -309,6 +311,8 @@ emit_property_op(TreeState *state, const char *className, char which)
|
|||
" return JS_TRUE;\n"
|
||||
" nsresult result;\n"
|
||||
" %s *priv = (%s *)JS_GetPrivate(cx, obj);\n"
|
||||
" if (!priv)\n"
|
||||
" return JS_TRUE;\n"
|
||||
" switch (JSVAL_TO_INT(id)) {\n",
|
||||
className, which, className, className);
|
||||
|
||||
|
@ -404,12 +408,22 @@ stub_interface(TreeState *state)
|
|||
fputs(" {0}\n};\n", state->file);
|
||||
}
|
||||
|
||||
if (priv->const_dbls) {
|
||||
if (priv->enums) {
|
||||
fprintf(state->file,
|
||||
"\nstatic JSConstDoubleSpec %s_const_dbls[] = {\n",
|
||||
className);
|
||||
for (i = 0; i < priv->nconst_dbls; i++) {
|
||||
fprintf(state->file, " {%g, \"%s\"},\n", 0., "d'oh!");
|
||||
for (i = 0; i < priv->nenums; i++) {
|
||||
unsigned j = 0;
|
||||
IDL_tree iter;
|
||||
for (iter = IDL_TYPE_ENUM(priv->enums[i]).enumerator_list;
|
||||
iter;
|
||||
iter = IDL_LIST(iter).next) {
|
||||
fprintf(state->file,
|
||||
" {%u, \"%s\"},\n",
|
||||
j,
|
||||
IDL_IDENT(IDL_LIST(iter).data).str);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
fputs(" {0}\n};\n", state->file);
|
||||
|
||||
|
@ -510,7 +524,7 @@ stub_interface(TreeState *state)
|
|||
else
|
||||
fputc('0', state->file);
|
||||
fputs( ", 0, 0);\n", state->file);
|
||||
if (priv->const_dbls) {
|
||||
if (priv->enums) {
|
||||
fprintf(state->file,
|
||||
" if (!proto)\n"
|
||||
" return 0;\n"
|
||||
|
|
Загрузка…
Ссылка в новой задаче