Skip to content

Commit 195055d

Browse files
committed
clean up, fix some stuff
1 parent dd0c14c commit 195055d

38 files changed

Lines changed: 906 additions & 728 deletions

‎.gitmodules‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎CMakeLists.txt‎

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if(METADATA_SIZE EQUAL 0)
5656
else()
5757
message(STATUS "EMBED_METADATA_SIZE = ${METADATA_SIZE}"
5858
" (metadata will be embedded in the library)")
59-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEMBED_METADATA_SIZE=${METADATA_SIZE}")
59+
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEMBED_METADATA_SIZE=${METADATA_SIZE}")
6060
endif()
6161

6262
message(STATUS "BRIDGE_TARGET_PLATFORM = ${BRIDGE_TARGET_PLATFORM}")
@@ -80,28 +80,25 @@ include_directories(
8080
${CMAKE_CURRENT_SOURCE_DIR}/metadata/include
8181
${CMAKE_CURRENT_SOURCE_DIR}/libffi/${LIBFFI_BUILD}/include
8282
/Library/Developer/CommandLineTools/usr/include
83-
${CMAKE_CURRENT_SOURCE_DIR}/segappend/include
8483
)
8584

8685
set(LIB_SOURCE_FILES
87-
src/autoreleasepool.mm
88-
src/objc.mm
89-
src/bridge.mm
90-
src/block.mm
91-
src/class.mm
92-
src/closure.mm
93-
src/bridged_class.mm
94-
src/native_call.mm
95-
src/method_cif.mm
96-
src/objc_bridge_data.mm
97-
src/type_conv.mm
98-
src/util.mm
99-
src/struct.mm
100-
src/object_ref.mm
101-
src/js_object.mm
102-
src/enum.mm
103-
src/variable.mm
104-
segappend/src/segappend.cc
86+
src/AutoreleasePool.mm
87+
src/Protocols.mm
88+
src/ObjCBridge.mm
89+
src/Block.mm
90+
src/Class.mm
91+
src/Closure.mm
92+
src/NativeCall.mm
93+
src/MethodCif.mm
94+
src/ObjCBridgeData.mm
95+
src/TypeConv.mm
96+
src/Util.mm
97+
src/Struct.mm
98+
src/ObjectRef.mm
99+
src/JSObject.mm
100+
src/Enum.mm
101+
src/Variable.mm
105102
)
106103

107104
add_library(
@@ -141,17 +138,17 @@ endif()
141138
if(NOT METADATA_SIZE EQUAL 0)
142139
message(STATUS "Added script to embed metadata in the library")
143140

144-
add_custom_command(TARGET ${NAME} POST_BUILD
145-
COMMAND codesign --remove-signature $<TARGET_FILE:${NAME}>
146-
)
141+
# add_custom_command(TARGET ${NAME} POST_BUILD
142+
# COMMAND codesign --remove-signature $<TARGET_FILE:${NAME}>
143+
# )
147144

148-
add_custom_command(TARGET ${NAME} POST_BUILD
149-
COMMAND deno run -A ${CMAKE_CURRENT_SOURCE_DIR}/scripts/write_metadata.ts $<TARGET_FILE:${NAME}> ${METADATA_FILE}
150-
)
145+
# add_custom_command(TARGET ${NAME} POST_BUILD
146+
# COMMAND deno run -A ${CMAKE_CURRENT_SOURCE_DIR}/scripts/write_metadata.ts $<TARGET_FILE:${NAME}> ${METADATA_FILE}
147+
# )
151148

152-
add_custom_command(TARGET ${NAME} POST_BUILD
153-
COMMAND codesign -fs - $<TARGET_FILE:${NAME}>
154-
)
149+
# add_custom_command(TARGET ${NAME} POST_BUILD
150+
# COMMAND codesign -fs - $<TARGET_FILE:${NAME}>
151+
# )
155152
endif()
156153

157154
message(STATUS "LIBFFI_BUILD = ${LIBFFI_BUILD}")

‎examples/appkit.js‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export class ApplicationDelegate extends NSObject {
1212
applicationDidFinishLaunching(_notification) {
1313
this.window = Window.new();
1414

15+
NSApp.activateIgnoringOtherApps(false);
16+
1517
NSApp.stop(this);
1618

1719
this.runloopMode = NSString.stringWithUTF8String("kCFRunLoopDefaultMode");
@@ -72,9 +74,20 @@ export class Window extends NSWindow {
7274
);
7375

7476
this.title = "NativeScript for macOS";
75-
7677
this.delegate = this;
7778

79+
this.makeKeyAndOrderFront(NSApp);
80+
this.releasedWhenClosed = false;
81+
82+
this.center();
83+
84+
this.backgroundColor = NSColor.colorWithSRGBRedGreenBlueAlpha(
85+
118 / 255,
86+
171 / 255,
87+
235 / 255,
88+
1,
89+
);
90+
7891
const label = NSTextField.alloc().initWithFrame({
7992
origin: { x: 0, y: 0 },
8093
size: { width: 390, height: 100 },
@@ -128,17 +141,6 @@ export class Window extends NSWindow {
128141
this.contentView.centerYAnchor,
129142
).active = true;
130143

131-
this.backgroundColor = NSColor.colorWithSRGBRedGreenBlueAlpha(
132-
118 / 255,
133-
171 / 255,
134-
235 / 255,
135-
1,
136-
);
137-
138-
this.center();
139-
this.makeKeyAndOrderFront(NSApp);
140-
this.releasedWhenClosed = false;
141-
142144
return this;
143145
}
144146

@@ -150,5 +152,4 @@ export class Window extends NSWindow {
150152
const NSApp = NSApplication.sharedApplication;
151153
NSApp.setActivationPolicy(NSApplicationActivationPolicy.regular);
152154
NSApp.delegate = ApplicationDelegate.new();
153-
NSApp.activateIgnoringOtherApps(true);
154155
NSApp.run();

‎examples/split_view.js‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ export class ApplicationDelegate extends NSObject {
3535
toolbar.allowsUserCustomization = true;
3636
toolbar.autosavesConfiguration = true;
3737

38-
window.toolbarStyle = 3 /* NSToolbarStyleUnified */;
38+
window.toolbarStyle = NSWindowToolbarStyle.unified;
3939

4040
window.toolbar = toolbar;
4141
toolbar.validateVisibleItems();
4242

43-
window.makeKeyAndOrderFront(this);
43+
window.makeKeyAndOrderFront(NSApp);
44+
45+
NSApp.activateIgnoringOtherApps(false);
4446
}
4547

4648
applicationShouldTerminateAfterLastWindowClosed(_sender) {
@@ -85,7 +87,7 @@ export class SidebarViewController extends NSViewController {
8587
outline.allowsColumnResizing = false;
8688
outline.allowsColumnSelection = false;
8789
outline.allowsEmptySelection = false;
88-
outline.rowSizeStyle = 2 /* NSTableViewRowSizeStyleMedium */;
90+
outline.rowSizeStyle = NSTableViewRowSizeStyle.medium;
8991

9092
outline.delegate = this;
9193
outline.dataSource = this;
@@ -100,9 +102,6 @@ export class SidebarViewController extends NSViewController {
100102

101103
scrollView.hasVerticalScroller = true;
102104
scrollView.hasHorizontalScroller = false;
103-
scrollView.borderType = 0 /* NSNoBorder */;
104-
scrollView.autohidesScrollers = true;
105-
scrollView.verticalScrollElasticity = 2;
106105
scrollView.documentView = outline;
107106
scrollView.drawsBackground = false;
108107
scrollView.setTranslatesAutoresizingMaskIntoConstraints(false);
@@ -185,7 +184,7 @@ export class ContentViewController extends NSViewController {
185184
const view = NSView.new();
186185

187186
const label = NSTextField.alloc().initWithFrame(
188-
{ point: { x: 0, y: 0 }, size: { width: 390, height: 100 } },
187+
{ origin: { x: 0, y: 0 }, size: { width: 390, height: 100 } },
189188
);
190189

191190
label.stringValue = "Hello, macOS";
@@ -208,7 +207,7 @@ export class ContentViewController extends NSViewController {
208207
this.label = label;
209208

210209
const vstack = NSStackView.alloc().initWithFrame(
211-
{ point: { x: 0, y: 0 }, size: { width: 500, height: 500 } },
210+
{ origin: { x: 0, y: 0 }, size: { width: 500, height: 500 } },
212211
);
213212

214213
vstack.orientation = 1 /* NSUserInterfaceLayoutOrientationVertical */;
@@ -257,7 +256,7 @@ export class SplitViewController extends NSSplitViewController {
257256

258257
viewDidLoad() {
259258
this.view.frame = {
260-
point: { x: 0, y: 0 },
259+
origin: { x: 0, y: 0 },
261260
size: { width: 800, height: 600 },
262261
};
263262

@@ -316,5 +315,4 @@ NSApp.setActivationPolicy(0);
316315

317316
NSApp.delegate = ApplicationDelegate.new();
318317

319-
NSApp.activateIgnoringOtherApps(true);
320318
NSApp.run();

‎examples/spritekit.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export class ApplicationDelegate extends NSObject {
3737
window.setAcceptsMouseMovedEvents(true);
3838

3939
window.makeKeyAndOrderFront(this);
40+
41+
NSApp.activateIgnoringOtherApps(false);
4042
}
4143

4244
windowWillClose(_notification) {

‎examples/view_controller.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export class ApplicationDelegate extends NSObject {
3333
);
3434

3535
window.makeKeyAndOrderFront(this);
36+
37+
NSApp.activateIgnoringOtherApps(false);
3638
}
3739

3840
windowWillClose(_notification) {
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "ffi.h"
66
#include "objc/message.h"
77
#include "objc/runtime.h"
8-
#include "type_conv.h"
8+
#include "TypeConv.h"
99
#include <string>
1010

1111
namespace objc_bridge {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define BRIDGED_METHOD_H
33

44
#include "objc/runtime.h"
5-
#include "objc_bridge_data.h"
5+
#include "ObjCBridgeData.h"
66

77
namespace objc_bridge {
88

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#ifndef OBJC_BRIDGE_DATA_H
22
#define OBJC_BRIDGE_DATA_H
33

4+
#include "AutoreleasePool.h"
5+
#include "Class.h"
46
#include "Metadata.h"
5-
#include "autoreleasepool.h"
6-
#include "bridged_class.h"
7+
#include "MethodCif.h"
8+
#include "Struct.h"
9+
#include "TypeConv.h"
710
#include "js_native_api.h"
8-
#include "method_cif.h"
911
#include "objc/runtime.h"
10-
#include "struct.h"
11-
#include "type_conv.h"
1212
#include <dlfcn.h>
1313
#include <map>
1414
#include <stdint.h>
@@ -46,11 +46,15 @@ class ObjCBridgeData {
4646
std::unordered_map<MDSectionOffset, CFunction *> cFunctionCache;
4747
std::unordered_map<MDSectionOffset, MethodCif *> mdSignatureCache;
4848
std::unordered_map<std::string, MDSectionOffset> structOffsets;
49+
std::unordered_map<std::string, MDSectionOffset> protocolOffsets;
4950

5051
void *self_dl;
5152

5253
MDMetadataReader *metadata;
5354

55+
ObjCBridgeData(const char *metadata_path = nullptr);
56+
~ObjCBridgeData();
57+
5458
static inline ObjCBridgeData *InstanceData(napi_env env) {
5559
ObjCBridgeData *bridgeData;
5660
napi_status status = napi_get_instance_data(env, (void **)&bridgeData);
@@ -82,9 +86,6 @@ class ObjCBridgeData {
8286
return structInfo;
8387
}
8488

85-
ObjCBridgeData(const char *metadata_path = nullptr);
86-
~ObjCBridgeData();
87-
8889
public:
8990
std::unordered_map<id, napi_ref> objectRefs;
9091

0 commit comments

Comments
 (0)