mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Quickly renamed.
This commit is contained in:
parent
fb221562a3
commit
0a3eaf0838
2 changed files with 247 additions and 250 deletions
|
@ -230,10 +230,10 @@ def generate(type, func, database):
|
||||||
# Stub header
|
# Stub header
|
||||||
#
|
#
|
||||||
print
|
print
|
||||||
print 'static object *'
|
print 'static PyObject *'
|
||||||
print 'gl_' + func + '(self, args)'
|
print 'gl_' + func + '(self, args)'
|
||||||
print '\tobject *self;'
|
print '\tPyObject *self;'
|
||||||
print '\tobject *args;'
|
print '\tPyObject *args;'
|
||||||
print '{'
|
print '{'
|
||||||
#
|
#
|
||||||
# Declare return value if any
|
# Declare return value if any
|
||||||
|
@ -317,11 +317,11 @@ def generate(type, func, database):
|
||||||
print '\tif ((arg' + `i+1`, '=',
|
print '\tif ((arg' + `i+1`, '=',
|
||||||
if a_factor:
|
if a_factor:
|
||||||
print '('+a_type+'(*)['+a_factor+'])',
|
print '('+a_type+'(*)['+a_factor+'])',
|
||||||
print 'NEW(' + a_type, ',',
|
print 'PyMem_NEW(' + a_type, ',',
|
||||||
if a_factor:
|
if a_factor:
|
||||||
print a_factor, '*',
|
print a_factor, '*',
|
||||||
print a_sub, ')) == NULL)'
|
print a_sub, ')) == NULL)'
|
||||||
print '\t\treturn err_nomem();'
|
print '\t\treturn PyErr_NoMemory();'
|
||||||
print '\tif',
|
print '\tif',
|
||||||
if a_factor or a_sub: # Get a fixed-size array array
|
if a_factor or a_sub: # Get a fixed-size array array
|
||||||
print '(!geti' + xtype + 'array(args,',
|
print '(!geti' + xtype + 'array(args,',
|
||||||
|
@ -368,7 +368,7 @@ def generate(type, func, database):
|
||||||
for i in range(len(database)):
|
for i in range(len(database)):
|
||||||
a_type, a_mode, a_factor, a_sub = database[i]
|
a_type, a_mode, a_factor, a_sub = database[i]
|
||||||
if a_mode == 's' and a_sub and not isnum(a_sub):
|
if a_mode == 's' and a_sub and not isnum(a_sub):
|
||||||
print '\tDEL(arg' + `i+1` + ');'
|
print '\tPyMem_DEL(arg' + `i+1` + ');'
|
||||||
#
|
#
|
||||||
# Return
|
# Return
|
||||||
#
|
#
|
||||||
|
@ -388,19 +388,19 @@ def generate(type, func, database):
|
||||||
print '\treturn',
|
print '\treturn',
|
||||||
print mkobject(a_type, 'arg' + `i+1`) + ';'
|
print mkobject(a_type, 'arg' + `i+1`) + ';'
|
||||||
else:
|
else:
|
||||||
print '\t{ object *v = newtupleobject(',
|
print '\t{ PyObject *v = PyTuple_New(',
|
||||||
print n_out_args, ');'
|
print n_out_args, ');'
|
||||||
print '\t if (v == NULL) return NULL;'
|
print '\t if (v == NULL) return NULL;'
|
||||||
i_out = 0
|
i_out = 0
|
||||||
if type <> 'void':
|
if type <> 'void':
|
||||||
print '\t settupleitem(v,',
|
print '\t PyTuple_SetItem(v,',
|
||||||
print `i_out` + ',',
|
print `i_out` + ',',
|
||||||
print mkobject(type, 'retval') + ');'
|
print mkobject(type, 'retval') + ');'
|
||||||
i_out = i_out + 1
|
i_out = i_out + 1
|
||||||
for i in range(len(database)):
|
for i in range(len(database)):
|
||||||
a_type, a_mode, a_factor, a_sub = database[i]
|
a_type, a_mode, a_factor, a_sub = database[i]
|
||||||
if a_mode == 'r':
|
if a_mode == 'r':
|
||||||
print '\t settupleitem(v,',
|
print '\t PyTuple_SetItem(v,',
|
||||||
print `i_out` + ',',
|
print `i_out` + ',',
|
||||||
s = mkobject(a_type, 'arg' + `i+1`)
|
s = mkobject(a_type, 'arg' + `i+1`)
|
||||||
print s + ');'
|
print s + ');'
|
||||||
|
@ -413,8 +413,8 @@ def generate(type, func, database):
|
||||||
# Return None or return value
|
# Return None or return value
|
||||||
#
|
#
|
||||||
if type == 'void':
|
if type == 'void':
|
||||||
print '\tINCREF(None);'
|
print '\tPy_INCREF(Py_None);'
|
||||||
print '\treturn None;'
|
print '\treturn Py_None;'
|
||||||
else:
|
else:
|
||||||
print '\treturn', mkobject(type, 'retval') + ';'
|
print '\treturn', mkobject(type, 'retval') + ';'
|
||||||
#
|
#
|
||||||
|
@ -527,7 +527,7 @@ while 1:
|
||||||
|
|
||||||
|
|
||||||
print
|
print
|
||||||
print 'static struct methodlist gl_methods[] = {'
|
print 'static struct PyMethodDef gl_methods[] = {'
|
||||||
for func in functions:
|
for func in functions:
|
||||||
print '\t{"' + func + '", gl_' + func + '},'
|
print '\t{"' + func + '", gl_' + func + '},'
|
||||||
print '\t{NULL, NULL} /* Sentinel */'
|
print '\t{NULL, NULL} /* Sentinel */'
|
||||||
|
@ -536,5 +536,5 @@ print
|
||||||
print 'void'
|
print 'void'
|
||||||
print 'initgl()'
|
print 'initgl()'
|
||||||
print '{'
|
print '{'
|
||||||
print '\tinitmodule("gl", gl_methods);'
|
print '\tPy_InitModule("gl", gl_methods);'
|
||||||
print '}'
|
print '}'
|
||||||
|
|
471
Modules/cstubs
471
Modules/cstubs
|
@ -78,11 +78,8 @@ extern int gewrite();
|
||||||
extern int gettp();
|
extern int gettp();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "allobjects.h"
|
#include "Python.h"
|
||||||
#include "import.h"
|
|
||||||
#include "modsupport.h"
|
|
||||||
#include "cgensupport.h"
|
#include "cgensupport.h"
|
||||||
#include "ceval.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Some stubs are too complicated for the stub generator.
|
Some stubs are too complicated for the stub generator.
|
||||||
|
@ -93,20 +90,20 @@ generator can include it in the table of functions.
|
||||||
|
|
||||||
% qread
|
% qread
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_qread(self, args)
|
gl_qread(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
long retval;
|
long retval;
|
||||||
short arg1 ;
|
short arg1 ;
|
||||||
BGN_SAVE
|
Py_BEGIN_ALLOW_THREADS
|
||||||
retval = qread( & arg1 );
|
retval = qread( & arg1 );
|
||||||
END_SAVE
|
Py_END_ALLOW_THREADS
|
||||||
{ object *v = newtupleobject( 2 );
|
{ PyObject *v = PyTuple_New( 2 );
|
||||||
if (v == NULL) return NULL;
|
if (v == NULL) return NULL;
|
||||||
settupleitem(v, 0, mknewlongobject(retval));
|
PyTuple_SetItem(v, 0, mknewlongobject(retval));
|
||||||
settupleitem(v, 1, mknewshortobject(arg1));
|
PyTuple_SetItem(v, 1, mknewshortobject(arg1));
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,35 +122,35 @@ and for each point v3d() is called.
|
||||||
|
|
||||||
% varray
|
% varray
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_varray(self, args)
|
gl_varray(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
object *v, *w=NULL;
|
PyObject *v, *w=NULL;
|
||||||
int i, n, width;
|
int i, n, width;
|
||||||
double vec[3];
|
double vec[3];
|
||||||
object * (*getitem) FPROTO((object *, int));
|
PyObject * (*getitem) Py_FPROTO((PyObject *, int));
|
||||||
|
|
||||||
if (!getiobjectarg(args, 1, 0, &v))
|
if (!PyArg_GetObject(args, 1, 0, &v))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (is_listobject(v)) {
|
if (PyList_Check(v)) {
|
||||||
n = getlistsize(v);
|
n = PyList_Size(v);
|
||||||
getitem = getlistitem;
|
getitem = PyList_GetItem;
|
||||||
}
|
}
|
||||||
else if (is_tupleobject(v)) {
|
else if (PyTuple_Check(v)) {
|
||||||
n = gettuplesize(v);
|
n = PyTuple_Size(v);
|
||||||
getitem = gettupleitem;
|
getitem = PyTuple_GetItem;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
INCREF(None);
|
Py_INCREF(Py_None);
|
||||||
return None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
w = (*getitem)(v, 0);
|
w = (*getitem)(v, 0);
|
||||||
|
@ -161,11 +158,11 @@ gl_varray(self, args)
|
||||||
width = 0;
|
width = 0;
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
}
|
}
|
||||||
else if (is_listobject(w)) {
|
else if (PyList_Check(w)) {
|
||||||
width = getlistsize(w);
|
width = PyList_Size(w);
|
||||||
}
|
}
|
||||||
else if (is_tupleobject(w)) {
|
else if (PyTuple_Check(w)) {
|
||||||
width = gettuplesize(w);
|
width = PyTuple_Size(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (width) {
|
switch (width) {
|
||||||
|
@ -175,19 +172,19 @@ gl_varray(self, args)
|
||||||
case 3:
|
case 3:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
w = (*getitem)(v, i);
|
w = (*getitem)(v, i);
|
||||||
if (!getidoublearray(w, 1, 0, width, vec))
|
if (!PyArg_GetDoubleArray(w, 1, 0, width, vec))
|
||||||
return NULL;
|
return NULL;
|
||||||
v3d(vec);
|
v3d(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
INCREF(None);
|
Py_INCREF(Py_None);
|
||||||
return None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -203,24 +200,24 @@ vnarray and nvarray differ only in the order of the vector and normal in
|
||||||
the pair: vnarray expects (v, n) while nvarray expects (n, v).
|
the pair: vnarray expects (v, n) while nvarray expects (n, v).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static object *gen_nvarray(); /* Forward */
|
static PyObject *gen_nvarray(); /* Forward */
|
||||||
|
|
||||||
% nvarray
|
% nvarray
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_nvarray(self, args)
|
gl_nvarray(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
return gen_nvarray(args, 0);
|
return gen_nvarray(args, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
% vnarray
|
% vnarray
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_vnarray(self, args)
|
gl_vnarray(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
return gen_nvarray(args, 1);
|
return gen_nvarray(args, 1);
|
||||||
}
|
}
|
||||||
|
@ -228,49 +225,49 @@ gl_vnarray(self, args)
|
||||||
/* Generic, internal version of {nv,nv}array: inorm indicates the
|
/* Generic, internal version of {nv,nv}array: inorm indicates the
|
||||||
argument order, 0: normal first, 1: vector first. */
|
argument order, 0: normal first, 1: vector first. */
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gen_nvarray(args, inorm)
|
gen_nvarray(args, inorm)
|
||||||
object *args;
|
PyObject *args;
|
||||||
int inorm;
|
int inorm;
|
||||||
{
|
{
|
||||||
object *v, *w, *wnorm, *wvec;
|
PyObject *v, *w, *wnorm, *wvec;
|
||||||
int i, n;
|
int i, n;
|
||||||
float norm[3], vec[3];
|
float norm[3], vec[3];
|
||||||
object * (*getitem) FPROTO((object *, int));
|
PyObject * (*getitem) Py_FPROTO((PyObject *, int));
|
||||||
|
|
||||||
if (!getiobjectarg(args, 1, 0, &v))
|
if (!PyArg_GetObject(args, 1, 0, &v))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (is_listobject(v)) {
|
if (PyList_Check(v)) {
|
||||||
n = getlistsize(v);
|
n = PyList_Size(v);
|
||||||
getitem = getlistitem;
|
getitem = PyList_GetItem;
|
||||||
}
|
}
|
||||||
else if (is_tupleobject(v)) {
|
else if (PyTuple_Check(v)) {
|
||||||
n = gettuplesize(v);
|
n = PyTuple_Size(v);
|
||||||
getitem = gettupleitem;
|
getitem = PyTuple_GetItem;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
w = (*getitem)(v, i);
|
w = (*getitem)(v, i);
|
||||||
if (!is_tupleobject(w) || gettuplesize(w) != 2) {
|
if (!PyTuple_Check(w) || PyTuple_Size(w) != 2) {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wnorm = gettupleitem(w, inorm);
|
wnorm = PyTuple_GetItem(w, inorm);
|
||||||
wvec = gettupleitem(w, 1 - inorm);
|
wvec = PyTuple_GetItem(w, 1 - inorm);
|
||||||
if (!getifloatarray(wnorm, 1, 0, 3, norm) ||
|
if (!PyArg_GetFloatArray(wnorm, 1, 0, 3, norm) ||
|
||||||
!getifloatarray(wvec, 1, 0, 3, vec))
|
!PyArg_GetFloatArray(wvec, 1, 0, 3, vec))
|
||||||
return NULL;
|
return NULL;
|
||||||
n3f(norm);
|
n3f(norm);
|
||||||
v3f(vec);
|
v3f(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
INCREF(None);
|
Py_INCREF(Py_None);
|
||||||
return None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type).
|
/* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type).
|
||||||
|
@ -280,10 +277,10 @@ gen_nvarray(args, inorm)
|
||||||
|
|
||||||
% nurbssurface
|
% nurbssurface
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_nurbssurface(self, args)
|
gl_nurbssurface(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
long arg1 ;
|
long arg1 ;
|
||||||
double * arg2 ;
|
double * arg2 ;
|
||||||
|
@ -297,58 +294,58 @@ gl_nurbssurface(self, args)
|
||||||
long s_byte_stride, t_byte_stride;
|
long s_byte_stride, t_byte_stride;
|
||||||
long s_nctl, t_nctl;
|
long s_nctl, t_nctl;
|
||||||
long s, t;
|
long s, t;
|
||||||
object *v, *w, *pt;
|
PyObject *v, *w, *pt;
|
||||||
double *pnext;
|
double *pnext;
|
||||||
if (!getilongarraysize(args, 6, 0, &arg1))
|
if (!PyArg_GetLongArraySize(args, 6, 0, &arg1))
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((arg2 = NEW(double, arg1 )) == NULL) {
|
if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) {
|
||||||
return err_nomem();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
if (!getidoublearray(args, 6, 0, arg1 , arg2))
|
if (!PyArg_GetDoubleArray(args, 6, 0, arg1 , arg2))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarraysize(args, 6, 1, &arg3))
|
if (!PyArg_GetLongArraySize(args, 6, 1, &arg3))
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((arg4 = NEW(double, arg3 )) == NULL) {
|
if ((arg4 = PyMem_NEW(double, arg3 )) == NULL) {
|
||||||
return err_nomem();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
if (!getidoublearray(args, 6, 1, arg3 , arg4))
|
if (!PyArg_GetDoubleArray(args, 6, 1, arg3 , arg4))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 6, 3, &arg6))
|
if (!PyArg_GetLong(args, 6, 3, &arg6))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 6, 4, &arg7))
|
if (!PyArg_GetLong(args, 6, 4, &arg7))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 6, 5, &arg8))
|
if (!PyArg_GetLong(args, 6, 5, &arg8))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (arg8 == N_XYZ)
|
if (arg8 == N_XYZ)
|
||||||
ncoords = 3;
|
ncoords = 3;
|
||||||
else if (arg8 == N_XYZW)
|
else if (arg8 == N_XYZW)
|
||||||
ncoords = 4;
|
ncoords = 4;
|
||||||
else {
|
else {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
s_nctl = arg1 - arg6;
|
s_nctl = arg1 - arg6;
|
||||||
t_nctl = arg3 - arg7;
|
t_nctl = arg3 - arg7;
|
||||||
if (!getiobjectarg(args, 6, 2, &v))
|
if (!PyArg_GetObject(args, 6, 2, &v))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!is_listobject(v) || getlistsize(v) != s_nctl) {
|
if (!PyList_Check(v) || PyList_Size(v) != s_nctl) {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((arg5 = NEW(double, s_nctl*t_nctl*ncoords )) == NULL) {
|
if ((arg5 = PyMem_NEW(double, s_nctl*t_nctl*ncoords )) == NULL) {
|
||||||
return err_nomem();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
pnext = arg5;
|
pnext = arg5;
|
||||||
for (s = 0; s < s_nctl; s++) {
|
for (s = 0; s < s_nctl; s++) {
|
||||||
w = getlistitem(v, s);
|
w = PyList_GetItem(v, s);
|
||||||
if (w == NULL || !is_listobject(w) ||
|
if (w == NULL || !PyList_Check(w) ||
|
||||||
getlistsize(w) != t_nctl) {
|
PyList_Size(w) != t_nctl) {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (t = 0; t < t_nctl; t++) {
|
for (t = 0; t < t_nctl; t++) {
|
||||||
pt = getlistitem(w, t);
|
pt = PyList_GetItem(w, t);
|
||||||
if (!getidoublearray(pt, 1, 0, ncoords, pnext))
|
if (!PyArg_GetDoubleArray(pt, 1, 0, ncoords, pnext))
|
||||||
return NULL;
|
return NULL;
|
||||||
pnext += ncoords;
|
pnext += ncoords;
|
||||||
}
|
}
|
||||||
|
@ -357,11 +354,11 @@ gl_nurbssurface(self, args)
|
||||||
t_byte_stride = s_byte_stride * s_nctl;
|
t_byte_stride = s_byte_stride * s_nctl;
|
||||||
nurbssurface( arg1 , arg2 , arg3 , arg4 ,
|
nurbssurface( arg1 , arg2 , arg3 , arg4 ,
|
||||||
s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 );
|
s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 );
|
||||||
DEL(arg2);
|
PyMem_DEL(arg2);
|
||||||
DEL(arg4);
|
PyMem_DEL(arg4);
|
||||||
DEL(arg5);
|
PyMem_DEL(arg5);
|
||||||
INCREF(None);
|
Py_INCREF(Py_None);
|
||||||
return None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nurbscurve(knots, ctlpoints, order, type).
|
/* nurbscurve(knots, ctlpoints, order, type).
|
||||||
|
@ -369,10 +366,10 @@ gl_nurbssurface(self, args)
|
||||||
|
|
||||||
%nurbscurve
|
%nurbscurve
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_nurbscurve(self, args)
|
gl_nurbscurve(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
long arg1 ;
|
long arg1 ;
|
||||||
double * arg2 ;
|
double * arg2 ;
|
||||||
|
@ -382,49 +379,49 @@ gl_nurbscurve(self, args)
|
||||||
long arg6 ;
|
long arg6 ;
|
||||||
int ncoords, npoints;
|
int ncoords, npoints;
|
||||||
int i;
|
int i;
|
||||||
object *v;
|
PyObject *v;
|
||||||
double *pnext;
|
double *pnext;
|
||||||
if (!getilongarraysize(args, 4, 0, &arg1))
|
if (!PyArg_GetLongArraySize(args, 4, 0, &arg1))
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((arg2 = NEW(double, arg1 )) == NULL) {
|
if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) {
|
||||||
return err_nomem();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
if (!getidoublearray(args, 4, 0, arg1 , arg2))
|
if (!PyArg_GetDoubleArray(args, 4, 0, arg1 , arg2))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 4, 2, &arg5))
|
if (!PyArg_GetLong(args, 4, 2, &arg5))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 4, 3, &arg6))
|
if (!PyArg_GetLong(args, 4, 3, &arg6))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (arg6 == N_ST)
|
if (arg6 == N_ST)
|
||||||
ncoords = 2;
|
ncoords = 2;
|
||||||
else if (arg6 == N_STW)
|
else if (arg6 == N_STW)
|
||||||
ncoords = 3;
|
ncoords = 3;
|
||||||
else {
|
else {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
npoints = arg1 - arg5;
|
npoints = arg1 - arg5;
|
||||||
if (!getiobjectarg(args, 4, 1, &v))
|
if (!PyArg_GetObject(args, 4, 1, &v))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!is_listobject(v) || getlistsize(v) != npoints) {
|
if (!PyList_Check(v) || PyList_Size(v) != npoints) {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((arg4 = NEW(double, npoints*ncoords )) == NULL) {
|
if ((arg4 = PyMem_NEW(double, npoints*ncoords )) == NULL) {
|
||||||
return err_nomem();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
pnext = arg4;
|
pnext = arg4;
|
||||||
for (i = 0; i < npoints; i++) {
|
for (i = 0; i < npoints; i++) {
|
||||||
if (!getidoublearray(getlistitem(v, i), 1, 0, ncoords, pnext))
|
if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext))
|
||||||
return NULL;
|
return NULL;
|
||||||
pnext += ncoords;
|
pnext += ncoords;
|
||||||
}
|
}
|
||||||
arg3 = (sizeof(double)) * ncoords;
|
arg3 = (sizeof(double)) * ncoords;
|
||||||
nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 );
|
nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 );
|
||||||
DEL(arg2);
|
PyMem_DEL(arg2);
|
||||||
DEL(arg4);
|
PyMem_DEL(arg4);
|
||||||
INCREF(None);
|
Py_INCREF(Py_None);
|
||||||
return None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pwlcurve(points, type).
|
/* pwlcurve(points, type).
|
||||||
|
@ -432,44 +429,44 @@ gl_nurbscurve(self, args)
|
||||||
|
|
||||||
%pwlcurve
|
%pwlcurve
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_pwlcurve(self, args)
|
gl_pwlcurve(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
object *v;
|
PyObject *v;
|
||||||
long type;
|
long type;
|
||||||
double *data, *pnext;
|
double *data, *pnext;
|
||||||
long npoints, ncoords;
|
long npoints, ncoords;
|
||||||
int i;
|
int i;
|
||||||
if (!getiobjectarg(args, 2, 0, &v))
|
if (!PyArg_GetObject(args, 2, 0, &v))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 2, 1, &type))
|
if (!PyArg_GetLong(args, 2, 1, &type))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!is_listobject(v)) {
|
if (!PyList_Check(v)) {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
npoints = getlistsize(v);
|
npoints = PyList_Size(v);
|
||||||
if (type == N_ST)
|
if (type == N_ST)
|
||||||
ncoords = 2;
|
ncoords = 2;
|
||||||
else {
|
else {
|
||||||
err_badarg();
|
PyErr_BadArgument();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((data = NEW(double, npoints*ncoords)) == NULL) {
|
if ((data = PyMem_NEW(double, npoints*ncoords)) == NULL) {
|
||||||
return err_nomem();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
pnext = data;
|
pnext = data;
|
||||||
for (i = 0; i < npoints; i++) {
|
for (i = 0; i < npoints; i++) {
|
||||||
if (!getidoublearray(getlistitem(v, i), 1, 0, ncoords, pnext))
|
if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext))
|
||||||
return NULL;
|
return NULL;
|
||||||
pnext += ncoords;
|
pnext += ncoords;
|
||||||
}
|
}
|
||||||
pwlcurve(npoints, data, sizeof(double)*ncoords, type);
|
pwlcurve(npoints, data, sizeof(double)*ncoords, type);
|
||||||
DEL(data);
|
PyMem_DEL(data);
|
||||||
INCREF(None);
|
Py_INCREF(Py_None);
|
||||||
return None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -478,37 +475,37 @@ gl_pwlcurve(self, args)
|
||||||
static short *pickbuffer = NULL;
|
static short *pickbuffer = NULL;
|
||||||
static long pickbuffersize;
|
static long pickbuffersize;
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
pick_select(args, func)
|
pick_select(args, func)
|
||||||
object *args;
|
PyObject *args;
|
||||||
void (*func)();
|
void (*func)();
|
||||||
{
|
{
|
||||||
if (!getilongarg(args, 1, 0, &pickbuffersize))
|
if (!PyArg_GetLong(args, 1, 0, &pickbuffersize))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (pickbuffer != NULL) {
|
if (pickbuffer != NULL) {
|
||||||
err_setstr(RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"pick/gselect: already picking/selecting");
|
"pick/gselect: already picking/selecting");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((pickbuffer = NEW(short, pickbuffersize)) == NULL) {
|
if ((pickbuffer = PyMem_NEW(short, pickbuffersize)) == NULL) {
|
||||||
return err_nomem();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
(*func)(pickbuffer, pickbuffersize);
|
(*func)(pickbuffer, pickbuffersize);
|
||||||
INCREF(None);
|
Py_INCREF(Py_None);
|
||||||
return None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
endpick_select(args, func)
|
endpick_select(args, func)
|
||||||
object *args;
|
PyObject *args;
|
||||||
long (*func)();
|
long (*func)();
|
||||||
{
|
{
|
||||||
object *v, *w;
|
PyObject *v, *w;
|
||||||
int i, nhits, n;
|
int i, nhits, n;
|
||||||
if (!getnoarg(args))
|
if (!PyArg_NoArgs(args))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (pickbuffer == NULL) {
|
if (pickbuffer == NULL) {
|
||||||
err_setstr(RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"endpick/endselect: not in pick/select mode");
|
"endpick/endselect: not in pick/select mode");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -521,20 +518,20 @@ endpick_select(args, func)
|
||||||
for (; nhits > 0; nhits--) {
|
for (; nhits > 0; nhits--) {
|
||||||
n += 1 + pickbuffer[n];
|
n += 1 + pickbuffer[n];
|
||||||
}
|
}
|
||||||
v = newlistobject(n);
|
v = PyList_New(n);
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* XXX Could do it nicer and interpret the data structure here,
|
/* XXX Could do it nicer and interpret the data structure here,
|
||||||
returning a list of lists. But this can be done in Python... */
|
returning a list of lists. But this can be done in Python... */
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
w = newintobject((long)pickbuffer[i]);
|
w = PyInt_FromLong((long)pickbuffer[i]);
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
DECREF(v);
|
Py_DECREF(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
setlistitem(v, i, w);
|
PyList_SetItem(v, i, w);
|
||||||
}
|
}
|
||||||
DEL(pickbuffer);
|
PyMem_DEL(pickbuffer);
|
||||||
pickbuffer = NULL;
|
pickbuffer = NULL;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -543,22 +540,22 @@ extern void pick(), gselect();
|
||||||
extern long endpick(), endselect();
|
extern long endpick(), endselect();
|
||||||
|
|
||||||
%pick
|
%pick
|
||||||
static object *gl_pick(self, args) object *self, *args; {
|
static PyObject *gl_pick(self, args) PyObject *self, *args; {
|
||||||
return pick_select(args, pick);
|
return pick_select(args, pick);
|
||||||
}
|
}
|
||||||
|
|
||||||
%endpick
|
%endpick
|
||||||
static object *gl_endpick(self, args) object *self, *args; {
|
static PyObject *gl_endpick(self, args) PyObject *self, *args; {
|
||||||
return endpick_select(args, endpick);
|
return endpick_select(args, endpick);
|
||||||
}
|
}
|
||||||
|
|
||||||
%gselect
|
%gselect
|
||||||
static object *gl_gselect(self, args) object *self, *args; {
|
static PyObject *gl_gselect(self, args) PyObject *self, *args; {
|
||||||
return pick_select(args, gselect);
|
return pick_select(args, gselect);
|
||||||
}
|
}
|
||||||
|
|
||||||
%endselect
|
%endselect
|
||||||
static object *gl_endselect(self, args) object *self, *args; {
|
static PyObject *gl_endselect(self, args) PyObject *self, *args; {
|
||||||
return endpick_select(args, endselect);
|
return endpick_select(args, endselect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,26 +566,26 @@ static object *gl_endselect(self, args) object *self, *args; {
|
||||||
|
|
||||||
% getmatrix float r[16]
|
% getmatrix float r[16]
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_getmatrix(self, args)
|
gl_getmatrix(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
Matrix arg1;
|
Matrix arg1;
|
||||||
object *v, *w;
|
PyObject *v, *w;
|
||||||
int i, j;
|
int i, j;
|
||||||
getmatrix( arg1 );
|
getmatrix( arg1 );
|
||||||
v = newlistobject(16);
|
v = PyList_New(16);
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
return err_nomem();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) {
|
for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) {
|
||||||
w = mknewfloatobject(arg1[i][j]);
|
w = mknewfloatobject(arg1[i][j]);
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
DECREF(v);
|
Py_DECREF(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
setlistitem(v, i*4+j, w);
|
PyList_SetItem(v, i*4+j, w);
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -599,35 +596,35 @@ gl_getmatrix(self, args)
|
||||||
|
|
||||||
% altgetmatrix float r[4][4]
|
% altgetmatrix float r[4][4]
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_altgetmatrix(self, args)
|
gl_altgetmatrix(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
Matrix arg1;
|
Matrix arg1;
|
||||||
object *v, *w;
|
PyObject *v, *w;
|
||||||
int i, j;
|
int i, j;
|
||||||
getmatrix( arg1 );
|
getmatrix( arg1 );
|
||||||
v = newlistobject(4);
|
v = PyList_New(4);
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
w = newlistobject(4);
|
w = PyList_New(4);
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
DECREF(v);
|
Py_DECREF(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
setlistitem(v, i, w);
|
PyList_SetItem(v, i, w);
|
||||||
}
|
}
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
w = mknewfloatobject(arg1[i][j]);
|
w = mknewfloatobject(arg1[i][j]);
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
DECREF(v);
|
Py_DECREF(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
setlistitem(getlistitem(v, i), j, w);
|
PyList_SetItem(PyList_GetItem(v, i), j, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
|
@ -635,99 +632,99 @@ gl_altgetmatrix(self, args)
|
||||||
|
|
||||||
% lrectwrite
|
% lrectwrite
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_lrectwrite(self, args)
|
gl_lrectwrite(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
short x1 ;
|
short x1 ;
|
||||||
short y1 ;
|
short y1 ;
|
||||||
short x2 ;
|
short x2 ;
|
||||||
short y2 ;
|
short y2 ;
|
||||||
string parray ;
|
string parray ;
|
||||||
object *s;
|
PyObject *s;
|
||||||
#if 0
|
#if 0
|
||||||
int pixcount;
|
int pixcount;
|
||||||
#endif
|
#endif
|
||||||
if (!getishortarg(args, 5, 0, &x1))
|
if (!PyArg_GetShort(args, 5, 0, &x1))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getishortarg(args, 5, 1, &y1))
|
if (!PyArg_GetShort(args, 5, 1, &y1))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getishortarg(args, 5, 2, &x2))
|
if (!PyArg_GetShort(args, 5, 2, &x2))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getishortarg(args, 5, 3, &y2))
|
if (!PyArg_GetShort(args, 5, 3, &y2))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getistringarg(args, 5, 4, &parray))
|
if (!PyArg_GetString(args, 5, 4, &parray))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getiobjectarg(args, 5, 4, &s))
|
if (!PyArg_GetObject(args, 5, 4, &s))
|
||||||
return NULL;
|
return NULL;
|
||||||
#if 0
|
#if 0
|
||||||
/* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */
|
/* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */
|
||||||
pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
|
pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
|
||||||
if (!is_stringobject(s) || getstringsize(s) != pixcount*sizeof(long)) {
|
if (!PyString_Check(s) || PyString_Size(s) != pixcount*sizeof(long)) {
|
||||||
err_setstr(RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"string arg to lrectwrite has wrong size");
|
"string arg to lrectwrite has wrong size");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray );
|
lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray );
|
||||||
INCREF(None);
|
Py_INCREF(Py_None);
|
||||||
return None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
% lrectread
|
% lrectread
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_lrectread(self, args)
|
gl_lrectread(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
short x1 ;
|
short x1 ;
|
||||||
short y1 ;
|
short y1 ;
|
||||||
short x2 ;
|
short x2 ;
|
||||||
short y2 ;
|
short y2 ;
|
||||||
object *parray;
|
PyObject *parray;
|
||||||
int pixcount;
|
int pixcount;
|
||||||
if (!getishortarg(args, 4, 0, &x1))
|
if (!PyArg_GetShort(args, 4, 0, &x1))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getishortarg(args, 4, 1, &y1))
|
if (!PyArg_GetShort(args, 4, 1, &y1))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getishortarg(args, 4, 2, &x2))
|
if (!PyArg_GetShort(args, 4, 2, &x2))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getishortarg(args, 4, 3, &y2))
|
if (!PyArg_GetShort(args, 4, 3, &y2))
|
||||||
return NULL;
|
return NULL;
|
||||||
pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
|
pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
|
||||||
parray = newsizedstringobject((char *)NULL, pixcount*sizeof(long));
|
parray = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
|
||||||
if (parray == NULL)
|
if (parray == NULL)
|
||||||
return NULL; /* No memory */
|
return NULL; /* No memory */
|
||||||
lrectread(x1, y1, x2, y2, (unsigned long *) getstringvalue(parray));
|
lrectread(x1, y1, x2, y2, (unsigned long *) PyString_AsString(parray));
|
||||||
return parray;
|
return parray;
|
||||||
}
|
}
|
||||||
|
|
||||||
% readdisplay
|
% readdisplay
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_readdisplay(self, args)
|
gl_readdisplay(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
short x1, y1, x2, y2;
|
short x1, y1, x2, y2;
|
||||||
unsigned long *parray, hints;
|
unsigned long *parray, hints;
|
||||||
long size, size_ret;
|
long size, size_ret;
|
||||||
object *rv;
|
PyObject *rv;
|
||||||
|
|
||||||
if ( !getargs(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) )
|
if ( !PyArg_Parse(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) )
|
||||||
return 0;
|
return 0;
|
||||||
size = (long)(x2+1-x1) * (long)(y2+1-y1);
|
size = (long)(x2+1-x1) * (long)(y2+1-y1);
|
||||||
rv = newsizedstringobject((char *)NULL, size*sizeof(long));
|
rv = PyString_FromStringAndSize((char *)NULL, size*sizeof(long));
|
||||||
if ( rv == NULL )
|
if ( rv == NULL )
|
||||||
return NULL;
|
return NULL;
|
||||||
parray = (unsigned long *)getstringvalue(rv);
|
parray = (unsigned long *)PyString_AsString(rv);
|
||||||
size_ret = readdisplay(x1, y1, x2, y2, parray, hints);
|
size_ret = readdisplay(x1, y1, x2, y2, parray, hints);
|
||||||
if ( size_ret != size ) {
|
if ( size_ret != size ) {
|
||||||
printf("gl_readdisplay: got %ld pixels, expected %ld\n",
|
printf("gl_readdisplay: got %ld pixels, expected %ld\n",
|
||||||
size_ret, size);
|
size_ret, size);
|
||||||
err_setstr(RuntimeError, "readdisplay returned unexpected length");
|
PyErr_SetString(PyExc_RuntimeError, "readdisplay returned unexpected length");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -751,45 +748,45 @@ gl_readdisplay(self, args)
|
||||||
|
|
||||||
% packrect
|
% packrect
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_packrect(self, args)
|
gl_packrect(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
long width, height, packfactor;
|
long width, height, packfactor;
|
||||||
char *s;
|
char *s;
|
||||||
object *unpacked, *packed;
|
PyObject *unpacked, *packed;
|
||||||
int pixcount, packedcount, x, y, r, g, b;
|
int pixcount, packedcount, x, y, r, g, b;
|
||||||
unsigned long pixel;
|
unsigned long pixel;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
unsigned long *parray;
|
unsigned long *parray;
|
||||||
if (!getilongarg(args, 4, 0, &width))
|
if (!PyArg_GetLong(args, 4, 0, &width))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 4, 1, &height))
|
if (!PyArg_GetLong(args, 4, 1, &height))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 4, 2, &packfactor))
|
if (!PyArg_GetLong(args, 4, 2, &packfactor))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getistringarg(args, 4, 3, &s)) /* For type checking only */
|
if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getiobjectarg(args, 4, 3, &unpacked))
|
if (!PyArg_GetObject(args, 4, 3, &unpacked))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (width <= 0 || height <= 0 || packfactor <= 0) {
|
if (width <= 0 || height <= 0 || packfactor <= 0) {
|
||||||
err_setstr(RuntimeError, "packrect args must be > 0");
|
PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pixcount = width*height;
|
pixcount = width*height;
|
||||||
packedcount = ((width+packfactor-1)/packfactor) *
|
packedcount = ((width+packfactor-1)/packfactor) *
|
||||||
((height+packfactor-1)/packfactor);
|
((height+packfactor-1)/packfactor);
|
||||||
if (getstringsize(unpacked) != pixcount*sizeof(long)) {
|
if (PyString_Size(unpacked) != pixcount*sizeof(long)) {
|
||||||
err_setstr(RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"string arg to packrect has wrong size");
|
"string arg to packrect has wrong size");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
packed = newsizedstringobject((char *)NULL, packedcount);
|
packed = PyString_FromStringAndSize((char *)NULL, packedcount);
|
||||||
if (packed == NULL)
|
if (packed == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
parray = (unsigned long *) getstringvalue(unpacked);
|
parray = (unsigned long *) PyString_AsString(unpacked);
|
||||||
p = (unsigned char *) getstringvalue(packed);
|
p = (unsigned char *) PyString_AsString(packed);
|
||||||
for (y = 0; y < height; y += packfactor, parray += packfactor*width) {
|
for (y = 0; y < height; y += packfactor, parray += packfactor*width) {
|
||||||
for (x = 0; x < width; x += packfactor) {
|
for (x = 0; x < width; x += packfactor) {
|
||||||
pixel = parray[x];
|
pixel = parray[x];
|
||||||
|
@ -807,14 +804,14 @@ gl_packrect(self, args)
|
||||||
static unsigned long unpacktab[256];
|
static unsigned long unpacktab[256];
|
||||||
static int unpacktab_inited = 0;
|
static int unpacktab_inited = 0;
|
||||||
|
|
||||||
static object *
|
static PyObject *
|
||||||
gl_unpackrect(self, args)
|
gl_unpackrect(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
long width, height, packfactor;
|
long width, height, packfactor;
|
||||||
char *s;
|
char *s;
|
||||||
object *unpacked, *packed;
|
PyObject *unpacked, *packed;
|
||||||
int pixcount, packedcount;
|
int pixcount, packedcount;
|
||||||
register unsigned char *p;
|
register unsigned char *p;
|
||||||
register unsigned long *parray;
|
register unsigned long *parray;
|
||||||
|
@ -824,33 +821,33 @@ gl_unpackrect(self, args)
|
||||||
unpacktab[white] = white * 0x010101L;
|
unpacktab[white] = white * 0x010101L;
|
||||||
unpacktab_inited++;
|
unpacktab_inited++;
|
||||||
}
|
}
|
||||||
if (!getilongarg(args, 4, 0, &width))
|
if (!PyArg_GetLong(args, 4, 0, &width))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 4, 1, &height))
|
if (!PyArg_GetLong(args, 4, 1, &height))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getilongarg(args, 4, 2, &packfactor))
|
if (!PyArg_GetLong(args, 4, 2, &packfactor))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getistringarg(args, 4, 3, &s)) /* For type checking only */
|
if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!getiobjectarg(args, 4, 3, &packed))
|
if (!PyArg_GetObject(args, 4, 3, &packed))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (width <= 0 || height <= 0 || packfactor <= 0) {
|
if (width <= 0 || height <= 0 || packfactor <= 0) {
|
||||||
err_setstr(RuntimeError, "packrect args must be > 0");
|
PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pixcount = width*height;
|
pixcount = width*height;
|
||||||
packedcount = ((width+packfactor-1)/packfactor) *
|
packedcount = ((width+packfactor-1)/packfactor) *
|
||||||
((height+packfactor-1)/packfactor);
|
((height+packfactor-1)/packfactor);
|
||||||
if (getstringsize(packed) != packedcount) {
|
if (PyString_Size(packed) != packedcount) {
|
||||||
err_setstr(RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"string arg to unpackrect has wrong size");
|
"string arg to unpackrect has wrong size");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
unpacked = newsizedstringobject((char *)NULL, pixcount*sizeof(long));
|
unpacked = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
|
||||||
if (unpacked == NULL)
|
if (unpacked == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
parray = (unsigned long *) getstringvalue(unpacked);
|
parray = (unsigned long *) PyString_AsString(unpacked);
|
||||||
p = (unsigned char *) getstringvalue(packed);
|
p = (unsigned char *) PyString_AsString(packed);
|
||||||
if (packfactor == 1 && width*height > 0) {
|
if (packfactor == 1 && width*height > 0) {
|
||||||
/* Just expand bytes to longs */
|
/* Just expand bytes to longs */
|
||||||
register int x = width * height;
|
register int x = width * height;
|
||||||
|
@ -878,14 +875,14 @@ gl_unpackrect(self, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
% gversion
|
% gversion
|
||||||
static object *
|
static PyObject *
|
||||||
gl_gversion(self, args)
|
gl_gversion(self, args)
|
||||||
object *self;
|
PyObject *self;
|
||||||
object *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
char buf[20];
|
char buf[20];
|
||||||
gversion(buf);
|
gversion(buf);
|
||||||
return newstringobject(buf);
|
return PyString_FromString(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue