mozilla
Your Search Results

    NPClass

    « Gecko Plugin API Reference « Scripting plugins

    Summary

    NPClass is a structure that holds a set of pointers to functions that make up the behavior of an instance of an NPClass (i.e. an NPObject).

    Syntax

    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;
    };
    
    Warning: Don't call these routines directly. You should instead use the appropriate API functions.

    Fields

    structVersion
    The version number of the structure. This is set to NP_CLASS_STRUCT_VERSION, which is 1 in Mozilla 1.8.*, 2 since Mozilla 1.9a1, and 3 since Firefox 3.0b1.
    allocate
    Returns a pointer to a newly allocated NPObject. Called by NPN_CreateObject() if non-NULL, otherwise the browser calls malloc(). This function is expected to allocate and return enough storage to hold the NPObject that is being created.
    deallocate
    Called by NPN_ReleaseObject() when an object's reference count reaches zero. If this field is NULL, free() is called isntead.
    invalidate
    Called on live objects that belong to a plugin instance that is being destroyed. This call is always followed by a call to the deallocate function, or free(). Any attempt to use an invalidated object will result in undefined behavior.
    hasMethod
    Called by NPN_HasMethod() to determine whether or not a specified method exists on a given NPObject. Returns true if the method exists, otherwise returns false.
    invoke
    Called by NPN_Invoke() to invoke a specific method on a given NPObject. Returns true if invocation succeeded or false if an error occurred.
    invokeDefault
    Called by NPN_InvokeDefault() to invoke the default method (if available) on a given NPObject. Returns true if invocation succeeded or false if an error occurred.
    hasProperty
    Called by NPN_HasProperty() to check whether a given property exists on a given NPObject. Returns true if the specified property exists, otherwise returns false.
    getProperty
    Called by NPN_GetProperty() to get the value of the specified property on a given NPObject. Returns true if the value was successfully retrieved, otherwise returns false.
    setProperty
    Called by NPN_SetProperty() to set the value of the specified property on a given NPObject. Returns true if the value was successfully set, otherwise returns false.
    removeProperty
    Called by NPN_RemoveProperty() to remove a given property from a specified NPObject. Returns true if the property was successfully removed, otherwise returns false.
    enumerate
    Called by NPN_Enumerate. This field is available only if structVersion is NP_CLASS_STRUCT_VERSION_ENUM (2) or greater.
    construct
    Called by . This field is available only if structVersion is NP_CLASS_STRUCT_VERSION_CTOR (3) or greater.

    Function pointer syntax

    typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass);
    typedef void (*NPDeallocateFunctionPtr)(NPObject *npobj);
    typedef void (*NPInvalidateFunctionPtr)(NPObject *npobj);
    typedef bool (*NPHasMethodFunctionPtr)(NPObject *npobj, NPIdentifier name);
    typedef bool (*NPInvokeFunctionPtr)(NPObject *npobj, 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 *npobj, NPIdentifier name);
    typedef bool (*NPGetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name,
                                             NPVariant *result);
    typedef bool (*NPSetPropertyFunctionPtr)(NPObject *npobj, 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);
    

    See also

    Document Tags and Contributors

    Tags: 
    Contributors to this page: Sheppy, Kazssym
    Last updated by: Kazssym,