From b67985862ad8342085f62711bea357a216afe4ad Mon Sep 17 00:00:00 2001 From: "coop%netscape.com" Date: Tue, 9 Feb 1999 00:14:38 +0000 Subject: [PATCH] NOT YET PART OF SEAMONKEY: * added function XPT_GetInterfaceIndexByName * replaced remaining occurences of 'namespace' with 'name_space' to keep C++ happy * added xpt_dump display for param types (in/out/retval) * changed xpt_dump handling for wchar_t strings * use shaver's print_IID function when displaying type descriptors * removed DoAnnotations (not used) --- xpcom/libxpt/public/xpt_struct.h | 5 ++-- xpcom/libxpt/src/xpt_struct.c | 17 +++++++++++-- xpcom/libxpt/tools/xpt_dump.c | 36 ++++++++++++++++----------- xpcom/typelib/xpt/public/xpt_struct.h | 5 ++-- xpcom/typelib/xpt/src/xpt_struct.c | 17 +++++++++++-- xpcom/typelib/xpt/tools/xpt_dump.c | 36 ++++++++++++++++----------- 6 files changed, 80 insertions(+), 36 deletions(-) diff --git a/xpcom/libxpt/public/xpt_struct.h b/xpcom/libxpt/public/xpt_struct.h index 81fefd0e768..7d750506b87 100644 --- a/xpcom/libxpt/public/xpt_struct.h +++ b/xpcom/libxpt/public/xpt_struct.h @@ -164,8 +164,9 @@ struct XPTInterfaceDescriptor { }; extern XPT_PUBLIC_API(PRBool) -XPT_IndexForInterface(XPTInterfaceDirectoryEntry *ide_block, - uint32 num_interfaces, nsID *iid, uint16 *indexp); +XPT_GetInterfaceIndexByName(XPTInterfaceDirectoryEntry *ide_block, + uint32 num_interfaces, char *name, + uint16 *indexp); extern XPT_PUBLIC_API(XPTInterfaceDescriptor *) XPT_NewInterfaceDescriptor(uint32 parent_interface, uint32 num_methods, diff --git a/xpcom/libxpt/src/xpt_struct.c b/xpcom/libxpt/src/xpt_struct.c index b278825b9ce..95b902fe2f2 100644 --- a/xpcom/libxpt/src/xpt_struct.c +++ b/xpcom/libxpt/src/xpt_struct.c @@ -46,6 +46,7 @@ DoTypeDescriptor(XPTCursor *cursor, XPTTypeDescriptor *td); static PRBool DoParamDescriptor(XPTCursor *cursor, XPTParamDescriptor *pd); + #define CURS_POOL_OFFSET_RAW(cursor) \ ((cursor)->pool == XPT_HEADER \ ? (cursor)->offset \ @@ -694,9 +695,21 @@ DoAnnotation(XPTCursor *cursor, XPTAnnotation **annp) XPT_ERROR_HANDLE(ann); } -PRBool -DoAnnotations(XPTCursor *cursor, XPTAnnotation **ap) +PRBool +XPT_GetInterfaceIndexByName(XPTInterfaceDirectoryEntry *ide_block, + uint32 num_interfaces, char *name, + uint16 *indexp) { + int i; + + for (i=1; i<=num_interfaces; i++) { + fprintf(stderr, "%s == %s ?\n", ide_block[i].name, name); + if (strcmp(ide_block[i].name, name) == 0) { + *indexp = i; + return PR_TRUE; + } + } + indexp = 0; return PR_FALSE; } diff --git a/xpcom/libxpt/tools/xpt_dump.c b/xpcom/libxpt/tools/xpt_dump.c index 623f4ab19f3..01cc4146b30 100644 --- a/xpcom/libxpt/tools/xpt_dump.c +++ b/xpcom/libxpt/tools/xpt_dump.c @@ -283,7 +283,7 @@ XPT_DumpInterfaceDirectoryEntry(XPTInterfaceDirectoryEntry *ide, fprintf(stdout, "%*sName: %s\n", indent, " ", ide->name); fprintf(stdout, "%*sNamespace: %s\n", - indent, " ", ide->namespace); + indent, " ", ide->name_space); fprintf(stdout, "%*sAddress of interface descriptor: %p\n", indent, " ", ide->interface_descriptor); @@ -295,7 +295,7 @@ XPT_DumpInterfaceDirectoryEntry(XPTInterfaceDirectoryEntry *ide, } } else { fprintf(stdout, "%*s- %s::%s (", indent, " ", - ide->namespace ? ide->namespace : "", ide->name); + ide->name_space ? ide->name_space : "", ide->name); print_IID(&ide->iid, stdout); fprintf(stdout, "):\n"); if (!XPT_DumpInterfaceDescriptor(ide->interface_descriptor, @@ -435,6 +435,24 @@ XPT_DumpMethodDescriptor(XPTMethodDescriptor *md, const int indent, fprintf(stdout, ", "); } pd = &md->params[i]; + if (XPT_PD_IS_IN(pd->flags)) { + fprintf(stdout, "in"); + if (XPT_PD_IS_OUT(pd->flags)) { + fprintf(stdout, "/out "); + if (XPT_PD_IS_RETVAL(pd->flags)) { + fprintf(stdout, "retval "); + } + } else { + fprintf(stdout, " "); + } + } else { + if (XPT_PD_IS_OUT(pd->flags)) { + fprintf(stdout, "out "); + if (XPT_PD_IS_RETVAL(pd->flags)) { + fprintf(stdout, "retval "); + } + } + } if (!XPT_GetStringForType(&pd->type, ¶m_type)) { return PR_FALSE; } @@ -605,24 +623,14 @@ XPT_DumpConstDescriptor(XPTConstDescriptor *cd, const int indent, PRBool verbose fprintf(stdout, "%c", cd->value.ch); break; case TD_WCHAR: - fprintf(stdout, "%d", cd->value.wch); + fprintf(stdout, "%c", cd->value.wch & 0xff); break; case TD_VOID: fprintf(stdout, "VOID"); break; case TD_PPNSIID: if (XPT_TDP_IS_POINTER(cd->type.prefix.flags)) { - fprintf(stdout, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - cd->value.iid->m0, (PRUint32) cd->value.iid->m1, - (PRUint32) cd->value.iid->m2, - (PRUint32) cd->value.iid->m3[0], - (PRUint32) cd->value.iid->m3[1], - (PRUint32) cd->value.iid->m3[2], - (PRUint32) cd->value.iid->m3[3], - (PRUint32) cd->value.iid->m3[4], - (PRUint32) cd->value.iid->m3[5], - (PRUint32) cd->value.iid->m3[6], - (PRUint32) cd->value.iid->m3[7]); + print_IID(cd->value.iid, stdout); } else return PR_FALSE; break; diff --git a/xpcom/typelib/xpt/public/xpt_struct.h b/xpcom/typelib/xpt/public/xpt_struct.h index 81fefd0e768..7d750506b87 100644 --- a/xpcom/typelib/xpt/public/xpt_struct.h +++ b/xpcom/typelib/xpt/public/xpt_struct.h @@ -164,8 +164,9 @@ struct XPTInterfaceDescriptor { }; extern XPT_PUBLIC_API(PRBool) -XPT_IndexForInterface(XPTInterfaceDirectoryEntry *ide_block, - uint32 num_interfaces, nsID *iid, uint16 *indexp); +XPT_GetInterfaceIndexByName(XPTInterfaceDirectoryEntry *ide_block, + uint32 num_interfaces, char *name, + uint16 *indexp); extern XPT_PUBLIC_API(XPTInterfaceDescriptor *) XPT_NewInterfaceDescriptor(uint32 parent_interface, uint32 num_methods, diff --git a/xpcom/typelib/xpt/src/xpt_struct.c b/xpcom/typelib/xpt/src/xpt_struct.c index b278825b9ce..95b902fe2f2 100644 --- a/xpcom/typelib/xpt/src/xpt_struct.c +++ b/xpcom/typelib/xpt/src/xpt_struct.c @@ -46,6 +46,7 @@ DoTypeDescriptor(XPTCursor *cursor, XPTTypeDescriptor *td); static PRBool DoParamDescriptor(XPTCursor *cursor, XPTParamDescriptor *pd); + #define CURS_POOL_OFFSET_RAW(cursor) \ ((cursor)->pool == XPT_HEADER \ ? (cursor)->offset \ @@ -694,9 +695,21 @@ DoAnnotation(XPTCursor *cursor, XPTAnnotation **annp) XPT_ERROR_HANDLE(ann); } -PRBool -DoAnnotations(XPTCursor *cursor, XPTAnnotation **ap) +PRBool +XPT_GetInterfaceIndexByName(XPTInterfaceDirectoryEntry *ide_block, + uint32 num_interfaces, char *name, + uint16 *indexp) { + int i; + + for (i=1; i<=num_interfaces; i++) { + fprintf(stderr, "%s == %s ?\n", ide_block[i].name, name); + if (strcmp(ide_block[i].name, name) == 0) { + *indexp = i; + return PR_TRUE; + } + } + indexp = 0; return PR_FALSE; } diff --git a/xpcom/typelib/xpt/tools/xpt_dump.c b/xpcom/typelib/xpt/tools/xpt_dump.c index 623f4ab19f3..01cc4146b30 100644 --- a/xpcom/typelib/xpt/tools/xpt_dump.c +++ b/xpcom/typelib/xpt/tools/xpt_dump.c @@ -283,7 +283,7 @@ XPT_DumpInterfaceDirectoryEntry(XPTInterfaceDirectoryEntry *ide, fprintf(stdout, "%*sName: %s\n", indent, " ", ide->name); fprintf(stdout, "%*sNamespace: %s\n", - indent, " ", ide->namespace); + indent, " ", ide->name_space); fprintf(stdout, "%*sAddress of interface descriptor: %p\n", indent, " ", ide->interface_descriptor); @@ -295,7 +295,7 @@ XPT_DumpInterfaceDirectoryEntry(XPTInterfaceDirectoryEntry *ide, } } else { fprintf(stdout, "%*s- %s::%s (", indent, " ", - ide->namespace ? ide->namespace : "", ide->name); + ide->name_space ? ide->name_space : "", ide->name); print_IID(&ide->iid, stdout); fprintf(stdout, "):\n"); if (!XPT_DumpInterfaceDescriptor(ide->interface_descriptor, @@ -435,6 +435,24 @@ XPT_DumpMethodDescriptor(XPTMethodDescriptor *md, const int indent, fprintf(stdout, ", "); } pd = &md->params[i]; + if (XPT_PD_IS_IN(pd->flags)) { + fprintf(stdout, "in"); + if (XPT_PD_IS_OUT(pd->flags)) { + fprintf(stdout, "/out "); + if (XPT_PD_IS_RETVAL(pd->flags)) { + fprintf(stdout, "retval "); + } + } else { + fprintf(stdout, " "); + } + } else { + if (XPT_PD_IS_OUT(pd->flags)) { + fprintf(stdout, "out "); + if (XPT_PD_IS_RETVAL(pd->flags)) { + fprintf(stdout, "retval "); + } + } + } if (!XPT_GetStringForType(&pd->type, ¶m_type)) { return PR_FALSE; } @@ -605,24 +623,14 @@ XPT_DumpConstDescriptor(XPTConstDescriptor *cd, const int indent, PRBool verbose fprintf(stdout, "%c", cd->value.ch); break; case TD_WCHAR: - fprintf(stdout, "%d", cd->value.wch); + fprintf(stdout, "%c", cd->value.wch & 0xff); break; case TD_VOID: fprintf(stdout, "VOID"); break; case TD_PPNSIID: if (XPT_TDP_IS_POINTER(cd->type.prefix.flags)) { - fprintf(stdout, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - cd->value.iid->m0, (PRUint32) cd->value.iid->m1, - (PRUint32) cd->value.iid->m2, - (PRUint32) cd->value.iid->m3[0], - (PRUint32) cd->value.iid->m3[1], - (PRUint32) cd->value.iid->m3[2], - (PRUint32) cd->value.iid->m3[3], - (PRUint32) cd->value.iid->m3[4], - (PRUint32) cd->value.iid->m3[5], - (PRUint32) cd->value.iid->m3[6], - (PRUint32) cd->value.iid->m3[7]); + print_IID(cd->value.iid, stdout); } else return PR_FALSE; break;