| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // WARNING: Do not edit - generated code. | 5 // WARNING: Do not edit - generated code. |
| 6 | 6 |
| 7 #ifndef {{dart_class}}_h | 7 #ifndef {{dart_class}}_h |
| 8 #define {{dart_class}}_h | 8 #define {{dart_class}}_h |
| 9 | 9 |
| 10 {% filter conditional(conditional_string) %} | 10 {% filter conditional(conditional_string) %} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 return toNative(value); | 50 return toNative(value); |
| 51 {% else %} | 51 {% else %} |
| 52 return 0; | 52 return 0; |
| 53 {% endif %} | 53 {% endif %} |
| 54 } | 54 } |
| 55 static {{cpp_class}}* toNative(void* value) | 55 static {{cpp_class}}* toNative(void* value) |
| 56 { | 56 { |
| 57 return static_cast<{{cpp_class}}*>(value); | 57 return static_cast<{{cpp_class}}*>(value); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // FIXME: This has redundant null checks, and much of this code should |
| 61 // be moved to a common place to reduce code bloat. |
| 62 // Convert to native, Dart_Null is an error |
| 60 static NativeType* toNative(Dart_Handle handle, Dart_Handle& exception) | 63 static NativeType* toNative(Dart_Handle handle, Dart_Handle& exception) |
| 61 { | 64 { |
| 65 if (!Dart_IsNull(handle)) { |
| 66 DartDOMData* domData = DartDOMData::current(); |
| 67 return DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(domData, ha
ndle, exception); |
| 68 } else { |
| 69 exception = Dart_NewStringFromCString("Null value is not a valid {{d
art_class}}"); |
| 70 return 0; |
| 71 } |
| 72 } |
| 73 |
| 74 // Convert nullable to native, Dart_Null maps to C++ null |
| 75 static NativeType* toNativeWithNullCheck(Dart_Handle handle, Dart_Handle& ex
ception) |
| 76 { |
| 62 DartDOMData* domData = DartDOMData::current(); | 77 DartDOMData* domData = DartDOMData::current(); |
| 63 return DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(domData, handle
, exception); | 78 return DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(domData, handle
, exception); |
| 64 } | 79 } |
| 65 | 80 |
| 66 static NativeType* toNativeWithNullCheck(Dart_Handle handle, Dart_Handle& ex
ception) | 81 // Convert to native, Dart_Null is an error |
| 82 static NativeType* toNative(Dart_NativeArguments args, int index, Dart_Handl
e& exception) |
| 67 { | 83 { |
| 68 return Dart_IsNull(handle) ? 0 : toNative(handle, exception); | 84 NativeType* result = DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(a
rgs, index, exception); |
| 85 if (result || exception) { |
| 86 return result; |
| 87 } |
| 88 exception = Dart_NewStringFromCString("Null value is not a valid {{dart_
class}}"); |
| 89 return 0; |
| 69 } | 90 } |
| 70 | 91 |
| 71 static NativeType* toNative(Dart_NativeArguments args, int index, Dart_Handl
e& exception) | 92 // Convert nullable to native, Dart_Null maps to C++ null |
| 93 static NativeType* toNativeWithNullCheck(Dart_NativeArguments args, int inde
x, Dart_Handle& exception) |
| 72 { | 94 { |
| 73 return DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(args, index, ex
ception); | 95 return DartDOMWrapper::unwrapDartWrapper<{{dart_class}}>(args, index, ex
ception); |
| 74 } | 96 } |
| 75 | 97 |
| 76 static NativeType* toNativeWithNullCheck(Dart_NativeArguments args, int inde
x, Dart_Handle& exception) | |
| 77 { | |
| 78 // toNative accounts for Null objects also. | |
| 79 return toNative(args, index, exception); | |
| 80 } | |
| 81 | |
| 82 static Dart_Handle toDart(NativeType* value) | 98 static Dart_Handle toDart(NativeType* value) |
| 83 { | 99 { |
| 84 if (!value) | 100 if (!value) |
| 85 return Dart_Null(); | 101 return Dart_Null(); |
| 86 DartDOMData* domData = DartDOMData::current(); | 102 DartDOMData* domData = DartDOMData::current(); |
| 87 Dart_WeakPersistentHandle result = | 103 Dart_WeakPersistentHandle result = |
| 88 DartDOMWrapper::lookupWrapper<{{dart_class}}>(domData, value); | 104 DartDOMWrapper::lookupWrapper<{{dart_class}}>(domData, value); |
| 89 if (result) | 105 if (result) |
| 90 return Dart_HandleFromWeakPersistent(result); | 106 return Dart_HandleFromWeakPersistent(result); |
| 91 return createWrapper(domData, value); | 107 return createWrapper(domData, value); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void propertyQuery(Dart_NativeArguments args); | 192 void propertyQuery(Dart_NativeArguments args); |
| 177 {% endif %} | 193 {% endif %} |
| 178 | 194 |
| 179 } | 195 } |
| 180 | 196 |
| 181 } // namespace WebCore | 197 } // namespace WebCore |
| 182 | 198 |
| 183 {% endfilter %} | 199 {% endfilter %} |
| 184 | 200 |
| 185 #endif // {{dart_class}}_h | 201 #endif // {{dart_class}}_h |
| OLD | NEW |