| OLD | NEW |
| 1 {% filter format_blink_cpp_source_code %} | 1 {% filter format_blink_cpp_source_code %} |
| 2 | 2 |
| 3 {% include 'copyright_block.txt' %} | 3 {% include 'copyright_block.txt' %} |
| 4 | 4 |
| 5 #ifndef {{cpp_class}}_h | 5 #ifndef {{cpp_class}}_h |
| 6 #define {{cpp_class}}_h | 6 #define {{cpp_class}}_h |
| 7 | 7 |
| 8 {% for filename in header_includes %} | 8 {% for filename in header_includes %} |
| 9 #include "{{filename}}" | 9 #include "{{filename}}" |
| 10 {% endfor %} | 10 {% endfor %} |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class ScriptState; | 14 class ScriptState; |
| 15 {% for forward_declaration in forward_declarations %} | 15 {% for forward_declaration in forward_declarations %} |
| 16 class {{forward_declaration}}; | 16 class {{forward_declaration}}; |
| 17 {% endfor %} | 17 {% endfor %} |
| 18 | 18 |
| 19 class {{exported}}{{cpp_class}} final : public GarbageCollectedFinalized<{{cpp_c
lass}}>, | 19 class {{exported}}{{cpp_class}} final : public GarbageCollectedFinalized<{{cpp_c
lass}}>, public TraceWrapperBase { |
| 20 public TraceWrapperBase { | 20 public: |
| 21 static {{cpp_class}}* create(ScriptState* scriptState, v8::Local<v8::Function>
callback) { |
| 22 return new {{cpp_class}}(scriptState, callback); |
| 23 } |
| 21 | 24 |
| 22 public: | 25 ~{{cpp_class}}() = default; |
| 23 static {{cpp_class}}* create(ScriptState* scriptState, v8::Local<v8::Functio
n> callback) | |
| 24 { | |
| 25 return new {{cpp_class}}(scriptState, callback); | |
| 26 } | |
| 27 | 26 |
| 28 ~{{cpp_class}}() = default; | 27 DECLARE_TRACE(); |
| 28 DECLARE_TRACE_WRAPPERS(); |
| 29 | 29 |
| 30 DECLARE_TRACE(); | 30 bool call({{argument_declarations | join(', ')}}); |
| 31 DECLARE_TRACE_WRAPPERS(); | |
| 32 | 31 |
| 33 bool call({{argument_declarations | join(', ')}}); | 32 v8::Local<v8::Function> v8Value(v8::Isolate* isolate) { |
| 33 return m_callback.newLocal(isolate); |
| 34 } |
| 34 | 35 |
| 35 v8::Local<v8::Function> v8Value(v8::Isolate* isolate) | 36 void setWrapperReference(v8::Isolate* isolate, const v8::Persistent<v8::Object
>& wrapper) { |
| 36 { | 37 DCHECK(!m_callback.isEmpty()); |
| 37 return m_callback.newLocal(isolate); | 38 m_callback.setReference(wrapper, isolate); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void setWrapperReference(v8::Isolate* isolate, const v8::Persistent<v8::Obje
ct>& wrapper) | 41 private: |
| 41 { | 42 {{cpp_class}}(ScriptState*, v8::Local<v8::Function>); |
| 42 DCHECK(!m_callback.isEmpty()); | |
| 43 m_callback.setReference(wrapper, isolate); | |
| 44 } | |
| 45 | 43 |
| 46 private: | 44 RefPtr<ScriptState> m_scriptState; |
| 47 {{cpp_class}}(ScriptState*, v8::Local<v8::Function>); | 45 ScopedPersistent<v8::Function> m_callback; |
| 48 | |
| 49 RefPtr<ScriptState> m_scriptState; | |
| 50 ScopedPersistent<v8::Function> m_callback; | |
| 51 }; | 46 }; |
| 52 | 47 |
| 53 } // namespace blink | 48 } // namespace blink |
| 54 | 49 |
| 55 #endif // {{cpp_class}}_h | 50 #endif // {{cpp_class}}_h |
| 56 | 51 |
| 57 {% endfilter %}{# format_blink_cpp_source_code #} | 52 {% endfilter %}{# format_blink_cpp_source_code #} |
| OLD | NEW |