本文整理汇总了C++中XPCNativeMember::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ XPCNativeMember::SetName方法的具体用法?C++ XPCNativeMember::SetName怎么用?C++ XPCNativeMember::SetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPCNativeMember
的用法示例。
在下文中一共展示了XPCNativeMember::SetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
// static
XPCNativeInterface*
XPCNativeInterface::NewInstance(XPCCallContext& ccx,
nsIInterfaceInfo* aInfo)
{
static const PRUint16 MAX_LOCAL_MEMBER_COUNT = 16;
XPCNativeMember local_members[MAX_LOCAL_MEMBER_COUNT];
XPCNativeInterface* obj = nsnull;
XPCNativeMember* members = nsnull;
int i;
JSBool failed = false;
PRUint16 constCount;
PRUint16 methodCount;
PRUint16 totalCount;
PRUint16 realTotalCount = 0;
XPCNativeMember* cur;
JSString* str = NULL;
jsid name;
jsid interfaceName;
// XXX Investigate lazy init? This is a problem given the
// 'placement new' scheme - we need to at least know how big to make
// the object. We might do a scan of methods to determine needed size,
// then make our object, but avoid init'ing *any* members until asked?
// Find out how often we create these objects w/o really looking at
// (or using) the members.
bool canScript;
if (NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript)
return nsnull;
if (NS_FAILED(aInfo->GetMethodCount(&methodCount)) ||
NS_FAILED(aInfo->GetConstantCount(&constCount)))
return nsnull;
// If the interface does not have nsISupports in its inheritance chain
// then we know we can't reflect its methods. However, some interfaces that
// are used just to reflect constants are declared this way. We need to
// go ahead and build the thing. But, we'll ignore whatever methods it may
// have.
if (!nsXPConnect::IsISupportsDescendant(aInfo))
methodCount = 0;
totalCount = methodCount + constCount;
if (totalCount > MAX_LOCAL_MEMBER_COUNT) {
members = new XPCNativeMember[totalCount];
if (!members)
return nsnull;
} else {
members = local_members;
}
// NOTE: since getters and setters share a member, we might not use all
// of the member objects.
for (i = 0; i < methodCount; i++) {
const nsXPTMethodInfo* info;
if (NS_FAILED(aInfo->GetMethodInfo(i, &info))) {
failed = true;
break;
}
// don't reflect Addref or Release
if (i == 1 || i == 2)
continue;
if (!XPCConvert::IsMethodReflectable(*info))
continue;
str = JS_InternString(ccx, info->GetName());
if (!str) {
NS_ERROR("bad method name");
failed = true;
break;
}
name = INTERNED_STRING_TO_JSID(ccx, str);
if (info->IsSetter()) {
NS_ASSERTION(realTotalCount,"bad setter");
// Note: ASSUMES Getter/Setter pairs are next to each other
// This is a rule of the typelib spec.
cur = &members[realTotalCount-1];
NS_ASSERTION(cur->GetName() == name,"bad setter");
NS_ASSERTION(cur->IsReadOnlyAttribute(),"bad setter");
NS_ASSERTION(cur->GetIndex() == i-1,"bad setter");
cur->SetWritableAttribute();
} else {
// XXX need better way to find dups
// NS_ASSERTION(!LookupMemberByID(name),"duplicate method name");
cur = &members[realTotalCount++];
cur->SetName(name);
if (info->IsGetter())
cur->SetReadOnlyAttribute(i);
else
cur->SetMethod(i);
}
}
//.........这里部分代码省略.........
示例2: str
//.........这里部分代码省略.........
// don't reflect Addref or Release
if (i == 1 || i == 2)
continue;
if (!XPCConvert::IsMethodReflectable(*info))
continue;
str = JS_AtomizeAndPinString(cx, info->GetName());
if (!str) {
NS_ERROR("bad method name");
failed = true;
break;
}
jsid name = INTERNED_STRING_TO_JSID(cx, str);
if (info->IsSetter()) {
MOZ_ASSERT(realTotalCount,"bad setter");
// Note: ASSUMES Getter/Setter pairs are next to each other
// This is a rule of the typelib spec.
cur = &members[realTotalCount-1];
MOZ_ASSERT(cur->GetName() == name,"bad setter");
MOZ_ASSERT(cur->IsReadOnlyAttribute(),"bad setter");
MOZ_ASSERT(cur->GetIndex() == i-1,"bad setter");
cur->SetWritableAttribute();
} else {
// XXX need better way to find dups
// MOZ_ASSERT(!LookupMemberByID(name),"duplicate method name");
if (realTotalCount == XPCNativeMember::GetMaxIndexInInterface()) {
NS_WARNING("Too many members in interface");
failed = true;
break;
}
cur = &members[realTotalCount];
cur->SetName(name);
if (info->IsGetter())
cur->SetReadOnlyAttribute(i);
else
cur->SetMethod(i);
cur->SetIndexInInterface(realTotalCount);
++realTotalCount;
}
}
if (!failed) {
for (i = 0; i < constCount; i++) {
RootedValue constant(cx);
nsXPIDLCString namestr;
if (NS_FAILED(aInfo->GetConstant(i, &constant, getter_Copies(namestr)))) {
failed = true;
break;
}
str = JS_AtomizeAndPinString(cx, namestr);
if (!str) {
NS_ERROR("bad constant name");
failed = true;
break;
}
jsid name = INTERNED_STRING_TO_JSID(cx, str);
// XXX need better way to find dups
//MOZ_ASSERT(!LookupMemberByID(name),"duplicate method/constant name");
if (realTotalCount == XPCNativeMember::GetMaxIndexInInterface()) {
NS_WARNING("Too many members in interface");
failed = true;
break;