Chinaunix首页 | 论坛 | 博客
  • 博客访问: 667045
  • 博文数量: 137
  • 博客积分: 7000
  • 博客等级: 少将
  • 技术积分: 1335
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-23 15:18
文章分类

全部博文(137)

文章存档

2010年(2)

2009年(2)

2008年(2)

2007年(30)

2006年(99)

2005年(2)

我的朋友

分类: 系统运维

2006-01-25 16:01:50

前面提到的:
xptiInterfaceEntry::GetMethodInfoForName(const char* methodName, uint16 *index, const nsXPTMethodInfo** result)
方法中用到了一个mInterface的变量,它是一个指向xptiInterfaceGuts类型的指针,xpiInterfaceGuts是一个类,原型如下:
class xptiInterfaceGuts
{
public:
uint16 mMethodBaseIndex;
uint16 mConstantBaseIndex;
xptiInterfaceEntry* mParent;
XPTInterfaceDescriptor* mDescriptor;
xptiTypelib mTypelib;
xptiWorkingSet* mWorkingSet;

static xptiInterfaceGuts* NewGuts(XPTInterfaceDescriptor* aDescriptor,
const xptiTypelib& aTypelib,
xptiWorkingSet* aWorkingSet)
{
void* place = XPT_MALLOC(aWorkingSet->GetStructArena(),
sizeof(xptiInterfaceGuts));
if(!place)
return nsnull;
return new(place) xptiInterfaceGuts(aDescriptor, aTypelib, aWorkingSet);
}

private:
void* operator new(size_t, void* p) CPP_THROW_NEW {return p;}
xptiInterfaceGuts(XPTInterfaceDescriptor* aDescriptor,
const xptiTypelib& aTypelib,
xptiWorkingSet* aWorkingSet)
: mMethodBaseIndex(0),
mConstantBaseIndex(0),
mParent(nsnull),
mDescriptor(aDescriptor),
mTypelib(aTypelib),
mWorkingSet(aWorkingSet) {}

~xptiInterfaceGuts() {}
};
其中有个指向XPTInterfaceDescriptor类型的指针mDescriptor,而XPTInterfaceDescriptor类型是一个结构体,原型如下:

233 /*
234 * An InterfaceDescriptor is a variable-size record used to describe a
235 * single XPCOM interface, including all of its methods.
236 */
237 struct XPTInterfaceDescriptor {
238 PRUint16 parent_interface;
239 PRUint16 num_methods;
240 XPTMethodDescriptor *method_descriptors;
241 PRUint16 num_constants;
242 XPTConstDescriptor *const_descriptors;
243 PRUint8 flags;
244
245 /* additional_types are used for arrays where we may need multiple
246 * XPTTypeDescriptors for a single XPTMethodDescriptor. Since we still
247 * want to have a simple array of XPTMethodDescriptor (each with a single
248 * embedded XPTTypeDescriptor), a XPTTypeDescriptor can have a reference
249 * to an 'additional_type'. That reference is an index in this
250 * "additional_types" array. So a given XPTMethodDescriptor might have
251 * a whole chain of these XPTTypeDescriptors to represent, say, a multi
252 * dimensional array.
253 *
254 * Note that in the typelib file these additional types are stored 'inline'
255 * in the MethodDescriptor. But, in the typelib MethodDescriptors can be
256 * of varying sizes, where in XPT's in memory mapping of the data we want
257 * them to be of fixed size. This additional_types scheme is here to allow
258 * for that.
259 */
260
261 XPTTypeDescriptor *additional_types;
262 PRUint16 num_additional_types;
263 };


其中的XPTMethodDescriptor *method_descriptors;又是一个结构体指针,指向的XPTMethodDescriptor的原型如下:
468 /*
469 * A MethodDescriptor is a variable-size record used to describe a single
470 * interface method.
471 */
472 struct XPTMethodDescriptor {
473 char *name;
474 XPTParamDescriptor *params;
475 XPTParamDescriptor *result;
476 PRUint8 flags;
477 PRUint8 num_args;
478 };



这个结构体里记录了接口中每个方法的详细信息。
因此XPTInterfaceDescriptor结构提供了接口里方法的个数,并且我们可以利用里面指向XPTMethodDescriptor类型的指针获取每个方法的详细信息了。
阅读(1382) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~