| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // WARNING: Do not edit - generated code. | |
| 6 | |
| 7 #ifndef {{dart_class}}_h | |
| 8 #define {{dart_class}}_h | |
| 9 | |
| 10 {% filter conditional(conditional_string) %} | |
| 11 {% for filename in header_includes %} | |
| 12 #include "{{filename}}" | |
| 13 {% endfor %} | |
| 14 | |
| 15 #include <dart_api.h> | |
| 16 | |
| 17 namespace blink { | |
| 18 | |
| 19 struct {{dart_class}} { | |
| 20 static const int dartClassId = {{interface_name}}ClassId; | |
| 21 typedef {{cpp_class}} NativeType; | |
| 22 static const bool isNode = {{is_node|lower}}; | |
| 23 static const bool isActive = {{is_active_dom_object|lower}}; | |
| 24 static const bool isEventTarget = {{is_event_target|lower}}; | |
| 25 static const bool isGarbageCollected = {{is_garbage_collected|lower}}; | |
| 26 | |
| 27 static ActiveDOMObject* toActiveDOMObject(void* value) | |
| 28 { | |
| 29 {% if is_active_dom_object %} | |
| 30 return toNative(value); | |
| 31 {% else %} | |
| 32 return 0; | |
| 33 {% endif %} | |
| 34 } | |
| 35 static EventTarget* toEventTarget(void* value) | |
| 36 { | |
| 37 {% if is_event_target %} | |
| 38 return toNative(value); | |
| 39 {% else %} | |
| 40 return 0; | |
| 41 {% endif %} | |
| 42 } | |
| 43 static Node* toNode(void* value) | |
| 44 { | |
| 45 {% if is_node %} | |
| 46 return toNative(value); | |
| 47 {% else %} | |
| 48 return 0; | |
| 49 {% endif %} | |
| 50 } | |
| 51 static {{cpp_class}}* toNative(void* value) | |
| 52 { | |
| 53 return static_cast<{{cpp_class}}*>(value); | |
| 54 } | |
| 55 | |
| 56 // FIXME: This has redundant null checks, and much of this code should | |
| 57 // be moved to a common place to reduce code bloat. | |
| 58 // Convert to native, Dart_Null is an error | |
| 59 static NativeType* toNative(Dart_Handle handle, Dart_Handle& exception) | |
| 60 { | |
| 61 if (!Dart_IsNull(handle)) { | |
| 62 DartDOMData* domData = DartDOMData::current(); | |
| 63 return DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(domData, ha
ndle, exception); | |
| 64 } else { | |
| 65 exception = Dart_NewStringFromCString("Null value is not a valid {{d
art_class}}"); | |
| 66 return 0; | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 // Convert nullable to native, Dart_Null maps to C++ null | |
| 71 static NativeType* toNativeWithNullCheck(Dart_Handle handle, Dart_Handle& ex
ception) | |
| 72 { | |
| 73 DartDOMData* domData = DartDOMData::current(); | |
| 74 return DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(domData, handle
, exception); | |
| 75 } | |
| 76 | |
| 77 // Convert to native, Dart_Null is an error | |
| 78 static NativeType* toNative(Dart_NativeArguments args, int index, Dart_Handl
e& exception) | |
| 79 { | |
| 80 NativeType* result = DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(a
rgs, index, exception); | |
| 81 if (result || exception) { | |
| 82 return result; | |
| 83 } | |
| 84 exception = Dart_NewStringFromCString("Null value is not a valid {{dart_
class}}"); | |
| 85 return 0; | |
| 86 } | |
| 87 | |
| 88 // Convert nullable to native, Dart_Null maps to C++ null | |
| 89 static NativeType* toNativeWithNullCheck(Dart_NativeArguments args, int inde
x, Dart_Handle& exception) | |
| 90 { | |
| 91 return DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(args, index, ex
ception); | |
| 92 } | |
| 93 | |
| 94 static bool hasInstance(Dart_Handle wrapper) | |
| 95 { | |
| 96 return DartDOMWrapper::subtypeOf(wrapper, dartClassId); | |
| 97 } | |
| 98 | |
| 99 static Dart_Handle toDart(NativeType* value) | |
| 100 { | |
| 101 if (!value) | |
| 102 return Dart_Null(); | |
| 103 DartDOMData* domData = DartDOMData::current(); | |
| 104 Dart_WeakPersistentHandle result = | |
| 105 DartDOMWrapper::lookupWrapper<{{dart_class}}>(domData, value); | |
| 106 if (result) | |
| 107 return Dart_HandleFromWeakPersistent(result); | |
| 108 return createWrapper(domData, value); | |
| 109 } | |
| 110 static void returnToDart(Dart_NativeArguments args, | |
| 111 NativeType* value, | |
| 112 bool autoDartScope = true) | |
| 113 { | |
| 114 if (value) { | |
| 115 DartDOMData* domData = static_cast<DartDOMData*>( | |
| 116 Dart_GetNativeIsolateData(args)); | |
| 117 Dart_WeakPersistentHandle result = | |
| 118 DartDOMWrapper::lookupWrapper<{{dart_class}}>(domData, value); | |
| 119 if (result) | |
| 120 Dart_SetWeakHandleReturnValue(args, result); | |
| 121 else { | |
| 122 if (autoDartScope) { | |
| 123 Dart_SetReturnValue(args, createWrapper(domData, value)); | |
| 124 } else { | |
| 125 DartApiScope apiScope; | |
| 126 Dart_SetReturnValue(args, createWrapper(domData, value)); | |
| 127 } | |
| 128 } | |
| 129 } | |
| 130 } | |
| 131 {% if has_custom_to_v8 or has_custom_wrap or special_wrap_for %} | |
| 132 static Dart_Handle createWrapper(DartDOMData* domData, NativeType* value); | |
| 133 {% else %} | |
| 134 static Dart_Handle createWrapper(DartDOMData* domData, NativeType* value) | |
| 135 { | |
| 136 return DartDOMWrapper::createWrapper<{{dart_class}}>(domData, value, {{d
art_class}}::dartClassId); | |
| 137 } | |
| 138 {% endif %} | |
| 139 static Dart_Handle toDart({{pass_cpp_type}} value) | |
| 140 { | |
| 141 return toDart(value.get()); | |
| 142 } | |
| 143 static Dart_Handle createWrapper({{pass_cpp_type}} value) | |
| 144 { | |
| 145 return createWrapper(value.get()); | |
| 146 } | |
| 147 static void returnToDart(Dart_NativeArguments args, | |
| 148 {{pass_cpp_type}} value, | |
| 149 bool autoDartScope = true) | |
| 150 { | |
| 151 return returnToDart(args, value.get(), autoDartScope); | |
| 152 } | |
| 153 | |
| 154 static Dart_NativeFunction resolver(Dart_Handle name, | |
| 155 int argumentCount, | |
| 156 bool* autoSetupScope); | |
| 157 | |
| 158 static const uint8_t* symbolizer(Dart_NativeFunction nf); | |
| 159 }; | |
| 160 | |
| 161 namespace {{dart_class}}Internal { | |
| 162 | |
| 163 {% from 'methods_cpp.template' import static_method_name %} | |
| 164 {% if has_custom_constructor %} | |
| 165 {# FIXME(vsm): Name this properly. #} | |
| 166 void constructorCallback(Dart_NativeArguments); | |
| 167 {% endif %} | |
| 168 {% if has_event_constructor %} | |
| 169 void initialize{{interface_name}}ForDart({{interface_name}}Init&, const String
&, const HashMap<String, Dart_Handle>&, Dart_Handle&); | |
| 170 {% endif %} | |
| 171 {% for method in methods if method.is_custom_element_callbacks and not method.
suppressed %} | |
| 172 void {{method.name}}_{{method.number_of_arguments}}(Dart_NativeArguments); | |
| 173 {% endfor %} | |
| 174 | |
| 175 {% for method in methods if method.is_custom or method.custom_dart_new %} | |
| 176 void {{static_method_name(method.name)}}(Dart_NativeArguments args); | |
| 177 {% if method.overload_index == 1 %} | |
| 178 void {{static_method_name(method.name, 0)}}(Dart_NativeArguments args); | |
| 179 {% endif %} | |
| 180 {% endfor %} | |
| 181 | |
| 182 {% for attribute in attributes %} | |
| 183 {% if attribute.has_custom_getter %} | |
| 184 void {{attribute.name}}Getter(Dart_NativeArguments); | |
| 185 {% endif %} | |
| 186 {% if attribute.has_custom_setter %} | |
| 187 void {{attribute.name}}Setter(Dart_NativeArguments); | |
| 188 {% endif %} | |
| 189 {% endfor %} | |
| 190 | |
| 191 {% if dart_class == 'DartCSSStyleDeclaration' %} | |
| 192 // TODO(efortuna): Pull in custom functions in a less hacky way! | |
| 193 void propertyQuery(Dart_NativeArguments args); | |
| 194 {% endif %} | |
| 195 | |
| 196 } | |
| 197 | |
| 198 } // namespace blink | |
| 199 | |
| 200 {% endfilter %} | |
| 201 | |
| 202 #endif // {{dart_class}}_h | |
| OLD | NEW |