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) {
202202
203203 id object = nil ;
204204
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+
205220 if (jsType == napi_external) {
206221 return jsThis;
207222 } else {
208- Class cls = (Class )data;
209- object = [cls new ];
223+ bool supercall = class_conformsToProtocol (cls, @protocol (ObjCBridgeClassBuilderProtocol));
210224
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 ];
212231 jsThis = bridgeState->proxyNativeObject (env, jsThis, object);
213232 }
214233
You can’t perform that action at this time.
0 commit comments