Objective-Everything Release 5.  Copyright ©1994-1998 by TipTop Software, Inc.  All Rights Reserved.

  Other ObjPy

ObjPy Module

Functions

lookup(name)

Lookup object by name.  If name represents an illegal object ValueError is raised.

 py% lookup("NSObject") 
 Class.NSObject 
 py% x=C.NSObject() 
 py% x 
 <NSObject: 0xfade8> 
 py% lookup('@NSObject@0xfade8') 
 <NSObject: 0xfade8> 
 py% lookup('0xfade8') 
 <NSObject: 0xfade8> 
dyload(file, ...)

Dynamically links (loads) the specified files.

is_nil(o)

Returns true if ObjPy object is nil, false otherwise.  Raises if o is not an ObjPy object.

 print is_nil(nil) # ==> 1 
 print is_nil(lookup("Object")) # ==> 0 
 print is_nil("hello")  # ==> raises 
is_bad(o)

Returns an error description if o is a bad ObjPy object, or if o is not an ObjPy object at all.  Returns false (0) if o is a valid ObjPy object.  Never raises.

 py% o=C.NSObject() 
 py% o.release() 
 py% print is_bad(o) 
 Dealloc'ed object 
 py% print is_bad(123) 
 not an ObjPy object 
 py% print is_bad(nil) 
 0 
is_rr(o)

Returns true if object is automatically retained/released by ObjPy.  Only NSAutoreleasePools are not automatically retained/released.

Method(target,name[,class[,exidx]])

Returns a method object (callable) for target with name.  If the class argument is included, implementation in that class is targeted.  In this case, object target must be a kind of class.

 py% o=C.MyObject() 
 # same as: m=o.respondsTo 
 py% m=Method(o,'respondsTo') 

 # m('respondsTo:') is equivalent to [obj respondsTo:@selector(respondsTo:)] 
 # or: o.msg_send('respondsTo:','respondsTo:') 
 py% print m('respondsTo:') 
 1 
 py% print m('xyz') 
 0 

 # Sending msg to super using Method. 
 # Get the method: 
 py% m=Method(o,'methodWithArg:',o.superclass()) 
 # invoke it: 
 py% m(args...) 
obj(py)

Converts Python object py to its ObjPy equivalent.

py(obj)

Converts ObjPy object obj to its Python equivalent.

Attributes

nil

The nil object.

 py% print str(nil) 
 nil 
 py% print repr(nil) 
 nil 
 py% print type(nil) 
 <type 'ObjPyObject'> 
super.name(args...)
ex.name(args...)

Within a method body, sends super/ex message.

C

Class namespace.  See the "Integration with C" section.

Class

Class lookup helper.  Access Objective-Everything classes as attributes.

Class.name

Returns the Objective-Everything class name.  If the class does not exist in the runtime system, an attempt to autoload the class will be made.

Class.__members__

Returns a list of all currently loaded classes

Protocol

Protocol lookup helper.  Access protocols as attributes.

Protocol.name

Returns protocol name

Protocol.__members__

Returns a list of all protocols known to the system.

CGlob

CGlob lookup helper.  Access C globals as attributes.

CGlob.name

Returns the value of C global name.

CGlob.name=val

Assigns value val to C global name.

CGlob.__members__

Returns a list of C global variable names.

Info

Get various runtime information.  See the "Introspection" section.

Types

ObjPyObject

ObjPyObject type is used to represent a generic object (id) in the Python domain.

Methods

o.msg_send(selector, args...)
o.msg_send_super(class, selector, args...)
o.msg_send_ex(class, idx, selector, args...)

Sends a regular, super, or ex mesage to o.

o.has_key(key)

Returns whether o has an instance variable key.

o.keys()

Returns a list of o's instance variable names.

o.values()

Returns a list of o's instance variable values.

o.items()

Returns a list of o's instance variable names and values.

len(o)

Returns the number of instance variables of o

Attributes

o.__iv__

Returns o's instance variable accessor object.

o.__xv__

Returns o's attribute variable accessor object.

ObjPySeqObject

ObjPySeqObject type is used to represent NSArrays in the Python domain.

Methods

a.append(v)

Appends object v to array a.

a.pycount(v)

Returns number of occurences of object v in array a.

a.index(v)

Returns index of object v in array a.

a.insert(i,v)

Inserts object v into array a at index i.

a.sort()

Sorts array a.

a.remove(v)

Removes element v from array a.

a.reverse()

Reverses array a.

cmp(a,b)

Compares arrays a and b.

a[i]
a[i]=v

Gets/sets the i-th element of array a.

a[i:j]
a[i:j]=v

Gets/sets the slice i:j of array a.

a+b

Retuns an array which is the result of concatenation of a and b.

a*i

Repeats a i times.

len(a)

Number of elements in a.

ObjPyMapObject

ObjPyMapObject type is used to represent NSDictionaries in the Python domain.

d.has_key(key)

Returns whether d has key.

d.keys()

Returns a list of d's keys.

d.values()

Returns a list of d's values.

d.items()

Returns a list of d's key names and values.

len(d)

Returns the number of elements in d.

d[key]
d[key]=v

Gets/sets the key value of dictionary d.

cmp(d,e)

Compares dictionaries d and e.

ObjPyClassObject

ObjPyClassObject type is used to represent Objective-Everything classes in the Python domain.

clazz(args... [, init=selector])

Constructs an instance of the class.  The number of arguments determines which constructor is used.  The initial constructor table is loaded at the startup time from the ObjCore.conmap file. The init keyword argument can be used to explicitly specify which constructor to use.  The selector name can start with + or -.

clazz.constructors([selector, ...])

Without any arguments, this method returns a list of constructors for this class. With arguments, this method specifies constructors for clazz.  Each selector name can start with + or -.

clazz.rename(newname)

Rename clazz.

clazz.subclass(name, ivarspec)

Subclass clazz with class named name, and instance variables ivarspec.

clazz.subclass(pyclass)

Subclass clazz with Python class pyclass.

clazz.category(methods)

Creates category for clazz.

clazz.bind(methods)

Binds methods into clazz.

ObjPyMethod

ObjPyMethod type is used to represent method invocations.

method(args...)

Invokes method with args.

method.action
method.__name__

Selector name.

method.target
method.__self__

Target of the method.

method.argc

Argument count.

method.types

Argument types.  Return type is element 0.

method.signature

Method signature.

AppKit Support

To load AppKit, simply import the AppKit module.

import AppKit

This brings in the AppKit and ObjAppKit frameworks.  NOTE: If dynamically loading, you must import the ObjPy module first!

AppKit.run(kwargs)

Runs the AppKit main event loop.

Keyword arguments:
nib
name or path of the main nib file
clazz
application class
command
function to be executed as soon as the main event loop starts running.

AppKit.after(callable[, delay])

Asynchronously executes callable.  If the delay argument is specified, callable is executed after delay seconds.


[previous][contents][next]