本文整理汇总了C++中XPCContext::SetLastResult方法的典型用法代码示例。如果您正苦于以下问题:C++ XPCContext::SetLastResult方法的具体用法?C++ XPCContext::SetLastResult怎么用?C++ XPCContext::SetLastResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPCContext
的用法示例。
在下文中一共展示了XPCContext::SetLastResult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Invoke
JSBool XPCDispObject::Invoke(XPCCallContext & ccx, CallMode mode)
{
nsresult rv = ccx.CanCallNow();
if(NS_FAILED(rv))
{
// If the security manager is complaining then this is not really an
// internal error in xpconnect. So, no reason to botch the assertion.
NS_ASSERTION(rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO,
"hmm? CanCallNow failed in XPCDispObject::Invoke. "
"We are finding out about this late!");
XPCThrower::Throw(rv, ccx);
return JS_FALSE;
}
// TODO: Remove type cast and change GetIDispatchMember to use the correct type
XPCDispInterface::Member* member = reinterpret_cast<XPCDispInterface::Member*>(ccx.GetIDispatchMember());
XPCJSRuntime* rt = ccx.GetRuntime();
XPCContext* xpcc = ccx.GetXPCContext();
XPCPerThreadData* tls = ccx.GetThreadData();
jsval* argv = ccx.GetArgv();
uintN argc = ccx.GetArgc();
tls->SetException(nsnull);
xpcc->SetLastResult(NS_ERROR_UNEXPECTED);
// set up the method index and do the security check if needed
PRUint32 secFlag;
PRUint32 secAction;
switch(mode)
{
case CALL_METHOD:
secFlag = nsIXPCSecurityManager::HOOK_CALL_METHOD;
secAction = nsIXPCSecurityManager::ACCESS_CALL_METHOD;
break;
case CALL_GETTER:
secFlag = nsIXPCSecurityManager::HOOK_GET_PROPERTY;
secAction = nsIXPCSecurityManager::ACCESS_GET_PROPERTY;
break;
case CALL_SETTER:
secFlag = nsIXPCSecurityManager::HOOK_SET_PROPERTY;
secAction = nsIXPCSecurityManager::ACCESS_SET_PROPERTY;
break;
default:
NS_ASSERTION(0,"bad value");
return JS_FALSE;
}
jsval name = member->GetName();
nsIXPCSecurityManager* sm = xpcc->GetAppropriateSecurityManager(secFlag);
XPCWrappedNative* wrapper = ccx.GetWrapper();
if(sm && NS_FAILED(sm->CanAccess(secAction, &ccx, ccx,
ccx.GetFlattenedJSObject(),
wrapper->GetIdentityObject(),
wrapper->GetClassInfo(), name,
wrapper->GetSecurityInfoAddr())))
{
// the security manager vetoed. It should have set an exception.
return JS_FALSE;
}
IDispatch * pObj = reinterpret_cast<IDispatch*>
(ccx.GetTearOff()->GetNative());
PRUint32 args = member->GetParamCount();
uintN err;
// Make sure setter has one argument
if(mode == CALL_SETTER)
args = 1;
// Allow for optional parameters. We'll let COM handle the error if there
// are not enough parameters
if(argc < args)
args = argc;
XPCDispParams * params = new XPCDispParams(args);
jsval val;
// If this is a setter, we just need to convert the first parameter
if(mode == CALL_SETTER)
{
params->SetNamedPropID();
if(!XPCDispConvert::JSToCOM(ccx, argv[0], params->GetParamRef(0), err))
{
delete params;
return ThrowBadParam(err, 0, ccx);
}
}
else if(mode != CALL_GETTER) // This is a function
{
// Convert the arguments to the function
for(PRUint32 index = 0; index < args; ++index)
{
const XPCDispInterface::Member::ParamInfo & paramInfo = member->GetParamInfo(index);
if(paramInfo.IsIn())
{
val = argv[index];
if(paramInfo.IsOut())
{
if(JSVAL_IS_PRIMITIVE(val) ||
!OBJ_GET_PROPERTY(ccx, JSVAL_TO_OBJECT(val),
rt->GetStringID(XPCJSRuntime::IDX_VALUE),
//.........这里部分代码省略.........