1 module awebview.wrapper.cpp.jsobject; 2 3 4 mixin template Awesomium() 5 { 6 enum JSObjectType { local, remote, remoteGlobal } 7 8 interface JSObject 9 { 10 static struct Field 11 { 12 bool is_local_; 13 union U_ { 14 void* local; 15 void* remote; 16 } 17 U_ instance_; 18 Error last_error_; 19 } 20 } 21 22 interface JSMethodHandler {} 23 } 24 25 26 mixin template Awesomium4D() 27 { 28 extern(C++, JSObjectMember) 29 { 30 size_t sizeOfInstance(); 31 void ctor(Awesomium.JSObject p); 32 void ctor(Awesomium.JSObject p, const(Awesomium.JSObject) obj); 33 Awesomium.JSObject newCtor(); 34 Awesomium.JSObject newCtor(const(Awesomium.JSObject) obj); 35 void dtor(Awesomium.JSObject p); 36 void deleteDtor(Awesomium.JSObject p); 37 Awesomium.JSObject opAssign(Awesomium.JSObject p, const(Awesomium.JSObject) rhs); 38 uint remote_id(const(Awesomium.JSObject) p); 39 int ref_count(const(Awesomium.JSObject) p); 40 JSObjectType type(const(Awesomium.JSObject) p); 41 Awesomium.WebView owner(const(Awesomium.JSObject) p); 42 void GetPropertyNames(const(Awesomium.JSObject) p, JSArray dst); 43 bool HasProperty(const(Awesomium.JSObject) p, const(Awesomium.WebString) name); 44 void GetProperty(const(Awesomium.JSObject) p, const(Awesomium.WebString) name, Awesomium.JSValue dst); 45 void SetProperty(Awesomium.JSObject p, const(Awesomium.WebString) name, const(JSValue) value); 46 void SetPropertyAsync(Awesomium.JSObject p, const(Awesomium.WebString) name, const(Awesomium.JSObject) value); 47 void RemoveProperty(Awesomium.JSObject p, const(Awesomium.WebString) name); 48 void GetMethodNames(const(Awesomium.JSObject) p, JSArray dst); 49 bool HasMethod(const(Awesomium.JSObject) p, const(Awesomium.WebString) name); 50 void Invoke(Awesomium.JSObject p, const(Awesomium.WebString) name, const(Awesomium.JSArray) args, Awesomium.JSValue dst); 51 void InvokeAsync(Awesomium.JSObject p, const(Awesomium.WebString) name, const(Awesomium.JSArray) args); 52 void ToString(const(Awesomium.JSObject) p, Awesomium.WebString dst); 53 void SetCustomMethod(Awesomium.JSObject p, const(Awesomium.WebString) name, bool has_return_value); 54 Awesomium.Error last_error(const(Awesomium.JSObject) p); 55 } 56 57 unittest { 58 assert(JSObjectMember.sizeOfInstance() 59 == JSObject.Field.sizeof); 60 } 61 62 interface IJSMethodHandlerD 63 { 64 void call(Awesomium.WebView, uint, const(Awesomium.WebString), const(Awesomium.JSArray)); 65 void callWithReturnValue(Awesomium.WebView, uint, const(Awesomium.WebString), const(Awesomium.JSArray), Awesomium.JSValue); 66 } 67 68 69 interface JSMethodHandlerD2Cpp : awebview.wrapper.cpp.JSMethodHandler {} 70 71 extern(C++, JSMethodHandlerD2CppMember) 72 { 73 version(Windows) 74 { 75 JSMethodHandlerD2Cpp newCtor(IJSMethodHandlerD, ulong); 76 void deleteDtor(JSMethodHandlerD2Cpp); 77 } 78 else 79 { 80 void* newCtor(void*, ulong); 81 void deleteDtor(void*); 82 83 JSMethodHandlerD2Cpp newCtor(IJSMethodHandlerD p, ulong mid) 84 { return cast(JSMethodHandlerD2Cpp)newCtor(cast(void*)p, mid); } 85 86 void deleteDtor(JSMethodHandlerD2Cpp p) 87 { deleteDtor(cast(void*)p); } 88 } 89 } 90 91 extern(C++, JSMethodHandlerMember) 92 { 93 void dtor(Awesomium.JSMethodHandler p); 94 void deleteDtor(Awesomium.JSMethodHandler p); 95 96 void OnMethodCall(Awesomium.JSMethodHandler p, 97 Awesomium.WebView caller, 98 uint remote_object_id, 99 const(Awesomium.WebString) method_name, 100 const(Awesomium.JSArray) args); 101 102 void OnMethodCallWithReturnValue(Awesomium.JSMethodHandler p, 103 Awesomium.WebView caller, 104 uint remote_object_id, 105 const(Awesomium.WebString) method_name, 106 const(Awesomium.JSArray) args, 107 JSValue dst); 108 109 } 110 }