00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef __CXX_ExtensionTypeBase__h
00039 #define __CXX_ExtensionTypeBase__h
00040
00041 namespace Py
00042 {
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 class PYCXX_EXPORT PythonExtensionBase : public PyObject
00063 {
00064 public:
00065 PythonExtensionBase();
00066 virtual ~PythonExtensionBase();
00067
00068 public:
00069
00070 virtual void reinit( Tuple &args, Dict &kwds );
00071
00072
00073 #if defined( PYCXX_PYTHON_2TO3 ) || !defined( PY3 )
00074 virtual int print( FILE *, int );
00075 #endif
00076 virtual Object getattr( const char * );
00077 virtual int setattr( const char *, const Object & );
00078 virtual Object getattro( const String & );
00079 Object genericGetAttro( const String & );
00080 virtual int setattro( const String &, const Object & );
00081 int genericSetAttro( const String &, const Object & );
00082 virtual int compare( const Object & );
00083 virtual Object rich_compare( const Object &, int );
00084 virtual Object repr();
00085 virtual Object str();
00086 virtual long hash();
00087 virtual Object call( const Object &, const Object & );
00088 virtual Object iter();
00089 virtual PyObject *iternext();
00090
00091
00092 virtual int sequence_length();
00093 virtual Object sequence_concat( const Object & );
00094 virtual Object sequence_repeat( Py_ssize_t );
00095 virtual Object sequence_item( Py_ssize_t );
00096 virtual Object sequence_slice( Py_ssize_t, Py_ssize_t );
00097 virtual int sequence_ass_item( Py_ssize_t, const Object & );
00098 virtual int sequence_ass_slice( Py_ssize_t, Py_ssize_t, const Object & );
00099
00100
00101 virtual int mapping_length();
00102 virtual Object mapping_subscript( const Object & );
00103 virtual int mapping_ass_subscript( const Object &, const Object & );
00104
00105
00106 virtual int number_nonzero();
00107 virtual Object number_negative();
00108 virtual Object number_positive();
00109 virtual Object number_absolute();
00110 virtual Object number_invert();
00111 virtual Object number_int();
00112 virtual Object number_float();
00113 virtual Object number_long();
00114 virtual Object number_oct();
00115 virtual Object number_hex();
00116 virtual Object number_add( const Object & );
00117 virtual Object number_subtract( const Object & );
00118 virtual Object number_multiply( const Object & );
00119 virtual Object number_divide( const Object & );
00120 virtual Object number_remainder( const Object & );
00121 virtual Object number_divmod( const Object & );
00122 virtual Object number_lshift( const Object & );
00123 virtual Object number_rshift( const Object & );
00124 virtual Object number_and( const Object & );
00125 virtual Object number_xor( const Object & );
00126 virtual Object number_or( const Object & );
00127 virtual Object number_power( const Object &, const Object & );
00128
00129
00130 virtual Py_ssize_t buffer_getreadbuffer( Py_ssize_t, void** );
00131 virtual Py_ssize_t buffer_getwritebuffer( Py_ssize_t, void** );
00132 virtual Py_ssize_t buffer_getsegcount( Py_ssize_t* );
00133
00134 public:
00135
00136 Object callOnSelf( const std::string &fn_name );
00137 Object callOnSelf( const std::string &fn_name,
00138 const Object &arg1 );
00139 Object callOnSelf( const std::string &fn_name,
00140 const Object &arg1, const Object &arg2 );
00141 Object callOnSelf( const std::string &fn_name,
00142 const Object &arg1, const Object &arg2, const Object &arg3 );
00143 Object callOnSelf( const std::string &fn_name,
00144 const Object &arg1, const Object &arg2, const Object &arg3,
00145 const Object &arg4 );
00146 Object callOnSelf( const std::string &fn_name,
00147 const Object &arg1, const Object &arg2, const Object &arg3,
00148 const Object &arg4, const Object &arg5 );
00149 Object callOnSelf( const std::string &fn_name,
00150 const Object &arg1, const Object &arg2, const Object &arg3,
00151 const Object &arg4, const Object &arg5, const Object &arg6 );
00152 Object callOnSelf( const std::string &fn_name,
00153 const Object &arg1, const Object &arg2, const Object &arg3,
00154 const Object &arg4, const Object &arg5, const Object &arg6,
00155 const Object &arg7 );
00156 Object callOnSelf( const std::string &fn_name,
00157 const Object &arg1, const Object &arg2, const Object &arg3,
00158 const Object &arg4, const Object &arg5, const Object &arg6,
00159 const Object &arg7, const Object &arg8 );
00160 Object callOnSelf( const std::string &fn_name,
00161 const Object &arg1, const Object &arg2, const Object &arg3,
00162 const Object &arg4, const Object &arg5, const Object &arg6,
00163 const Object &arg7, const Object &arg8, const Object &arg9 );
00164
00165 public:
00166 virtual PyObject *selfPtr() = 0;
00167 virtual Object self() = 0;
00168
00169 private:
00170 void missing_method( void );
00171 static PyObject *method_call_handler( PyObject *self, PyObject *args );
00172 };
00173
00174 }
00175
00176
00177 #endif