static gboolean typelib_attr_dcl(TreeState *state) { XPTInterfaceDescriptor *id = CURRENT(state); XPTMethodDescriptor *meth; gboolean read_only = IDL_ATTR_DCL(state->tree).f_readonly; /* XXX this only handles the first ident; elsewhere too... */ IDL_tree ident = IDL_LIST(IDL_ATTR_DCL(state->tree).simple_declarations).data; /* If it's marked [noscript], mark it as hidden in the typelib. */ gboolean hidden = (IDL_tree_property_get(ident, "noscript") != NULL); gboolean wantsJSContext = (IDL_tree_property_get(ident, "implicit_jscontext") != NULL); if (!verify_attribute_declaration(state->tree)) return FALSE; if (!XPT_InterfaceDescriptorAddMethods(ARENA(state), id, (PRUint16) (read_only ? 1 : 2))) return FALSE; meth = &id->method_descriptors[NEXT_METH(state)]; return typelib_attr_accessor(state, meth, TRUE, hidden, wantsJSContext) && (read_only || typelib_attr_accessor(state, meth + 1, FALSE, hidden, wantsJSContext)); }
static gboolean attr_dcl(TreeState *state) { GSList *doc_comments; if (!verify_attribute_declaration(state->tree)) return FALSE; doc_comments = IDL_IDENT(IDL_LIST(IDL_ATTR_DCL (state->tree).simple_declarations).data).comments; if (doc_comments != NULL && comment_level >= 2) { write_indent(state->file); printlist(state->file, doc_comments); } /* * XXX lists of attributes with the same type, e.g. * attribute string foo, bar sil; * are legal IDL... but we don't do anything with 'em. */ if (IDL_LIST(IDL_ATTR_DCL(state->tree).simple_declarations).next != NULL) { XPIDL_WARNING((state->tree, IDL_WARNING1, "multiple attributes in a single declaration aren't " "currently supported by xpidl")); } xpidl_write_comment(state, 2); write_indent(state->file); write_indent(state->file); if (!write_attr_accessor(state->tree, state->file, TRUE, NULL)) return FALSE; fputs(": Longword; stdcall;\n", state->file); if (!IDL_ATTR_DCL(state->tree).f_readonly) { write_indent(state->file); write_indent(state->file); if (!write_attr_accessor(state->tree, state->file, FALSE, NULL)) return FALSE; fputs(": Longword; stdcall;\n", state->file); } /*fputc('\n', state->file);*/ return TRUE; }
static gboolean attribute_declaration(TreeState *state) { gboolean read_only = IDL_ATTR_DCL(state->tree).f_readonly; char *attribute_name = ATTR_IDENT(state->tree).str; gboolean method_noscript = (IDL_tree_property_get(ATTR_PROPS(state->tree), "noscript") != NULL); gboolean method_notxpcom = (IDL_tree_property_get(ATTR_PROPS(state->tree), "notxpcom") != NULL); #if 0 /* * Disabled here because I can't verify this check against possible * users of the java xpidl backend. */ if (!verify_attribute_declaration(state->tree)) return FALSE; #endif /* Comment */ fputc('\n', state->file); xpidl_write_comment(state, 4); #if 1 /* * Write access permission ("public") */ fputs(" public ", state->file); #else if (method_notxpcom || method_noscript) return TRUE; /* * Write access permission ("public" unless nonscriptable) */ fputs(" ", state->file); if (!method_noscript) { fputs("public ", state->file); } #endif /* * Write the proper Java return value for the get operation */ if (!xpcom_to_java_type(state, ATTR_TYPE_DECL(state->tree))) { return FALSE; } /* * Write the name of the accessor ("get") method. */ fprintf(state->file, " get%c%s();\n", toupper(attribute_name[0]), attribute_name + 1); if (!read_only) { #if 1 fputs(" public ", state->file); #else /* Nonscriptable methods become package-protected */ fputs(" ", state->file); if (!method_noscript) { fputs("public ", state->file); } #endif /* * Write attribute access method name and return type */ fprintf(state->file, "void set%c%s(", toupper(attribute_name[0]), attribute_name+1); /* * Write the proper Java type for the set operation */ if (!xpcom_to_java_type(state, ATTR_TYPE_DECL(state->tree))) { return FALSE; } /* * Write the name of the formal parameter. */ fprintf(state->file, " a%c%s);\n", toupper(attribute_name[0]), attribute_name + 1); } return TRUE; }