[cl-objc-devel] New years hacking

Geoff Cant nem at lisp.geek.nz
Sat Dec 30 07:04:04 UTC 2006


Hi everyone, I've done a bit of new year's hacking on cl-objc and made
some real progress. You can now use cl-objc to read classes, methods
and meta classes. Examples include:

OBJC-CFFI> (loop for class in (get-class-list)
                collect (list class (get-class-methods class)))
((#<ObjC-Class List>
  ((#<ObjC-Method appendList:> #<ObjC-Method makeObjectsPerform:with:>
    #<ObjC-Method makeObjectsPerform:> #<ObjC-Method replaceObjectAt:with:>
    #<ObjC-Method replaceObject:with:> #<ObjC-Method empty>
    #<ObjC-Method removeLastObject> #<ObjC-Method removeObject:>
    #<ObjC-Method removeObjectAt:> #<ObjC-Method addObjectIfAbsent:>
    #<ObjC-Method addObject:> #<ObjC-Method insertObject:at:>
    #<ObjC-Method setAvailableCapacity:> #<ObjC-Method lastObject>
    #<ObjC-Method indexOf:> #<ObjC-Method objectAt:> #<ObjC-Method count>
    #<ObjC-Method capacity> #<ObjC-Method isEqual:>
    #<ObjC-Method copyFromZone:> #<ObjC-Method freeObjects> #<ObjC-Method free>
    #<ObjC-Method init> #<ObjC-Method initCount:>)))
 (#<ObjC-Class Protocol>
  ((#<ObjC-Method hash> #<ObjC-Method isEqual:> #<ObjC-Method name>
    #<ObjC-Method descriptionForClassMethod:>
    #<ObjC-Method descriptionForInstanceMethod:> #<ObjC-Method conformsTo:>)))
 (#<ObjC-Class Object>
  ((#<ObjC-Method shouldNotImplement:> #<ObjC-Method findClass:>
    #<ObjC-Method methodDescFor:> #<ObjC-Method isMemberOfGivenName:>
    #<ObjC-Method isKindOfGivenName:> #<ObjC-Method superClass>
    #<ObjC-Method descriptionForMethod:> #<ObjC-Method conformsTo:>
    #<ObjC-Method performv::> #<ObjC-Method methodArgSize:>
    #<ObjC-Method forward::> #<ObjC-Method read:> #<ObjC-Method write:>
    #<ObjC-Method printForDebugger:> #<ObjC-Method error:>
    #<ObjC-Method doesNotRecognize:> #<ObjC-Method notImplemented:>
    #<ObjC-Method subclassResponsibility:> #<ObjC-Method perform:with:with:>
    #<ObjC-Method perform:with:> #<ObjC-Method perform:>
    #<ObjC-Method methodFor:> #<ObjC-Method copyFromZone:> #<ObjC-Method copy>
    #<ObjC-Method respondsTo:> #<ObjC-Method isMemberOfClassNamed:>
    #<ObjC-Method isKindOfClassNamed:> #<ObjC-Method isMemberOf:>
    #<ObjC-Method isKindOf:> #<ObjC-Method superclass> #<ObjC-Method zone>
    #<ObjC-Method class> #<ObjC-Method self> #<ObjC-Method free>
    #<ObjC-Method isEqual:> #<ObjC-Method hash> #<ObjC-Method name>
    #<ObjC-Method init> #<ObjC-Method awake>)))
 (#<ObjC-Class NSResurrectedObject>
  ((#<ObjC-Method finalize> #<ObjC-Method forward::> #<ObjC-Method class>)))
 (#<ObjC-Class NSDeallocatedObject>
  ((#<ObjC-Method forward::> #<ObjC-Method isKindOfClass:>
    #<ObjC-Method class>))))
OBJC-CFFI> OBJC-CFFI> (method-get-number-of-arguments (class-get-instance-method "Object" "init"))
2
OBJC-CFFI> (method-get-size-of-arguments (class-get-instance-method "Object" "init"))
8

OBJC-CFFI> (class-get-class-method "Object" "alloc")
#<ObjC-Method alloc>
OBJC-CFFI> (describe *)
#<ObjC-Method alloc> is an Objective C method named "alloc".
Type defintion @8 at 0:4
Implementation pointer #.(SB-SYS:INT-SAP #X90A59106)
*objc_method #.(SB-SYS:INT-SAP #X00301754)


Anyway, if anyone would like to contribute
bugs/documentation/advice/code please feel welcome. I'd also be interested
to know how well the code runs on implementations other than sbcl/macosx/x86-32.

Happy new year,
-- 
Geoff




More information about the Cl-objc-devel mailing list