Pepper_47_C++_interfaces
|
#include <module.h>
Public Types | |
typedef std::map< PP_Instance, Instance * > | InstanceMap |
Public Member Functions | |
Module () | |
virtual | ~Module () |
virtual bool | Init () |
PP_Module | pp_module () const |
PPB_GetInterface | get_browser_interface () const |
Core * | core () |
const void * | GetPluginInterface (const char *interface_name) |
const void * | GetBrowserInterface (const char *interface_name) |
Instance * | InstanceForPPInstance (PP_Instance instance) |
void | AddPluginInterface (const std::string &interface_name, const void *vtable) |
bool | InternalInit (PP_Module mod, PPB_GetInterface get_browser_interface) |
const InstanceMap & | current_instances () const |
Static Public Member Functions | |
static Module * | Get () |
Protected Member Functions | |
virtual Instance * | CreateInstance (PP_Instance instance)=0 |
Friends | |
PP_Bool | Instance_DidCreate (PP_Instance pp_instance, uint32_t argc, const char *argn[], const char *argv[]) |
void | Instance_DidDestroy (PP_Instance instance) |
The Module class. The browser calls CreateInstance() to create an instance of your module on the web page. The browser creates a new instance for each <embed>
tag with type="application/x-nacl"
typedef std::map<PP_Instance, Instance*> pp::Module::InstanceMap |
void pp::Module::AddPluginInterface | ( | const std::string & | interface_name, |
const void * | vtable | ||
) |
AddPluginInterface() adds a handler for a provided interface name. When the browser requests that interface name, the provided vtable
will be returned.
In general, modules will not need to call this directly. Instead, the C++ wrappers for each interface will register themselves with this function.
This function may be called more than once with the same interface name and vtable with no effect. However, it may not be used to register a different vtable for an already-registered interface. It will assert for a different registration for an already-registered interface in debug mode, and just ignore the registration in release mode.
[in] | interface_name | The interface name that will receive a handler. |
[in,out] | vtable | The vtable to return for interface_name . |
Definition at line 190 of file module.cc.
References GetPluginInterface(), and PP_DCHECK.
Referenced by pp::Graphics3DClient::Graphics3DClient(), pp::InstancePrivate::InstancePrivate(), pp::MouseLock::MouseLock(), and pp::VideoCaptureClient_Dev::VideoCaptureClient_Dev().
|
inline |
The core() function returns the core interface for doing basic global operations. The return value is guaranteed to be non-NULL once the module has successfully initialized and during the Init() call.
It will be NULL before Init() has been called.
Definition at line 74 of file module.h.
Referenced by pp::ResourceArray_Dev::ArrayOutputCallbackConverter(), pp::Resource::Clear(), pp::DirectoryEntry::DirectoryEntry(), pp::IMEInputEvent::IMEInputEvent(), pp::InputEvent::InputEvent(), InternalInit(), pp::KeyboardInputEvent::KeyboardInputEvent(), pp::CompletionCallback::MayForce(), pp::MouseInputEvent::MouseInputEvent(), pp::Resource::operator=(), pp::DirectoryEntry::operator=(), pp::Resource::Resource(), pp::TouchInputEvent::TouchInputEvent(), pp::WheelInputEvent::WheelInputEvent(), pp::DirectoryEntry::~DirectoryEntry(), and pp::Resource::~Resource().
|
protectedpure virtual |
CreateInstance() should be overridden to create your own module type.
[in] | instance | A PP_Instance . |
Referenced by pp::Instance_DidCreate().
|
inline |
The current_instances() function allows iteration over the current instances in the module.
InstanceMap
of all instances in the module.
|
static |
Get() returns the global instance of this module object, or NULL if the module is not initialized yet.
Definition at line 22 of file ppp_entrypoints.cc.
References g_module_singleton.
Referenced by pp::ResourceArray_Dev::ArrayOutputCallbackConverter(), pp::Resource::Clear(), pp::NetAddressPrivate::Describe(), pp::DirectoryEntry::DirectoryEntry(), pp::VarPrivate::GetAllPropertyNames(), pp::Instance::GetPerInstanceObject(), pp::Graphics3DClient::Graphics3DClient(), pp::IMEInputEvent::IMEInputEvent(), pp::InputEvent::InputEvent(), pp::InputEvent_HandleEvent(), pp::Instance_DidChangeFocus(), pp::Instance_DidChangeView(), pp::Instance_DidCreate(), pp::Instance_DidDestroy(), pp::Instance_HandleDocumentLoad(), pp::InstancePrivate::InstancePrivate(), pp::KeyboardInputEvent::KeyboardInputEvent(), pp::CompletionCallback::MayForce(), pp::Messaging_HandleMessage(), pp::MouseInputEvent::MouseInputEvent(), pp::MouseLock::MouseLock(), pp::Resource::operator=(), pp::DirectoryEntry::operator=(), pp::Instance::RemovePerInstanceObject(), pp::Resource::Resource(), pp::TouchInputEvent::TouchInputEvent(), pp::VideoCaptureClient_Dev::VideoCaptureClient_Dev(), pp::WheelInputEvent::WheelInputEvent(), pp::DirectoryEntry::~DirectoryEntry(), and pp::Resource::~Resource().
|
inline |
The get_browser_interface() function returns the internal get_browser_interface
pointer.
PPB_GetInterface
internal pointer. Definition at line 63 of file module.h.
Referenced by InternalInit().
const void * pp::Module::GetBrowserInterface | ( | const char * | interface_name | ) |
GetBrowserInterface() returns interfaces which the browser implements (i.e. PPB interfaces).
[in] | interface_name | The browser interface for the module to get. |
Definition at line 179 of file module.cc.
Referenced by pp::VarPrivate::GetAllPropertyNames(), and InternalInit().
const void * pp::Module::GetPluginInterface | ( | const char * | interface_name | ) |
GetPluginInterface() implements GetInterface
for the browser to get module interfaces. If you need to provide your own implementations of new interfaces, use AddPluginInterface() which this function will use.
[in] | interface_name | The module interface for the browser to get. |
Definition at line 162 of file module.cc.
References pp::input_event_interface, pp::instance_interface, and pp::instance_messaging_interface.
Referenced by AddPluginInterface(), and PPP_GetInterface().
|
virtual |
Init() is automatically called after the object is created. This is where you can put functions that rely on other parts of the API, now that the module has been created.
Definition at line 158 of file module.cc.
Referenced by InternalInit().
Instance * pp::Module::InstanceForPPInstance | ( | PP_Instance | instance | ) |
InstanceForPPInstance() returns the object associated with this PP_Instance
, or NULL if one is not found. This should only be called from the main thread! This instance object may be destroyed at any time on the main thread, so using it on other threads may cause a crash.
[in] | instance | This PP_Instance . |
PP_Instance
, or NULL if one is not found. Definition at line 183 of file module.cc.
Referenced by pp::Instance::GetPerInstanceObject(), pp::InputEvent_HandleEvent(), pp::Instance_DidChangeFocus(), pp::Instance_DidChangeView(), pp::Instance_HandleDocumentLoad(), pp::Messaging_HandleMessage(), and pp::Instance::RemovePerInstanceObject().
bool pp::Module::InternalInit | ( | PP_Module | mod, |
PPB_GetInterface | get_browser_interface | ||
) |
function that can be overridden by the base classes.
[in] | mod | A PP_Module . |
[in] | get_browser_interface | The browser interface to set. |
Definition at line 204 of file module.cc.
References core(), get_browser_interface(), GetBrowserInterface(), and Init().
Referenced by PPP_InitializeModule().
|
inline |
The pp_module() function returns the internal module handle.
PP_Module
internal module handle. Definition at line 55 of file module.h.
Referenced by pp::NetAddressPrivate::Describe().
|
friend |