• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ XPCWrappedNativeProto类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中XPCWrappedNativeProto的典型用法代码示例。如果您正苦于以下问题:C++ XPCWrappedNativeProto类的具体用法?C++ XPCWrappedNativeProto怎么用?C++ XPCWrappedNativeProto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了XPCWrappedNativeProto类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: XPC_WN_NoMods_Proto_Resolve

static bool
XPC_WN_NoMods_Proto_Resolve(JSContext* cx, HandleObject obj, HandleId id, bool* resolvedp)
{
    MOZ_ASSERT(js::GetObjectClass(obj) == &XPC_WN_NoMods_Proto_JSClass,
               "bad proto");

    XPCWrappedNativeProto* self =
        (XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
    if (!self)
        return false;

    XPCCallContext ccx(cx);
    if (!ccx.IsValid())
        return false;

    XPCNativeScriptableInfo* si = self->GetScriptableInfo();

    return DefinePropertyIfFound(ccx, obj, id,
                                 self->GetSet(), nullptr, nullptr,
                                 self->GetScope(),
                                 true, nullptr, nullptr, si,
                                 JSPROP_READONLY |
                                 JSPROP_PERMANENT |
                                 JSPROP_ENUMERATE, resolvedp);
}
开发者ID:mephisto41,项目名称:gecko-dev,代码行数:25,代码来源:XPCWrappedNativeJSOps.cpp


示例2: GetMemberInfo

/**
 * Get the interface name and member name (for error messages).
 *
 * We could instead have each quick stub pass its name to the error-handling
 * functions, as that name is statically known.  But that would be redundant;
 * the information is handy at runtime anyway.  Also, this code often produces
 * a more specific error message, e.g. "[nsIDOMHTMLDocument.appendChild]"
 * rather than "[nsIDOMNode.appendChild]".
 */
static void
GetMemberInfo(JSObject *obj, jsid memberId, const char **ifaceName)
{
    *ifaceName = "Unknown";

    // Don't try to generate a useful name if there are security wrappers,
    // because it isn't worth the risk of something going wrong just to generate
    // an error message. Instead, only handle the simple case where we have the
    // reflector in hand.
    if (IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
        XPCWrappedNativeProto *proto;
        if (IS_SLIM_WRAPPER_OBJECT(obj)) {
            proto = GetSlimWrapperProto(obj);
        } else {
            MOZ_ASSERT(IS_WN_WRAPPER_OBJECT(obj));
            XPCWrappedNative *wrapper =
                static_cast<XPCWrappedNative *>(js::GetObjectPrivate(obj));
            proto = wrapper->GetProto();
        }
        if (proto) {
            XPCNativeSet *set = proto->GetSet();
            if (set) {
                XPCNativeMember *member;
                XPCNativeInterface *iface;

                if (set->FindMember(memberId, &member, &iface))
                    *ifaceName = iface->GetNameString();
            }
        }
    }
}
开发者ID:hwine,项目名称:test-mc-ma-cvs,代码行数:40,代码来源:XPCQuickStubs.cpp


示例3: XPC_WN_Shared_Proto_Enumerate

static bool
XPC_WN_Shared_Proto_Enumerate(JSContext* cx, HandleObject obj)
{
    MOZ_ASSERT(js::GetObjectClass(obj) == &XPC_WN_ModsAllowed_Proto_JSClass ||
               js::GetObjectClass(obj) == &XPC_WN_NoMods_Proto_JSClass,
               "bad proto");
    XPCWrappedNativeProto* self =
        (XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
    if (!self)
        return false;

    XPCNativeSet* set = self->GetSet();
    if (!set)
        return false;

    XPCCallContext ccx(cx);
    if (!ccx.IsValid())
        return false;

    uint16_t interface_count = set->GetInterfaceCount();
    XPCNativeInterface** interfaceArray = set->GetInterfaceArray();
    for (uint16_t i = 0; i < interface_count; i++) {
        XPCNativeInterface* iface = interfaceArray[i];
        uint16_t member_count = iface->GetMemberCount();

        for (uint16_t k = 0; k < member_count; k++) {
            if (!xpc_ForcePropertyResolve(cx, obj, iface->GetMemberAt(k)->GetName()))
                return false;
        }
    }

    return true;
}
开发者ID:mephisto41,项目名称:gecko-dev,代码行数:33,代码来源:XPCWrappedNativeJSOps.cpp


示例4: WNProtoSecPolicyClearer

WNProtoSecPolicyClearer(JSDHashTable *table, JSDHashEntryHdr *hdr,
                        uint32 number, void *arg)
{
    XPCWrappedNativeProto* proto =
        ((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value;
    *(proto->GetSecurityInfoAddr()) = nsnull;
    return JS_DHASH_NEXT;
}
开发者ID:,项目名称:,代码行数:8,代码来源:


示例5: XPC_WN_Shared_Proto_ObjectMoved

static void
XPC_WN_Shared_Proto_ObjectMoved(JSObject* obj, const JSObject* old)
{
    // This can be null if xpc shutdown has already happened
    XPCWrappedNativeProto* p = (XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
    if (p)
        p->JSProtoObjectMoved(obj, old);
}
开发者ID:mephisto41,项目名称:gecko-dev,代码行数:8,代码来源:XPCWrappedNativeJSOps.cpp


示例6: XPC_WN_Shared_Proto_Finalize

static void
XPC_WN_Shared_Proto_Finalize(js::FreeOp* fop, JSObject* obj)
{
    // This can be null if xpc shutdown has already happened
    XPCWrappedNativeProto* p = (XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
    if (p)
        p->JSProtoObjectFinalized(fop, obj);
}
开发者ID:mephisto41,项目名称:gecko-dev,代码行数:8,代码来源:XPCWrappedNativeJSOps.cpp


示例7: DetachedWrappedNativeProtoShutdownMarker

DetachedWrappedNativeProtoShutdownMarker(JSDHashTable *table, JSDHashEntryHdr *hdr,
                                         uint32 number, void *arg)
{
    XPCWrappedNativeProto* proto = 
        (XPCWrappedNativeProto*)((JSDHashEntryStub*)hdr)->key;

    proto->SystemIsBeingShutDown((JSContext*)arg);
    return JS_DHASH_NEXT;
}
开发者ID:,项目名称:,代码行数:9,代码来源:


示例8: DetachedWrappedNativeProtoMarker

DetachedWrappedNativeProtoMarker(JSDHashTable *table, JSDHashEntryHdr *hdr,
                                 uint32 number, void *arg)
{
    XPCWrappedNativeProto* proto = 
        (XPCWrappedNativeProto*)((JSDHashEntryStub*)hdr)->key;

    proto->Mark();
    return JS_DHASH_NEXT;
}
开发者ID:,项目名称:,代码行数:9,代码来源:


示例9: WNProtoSecPolicyClearer

static PLDHashOperator
WNProtoSecPolicyClearer(PLDHashTable *table, PLDHashEntryHdr *hdr,
                        uint32_t number, void *arg)
{
    XPCWrappedNativeProto* proto =
        ((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value;
    *(proto->GetSecurityInfoAddr()) = nullptr;
    return PL_DHASH_NEXT;
}
开发者ID:jonathanmarvens,项目名称:mozilla-central,代码行数:9,代码来源:XPCWrappedNativeScope.cpp


示例10: XPC_WN_Shared_Proto_Trace

static void
XPC_WN_Shared_Proto_Trace(JSTracer* trc, JSObject* obj)
{
    // This can be null if xpc shutdown has already happened
    XPCWrappedNativeProto* p =
        (XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
    if (p)
        p->TraceInside(trc);
}
开发者ID:mephisto41,项目名称:gecko-dev,代码行数:9,代码来源:XPCWrappedNativeJSOps.cpp


示例11: GetMemberInfo

/**
 * Get the interface name and member name (for error messages).
 *
 * We could instead have each quick stub pass its name to the error-handling
 * functions, as that name is statically known.  But that would be redundant;
 * the information is handy at runtime anyway.  Also, this code often produces
 * a more specific error message, e.g. "[nsIDOMHTMLDocument.appendChild]"
 * rather than "[nsIDOMNode.appendChild]".
 */
static void
GetMemberInfo(JSObject *obj,
              jsval memberId,
              const char **ifaceName,
              const char **memberName)
{
    // Get the interface name.  From DefinePropertyIfFound (in
    // xpcwrappednativejsops.cpp) and XPCThrower::Verbosify.
    //
    // We could instead make the quick stub could pass in its interface name,
    // but this code often produces a more specific error message, e.g.
    *ifaceName = "Unknown";

    NS_ASSERTION(IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)) ||
                 STOBJ_GET_CLASS(obj) == &XPC_WN_Tearoff_JSClass ||
                 IS_SLIM_WRAPPER(obj),
                 "obj must be a wrapper");
    XPCWrappedNativeProto *proto;
    if(IS_SLIM_WRAPPER(obj))
    {
        proto = GetSlimWrapperProto(obj);
    }
    else
    {
        XPCWrappedNative *wrapper = (XPCWrappedNative *) obj->getPrivate();
        proto = wrapper->GetProto();
    }
    if(proto)
    {
        XPCNativeSet *set = proto->GetSet();
        if(set)
        {
            XPCNativeMember *member;
            XPCNativeInterface *iface;

            if(set->FindMember(memberId, &member, &iface))
                *ifaceName = iface->GetNameString();
        }
    }

    *memberName = (JSVAL_IS_STRING(memberId)
                   ? JS_GetStringBytes(JSVAL_TO_STRING(memberId))
                   : "unknown");
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:53,代码来源:xpcquickstubs.cpp


示例12: GetMemberInfo

/**
 * Get the interface name and member name (for error messages).
 *
 * We could instead have each quick stub pass its name to the error-handling
 * functions, as that name is statically known.  But that would be redundant;
 * the information is handy at runtime anyway.  Also, this code often produces
 * a more specific error message, e.g. "[nsIDOMHTMLDocument.appendChild]"
 * rather than "[nsIDOMNode.appendChild]".
 */
static void
GetMemberInfo(JSObject *obj, jsid memberId, const char **ifaceName)
{
    *ifaceName = "Unknown";

    // Don't try to generate a useful name if there are security wrappers,
    // because it isn't worth the risk of something going wrong just to generate
    // an error message. Instead, only handle the simple case where we have the
    // reflector in hand.
    if (IS_WN_REFLECTOR(obj)) {
        XPCWrappedNative *wrapper = XPCWrappedNative::Get(obj);
        XPCWrappedNativeProto *proto = wrapper->GetProto();
        if (proto) {
            XPCNativeSet *set = proto->GetSet();
            if (set) {
                XPCNativeMember *member;
                XPCNativeInterface *iface;

                if (set->FindMember(memberId, &member, &iface))
                    *ifaceName = iface->GetNameString();
            }
        }
    }
}
开发者ID:chenghuk,项目名称:mozilla-central,代码行数:33,代码来源:XPCQuickStubs.cpp


示例13: WrappedNativeSuspecter

WrappedNativeSuspecter(JSDHashTable *table, JSDHashEntryHdr *hdr,
                       uint32 number, void *arg)
{
    SuspectClosure* closure = static_cast<SuspectClosure*>(arg);
    XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
    XPCWrappedNativeProto* proto = wrapper->GetProto();
    if(proto && proto->ClassIsMainThreadOnly() && wrapper->IsValid())
    {
        NS_ASSERTION(NS_IsMainThread(), 
                     "Suspecting wrapped natives from non-main thread");

#ifndef DEBUG_CC
        // Only record objects that might be part of a cycle as roots.
        if(!JS_IsAboutToBeFinalized(closure->cx, wrapper->GetFlatJSObject()))
            return JS_DHASH_NEXT;
#endif

        closure->cb.NoteRoot(nsIProgrammingLanguage::JAVASCRIPT,
                             wrapper->GetFlatJSObject(),
                             nsXPConnect::GetXPConnect());
    }

    return JS_DHASH_NEXT;
}
开发者ID:,项目名称:,代码行数:24,代码来源:


示例14: JSVAL_TO_OBJECT

/* PRBool hasInstance (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval val, out PRBool bp); */
NS_IMETHODIMP
nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
                     JSContext * cx, JSObject * obj,
                     const jsval &val, PRBool *bp, PRBool *_retval)
{
    *bp = JS_FALSE;
    nsresult rv = NS_OK;

    if(!JSVAL_IS_PRIMITIVE(val))
    {
        // we have a JSObject
        JSObject* obj = JSVAL_TO_OBJECT(val);

        NS_ASSERTION(obj, "when is an object not an object?");

        // is this really a native xpcom object with a wrapper?
        const nsIID* iid;
        mInfo->GetIIDShared(&iid);

        if(IS_SLIM_WRAPPER(obj))
        {
            XPCWrappedNativeProto* proto = GetSlimWrapperProto(obj);
            if(proto->GetSet()->HasInterfaceWithAncestor(iid))
            {
                *bp = JS_TRUE;
                return NS_OK;
            }

#ifdef DEBUG_slimwrappers
            char foo[NSID_LENGTH];
            iid->ToProvidedString(foo);
            SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, foo);
#endif
            if(!MorphSlimWrapper(cx, obj))
                return NS_ERROR_FAILURE;
        }

        XPCWrappedNative* other_wrapper =
           XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);

        if(!other_wrapper)
            return NS_OK;

        // We'll trust the interface set of the wrapper if this is known
        // to be an interface that the objects *expects* to be able to
        // handle.
        if(other_wrapper->HasInterfaceNoQI(*iid))
        {
            *bp = JS_TRUE;
            return NS_OK;
        }

        // Otherwise, we'll end up Querying the native object to be sure.
        XPCCallContext ccx(JS_CALLER, cx);

        AutoMarkingNativeInterfacePtr iface(ccx);
        iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);

        if(iface && other_wrapper->FindTearOff(ccx, iface))
            *bp = JS_TRUE;
    }
    return rv;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:64,代码来源:xpcjsid.cpp


示例15: JSVAL_TO_OBJECT

/* bool hasInstance (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval val, out bool bp); */
NS_IMETHODIMP
nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
                     JSContext * cx, JSObject * obj,
                     const jsval &val, bool *bp, bool *_retval)
{
    *bp = false;
    nsresult rv = NS_OK;

    if (!JSVAL_IS_PRIMITIVE(val)) {
        // we have a JSObject
        JSObject* obj = JSVAL_TO_OBJECT(val);

        NS_ASSERTION(obj, "when is an object not an object?");

        // is this really a native xpcom object with a wrapper?
        const nsIID* iid;
        mInfo->GetIIDShared(&iid);

        if (IS_SLIM_WRAPPER(obj)) {
            XPCWrappedNativeProto* proto = GetSlimWrapperProto(obj);
            if (proto->GetSet()->HasInterfaceWithAncestor(iid)) {
                *bp = true;
                return NS_OK;
            }

#ifdef DEBUG_slimwrappers
            char foo[NSID_LENGTH];
            iid->ToProvidedString(foo);
            SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, foo);
#endif
            if (!MorphSlimWrapper(cx, obj))
                return NS_ERROR_FAILURE;
        }

        nsISupports *identity;
        if (mozilla::dom::binding::instanceIsProxy(obj)) {
            identity =
                static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
        } else if (mozilla::dom::bindings::IsDOMClass(js::GetObjectJSClass(obj))) {
            NS_ASSERTION(mozilla::dom::bindings::DOMJSClass::FromJSClass(
                              js::GetObjectJSClass(obj))->mDOMObjectIsISupports,
                         "This only works on nsISupports classes!");
            identity =
                mozilla::dom::bindings::UnwrapDOMObject<nsISupports>(obj,
                                                                     js::GetObjectJSClass(obj));
        } else {
            identity = nsnull;
        }

        if (identity) {
            nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(identity);

            XPCCallContext ccx(JS_CALLER, cx);

            AutoMarkingNativeSetPtr set(ccx);
            set = XPCNativeSet::GetNewOrUsed(ccx, ci);
            if (!set)
                return NS_ERROR_FAILURE;
            *bp = set->HasInterfaceWithAncestor(iid);
            return NS_OK;
        }

        XPCWrappedNative* other_wrapper =
           XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);

        if (!other_wrapper)
            return NS_OK;

        // We'll trust the interface set of the wrapper if this is known
        // to be an interface that the objects *expects* to be able to
        // handle.
        if (other_wrapper->HasInterfaceNoQI(*iid)) {
            *bp = true;
            return NS_OK;
        }

        // Otherwise, we'll end up Querying the native object to be sure.
        XPCCallContext ccx(JS_CALLER, cx);

        AutoMarkingNativeInterfacePtr iface(ccx);
        iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);

        nsresult findResult = NS_OK;
        if (iface && other_wrapper->FindTearOff(ccx, iface, false, &findResult))
            *bp = true;
        if (NS_FAILED(findResult) && findResult != NS_ERROR_NO_INTERFACE)
            rv = findResult;
    }
    return rv;
}
开发者ID:michaelrhanson,项目名称:mozilla-central,代码行数:91,代码来源:XPCJSID.cpp



注:本文中的XPCWrappedNativeProto类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ XPCWrappedNativeScope类代码示例发布时间:2022-05-31
下一篇:
C++ XPCWrappedNative类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap