File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -202,13 +202,32 @@ void setupObjCClassDecorator(napi_env env) {
202
202
203
203
id object = nil ;
204
204
205
+ ObjCBridgeState* bridgeState = ObjCBridgeState::InstanceData (env);
206
+
207
+ Class cls = (Class )data;
208
+
209
+ if (jsThis != nullptr ) {
210
+ napi_value constructor;
211
+ napi_get_named_property (env, jsThis, " constructor" , &constructor);
212
+ Class newTargetCls = nil ;
213
+ napi_unwrap (env, constructor, (void **)&newTargetCls);
214
+
215
+ if (newTargetCls != nil ) {
216
+ cls = newTargetCls;
217
+ }
218
+ }
219
+
205
220
if (jsType == napi_external) {
206
221
return jsThis;
207
222
} else {
208
- Class cls = (Class )data;
209
- object = [cls new ];
223
+ bool supercall = class_conformsToProtocol (cls, @protocol (ObjCBridgeClassBuilderProtocol));
210
224
211
- ObjCBridgeState* bridgeState = ObjCBridgeState::InstanceData (env);
225
+ if (supercall) {
226
+ ClassBuilder* builder = (ClassBuilder*)bridgeState->classesByPointer [cls];
227
+ if (!builder->isFinal ) builder->build ();
228
+ }
229
+
230
+ object = [cls new ];
212
231
jsThis = bridgeState->proxyNativeObject (env, jsThis, object);
213
232
}
214
233
You can’t perform that action at this time.
0 commit comments