Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/garettbass/oc
Macro magic for declaring/calling Objective-C APIs from C11 or C++. Preloads selectors, chooses the correct objc_msgSend to call per method/platform.
https://github.com/garettbass/oc
Last synced: 27 days ago
JSON representation
Macro magic for declaring/calling Objective-C APIs from C11 or C++. Preloads selectors, chooses the correct objc_msgSend to call per method/platform.
- Host: GitHub
- URL: https://github.com/garettbass/oc
- Owner: garettbass
- License: mit
- Created: 2019-05-27T15:38:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-19T13:54:07.000Z (8 months ago)
- Last Synced: 2024-08-04T02:10:56.850Z (4 months ago)
- Language: C
- Size: 34.2 KB
- Stars: 56
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - oc - C APIs from C11 or C++. Preloads selectors, chooses the correct objc_msgSend to call per method/platform. (Scripting)
README
# OC - Easily Declare/Invoke Objective-C APIs from C11 or C++11
## Usage
```c
// Call class and instance methods:
NSWindow* const nswindow = oc_cls(NSWindow,new);
oc_obj(nswindow,NSWindow,setRestorable,false);
oc_obj(nswindow,NSWindow,setReleasedWhenClosed,false);
oc_obj(nswindow,NSWindow,setStyleMask,windowStyle);
oc_obj(nswindow,NSWindow,setFrame,windowRect,display,true);
oc_obj(nswindow,NSWindow,setIsVisible,true);
oc_obj(nswindow,NSWindow,center);
``````c
// Swizzle methods:
oc_obj_swizzle(void,NSWindow,dealloc) {
printf("NSWindow.%s\n",(const char*)cmd);
imp(self, cmd);
}
``````c
// Declare and implement classes:
oc_interface(
AppDelegate,
)oc_implementation(
AppDelegate, NSObject,
obj(void,
applicationDidFinishLaunching,NSNotification*),
obj(NSApplicationTerminateReply,
applicationShouldTerminate,NSApplication*),
obj(void,
applicationWillTerminate,NSNotification*),
)oc_method(
void,
AppDelegate,
applicationDidFinishLaunching,NSNotification*
) {
puts(__func__);
}oc_method(
NSApplicationTerminateReply,
AppDelegate,
applicationShouldTerminate,NSApplication*
) {
puts(__func__);
app_quit();
return NSApplicationTerminateCancel;
}oc_method(
void,
AppDelegate,
applicationWillTerminate,NSNotification*
) {
puts(__func__);
app_quit();
}
```