From c5e87476497cc6c11429b38d44b7d052e5f70898 Mon Sep 17 00:00:00 2001 From: "jband%netscape.com" Date: Sun, 28 Mar 1999 22:01:33 +0000 Subject: [PATCH] many changes to xpidl: - Removed '-n' from usage message. - Added name_space (if declared) to comment in generated C++ header. - Added [ptr], [ref], and [nsid] support for native declarations. - Added support for [const] on 'in' params. - Now add 'const' automatically for nsID in params. - Added support for [shared] on 'out' params. - Added -w warnings support for non-support of sequences. - Removed support for enum and added -w wrning that they are ignored. - Added support in header and typelib output for constants (short and long only). --- xpcom/tools/xpidl/xpidl.c | 2 +- xpcom/tools/xpidl/xpidl_header.c | 85 ++++++++++++++++++++--- xpcom/tools/xpidl/xpidl_typelib.c | 101 +++++++++++++++++++++++++++- xpcom/typelib/xpidl/xpidl.c | 2 +- xpcom/typelib/xpidl/xpidl_header.c | 85 ++++++++++++++++++++--- xpcom/typelib/xpidl/xpidl_typelib.c | 101 +++++++++++++++++++++++++++- 6 files changed, 352 insertions(+), 24 deletions(-) diff --git a/xpcom/tools/xpidl/xpidl.c b/xpcom/tools/xpidl/xpidl.c index f54dd3c07b26..5c5725c617dd 100644 --- a/xpcom/tools/xpidl/xpidl.c +++ b/xpcom/tools/xpidl/xpidl.c @@ -46,7 +46,7 @@ gboolean enable_warnings = FALSE; gboolean verbose_mode = FALSE; static char xpidl_usage_str[] = -"Usage: %s [-m mode] [-w] [-v] [-I path] [-n] [-o basename] filename.idl\n" +"Usage: %s [-m mode] [-w] [-v] [-I path] [-o basename] filename.idl\n" " -w turn on warnings (recommended)\n" " -v verbose mode (NYI)\n" " -I add entry to start of include path for ``#include \"nsIThing.idl\"''\n" diff --git a/xpcom/tools/xpidl/xpidl_header.c b/xpcom/tools/xpidl/xpidl_header.c index aa3754372a68..394357853d2d 100644 --- a/xpcom/tools/xpidl/xpidl_header.c +++ b/xpcom/tools/xpidl/xpidl_header.c @@ -96,17 +96,28 @@ interface(TreeState *state) IDL_tree iface = state->tree, iter; char *className = IDL_IDENT(IDL_INTERFACE(iface).ident).str; const char *iid; + const char *name_space; - fprintf(state->file, "\n/* starting interface %s */\n", + fprintf(state->file, "\n/* starting interface: %s */\n", className); + #ifndef LIBIDL_MAJOR_VERSION /* pre-VERSIONing libIDLs put the attributes on the interface */ + name_space = IDL_tree_property_get(iface, "namespace"); iid = IDL_tree_property_get(iface, "uuid"); #else /* post-VERSIONing (>= 0.5.11) put the attributes on the ident */ + name_space = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "namespace"); iid = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "uuid"); #endif - + + if (name_space) { + fprintf(state->file, "/* namespace: %s */\n", + name_space); + fprintf(state->file, "/* fully qualified name: %s.%s */\n", + name_space,className); + } + if (iid) { /* XXX use nsID parsing routines to validate? */ if (strlen(iid) != 36) @@ -232,10 +243,10 @@ xpcom_type(TreeState *state) break; case IDLN_TYPE_FLOAT: switch (IDL_TYPE_FLOAT(state->tree).f_type) { - case IDL_FLOAT_TYPE_FLOAT: + case IDL_FLOAT_TYPE_FLOAT: fputs("float", state->file); break; - case IDL_FLOAT_TYPE_DOUBLE: + case IDL_FLOAT_TYPE_DOUBLE: fputs("double", state->file); break; /* XXX 'long double' just ignored, or what? */ @@ -247,6 +258,11 @@ xpcom_type(TreeState *state) case IDLN_IDENT: if (UP_IS_NATIVE(state->tree)) { fputs(IDL_NATIVE(IDL_NODE_UP(state->tree)).user_type, state->file); + if (IDL_tree_property_get(state->tree, "ptr")) { + fputs(" *", state->file); + } else if (IDL_tree_property_get(state->tree, "ref")) { + fputs(" &", state->file); + } } else { fputs(IDL_IDENT(state->tree).str, state->file); } @@ -305,6 +321,11 @@ attr_dcl(TreeState *state) static gboolean do_enum(TreeState *state) { + IDL_tree_warning(state->tree, IDL_WARNING1, + "enums not supported, enum \'%s\' ignored", + IDL_IDENT(IDL_TYPE_ENUM(state->tree).ident).str); + return TRUE; +#if 0 IDL_tree enumb = state->tree, iter; fprintf(state->file, "enum %s {\n", @@ -319,6 +340,45 @@ do_enum(TreeState *state) fputs("};\n\n", state->file); return TRUE; +#endif +} + +static gboolean +do_const_dcl(TreeState *state) +{ + struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree); + const char *name = IDL_IDENT(dcl->ident).str; + gboolean success; + + /* const -> list -> interface */ + if (!IDL_NODE_UP(IDL_NODE_UP(state->tree)) || + IDL_NODE_TYPE(IDL_NODE_UP(IDL_NODE_UP(state->tree))) + != IDLN_INTERFACE) { + IDL_tree_warning(state->tree, IDL_WARNING1, + "const decl \'%s\' not inside interface, ignored", + name); + return TRUE; + } + + success = (IDLN_TYPE_INTEGER == IDL_NODE_TYPE(dcl->const_type)); + if(success) { + switch(IDL_TYPE_INTEGER(dcl->const_type).f_type) { + case IDL_INTEGER_TYPE_SHORT: + case IDL_INTEGER_TYPE_LONG: + break; + default: + success = FALSE; + } + } + + if(success) { + fprintf(state->file, " enum { %s = %d };\n", + name, (int) IDL_INTEGER(dcl->const_exp).value); + } else { + IDL_tree_warning(state->tree, IDL_WARNING1, + "const decl \'%s\' was not of type short or long, ignored", name); + } + return TRUE; } static gboolean @@ -327,14 +387,15 @@ do_typedef(TreeState *state) IDL_tree type = IDL_TYPE_DCL(state->tree).type_spec, dcls = IDL_TYPE_DCL(state->tree).dcls, complex; - fputs("typedef ", state->file); if (IDL_NODE_TYPE(type) == IDLN_TYPE_SEQUENCE) { - fprintf(stderr, "SEQUENCE!\n"); + IDL_tree_warning(state->tree, IDL_WARNING1, + "sequences not supported, ignored"); } else { state->tree = type; if (!xpcom_type(state)) return FALSE; + fputs("typedef ", state->file); fputs(" ", state->file); if (IDL_NODE_TYPE(complex = IDL_LIST(dcls).data) == IDLN_TYPE_ARRAY) { fprintf(state->file, "%s[%ld]", @@ -345,8 +406,8 @@ do_typedef(TreeState *state) fputs(" ", state->file); fputs(IDL_IDENT(IDL_LIST(dcls).data).str, state->file); } + fputs(";\n", state->file); } - fputs(";\n", state->file); return TRUE; } @@ -363,11 +424,14 @@ xpcom_param(TreeState *state) IDL_tree param = state->tree; state->tree = IDL_PARAM_DCL(param).param_type_spec; - /* in string and in wstring are const */ + /* in string, wstring, explicitly marked [const], and nsid are const */ if (IDL_PARAM_DCL(param).attr == IDL_PARAM_IN && (IDL_NODE_TYPE(state->tree) == IDLN_TYPE_STRING || - IDL_NODE_TYPE(state->tree) == IDLN_TYPE_WIDE_STRING)) + IDL_NODE_TYPE(state->tree) == IDLN_TYPE_WIDE_STRING || + IDL_tree_property_get(IDL_OP_DCL(param).ident, "const") || + IDL_tree_property_get(state->tree, "nsid"))) { fputs("const ", state->file); + } if (!xpcom_type(state)) return FALSE; @@ -421,7 +485,7 @@ op_dcl(TreeState *state) fputc(')', state->file); } else { fputs("NS_IMETHOD", state->file); - } + } fprintf(state->file, " %s(", IDL_IDENT(op->ident).str); for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) { state->tree = IDL_LIST(iter).data; @@ -488,6 +552,7 @@ xpidl_header_dispatch(void) table[IDLN_INTERFACE] = interface; table[IDLN_CODEFRAG] = codefrag; table[IDLN_TYPE_DCL] = do_typedef; + table[IDLN_CONST_DCL] = do_const_dcl; } return table; diff --git a/xpcom/tools/xpidl/xpidl_typelib.c b/xpcom/tools/xpidl/xpidl_typelib.c index 97d9d569e505..70d31fa7027d 100644 --- a/xpcom/tools/xpidl/xpidl_typelib.c +++ b/xpcom/tools/xpidl/xpidl_typelib.c @@ -615,6 +615,7 @@ handle_iid_is: char *name; name = IDL_IDENT(IDL_PARAM_DCL(IDL_LIST(params).data).simple_declarator).str; if (!strcmp(name, iid_is)) { + /* XXX verify that this is an nsid here */ argnum = count; break; } @@ -654,8 +655,14 @@ handle_iid_is: ident = IDL_IDENT(type).str; isID = FALSE; + + if(IDL_tree_property_get(type, "nsid")) + isID = TRUE; + + /* XXX obsolete the below! */ + /* check for nsID, nsCID, nsIID, nsIIDRef */ - if (ident[0] == 'n' && ident[1] == 's') { + if (!isID && ident[0] == 'n' && ident[1] == 's') { ident += 2; if (ident[0] == 'C') ident ++; @@ -676,6 +683,8 @@ handle_iid_is: IDL_IDENT(type).str); #endif td->prefix.flags = TD_PNSIID | XPT_TDP_POINTER; + if(IDL_tree_property_get(type, "ref")) + td->prefix.flags |= XPT_TDP_REFERENCE; } else { #ifdef DEBUG_shaver fprintf(stderr, "not doing nsID for %s\n", @@ -762,6 +771,17 @@ fill_pd_from_param(TreeState *state, XPTParamDescriptor *pd, IDL_tree tree) flags |= XPT_PD_RETVAL; } + if (IDL_tree_property_get(IDL_PARAM_DCL(tree).simple_declarator, + "shared")) { + if (flags == XPT_PD_IN) { + IDL_tree_error(tree, "can't have [shared] with in%s param " + "(only out)\n", + flags & XPT_PD_OUT ? "out" : ""); + return FALSE; + } + flags |= XPT_PD_SHARED; + } + /* stick param where we can see it later */ state->tree = tree; return fill_pd_from_type(state, pd, flags, @@ -883,6 +903,74 @@ typelib_op_dcl(TreeState *state) static gboolean typelib_const_dcl(TreeState *state) { + struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree); + const char *name = IDL_IDENT(dcl->ident).str; + gboolean success; + gboolean is_long; + + /* const -> list -> interface */ + if (!IDL_NODE_UP(IDL_NODE_UP(state->tree)) || + IDL_NODE_TYPE(IDL_NODE_UP(IDL_NODE_UP(state->tree))) + != IDLN_INTERFACE) { + IDL_tree_warning(state->tree, IDL_WARNING1, + "const decl \'%s\' not inside interface, ignored", + name); + return TRUE; + } + + success = (IDLN_TYPE_INTEGER == IDL_NODE_TYPE(dcl->const_type)); + if(success) { + switch(IDL_TYPE_INTEGER(dcl->const_type).f_type) { + case IDL_INTEGER_TYPE_SHORT: + is_long = FALSE; + break; + case IDL_INTEGER_TYPE_LONG: + is_long = TRUE; + break; + default: + success = FALSE; + } + } + + if(success) { + XPTInterfaceDescriptor *id; + XPTConstDescriptor *cd; + IDL_longlong_t value; + gboolean sign; + + id = CURRENT(state); + if (!XPT_InterfaceDescriptorAddConsts(id, 1)) + return FALSE; + cd = &id->const_descriptors[NEXT_CONST(state)]; + + cd->name = IDL_IDENT(dcl->ident).str; +#ifdef DEBUG_shaver_const + fprintf(stderr, "DBG: adding const %s\n", cd->name); +#endif + if (!fill_td_from_type(state, &cd->type, dcl->const_type)) + return FALSE; + + value = IDL_INTEGER(dcl->const_exp).value; + sign = IDL_TYPE_INTEGER(dcl->const_type).f_signed; + if (is_long) { + if(sign) + cd->value.i32 = value; + else + cd->value.ui32 = value; + } else { + if(sign) + cd->value.i16 = value; + else + cd->value.ui16 = value; + } + NEXT_CONST(state)++; + } else { + IDL_tree_warning(state->tree, IDL_WARNING1, + "const decl \'%s\' was not of type short or long, ignored", name); + } + return TRUE; + +#if 0 XPTInterfaceDescriptor *id; XPTConstDescriptor *cd; struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree); @@ -972,6 +1060,16 @@ typelib_const_dcl(TreeState *state) NEXT_CONST(state)++; return TRUE; +#endif +} + +static gboolean +typelib_enum(TreeState *state) +{ + IDL_tree_warning(state->tree, IDL_WARNING1, + "enums not supported, enum \'%s\' ignored", + IDL_IDENT(IDL_TYPE_ENUM(state->tree).ident).str); + return TRUE; } nodeHandler * @@ -988,6 +1086,7 @@ xpidl_typelib_dispatch(void) table[IDLN_OP_DCL] = typelib_op_dcl; table[IDLN_INTERFACE] = typelib_interface; table[IDLN_CONST_DCL] = typelib_const_dcl; + table[IDLN_TYPE_ENUM] = typelib_enum; initialized = TRUE; } diff --git a/xpcom/typelib/xpidl/xpidl.c b/xpcom/typelib/xpidl/xpidl.c index f54dd3c07b26..5c5725c617dd 100644 --- a/xpcom/typelib/xpidl/xpidl.c +++ b/xpcom/typelib/xpidl/xpidl.c @@ -46,7 +46,7 @@ gboolean enable_warnings = FALSE; gboolean verbose_mode = FALSE; static char xpidl_usage_str[] = -"Usage: %s [-m mode] [-w] [-v] [-I path] [-n] [-o basename] filename.idl\n" +"Usage: %s [-m mode] [-w] [-v] [-I path] [-o basename] filename.idl\n" " -w turn on warnings (recommended)\n" " -v verbose mode (NYI)\n" " -I add entry to start of include path for ``#include \"nsIThing.idl\"''\n" diff --git a/xpcom/typelib/xpidl/xpidl_header.c b/xpcom/typelib/xpidl/xpidl_header.c index aa3754372a68..394357853d2d 100644 --- a/xpcom/typelib/xpidl/xpidl_header.c +++ b/xpcom/typelib/xpidl/xpidl_header.c @@ -96,17 +96,28 @@ interface(TreeState *state) IDL_tree iface = state->tree, iter; char *className = IDL_IDENT(IDL_INTERFACE(iface).ident).str; const char *iid; + const char *name_space; - fprintf(state->file, "\n/* starting interface %s */\n", + fprintf(state->file, "\n/* starting interface: %s */\n", className); + #ifndef LIBIDL_MAJOR_VERSION /* pre-VERSIONing libIDLs put the attributes on the interface */ + name_space = IDL_tree_property_get(iface, "namespace"); iid = IDL_tree_property_get(iface, "uuid"); #else /* post-VERSIONing (>= 0.5.11) put the attributes on the ident */ + name_space = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "namespace"); iid = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "uuid"); #endif - + + if (name_space) { + fprintf(state->file, "/* namespace: %s */\n", + name_space); + fprintf(state->file, "/* fully qualified name: %s.%s */\n", + name_space,className); + } + if (iid) { /* XXX use nsID parsing routines to validate? */ if (strlen(iid) != 36) @@ -232,10 +243,10 @@ xpcom_type(TreeState *state) break; case IDLN_TYPE_FLOAT: switch (IDL_TYPE_FLOAT(state->tree).f_type) { - case IDL_FLOAT_TYPE_FLOAT: + case IDL_FLOAT_TYPE_FLOAT: fputs("float", state->file); break; - case IDL_FLOAT_TYPE_DOUBLE: + case IDL_FLOAT_TYPE_DOUBLE: fputs("double", state->file); break; /* XXX 'long double' just ignored, or what? */ @@ -247,6 +258,11 @@ xpcom_type(TreeState *state) case IDLN_IDENT: if (UP_IS_NATIVE(state->tree)) { fputs(IDL_NATIVE(IDL_NODE_UP(state->tree)).user_type, state->file); + if (IDL_tree_property_get(state->tree, "ptr")) { + fputs(" *", state->file); + } else if (IDL_tree_property_get(state->tree, "ref")) { + fputs(" &", state->file); + } } else { fputs(IDL_IDENT(state->tree).str, state->file); } @@ -305,6 +321,11 @@ attr_dcl(TreeState *state) static gboolean do_enum(TreeState *state) { + IDL_tree_warning(state->tree, IDL_WARNING1, + "enums not supported, enum \'%s\' ignored", + IDL_IDENT(IDL_TYPE_ENUM(state->tree).ident).str); + return TRUE; +#if 0 IDL_tree enumb = state->tree, iter; fprintf(state->file, "enum %s {\n", @@ -319,6 +340,45 @@ do_enum(TreeState *state) fputs("};\n\n", state->file); return TRUE; +#endif +} + +static gboolean +do_const_dcl(TreeState *state) +{ + struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree); + const char *name = IDL_IDENT(dcl->ident).str; + gboolean success; + + /* const -> list -> interface */ + if (!IDL_NODE_UP(IDL_NODE_UP(state->tree)) || + IDL_NODE_TYPE(IDL_NODE_UP(IDL_NODE_UP(state->tree))) + != IDLN_INTERFACE) { + IDL_tree_warning(state->tree, IDL_WARNING1, + "const decl \'%s\' not inside interface, ignored", + name); + return TRUE; + } + + success = (IDLN_TYPE_INTEGER == IDL_NODE_TYPE(dcl->const_type)); + if(success) { + switch(IDL_TYPE_INTEGER(dcl->const_type).f_type) { + case IDL_INTEGER_TYPE_SHORT: + case IDL_INTEGER_TYPE_LONG: + break; + default: + success = FALSE; + } + } + + if(success) { + fprintf(state->file, " enum { %s = %d };\n", + name, (int) IDL_INTEGER(dcl->const_exp).value); + } else { + IDL_tree_warning(state->tree, IDL_WARNING1, + "const decl \'%s\' was not of type short or long, ignored", name); + } + return TRUE; } static gboolean @@ -327,14 +387,15 @@ do_typedef(TreeState *state) IDL_tree type = IDL_TYPE_DCL(state->tree).type_spec, dcls = IDL_TYPE_DCL(state->tree).dcls, complex; - fputs("typedef ", state->file); if (IDL_NODE_TYPE(type) == IDLN_TYPE_SEQUENCE) { - fprintf(stderr, "SEQUENCE!\n"); + IDL_tree_warning(state->tree, IDL_WARNING1, + "sequences not supported, ignored"); } else { state->tree = type; if (!xpcom_type(state)) return FALSE; + fputs("typedef ", state->file); fputs(" ", state->file); if (IDL_NODE_TYPE(complex = IDL_LIST(dcls).data) == IDLN_TYPE_ARRAY) { fprintf(state->file, "%s[%ld]", @@ -345,8 +406,8 @@ do_typedef(TreeState *state) fputs(" ", state->file); fputs(IDL_IDENT(IDL_LIST(dcls).data).str, state->file); } + fputs(";\n", state->file); } - fputs(";\n", state->file); return TRUE; } @@ -363,11 +424,14 @@ xpcom_param(TreeState *state) IDL_tree param = state->tree; state->tree = IDL_PARAM_DCL(param).param_type_spec; - /* in string and in wstring are const */ + /* in string, wstring, explicitly marked [const], and nsid are const */ if (IDL_PARAM_DCL(param).attr == IDL_PARAM_IN && (IDL_NODE_TYPE(state->tree) == IDLN_TYPE_STRING || - IDL_NODE_TYPE(state->tree) == IDLN_TYPE_WIDE_STRING)) + IDL_NODE_TYPE(state->tree) == IDLN_TYPE_WIDE_STRING || + IDL_tree_property_get(IDL_OP_DCL(param).ident, "const") || + IDL_tree_property_get(state->tree, "nsid"))) { fputs("const ", state->file); + } if (!xpcom_type(state)) return FALSE; @@ -421,7 +485,7 @@ op_dcl(TreeState *state) fputc(')', state->file); } else { fputs("NS_IMETHOD", state->file); - } + } fprintf(state->file, " %s(", IDL_IDENT(op->ident).str); for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) { state->tree = IDL_LIST(iter).data; @@ -488,6 +552,7 @@ xpidl_header_dispatch(void) table[IDLN_INTERFACE] = interface; table[IDLN_CODEFRAG] = codefrag; table[IDLN_TYPE_DCL] = do_typedef; + table[IDLN_CONST_DCL] = do_const_dcl; } return table; diff --git a/xpcom/typelib/xpidl/xpidl_typelib.c b/xpcom/typelib/xpidl/xpidl_typelib.c index 97d9d569e505..70d31fa7027d 100644 --- a/xpcom/typelib/xpidl/xpidl_typelib.c +++ b/xpcom/typelib/xpidl/xpidl_typelib.c @@ -615,6 +615,7 @@ handle_iid_is: char *name; name = IDL_IDENT(IDL_PARAM_DCL(IDL_LIST(params).data).simple_declarator).str; if (!strcmp(name, iid_is)) { + /* XXX verify that this is an nsid here */ argnum = count; break; } @@ -654,8 +655,14 @@ handle_iid_is: ident = IDL_IDENT(type).str; isID = FALSE; + + if(IDL_tree_property_get(type, "nsid")) + isID = TRUE; + + /* XXX obsolete the below! */ + /* check for nsID, nsCID, nsIID, nsIIDRef */ - if (ident[0] == 'n' && ident[1] == 's') { + if (!isID && ident[0] == 'n' && ident[1] == 's') { ident += 2; if (ident[0] == 'C') ident ++; @@ -676,6 +683,8 @@ handle_iid_is: IDL_IDENT(type).str); #endif td->prefix.flags = TD_PNSIID | XPT_TDP_POINTER; + if(IDL_tree_property_get(type, "ref")) + td->prefix.flags |= XPT_TDP_REFERENCE; } else { #ifdef DEBUG_shaver fprintf(stderr, "not doing nsID for %s\n", @@ -762,6 +771,17 @@ fill_pd_from_param(TreeState *state, XPTParamDescriptor *pd, IDL_tree tree) flags |= XPT_PD_RETVAL; } + if (IDL_tree_property_get(IDL_PARAM_DCL(tree).simple_declarator, + "shared")) { + if (flags == XPT_PD_IN) { + IDL_tree_error(tree, "can't have [shared] with in%s param " + "(only out)\n", + flags & XPT_PD_OUT ? "out" : ""); + return FALSE; + } + flags |= XPT_PD_SHARED; + } + /* stick param where we can see it later */ state->tree = tree; return fill_pd_from_type(state, pd, flags, @@ -883,6 +903,74 @@ typelib_op_dcl(TreeState *state) static gboolean typelib_const_dcl(TreeState *state) { + struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree); + const char *name = IDL_IDENT(dcl->ident).str; + gboolean success; + gboolean is_long; + + /* const -> list -> interface */ + if (!IDL_NODE_UP(IDL_NODE_UP(state->tree)) || + IDL_NODE_TYPE(IDL_NODE_UP(IDL_NODE_UP(state->tree))) + != IDLN_INTERFACE) { + IDL_tree_warning(state->tree, IDL_WARNING1, + "const decl \'%s\' not inside interface, ignored", + name); + return TRUE; + } + + success = (IDLN_TYPE_INTEGER == IDL_NODE_TYPE(dcl->const_type)); + if(success) { + switch(IDL_TYPE_INTEGER(dcl->const_type).f_type) { + case IDL_INTEGER_TYPE_SHORT: + is_long = FALSE; + break; + case IDL_INTEGER_TYPE_LONG: + is_long = TRUE; + break; + default: + success = FALSE; + } + } + + if(success) { + XPTInterfaceDescriptor *id; + XPTConstDescriptor *cd; + IDL_longlong_t value; + gboolean sign; + + id = CURRENT(state); + if (!XPT_InterfaceDescriptorAddConsts(id, 1)) + return FALSE; + cd = &id->const_descriptors[NEXT_CONST(state)]; + + cd->name = IDL_IDENT(dcl->ident).str; +#ifdef DEBUG_shaver_const + fprintf(stderr, "DBG: adding const %s\n", cd->name); +#endif + if (!fill_td_from_type(state, &cd->type, dcl->const_type)) + return FALSE; + + value = IDL_INTEGER(dcl->const_exp).value; + sign = IDL_TYPE_INTEGER(dcl->const_type).f_signed; + if (is_long) { + if(sign) + cd->value.i32 = value; + else + cd->value.ui32 = value; + } else { + if(sign) + cd->value.i16 = value; + else + cd->value.ui16 = value; + } + NEXT_CONST(state)++; + } else { + IDL_tree_warning(state->tree, IDL_WARNING1, + "const decl \'%s\' was not of type short or long, ignored", name); + } + return TRUE; + +#if 0 XPTInterfaceDescriptor *id; XPTConstDescriptor *cd; struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree); @@ -972,6 +1060,16 @@ typelib_const_dcl(TreeState *state) NEXT_CONST(state)++; return TRUE; +#endif +} + +static gboolean +typelib_enum(TreeState *state) +{ + IDL_tree_warning(state->tree, IDL_WARNING1, + "enums not supported, enum \'%s\' ignored", + IDL_IDENT(IDL_TYPE_ENUM(state->tree).ident).str); + return TRUE; } nodeHandler * @@ -988,6 +1086,7 @@ xpidl_typelib_dispatch(void) table[IDLN_OP_DCL] = typelib_op_dcl; table[IDLN_INTERFACE] = typelib_interface; table[IDLN_CONST_DCL] = typelib_const_dcl; + table[IDLN_TYPE_ENUM] = typelib_enum; initialized = TRUE; }