Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __METHOD_DISPATCHER_H__
- #define __METHOD_DISPATCHER_H__
- #include <Awesomium/WebCore.h>
- #include <functional>
- #include <map>
- using namespace Awesomium;
- class Application;
- typedef std::pair<int, WebString> ObjectMethodKey;
- typedef std::function<void(Application*, WebView*, const Awesomium::JSArray&)>
- ObjectMethodDelegate;
- typedef std::function<JSValue(Application*, WebView*, const Awesomium::JSArray&)>
- ObjectMethodWithRetvalDelegate;
- typedef std::map<ObjectMethodKey, ObjectMethodDelegate> BoundMethodMap;
- typedef std::map<ObjectMethodKey, ObjectMethodWithRetvalDelegate> BoundMethodWithRetvalMap;
- class MethodDispatcher : public JSMethodHandler {
- public:
- MethodDispatcher(Application* app);
- void Bind(JSObject& object,
- const WebString& name,
- ObjectMethodDelegate callback);
- void BindWithRetval(JSObject& object,
- const WebString& name,
- ObjectMethodWithRetvalDelegate callback);
- // Inherited from JSMethodHandler
- void OnMethodCall(Awesomium::WebView* caller,
- unsigned int remote_object_id,
- const Awesomium::WebString& method_name,
- const Awesomium::JSArray& args);
- // Inherited from JSMethodHandler
- JSValue OnMethodCallWithReturnValue(Awesomium::WebView* caller,
- unsigned int remote_object_id,
- const Awesomium::WebString& method_name,
- const Awesomium::JSArray& args);
- protected:
- Application* app_;
- BoundMethodMap bound_methods_;
- BoundMethodWithRetvalMap bound_methods_with_retval_;
- };
- #endif // __METHOD_DISPATCHER_H__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement