⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 npruntime.h

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 H
📖 第 1 页 / 共 2 页
字号:
#define STRINGN_TO_NPVARIANT(_val, _len, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, _len }; (_v).value.stringValue = str; NP_END_MACRO#define OBJECT_TO_NPVARIANT(_val, _v)        NP_BEGIN_MACRO (_v).type = NPVariantType_Object; (_v).value.objectValue = _val; NP_END_MACRO/*        Type mappings (JavaScript types have been used for illustration    purposes):        JavaScript       to             C (NPVariant with type:)        undefined                       NPVariantType_Void        null                            NPVariantType_Null        Boolean                         NPVariantType_Bool        Number                          NPVariantType_Double or NPVariantType_Int32        String                          NPVariantType_String        Object                          NPVariantType_Object        C (NPVariant with type:)   to   JavaScript        NPVariantType_Void              undefined        NPVariantType_Null              null        NPVariantType_Bool              Boolean         NPVariantType_Int32             Number        NPVariantType_Double            Number        NPVariantType_String            String        NPVariantType_Object            Object*/typedef void *NPIdentifier;/*    NPObjects have methods and properties.  Methods and properties are    identified with NPIdentifiers.  These identifiers may be reflected    in script.  NPIdentifiers can be either strings or integers, IOW,    methods and properties can be identified by either strings or    integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be    compared using ==.  In case of any errors, the requested    NPIdentifier(s) will be NULL.*/NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name);void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers);NPIdentifier NPN_GetIntIdentifier(int32_t intid);bool NPN_IdentifierIsString(NPIdentifier identifier);/*    The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed.*/NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier);/*    Get the integer represented by identifier. If identifier is not an    integer identifier, the behaviour is undefined.*/int32_t NPN_IntFromIdentifier(NPIdentifier identifier);/*    NPObject behavior is implemented using the following set of    callback functions.    The NPVariant *result argument of these functions (where    applicable) should be released using NPN_ReleaseVariantValue().*/typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass);typedef void (*NPDeallocateFunctionPtr)(NPObject *obj);typedef void (*NPInvalidateFunctionPtr)(NPObject *obj);typedef bool (*NPHasMethodFunctionPtr)(NPObject *obj, NPIdentifier name);typedef bool (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result);typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);typedef bool (*NPHasPropertyFunctionPtr)(NPObject *obj, NPIdentifier name);typedef bool (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);typedef bool (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, NPIdentifier name);typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, uint32_t *count);typedef bool (*NPConstructFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);/*    NPObjects returned by create have a reference count of one.  It is the caller's responsibility    to release the returned object.    NPInvokeFunctionPtr function may return false to indicate a the method could not be invoked.        NPGetPropertyFunctionPtr and NPSetPropertyFunctionPtr may return false to indicate a property doesn't    exist.        NPInvalidateFunctionPtr is called by the scripting environment when the native code is    shutdown.  Any attempt to message a NPObject instance after the invalidate    callback has been called will result in undefined behavior, even if the    native code is still retaining those NPObject instances.    (The runtime will typically return immediately, with 0 or NULL, from an attempt to    dispatch to a NPObject, but this behavior should not be depended upon.)        The NPEnumerationFunctionPtr function may pass an array of                      NPIdentifiers back to the caller. The callee allocs the memory of               the array using NPN_MemAlloc(), and it's the caller's responsibility            to release it using NPN_MemFree().           */struct NPClass{    uint32_t structVersion;    NPAllocateFunctionPtr allocate;    NPDeallocateFunctionPtr deallocate;    NPInvalidateFunctionPtr invalidate;    NPHasMethodFunctionPtr hasMethod;    NPInvokeFunctionPtr invoke;    NPInvokeDefaultFunctionPtr invokeDefault;    NPHasPropertyFunctionPtr hasProperty;    NPGetPropertyFunctionPtr getProperty;    NPSetPropertyFunctionPtr setProperty;    NPRemovePropertyFunctionPtr removeProperty;    NPEnumerationFunctionPtr enumerate;    NPConstructFunctionPtr construct;};#define NP_CLASS_STRUCT_VERSION      3#define NP_CLASS_STRUCT_VERSION_ENUM 2#define NP_CLASS_STRUCT_VERSION_CTOR 3#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass)   \    ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM)#define NP_CLASS_STRUCT_VERSION_HAS_CTOR(npclass)   \    ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_CTOR)struct NPObject {    NPClass *_class;    uint32_t referenceCount;    // Additional space may be allocated here by types of NPObjects};/*    If the class has an allocate function, NPN_CreateObject invokes that function,    otherwise a NPObject is allocated and returned.  If a class has an allocate    function it is the responsibility of that implementation to set the initial retain    count to 1.*/NPObject *NPN_CreateObject(NPP npp, NPClass *aClass);/*    Increment the NPObject's reference count.*/NPObject *NPN_RetainObject (NPObject *obj);/*    Decremented the NPObject's reference count.  If the reference    count goes to zero, the class's destroy function is invoke if    specified, otherwise the object is freed directly.*/void NPN_ReleaseObject (NPObject *obj);/*    Functions to access script objects represented by NPObject.    Calls to script objects are synchronous.  If a function returns a    value, it will be supplied via the result NPVariant    argument. Successful calls will return true, false will be    returned in case of an error.        Calls made from plugin code to script must be made from the thread    on which the plugin was initialized.*/bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *result);bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result);bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value);bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);bool NPN_Construct(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);/*    NPN_SetException may be called to trigger a script exception upon return    from entry points into NPObjects.*/void NPN_SetException (NPObject *obj, const NPUTF8 *message);#ifdef __cplusplus}#endif#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -