Index: xpcom/typelib/xpidl/xpidl_doc.c
===================================================================
RCS file: /cvsroot/mozilla/xpcom/typelib/xpidl/xpidl_doc.c,v
retrieving revision 1.13
diff -u -p -8 -r1.13 xpidl_doc.c
--- xpcom/typelib/xpidl/xpidl_doc.c 31 Dec 2005 13:18:08 -0000 1.13
+++ xpcom/typelib/xpidl/xpidl_doc.c 16 Mar 2007 14:52:00 -0000
@@ -39,35 +39,39 @@
/*
* Generates documentation from javadoc-style comments in XPIDL files.
*/
static gboolean
doc_prolog(TreeState *state)
{
+/*
fprintf(state->file, "\n");
fprintf(state->file, "
\n");
fprintf(state->file,
"\n",
state->basename);
fprintf(state->file, "documentation for %s.idl interfaces\n",
state->basename);
fprintf(state->file, "\n\n");
fprintf(state->file, "\n");
+*/
return TRUE;
}
static gboolean
doc_epilog(TreeState *state)
{
+/*
fprintf(state->file, "\n");
fprintf(state->file, "\n");
+*/
return TRUE;
}
static gboolean
doc_list(TreeState *state)
{
@@ -81,61 +85,66 @@ doc_list(TreeState *state)
}
static gboolean
print_list(FILE *outfile, IDL_tree list)
{
if (list == NULL)
return TRUE;
- fprintf(outfile, "\n");
while (list != NULL) {
- fprintf(outfile, " - %s\n",
+ fprintf(outfile, "%s",
IDL_IDENT(IDL_LIST(list).data).str);
list = IDL_LIST(list).next;
}
- fprintf(outfile, "
\n");
+ fprintf(outfile, "\n");
return TRUE;
}
static gboolean
doc_interface(TreeState *state)
{
+ char *iid;
IDL_tree iface = state->tree;
IDL_tree iter;
IDL_tree orig;
char *classname = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
GSList *doc_comments = IDL_IDENT(IDL_INTERFACE(iface).ident).comments;
- fprintf(state->file, "interface %s
\n", classname);
+ fprintf(state->file, "\n");
- /* Much more could happen at this step. */
/*
* If parsing doc comments, you might need to take some care with line
* endings, as the xpidl frontend will return comments containing of /r,
* /n, /r/n depending on the platform. It's best to leave out platform
* #defines and just treat them all as equivalent.
*/
if (doc_comments != NULL) {
- fprintf(state->file, "doc comments:
\n");
- fprintf(state->file, "\n");
printlist(state->file, doc_comments);
- fprintf(state->file, "\n");
- fprintf(state->file, "
\n");
}
+ fprintf(state->file, "interface");
+
+ if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable") == NULL)
+ fprintf(state->file, " noscript");
+
+ fprintf(state->file, " %s\n", classname);
+
+ iid = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "uuid");
+ fprintf(state->file, " iid %s\n", iid);
+
/* inherits from */
/*
* Note that we accept multiple inheritance here (for e.g. gnome idl)
* even though the header backend (specific to mozilla idl) rejects it.
*/
if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
- fprintf(state->file, "%s inherits from:
\n", classname);
+ fprintf(state->file, " inheritsfrom ");
print_list(state->file, iter);
- fprintf(state->file, "
\n");
+ fprintf(state->file, "\n");
}
/*
* Call xpidl_process_node to recur through list of declarations in
* interface body; another option would be to explicitly iterate through
* the list. xpidl_process_node currently requires twiddling the state to
* get the right node; I'll fix that soon to just take the node. Makes it
* easier to follow what's going on, I think...
@@ -211,17 +220,19 @@ write_type(IDL_tree type_tree, FILE *out
/* XXX 'long double' just ignored, or what? */
default:
fprintf(outfile, "unknown_type_%d", IDL_NODE_TYPE(type_tree));
break;
}
break;
case IDLN_IDENT:
if (UP_IS_NATIVE(type_tree)) {
- fputs(IDL_NATIVE(IDL_NODE_UP(type_tree)).user_type, outfile);
+ char *identstr = IDL_IDENT(IDL_NATIVE(IDL_NODE_UP(type_tree)).ident).str;
+ if (identstr) fputs(identstr, outfile);
+ else fputs(IDL_NATIVE(IDL_NODE_UP(type_tree)).user_type, outfile);
if (IDL_tree_property_get(type_tree, "ptr")) {
fputs(" *", outfile);
} else if (IDL_tree_property_get(type_tree, "ref")) {
fputs(" &", outfile);
}
} else {
fputs(IDL_IDENT(type_tree).str, outfile);
}
@@ -230,62 +241,131 @@ write_type(IDL_tree type_tree, FILE *out
break;
default:
fprintf(outfile, "unknown_type_%d", IDL_NODE_TYPE(type_tree));
break;
}
return TRUE;
}
+static gboolean
+doc_const_declaration(TreeState *state)
+{
+ IDL_tree attr = state->tree;
+ IDL_tree expr;
+
+ fprintf(state->file, "\n");
+
+ GSList *comments = IDL_IDENT(IDL_CONST_DCL(state->tree).ident).comments;
+ if (comments != NULL) {
+ printlist(state->file, comments);
+ }
+
+ fprintf(state->file, "const ");
+
+ if (!write_type(IDL_CONST_DCL(attr).const_type, state->file))
+ return FALSE;
+
+ fprintf(state->file, " %s",IDL_IDENT(IDL_CONST_DCL(state->tree).ident).str);
+
+ expr = IDL_CONST_DCL(state->tree).const_exp;
+ if (expr->_type == IDLN_INTEGER) fprintf(state->file, " = %d", IDL_INTEGER(expr).value);
+ fprintf(state->file, "\n");
+ return TRUE;
+}
+
/* handle ATTR_DCL (attribute declaration) nodes */
static gboolean
doc_attribute_declaration(TreeState *state)
{
IDL_tree attr = state->tree;
+ IDL_tree ident;
if (!verify_attribute_declaration(attr))
return FALSE;
- /*
- * Attribute idents can also take doc comments. They're ignored here;
- * should they be?
- */
+
+ fprintf(state->file, "\n");
+
+ ident = IDL_LIST(IDL_ATTR_DCL(attr).simple_declarations).data;
+ if (IDL_IDENT(ident).comments != NULL) {
+ printlist(state->file, IDL_IDENT(ident).comments);
+ }
+
+ fprintf(state->file, "attribute ");
if (IDL_ATTR_DCL(attr).f_readonly)
fprintf(state->file, "readonly ");
- fprintf(state->file, "attribute ");
+ if (IDL_tree_property_get(ident, "notxpcom") != NULL)
+ fprintf(state->file, "notxpcom ");
if (!write_type(IDL_ATTR_DCL(attr).param_type_spec, state->file))
return FALSE;
- fprintf(state->file, "\n");
+ fprintf(state->file, " ");
print_list(state->file, IDL_ATTR_DCL(attr).simple_declarations);
- fprintf(state->file, "
\n");
return TRUE;
}
/* handle OP_DCL (method declaration) nodes */
static gboolean
doc_method_declaration(TreeState *state)
{
- /*
- * Doc comment for attributes also applies here.
- */
+ gboolean scriptable_method;
+ IDL_tree iter;
+ GSList *comments;
+ struct _IDL_OP_DCL *op = &IDL_OP_DCL(state->tree);
+
+ fprintf(state->file, "\n");
+
+ comments = IDL_IDENT(IDL_OP_DCL(state->tree).ident).comments;
+ if (comments != NULL) {
+ printlist(state->file, comments);
+ }
+
+ scriptable_method = (IDL_tree_property_get(op->ident, "noscript") == NULL);
/*
* Look at 'write_method_signature' in xpidl_header.c for an example of how
* to navigate parse trees for methods. For here, I just print the method
* name.
*/
fprintf(state->file,
- "method %s
\n",
+ "method %s %s\n", ((scriptable_method) ? "scriptable" : "unscriptable"),
IDL_IDENT(IDL_OP_DCL(state->tree).ident).str);
+ if (IDL_tree_property_get(op->ident, "notxpcom") != NULL)
+ fprintf(state->file, " notxpcom\n");
+
+ /* Loop through the parameters and check. */
+ for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) {
+ IDL_tree param = IDL_LIST(iter).data;
+ IDL_tree param_type =
+ IDL_PARAM_DCL(param).param_type_spec;
+ IDL_tree simple_decl =
+ IDL_PARAM_DCL(param).simple_declarator;
+ const char *param_name = IDL_IDENT(simple_decl).str;
+
+ fprintf(state->file, " argument ");
+
+ if (IDL_PARAM_DCL(param).attr == IDL_PARAM_INOUT) fprintf(state->file, "inout ");
+ else if (IDL_PARAM_DCL(param).attr == IDL_PARAM_OUT) fprintf(state->file, "out ");
+ else fprintf(state->file, "in ");
+
+ if (IDL_tree_property_get(simple_decl, "array") != NULL) fprintf(state->file, "arrayof ");
+
+ write_type(param_type,state->file);
+ fprintf(state->file, " %s\n", param_name);
+ }
+ fprintf(state->file, " returns ");
+ write_type(op->op_type_spec,state->file);
+ fprintf(state->file, "\n");
+
return TRUE;
}
backend *
xpidl_doc_dispatch(void)
{
static backend result;
static nodeHandler table[IDLN_LAST];
@@ -297,16 +377,17 @@ xpidl_doc_dispatch(void)
if (!initialized) {
/* Initialize non-NULL elements */
/* I just handle a few... many still to be filled in! */
table[IDLN_LIST] = doc_list;
table[IDLN_INTERFACE] = doc_interface;
table[IDLN_ATTR_DCL] = doc_attribute_declaration;
+ table[IDLN_CONST_DCL] = doc_const_declaration;
table[IDLN_OP_DCL] = doc_method_declaration;
initialized = TRUE;
}
result.dispatch_table = table;
return &result;
}