home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1996 by Lele Gaifax. All Rights Reserved
- *
- * This software may be used and distributed freely for any purpose
- * provided that this notice is included unchanged on any and all
- * copies. The author does not warrant or guarantee this software in
- * any way.
- *
- * This file is part of the PyObjC package.
- *
- * $RCSfile: ObjC.h,v $
- * $Revision: 1.1.1.7 $
- * $Date: 1996/11/14 01:50:11 $
- *
- * Created Thu Sep 5 16:04:09 1996.
- */
-
- #ifndef _ObjC_H
- #define _ObjC_H
-
- /* Version of the module. Should be bumped at each release.
- Versions < 1.0 are to be considered buggy, incomplete and
- NOT stable */
- #define PyObjC_VERSION 0.47
-
- /* ObjC headers */
- #include <objc/objc.h>
-
- /* Python header file */
- #include "Python.h"
-
- /* Exception raised for ObjC specific errors */
- extern PyObject *ObjC_Error;
-
- #if defined(GNU_RUNTIME) || defined(OpENstep)
- #ifndef WITH_FOUNDATION
- #define WITH_FOUNDATION
- #endif
- #endif
-
- /****************************/
- /*** ObjCObject interface ***/
- /****************************/
-
- /* Python wrapper around ObjC id (instance or class) */
- typedef struct
- {
- PyObject_HEAD
-
- id oc_object; // The real ObjC object
- PyObject *methods; // Methods cache
- } ObjCObject;
-
- /* Corresponding Python type object */
- extern PyTypeObject ObjCObject_Type,
- ObjCMappingObject_Type,
- ObjCSequenceObject_Type;
-
- /* Corresponding Python type check macro */
- #define ObjCObject_Check(o) ({ PyTypeObject *_t = (o)->ob_type; \
- _t == &ObjCObject_Type || \
- _t == &ObjCMappingObject_Type || \
- _t == &ObjCSequenceObject_Type; })
- #define ObjCSequenceObject_Check(o) ((o)->ob_type == &ObjCSequenceObject_Type)
- #define ObjCMappingObject_Check(o) ((o)->ob_type == &ObjCMappingObject_Type)
-
- extern ObjCObject *ObjCObject_new (id obj);
-
-
- /****************************/
- /*** ObjCMethod interface ***/
- /****************************/
-
- /* Python wrapper around ObjC SEL */
- typedef struct
- {
- PyObject_HEAD
-
- ObjCObject *obj; // The object we are bound to
- SEL sel; // The ObjC selector
- } ObjCMethod;
-
- /* Corresponding Python type object */
- extern PyTypeObject ObjCMethod_Type;
-
- /* Corresponding Python type check macro */
- #define ObjCMethod_Check(o) ((o)->ob_type == &ObjCMethod_Type)
-
- extern ObjCMethod *ObjCMethod_new_with_name (ObjCObject *obj, const char *name);
- extern ObjCMethod *ObjCMethod_new_with_selector (ObjCObject *obj, SEL sel);
-
-
- /*****************************/
- /*** ObjCPointer interface ***/
- /*****************************/
-
- /* Python wrapper around C pointer */
- typedef struct
- {
- PyObject_VAR_HEAD
-
- void *ptr;
- PyStringObject *type;
- char contents[0];
- } ObjCPointer;
-
- /* Corresponding Python type object */
- extern PyTypeObject ObjCPointer_Type;
-
- /* Corresponding Python type check macro */
- #define ObjCPointer_Check(o) ((o)->ob_type == &ObjCPointer_Type)
-
- extern ObjCPointer *ObjCPointer_new (void *ptr, const char *type);
-
-
- /****************************/
- /*** ObjCStream interface ***/
- /****************************/
-
- #include "OC_Stream.h"
-
- /* Exception raised for Stream specific errors */
- extern PyObject *ObjCStreams_Error;
-
- /* Python wrapper around OC_Stream */
- typedef struct
- {
- PyObject_HEAD
-
- id <Streaming> stream;
- PyObject *from; // this is the normally the filename, or the
- // init string for memory streams.
- } ObjCStream;
-
- /* Corresponding Python type object */
- extern PyTypeObject ObjCStream_Type;
-
- /* Corresponding Python type check macro */
- #define ObjCStream_Check(o) ((o)->ob_type == &ObjCStream_Type)
-
- extern ObjCStream *ObjCStream_new (OC_Stream *stream);
- extern ObjCStream *ObjCStream_new_from_file_and_mode (const char *name, int mode);
- extern ObjCStream *ObjCStream_new_from_file (const char *name);
-
- #ifndef WITH_FOUNDATION
-
- extern ObjCStream *ObjCStream_new_from_stream (NXStream *stream);
- extern NXStream *ObjCStream_stream (ObjCStream *s);
-
- enum
- {
- OC_closedStreamError = NX_STREAMERRBASE + 990, // XXX
- OC_nonSeekableStreamError,
- OC_nonReadableStreamError,
- OC_nonWriteableStreamError
- };
-
- #endif /* WITH_FOUNDATION */
-
-
- /*****************************/
- /*** ObjCRuntime interface ***/
- /*****************************/
-
- typedef struct
- {
- PyObject_HEAD
-
- PyObject *classes; // classes cache
- } ObjCRuntime;
-
- /* Corresponding Python type object */
- extern PyTypeObject ObjCRuntime_Type;
-
- /* Corresponding Python type check macro */
- #define ObjCRuntime_Check(o) ((o)->ob_type == &ObjCRuntime_Type)
-
- extern ObjCRuntime *ObjCRuntime_new (void);
-
- #define FUNDESCR(s) s "\n"
- #define FUNSYN(s) "\nSynopsis:\t" s "\n"
- #define FUNARGS(s) "Arguments:\t" s "\n"
- #define FUNRET(s) "Returns:\t" s "\n"
- #define FUNDOC(d,s,a,r) FUNDESCR(d) FUNSYN(s) FUNARGS(a) FUNRET(r)
-
- #endif /* _ObjC_H */
-
- /*
- ** Local Variables:
- ** change-log-default-name:"../ChangeLog.PyObjC"
- ** End:
- */
-