Skip to content

Commit 7a3efff

Browse files
committed
x
1 parent 912ebee commit 7a3efff

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

‎scripts/build.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function build(target: string) {
6363
if (target.startsWith("macos")) {
6464
// Copy the built app to the build directory
6565
await Deno.copyFile(
66-
`../build/${target}/Release/libObjCBridge.dylib`,
66+
`../build/${target}/${buildConfig}/libObjCBridge.dylib`,
6767
`../build/${target}/ObjCBridge.node`,
6868
);
6969
}

‎src/class.mm‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,12 @@ void defineProperties(napi_env env, ObjCBridgeData *bridgeData,
218218
napi_value superObject, bool supercall) {
219219
NAPI_PREAMBLE
220220

221-
unsigned int count, actualCount;
222-
count = actualCount = 0;
223-
auto methods = class_copyMethodList(nativeClass, &count);
224-
225221
unsigned int propertyCount = 0;
226222
auto properties = class_copyPropertyList(nativeClass, &propertyCount);
227223

228224
std::set<std::string> addedMethods, addedProperties, addedSelectors;
229225

226+
// Define properties
230227
for (unsigned int i = 0; i < propertyCount; i++) {
231228
objc_property_t property = properties[i];
232229
std::string name = property_getName(property);
@@ -309,13 +306,22 @@ void defineProperties(napi_env env, ObjCBridgeData *bridgeData,
309306
continue;
310307
}
311308

309+
if (!supercall)
310+
NSLog(@"- property: %s", (&*pair.first)->c_str());
311+
312312
NAPI_GUARD(napi_define_properties(env, object, 1, &desc)) {
313313
NAPI_THROW_LAST_ERROR
314314
return;
315315
}
316316
}
317317

318-
for (unsigned int i = 0; i < count; i++) {
318+
free(properties);
319+
320+
unsigned int methodCount = 0;
321+
auto methods = class_copyMethodList(nativeClass, &methodCount);
322+
323+
// Define methods
324+
for (unsigned int i = 0; i < methodCount; i++) {
319325
auto method = methods[i];
320326
auto sel = method_getName(methods[i]);
321327
std::string selector = sel_getName(sel);
@@ -369,14 +375,17 @@ void defineProperties(napi_env env, ObjCBridgeData *bridgeData,
369375
desc.getter = nil;
370376
desc.setter = nil;
371377
desc.value = nil;
372-
desc.attributes = (napi_property_attributes)(napi_enumerable);
378+
desc.attributes =
379+
(napi_property_attributes)(napi_enumerable | napi_configurable);
373380
desc.method = JS_BridgedMethod;
374381

375382
NAPI_GUARD(napi_define_properties(env, object, 1, &desc)) {
376383
NAPI_THROW_LAST_ERROR
377384
return;
378385
}
379386
}
387+
388+
free(methods);
380389
}
381390

382391
std::string NativeObjectName = "NativeObject";

0 commit comments

Comments
 (0)