GithubHelp home page GithubHelp logo

Comments (8)

hansent avatar hansent commented on September 28, 2024

see focumetation for obj-c runtime here: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html

from pyobjus.

tito avatar tito commented on September 28, 2024

nice start :)

from pyobjus.

hansent avatar hansent commented on September 28, 2024

using NSBundle, we can load frameworks at runtime (not sure if possible on iOS), but otherwise, all frameworks have to be linked at compile time:
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingCode/Tasks/LoadingBundles.html#//apple_ref/doc/uid/20001273-CJBDDCAB

from pyobjus.

hansent avatar hansent commented on September 28, 2024

C code (needs to link against libobjc.dylib [and if getting e.g. NSWindow class, also AppKit.framework]):

#include <stdio.h>
#include "objc/runtime.h"

int main(int argc, const char * argv[])
{
    Class _NSWindow = (Class)objc_getClass("NSWindow");
    printf("getting class NSWindow");
    unsigned int num_methods = 0;
    Method* class_methods = class_copyMethodList(_NSWindow, &num_methods);

    for(int i=0; i<num_methods; i++){
        const char* name = sel_getName(method_getName(class_methods[i]));
        const char* typeenc = method_getTypeEncoding(class_methods[i]);

        printf("name: '%s',   type_enc: %s\n", name, typeenc);
    }
    return 0;
}

from pyobjus.

hansent avatar hansent commented on September 28, 2024

objc/runtime.h:
https://gist.github.com/3362098

from pyobjus.

hansent avatar hansent commented on September 28, 2024

mhhh...C code in xcode runs OK, but trying to do it from cython the class registry seems to be empty:

http://www.stypi.com/hansent/simple.pyx compiles ok. since it's using objc_getRequiredClass it also errors, but problem is registry is not created with classes...not sure how to do it/what to load, tried copying all compiler args/linker args from Xcode c example...but still the same

from pyobjus.

tito avatar tito commented on September 28, 2024

dlopen() the foundation make the example works. fix commited

from pyobjus.

tito avatar tito commented on September 28, 2024

done!

from pyobjus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.