home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Languages / python / PyObjC-0.47-MIHS / pyobjc-0.47-src / Include / ObjC.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-13  |  4.7 KB  |  192 lines

  1. /* Copyright (c) 1996 by Lele Gaifax.  All Rights Reserved
  2.  *
  3.  * This software may be used and distributed freely for any purpose
  4.  * provided that this notice is included unchanged on any and all
  5.  * copies. The author does not warrant or guarantee this software in
  6.  * any way.
  7.  *
  8.  * This file is part of the PyObjC package.
  9.  *
  10.  * $RCSfile: ObjC.h,v $
  11.  * $Revision: 1.1.1.7 $
  12.  * $Date: 1996/11/14 01:50:11 $
  13.  *
  14.  * Created Thu Sep 5 16:04:09 1996.
  15.  */
  16.  
  17. #ifndef _ObjC_H
  18. #define _ObjC_H
  19.  
  20. /* Version of the module. Should be bumped at each release.
  21.    Versions < 1.0 are to be considered buggy, incomplete and
  22.    NOT stable */
  23. #define PyObjC_VERSION 0.47
  24.  
  25. /* ObjC headers */
  26. #include <objc/objc.h>
  27.  
  28. /* Python header file */
  29. #include "Python.h"
  30.  
  31. /* Exception raised for ObjC specific errors */
  32. extern PyObject *ObjC_Error;
  33.  
  34. #if defined(GNU_RUNTIME) || defined(OpENstep)
  35. #ifndef WITH_FOUNDATION
  36. #define WITH_FOUNDATION
  37. #endif
  38. #endif
  39.  
  40. /****************************/
  41. /*** ObjCObject interface ***/
  42. /****************************/
  43.  
  44. /* Python wrapper around ObjC id (instance or class) */
  45. typedef struct
  46. {
  47.   PyObject_HEAD
  48.     
  49.   id        oc_object;        // The real ObjC object
  50.   PyObject *methods;        // Methods cache
  51. } ObjCObject;
  52.  
  53. /* Corresponding Python type object */
  54. extern PyTypeObject ObjCObject_Type,
  55.                     ObjCMappingObject_Type,
  56.                     ObjCSequenceObject_Type;
  57.  
  58. /* Corresponding Python type check macro */
  59. #define ObjCObject_Check(o) ({ PyTypeObject *_t = (o)->ob_type;        \
  60.                                _t == &ObjCObject_Type ||        \
  61.                    _t == &ObjCMappingObject_Type ||        \
  62.                    _t == &ObjCSequenceObject_Type; })
  63. #define ObjCSequenceObject_Check(o) ((o)->ob_type == &ObjCSequenceObject_Type)
  64. #define ObjCMappingObject_Check(o) ((o)->ob_type == &ObjCMappingObject_Type)
  65.  
  66. extern ObjCObject *ObjCObject_new (id obj);
  67.  
  68.  
  69. /****************************/
  70. /*** ObjCMethod interface ***/
  71. /****************************/
  72.  
  73. /* Python wrapper around ObjC SEL */
  74. typedef struct
  75. {
  76.   PyObject_HEAD
  77.     
  78.   ObjCObject *obj;        // The object we are bound to
  79.   SEL         sel;        // The ObjC selector
  80. } ObjCMethod;
  81.  
  82. /* Corresponding Python type object */
  83. extern PyTypeObject ObjCMethod_Type;
  84.  
  85. /* Corresponding Python type check macro */
  86. #define ObjCMethod_Check(o) ((o)->ob_type == &ObjCMethod_Type)
  87.  
  88. extern ObjCMethod *ObjCMethod_new_with_name (ObjCObject *obj, const char *name);
  89. extern ObjCMethod *ObjCMethod_new_with_selector (ObjCObject *obj, SEL sel);
  90.  
  91.  
  92. /*****************************/
  93. /*** ObjCPointer interface ***/
  94. /*****************************/
  95.  
  96. /* Python wrapper around C pointer */
  97. typedef struct
  98. {
  99.   PyObject_VAR_HEAD
  100.  
  101.   void *ptr;
  102.   PyStringObject *type;
  103.   char contents[0];
  104. } ObjCPointer;
  105.  
  106. /* Corresponding Python type object */
  107. extern PyTypeObject ObjCPointer_Type;
  108.  
  109. /* Corresponding Python type check macro */
  110. #define ObjCPointer_Check(o) ((o)->ob_type == &ObjCPointer_Type)
  111.  
  112. extern ObjCPointer *ObjCPointer_new (void *ptr, const char *type);
  113.  
  114.  
  115. /****************************/
  116. /*** ObjCStream interface ***/
  117. /****************************/
  118.  
  119. #include "OC_Stream.h"
  120.  
  121. /* Exception raised for Stream specific errors */
  122. extern PyObject *ObjCStreams_Error;
  123.  
  124. /* Python wrapper around OC_Stream */
  125. typedef struct
  126. {
  127.   PyObject_HEAD
  128.  
  129.   id <Streaming> stream;
  130.   PyObject *from;        // this is the normally the filename, or the
  131.                 // init string for memory streams.
  132. } ObjCStream;
  133.  
  134. /* Corresponding Python type object */
  135. extern PyTypeObject ObjCStream_Type;
  136.  
  137. /* Corresponding Python type check macro */
  138. #define ObjCStream_Check(o) ((o)->ob_type == &ObjCStream_Type)
  139.  
  140. extern ObjCStream *ObjCStream_new (OC_Stream *stream);
  141. extern ObjCStream *ObjCStream_new_from_file_and_mode (const char *name, int mode);
  142. extern ObjCStream *ObjCStream_new_from_file (const char *name);
  143.  
  144. #ifndef WITH_FOUNDATION
  145.  
  146. extern ObjCStream *ObjCStream_new_from_stream (NXStream *stream);
  147. extern NXStream *ObjCStream_stream (ObjCStream *s);
  148.  
  149. enum
  150. {
  151.   OC_closedStreamError = NX_STREAMERRBASE + 990, // XXX
  152.   OC_nonSeekableStreamError,
  153.   OC_nonReadableStreamError,
  154.   OC_nonWriteableStreamError
  155. };
  156.  
  157. #endif /* WITH_FOUNDATION */
  158.  
  159.  
  160. /*****************************/
  161. /*** ObjCRuntime interface ***/
  162. /*****************************/
  163.  
  164. typedef struct
  165. {
  166.   PyObject_HEAD
  167.  
  168.   PyObject *classes;                  // classes cache
  169. } ObjCRuntime;
  170.  
  171. /* Corresponding Python type object */
  172. extern PyTypeObject ObjCRuntime_Type;
  173.  
  174. /* Corresponding Python type check macro */
  175. #define ObjCRuntime_Check(o) ((o)->ob_type == &ObjCRuntime_Type)
  176.  
  177. extern ObjCRuntime *ObjCRuntime_new (void);
  178.  
  179. #define FUNDESCR(s) s "\n"
  180. #define FUNSYN(s) "\nSynopsis:\t" s "\n"
  181. #define FUNARGS(s) "Arguments:\t" s "\n"
  182. #define FUNRET(s) "Returns:\t" s "\n"
  183. #define FUNDOC(d,s,a,r) FUNDESCR(d) FUNSYN(s) FUNARGS(a) FUNRET(r)
  184.  
  185. #endif /* _ObjC_H */
  186.  
  187. /*
  188. ** Local Variables:
  189. ** change-log-default-name:"../ChangeLog.PyObjC"
  190. ** End:
  191. */
  192.