resonance 1.0.1
Loading...
Searching...
No Matches
pythonextensionbase.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdio.h>
4
5#include "script/cxx/config.h"
6#include "script/cxx/object.h"
7
8namespace Py {
9
33class PythonExtensionBase : public _object {
34public:
42 }
43
53 virtual int print(FILE *pFile, int nFlags);
54
63 virtual Object getattr(const char *pszName);
64
74 virtual int setattr(const char *pszName, const Object &value);
75
84 virtual Object getattro(const Object &name);
85
95 virtual int setattro(const Object &name, const Object &value);
96
105 virtual int compare(const Object &other);
106
114 virtual Object repr();
115
123 virtual Object str();
124
132 virtual Py_LONG hash();
133
143 virtual Object call(const Object &args, const Object &keywords);
144
152 virtual int sequence_length();
153
162 virtual Object sequence_concat(const Object &other);
163
172 virtual Object sequence_repeat(int nCount);
173
182 virtual Object sequence_item(int nIndex);
183
193 virtual Object sequence_slice(int nFirst, int nLast);
194
204 virtual int sequence_ass_item(int nIndex, const Object &value);
205
216 virtual int sequence_ass_slice(int nFirst, int nLast, const Object &value);
217
225 virtual int mapping_length();
226
235 virtual Object mapping_subscript(const Object &key);
236
246 virtual int mapping_ass_subscript(const Object &key, const Object &value);
247
255 virtual int number_nonzero();
256
265
274
283
292
301
310
319
328
337
346 virtual Object number_add(const Object &other);
347
356 virtual Object number_subtract(const Object &other);
357
366 virtual Object number_multiply(const Object &other);
367
376 virtual Object number_divide(const Object &other);
377
386 virtual Object number_remainder(const Object &other);
387
396 virtual Object number_divmod(const Object &other);
397
406 virtual Object number_lshift(const Object &other);
407
416 virtual Object number_rshift(const Object &other);
417
426 virtual Object number_and(const Object &other);
427
436 virtual Object number_xor(const Object &other);
437
446 virtual Object number_or(const Object &other);
447
457 virtual Object number_power(const Object &exponent, const Object &modulus);
458
468 virtual int buffer_getreadbuffer(int nSegment, void **ppData);
469
479 virtual int buffer_getwritebuffer(int nSegment, void **ppData);
480
489 virtual int buffer_getsegcount(int *pnLength);
490
501 static int print_handler(PyObject *self, FILE *pFile, int nFlags);
502
511 static Py_LONG hash_handler(PyObject *self);
512
521 static int sequence_length_handler(PyObject *self);
522
531 static int mapping_length_handler(PyObject *self);
532
541 static int number_nonzero_handler(PyObject *self);
542
553 static int buffer_getreadbuffer_handler(PyObject *self, int nSegment, void **ppData);
554
565 static int buffer_getwritebuffer_handler(PyObject *self, int nSegment, void **ppData);
566
576 static int buffer_getsegcount_handler(PyObject *self, int *pnLength);
577
587 static PyObject *sequence_concat_handler(PyObject *self, PyObject *other);
588
598 static PyObject *sequence_repeat_handler(PyObject *self, int nCount);
599
609 static PyObject *sequence_item_handler(PyObject *self, int nIndex);
610
621 static PyObject *sequence_slice_handler(PyObject *self, int nFirst, int nLast);
622
633 static int sequence_ass_item_handler(PyObject *self, int nIndex, PyObject *value);
634
646 static int sequence_ass_slice_handler(PyObject *self, int nFirst, int nLast, PyObject *value);
647
657 static PyObject *mapping_subscript_handler(PyObject *self, PyObject *key);
658
669 static int mapping_ass_subscript_handler(PyObject *self, PyObject *key, PyObject *value);
670
671private:
678 void missing_method();
679};
680
681} // namespace Py
Reference-counted handle on any Python object, and the root of the PyCXX object hierarchy.
Definition object.h:42
Base of every C++ object the binding exposes to Python as an extension object.
Definition pythonextensionbase.h:33
virtual Object number_divide(const Object &other)
Divide by a number.
virtual Object number_lshift(const Object &other)
Shift left.
static int mapping_length_handler(PyObject *self)
Forward mp_length to mapping_length().
static PyObject * mapping_subscript_handler(PyObject *self, PyObject *key)
Forward mp_subscript to mapping_subscript().
virtual Object sequence_repeat(int nCount)
Repeat the sequence.
virtual int sequence_ass_slice(int nFirst, int nLast, const Object &value)
Write a sequence slice.
virtual int sequence_length()
Report the sequence length.
virtual int print(FILE *pFile, int nFlags)
Print the object.
virtual Object sequence_slice(int nFirst, int nLast)
Read a sequence slice.
virtual int number_nonzero()
Report whether the number is nonzero.
virtual Object getattr(const char *pszName)
Read an attribute by name.
static int mapping_ass_subscript_handler(PyObject *self, PyObject *key, PyObject *value)
Forward mp_ass_subscript to mapping_ass_subscript().
static PyObject * sequence_repeat_handler(PyObject *self, int nCount)
Forward sq_repeat to sequence_repeat().
virtual Object number_remainder(const Object &other)
Produce the remainder.
static int buffer_getwritebuffer_handler(PyObject *self, int nSegment, void **ppData)
Forward bf_getwritebuffer to buffer_getwritebuffer().
virtual int sequence_ass_item(int nIndex, const Object &value)
Write one sequence element.
virtual int buffer_getreadbuffer(int nSegment, void **ppData)
Expose a read buffer segment.
virtual Object number_absolute()
Produce the absolute value.
static PyObject * sequence_concat_handler(PyObject *self, PyObject *other)
Forward sq_concat to sequence_concat().
virtual Py_LONG hash()
Produce the hash.
static int number_nonzero_handler(PyObject *self)
Forward nb_nonzero to number_nonzero().
virtual Object sequence_concat(const Object &other)
Concatenate a sequence.
static int sequence_length_handler(PyObject *self)
Forward sq_length to sequence_length().
static int buffer_getsegcount_handler(PyObject *self, int *pnLength)
Forward bf_getsegcount to buffer_getsegcount().
virtual Object number_int()
Convert to an integer.
virtual int mapping_length()
Report the mapping length.
static int print_handler(PyObject *self, FILE *pFile, int nFlags)
Forward tp_print to print().
static PyObject * sequence_slice_handler(PyObject *self, int nFirst, int nLast)
Forward sq_slice to sequence_slice().
static int sequence_ass_slice_handler(PyObject *self, int nFirst, int nLast, PyObject *value)
Forward sq_ass_slice to sequence_ass_slice().
static int sequence_ass_item_handler(PyObject *self, int nIndex, PyObject *value)
Forward sq_ass_item to sequence_ass_item().
virtual Object str()
Produce the str() text.
virtual Object number_positive()
Apply unary plus.
virtual Object number_subtract(const Object &other)
Subtract a number.
virtual Object number_oct()
Produce the octal text.
virtual Object number_and(const Object &other)
Apply bitwise and.
virtual int buffer_getwritebuffer(int nSegment, void **ppData)
Expose a write buffer segment.
virtual int compare(const Object &other)
Compare with another object.
virtual int buffer_getsegcount(int *pnLength)
Count the buffer segments.
virtual Object number_power(const Object &exponent, const Object &modulus)
Raise to a power.
static PyObject * sequence_item_handler(PyObject *self, int nIndex)
Forward sq_item to sequence_item().
virtual Object number_float()
Convert to a float.
virtual Object number_add(const Object &other)
Add a number.
virtual int setattro(const Object &name, const Object &value)
Write an attribute by name object.
virtual Object call(const Object &args, const Object &keywords)
Call the object.
virtual Object number_divmod(const Object &other)
Produce the quotient and remainder.
virtual Object number_invert()
Invert the bits.
virtual ~PythonExtensionBase()
Destroy the object.
Definition pythonextensionbase.h:41
virtual Object number_xor(const Object &other)
Apply bitwise exclusive or.
virtual Object number_multiply(const Object &other)
Multiply by a number.
virtual int mapping_ass_subscript(const Object &key, const Object &value)
Write one mapping entry.
virtual Object number_or(const Object &other)
Apply bitwise or.
static Py_LONG hash_handler(PyObject *self)
Forward tp_hash to hash().
virtual Object number_hex()
Produce the hexadecimal text.
virtual int setattr(const char *pszName, const Object &value)
Write an attribute by name.
static int buffer_getreadbuffer_handler(PyObject *self, int nSegment, void **ppData)
Forward bf_getreadbuffer to buffer_getreadbuffer().
virtual Object repr()
Produce the repr() text.
virtual Object number_negative()
Negate the number.
virtual Object number_rshift(const Object &other)
Shift right.
virtual Object sequence_item(int nIndex)
Read one sequence element.
virtual Object getattro(const Object &name)
Read an attribute by name object.
virtual Object mapping_subscript(const Object &key)
Read one mapping entry.
virtual Object number_long()
Convert to a long integer.
Configuration header of the PyCXX binding layer.
C++ wrappers for the embedded Python interpreter's objects, types, and extension modules.
Definition attributeerror.h:7