Macro magic for declaring/calling Objective-C APIs from C11 or C++. Preloads selectors, chooses the correct objc_msgSend to call per method/platform.

Related tags

Miscellaneous oc
Overview

OC - Easily Declare/Invoke Objective-C APIs from C11 or C++11

Usage

// 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);
// Swizzle methods:
oc_obj_swizzle(void,NSWindow,dealloc) {
    printf("NSWindow.%s\n",(const char*)cmd);
    imp(self, cmd);
}
// 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__);
    appQuit();
    return NSApplicationTerminateCancel;
}

oc_method(
    void,
    AppDelegate,
    applicationWillTerminate,NSNotification*
) {
    puts(__func__);
    appQuit();
}
You might also like...
Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum

_ _ __ _____ | \ | | / _| / ____|_ _ | \| | __ _ _ __ ___ ___ ___ | |_ | | _| |

per - Simple unix permission viewer and converter

Per is a simple utility that can verbosely print unix permissions and convert between symbolic and numeric notations and vice-versa.

The littlest Bluetooth macro pad

The littlest wireless macro pad! AWWWWW!!! (c) 2021 Zack Freedman and Voidstar Lab. Licensed CC-BY-NC (credit me and don't sell it) Built partially on

Repo per il corso di Programmazione 2 - canale M-Z - A.A. 2020/21

Argomenti del corso Principi della Programmazione a Oggetti Astrazione Incapsulamento e Information Hiding Ereditarietà Polimorfismo Classi e oggetti

Macro keypad and rotary input based on the ATmega32U4 Pro Micro board
Macro keypad and rotary input based on the ATmega32U4 Pro Micro board

JC-Pro-Macro Macro keypad and rotary input based on the ATmega32U4 Pro Micro Videos: Development: https://www.youtube.com/watch?v=g-XJLiv03rI Assembly

WTD is a python tool for replacing values with the C preprocessor macro which defined them.

Where's That Define WTD is a python tool for replacing values with the C preprocessor macro which defined them. An example of this is when trying to u

Repository per gli studenti dell'UNICAL che seguono il corso di Fondamenti di Programmazione 2

Fondamenti di programmazione 2 Per gli studenti dell'UNICAL che seguono il corso di Fondamenti di Programmazione 2 (2021/2022) Indice degli argomenti

A BOF to parse the imports of a provided PE-file, optionally extracting symbols on a per-dll basis.

PE Import Enumerator BOF What is this? This is a BOF to enumerate DLL files to-be-loaded by a given PE file. Depending on the number of arguments, thi

Owner
Garett Bass
an unsophisticated sophont, on an excellent quest for the necessary items. he/him. experienced game mechanic.
Garett Bass
Typewriter Effect with Rich Text + *Correct* Text Wrapping

Typewriter Effect with Rich Text + Correct Text Wrapping I've spent way too long getting this right. This is meant as a base class for a UMG dialogue

Sam Bloomberg 27 Aug 22, 2022
Code repo for infos and demos on the DaFit Magic 3 Smartwatch

Magic3_DaFit Code repo for infos and demos on the DaFit Magic 3 Smartwatch Demos: Magic3_Display_test_by_atc1441 = Minimal full buffer Display example

null 6 Dec 28, 2021
The Magic Mask for Android

Magisk is a suite of open source software for customizing Android, supporting devices higher than Android 5.0.

Kartik Verma 9 Aug 22, 2022
The Magic Mask for Android

This is not an officially supported Google product Introduction Magisk is a suite of open source software for customizing Android, supporting devices

John Wu 29.1k Sep 23, 2022
Binary Ninja plugin & workflow to help analyze Objective-C code

Objective Ninja Objective Ninja is a Binary Ninja plugin to assist in reverse engineering Objective-C code. Beware, Objective Ninja is still in very e

Jon Palmisciano 80 Aug 16, 2022
A different way of calling the notify function on the ps4 for homebrew development.

PS4-Notify A different way of calling the notify function on the ps4 for homebrew development. Calling the new Notify void Notify(char* IconURI, char*

Greg 21 Aug 29, 2022
C-function for traversing files/directories effectively and calling a given function with each encountered file and a void-pointer as parameters

C-function for traversing files/directories effectively and calling a given function with each encountered file and a void-pointer as parameters

null 1 Jun 27, 2022
CHIP-8 interpreter in C11

shoganai | しょうがない It means accepting what happens beyond our control and cannot be avoided. It is used to encourage people to move forward without bei

Gioele 2 Sep 28, 2021
Single-header C11 port of abseil.io's Swiss Table

cwisstable.h cwisstable is a single-header C11 port of the Abseil project's Swiss Tables. This project is intended to bring the proven performance and

Google 25 Sep 12, 2022
A Modern C11 compiler (STILL EARLY)

Cuik (pronounced 'Quick') warning: unfinished The plan is a modern C11 compiler which can mostly work with Clang, GCC, and MSVC while also introducing

Yasser Arguelles 98 Sep 19, 2022