| 78 | } |
| 79 | |
| 80 | struct NativeV8Handler : CefRefCount<cef_v8handler_t> |
| 81 | { |
| 82 | std::unordered_map<std::string, V8FunctionHandler> map_; |
| 83 | |
| 84 | NativeV8Handler() : CefRefCount(this) |
| 85 | { |
| 86 | cef_bind_method(NativeV8Handler, execute); |
| 87 | } |
| 88 | |
| 89 | private: |
| 90 | int CALLBACK _execute( |
| 91 | const cef_string_t* name, |
| 92 | cef_v8value_t* object, |
| 93 | size_t _argc, |
| 94 | cef_v8value_t* const* _args, |
| 95 | cef_v8value_t** retval, |
| 96 | cef_string_t* exception) |
| 97 | { |
| 98 | cef_string_utf8_t func{""}; |
| 99 | cef_string_to_utf8(name->str, name->length, &func); |
| 100 | |
| 101 | bool handled = false; |
| 102 | auto it = map_.find(func.str); |
| 103 | |
| 104 | if (it != map_.end()) |
| 105 | { |
| 106 | int argc = static_cast<int>(_argc); |
| 107 | auto args = reinterpret_cast<V8Value *const *>(_args); |
| 108 | |
| 109 | auto result = it->second(args, argc); |
| 110 | if (result != nullptr) |
| 111 | *retval = reinterpret_cast<cef_v8value_t *>(result); |
| 112 | |
| 113 | handled = true; |
| 114 | } |
| 115 | |
| 116 | cef_string_utf8_clear(&func); |
| 117 | return handled; |
| 118 | } |
| 119 | }; |
| 120 | |
| 121 | static void ExposeNativeFunctions(V8Object *window) |
| 122 | { |
nothing calls this directly
no outgoing calls
no test coverage detected