Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0a3eaf08
Kaydet (Commit)
0a3eaf08
authored
Nis 29, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Quickly renamed.
üst
fb221562
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
247 additions
and
250 deletions
+247
-250
cgen.py
Modules/cgen.py
+13
-13
cstubs
Modules/cstubs
+234
-237
No files found.
Modules/cgen.py
Dosyayı görüntüle @
0a3eaf08
...
...
@@ -230,10 +230,10 @@ def generate(type, func, database):
# Stub header
#
print
print
'static
o
bject *'
print
'static
PyO
bject *'
print
'gl_'
+
func
+
'(self, args)'
print
'
\t
o
bject *self;'
print
'
\t
o
bject *args;'
print
'
\t
PyO
bject *self;'
print
'
\t
PyO
bject *args;'
print
'{'
#
# Declare return value if any
...
...
@@ -317,11 +317,11 @@ def generate(type, func, database):
print
'
\t
if ((arg'
+
`i+1`
,
'='
,
if
a_factor
:
print
'('
+
a_type
+
'(*)['
+
a_factor
+
'])'
,
print
'NEW('
+
a_type
,
','
,
print
'
PyMem_
NEW('
+
a_type
,
','
,
if
a_factor
:
print
a_factor
,
'*'
,
print
a_sub
,
')) == NULL)'
print
'
\t\t
return
err_nomem
();'
print
'
\t\t
return
PyErr_NoMemory
();'
print
'
\t
if'
,
if
a_factor
or
a_sub
:
# Get a fixed-size array array
print
'(!geti'
+
xtype
+
'array(args,'
,
...
...
@@ -368,7 +368,7 @@ def generate(type, func, database):
for
i
in
range
(
len
(
database
)):
a_type
,
a_mode
,
a_factor
,
a_sub
=
database
[
i
]
if
a_mode
==
's'
and
a_sub
and
not
isnum
(
a_sub
):
print
'
\t
DEL(arg'
+
`i+1`
+
');'
print
'
\t
PyMem_
DEL(arg'
+
`i+1`
+
');'
#
# Return
#
...
...
@@ -388,19 +388,19 @@ def generate(type, func, database):
print
'
\t
return'
,
print
mkobject
(
a_type
,
'arg'
+
`i+1`
)
+
';'
else
:
print
'
\t
{
object *v = newtupleobject
('
,
print
'
\t
{
PyObject *v = PyTuple_New
('
,
print
n_out_args
,
');'
print
'
\t
if (v == NULL) return NULL;'
i_out
=
0
if
type
<>
'void'
:
print
'
\t
settuplei
tem(v,'
,
print
'
\t
PyTuple_SetI
tem(v,'
,
print
`i_out`
+
','
,
print
mkobject
(
type
,
'retval'
)
+
');'
i_out
=
i_out
+
1
for
i
in
range
(
len
(
database
)):
a_type
,
a_mode
,
a_factor
,
a_sub
=
database
[
i
]
if
a_mode
==
'r'
:
print
'
\t
settuplei
tem(v,'
,
print
'
\t
PyTuple_SetI
tem(v,'
,
print
`i_out`
+
','
,
s
=
mkobject
(
a_type
,
'arg'
+
`i+1`
)
print
s
+
');'
...
...
@@ -413,8 +413,8 @@ def generate(type, func, database):
# Return None or return value
#
if
type
==
'void'
:
print
'
\t
INCREF(
None);'
print
'
\t
return None;'
print
'
\t
Py_INCREF(Py_
None);'
print
'
\t
return
Py_
None;'
else
:
print
'
\t
return'
,
mkobject
(
type
,
'retval'
)
+
';'
#
...
...
@@ -527,7 +527,7 @@ while 1:
print
print
'static struct
methodlist
gl_methods[] = {'
print
'static struct
PyMethodDef
gl_methods[] = {'
for
func
in
functions
:
print
'
\t
{"'
+
func
+
'", gl_'
+
func
+
'},'
print
'
\t
{NULL, NULL} /* Sentinel */'
...
...
@@ -536,5 +536,5 @@ print
print
'void'
print
'initgl()'
print
'{'
print
'
\t
initm
odule("gl", gl_methods);'
print
'
\t
Py_InitM
odule("gl", gl_methods);'
print
'}'
Modules/cstubs
Dosyayı görüntüle @
0a3eaf08
...
...
@@ -78,11 +78,8 @@ extern int gewrite();
extern int gettp();
#endif
#include "allobjects.h"
#include "import.h"
#include "modsupport.h"
#include "Python.h"
#include "cgensupport.h"
#include "ceval.h"
/*
Some stubs are too complicated for the stub generator.
...
...
@@ -93,20 +90,20 @@ generator can include it in the table of functions.
% qread
static
o
bject *
static
PyO
bject *
gl_qread(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
long retval;
short arg1 ;
BGN_SAVE
Py_BEGIN_ALLOW_THREADS
retval = qread( & arg1 );
END_SAVE
{
object *v = newtupleobject
( 2 );
Py_END_ALLOW_THREADS
{
PyObject *v = PyTuple_New
( 2 );
if (v == NULL) return NULL;
settuplei
tem(v, 0, mknewlongobject(retval));
settuplei
tem(v, 1, mknewshortobject(arg1));
PyTuple_SetI
tem(v, 0, mknewlongobject(retval));
PyTuple_SetI
tem(v, 1, mknewshortobject(arg1));
return v;
}
}
...
...
@@ -125,35 +122,35 @@ and for each point v3d() is called.
% varray
static
o
bject *
static
PyO
bject *
gl_varray(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
o
bject *v, *w=NULL;
PyO
bject *v, *w=NULL;
int i, n, width;
double vec[3];
object * (*getitem) FPROTO((o
bject *, int));
PyObject * (*getitem) Py_FPROTO((PyO
bject *, int));
if (!
getiobjectarg
(args, 1, 0, &v))
if (!
PyArg_GetObject
(args, 1, 0, &v))
return NULL;
if (
is_listobject
(v)) {
n =
getlists
ize(v);
getitem =
getlisti
tem;
if (
PyList_Check
(v)) {
n =
PyList_S
ize(v);
getitem =
PyList_GetI
tem;
}
else if (
is_tupleobject
(v)) {
n =
gettuples
ize(v);
getitem =
gettuplei
tem;
else if (
PyTuple_Check
(v)) {
n =
PyTuple_S
ize(v);
getitem =
PyTuple_GetI
tem;
}
else {
err_badarg
();
PyErr_BadArgument
();
return NULL;
}
if (n == 0) {
INCREF(
None);
return None;
Py_INCREF(Py_
None);
return
Py_
None;
}
if (n > 0)
w = (*getitem)(v, 0);
...
...
@@ -161,11 +158,11 @@ gl_varray(self, args)
width = 0;
if (w == NULL) {
}
else if (
is_listobject
(w)) {
width =
getlists
ize(w);
else if (
PyList_Check
(w)) {
width =
PyList_S
ize(w);
}
else if (
is_tupleobject
(w)) {
width =
gettuples
ize(w);
else if (
PyTuple_Check
(w)) {
width =
PyTuple_S
ize(w);
}
switch (width) {
...
...
@@ -175,19 +172,19 @@ gl_varray(self, args)
case 3:
break;
default:
err_badarg
();
PyErr_BadArgument
();
return NULL;
}
for (i = 0; i < n; i++) {
w = (*getitem)(v, i);
if (!
getidoublea
rray(w, 1, 0, width, vec))
if (!
PyArg_GetDoubleA
rray(w, 1, 0, width, vec))
return NULL;
v3d(vec);
}
INCREF(
None);
return None;
Py_INCREF(Py_
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).
*/
static
o
bject *gen_nvarray(); /* Forward */
static
PyO
bject *gen_nvarray(); /* Forward */
% nvarray
static
o
bject *
static
PyO
bject *
gl_nvarray(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
return gen_nvarray(args, 0);
}
% vnarray
static
o
bject *
static
PyO
bject *
gl_vnarray(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
return gen_nvarray(args, 1);
}
...
...
@@ -228,49 +225,49 @@ gl_vnarray(self, args)
/* Generic, internal version of {nv,nv}array: inorm indicates the
argument order, 0: normal first, 1: vector first. */
static
o
bject *
static
PyO
bject *
gen_nvarray(args, inorm)
o
bject *args;
PyO
bject *args;
int inorm;
{
o
bject *v, *w, *wnorm, *wvec;
PyO
bject *v, *w, *wnorm, *wvec;
int i, n;
float norm[3], vec[3];
object * (*getitem) FPROTO((o
bject *, int));
PyObject * (*getitem) Py_FPROTO((PyO
bject *, int));
if (!
getiobjectarg
(args, 1, 0, &v))
if (!
PyArg_GetObject
(args, 1, 0, &v))
return NULL;
if (
is_listobject
(v)) {
n =
getlists
ize(v);
getitem =
getlisti
tem;
if (
PyList_Check
(v)) {
n =
PyList_S
ize(v);
getitem =
PyList_GetI
tem;
}
else if (
is_tupleobject
(v)) {
n =
gettuples
ize(v);
getitem =
gettuplei
tem;
else if (
PyTuple_Check
(v)) {
n =
PyTuple_S
ize(v);
getitem =
PyTuple_GetI
tem;
}
else {
err_badarg
();
PyErr_BadArgument
();
return NULL;
}
for (i = 0; i < n; i++) {
w = (*getitem)(v, i);
if (!
is_tupleobject(w) || gettuples
ize(w) != 2) {
err_badarg
();
if (!
PyTuple_Check(w) || PyTuple_S
ize(w) != 2) {
PyErr_BadArgument
();
return NULL;
}
wnorm =
gettuplei
tem(w, inorm);
wvec =
gettuplei
tem(w, 1 - inorm);
if (!
getifloata
rray(wnorm, 1, 0, 3, norm) ||
!
getifloata
rray(wvec, 1, 0, 3, vec))
wnorm =
PyTuple_GetI
tem(w, inorm);
wvec =
PyTuple_GetI
tem(w, 1 - inorm);
if (!
PyArg_GetFloatA
rray(wnorm, 1, 0, 3, norm) ||
!
PyArg_GetFloatA
rray(wvec, 1, 0, 3, vec))
return NULL;
n3f(norm);
v3f(vec);
}
INCREF(
None);
return None;
Py_INCREF(Py_
None);
return
Py_
None;
}
/* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type).
...
...
@@ -280,10 +277,10 @@ gen_nvarray(args, inorm)
% nurbssurface
static
o
bject *
static
PyO
bject *
gl_nurbssurface(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
long arg1 ;
double * arg2 ;
...
...
@@ -297,58 +294,58 @@ gl_nurbssurface(self, args)
long s_byte_stride, t_byte_stride;
long s_nctl, t_nctl;
long s, t;
o
bject *v, *w, *pt;
PyO
bject *v, *w, *pt;
double *pnext;
if (!
getilongarrays
ize(args, 6, 0, &arg1))
if (!
PyArg_GetLongArrayS
ize(args, 6, 0, &arg1))
return NULL;
if ((arg2 = NEW(double, arg1 )) == NULL) {
return
err_nomem
();
if ((arg2 =
PyMem_
NEW(double, arg1 )) == NULL) {
return
PyErr_NoMemory
();
}
if (!
getidoublea
rray(args, 6, 0, arg1 , arg2))
if (!
PyArg_GetDoubleA
rray(args, 6, 0, arg1 , arg2))
return NULL;
if (!
getilongarrays
ize(args, 6, 1, &arg3))
if (!
PyArg_GetLongArrayS
ize(args, 6, 1, &arg3))
return NULL;
if ((arg4 = NEW(double, arg3 )) == NULL) {
return
err_nomem
();
if ((arg4 =
PyMem_
NEW(double, arg3 )) == NULL) {
return
PyErr_NoMemory
();
}
if (!
getidoublea
rray(args, 6, 1, arg3 , arg4))
if (!
PyArg_GetDoubleA
rray(args, 6, 1, arg3 , arg4))
return NULL;
if (!
getilongar
g(args, 6, 3, &arg6))
if (!
PyArg_GetLon
g(args, 6, 3, &arg6))
return NULL;
if (!
getilongar
g(args, 6, 4, &arg7))
if (!
PyArg_GetLon
g(args, 6, 4, &arg7))
return NULL;
if (!
getilongar
g(args, 6, 5, &arg8))
if (!
PyArg_GetLon
g(args, 6, 5, &arg8))
return NULL;
if (arg8 == N_XYZ)
ncoords = 3;
else if (arg8 == N_XYZW)
ncoords = 4;
else {
err_badarg
();
PyErr_BadArgument
();
return NULL;
}
s_nctl = arg1 - arg6;
t_nctl = arg3 - arg7;
if (!
getiobjectarg
(args, 6, 2, &v))
if (!
PyArg_GetObject
(args, 6, 2, &v))
return NULL;
if (!
is_listobject(v) || getlists
ize(v) != s_nctl) {
err_badarg
();
if (!
PyList_Check(v) || PyList_S
ize(v) != s_nctl) {
PyErr_BadArgument
();
return NULL;
}
if ((arg5 = NEW(double, s_nctl*t_nctl*ncoords )) == NULL) {
return
err_nomem
();
if ((arg5 =
PyMem_
NEW(double, s_nctl*t_nctl*ncoords )) == NULL) {
return
PyErr_NoMemory
();
}
pnext = arg5;
for (s = 0; s < s_nctl; s++) {
w =
getlisti
tem(v, s);
if (w == NULL || !
is_listobject
(w) ||
getlists
ize(w) != t_nctl) {
err_badarg
();
w =
PyList_GetI
tem(v, s);
if (w == NULL || !
PyList_Check
(w) ||
PyList_S
ize(w) != t_nctl) {
PyErr_BadArgument
();
return NULL;
}
for (t = 0; t < t_nctl; t++) {
pt =
getlisti
tem(w, t);
if (!
getidoublea
rray(pt, 1, 0, ncoords, pnext))
pt =
PyList_GetI
tem(w, t);
if (!
PyArg_GetDoubleA
rray(pt, 1, 0, ncoords, pnext))
return NULL;
pnext += ncoords;
}
...
...
@@ -357,11 +354,11 @@ gl_nurbssurface(self, args)
t_byte_stride = s_byte_stride * s_nctl;
nurbssurface( arg1 , arg2 , arg3 , arg4 ,
s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 );
DEL(arg2);
DEL(arg4);
DEL(arg5);
INCREF(
None);
return None;
PyMem_
DEL(arg2);
PyMem_
DEL(arg4);
PyMem_
DEL(arg5);
Py_INCREF(Py_
None);
return
Py_
None;
}
/* nurbscurve(knots, ctlpoints, order, type).
...
...
@@ -369,10 +366,10 @@ gl_nurbssurface(self, args)
%nurbscurve
static
o
bject *
static
PyO
bject *
gl_nurbscurve(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
long arg1 ;
double * arg2 ;
...
...
@@ -382,49 +379,49 @@ gl_nurbscurve(self, args)
long arg6 ;
int ncoords, npoints;
int i;
o
bject *v;
PyO
bject *v;
double *pnext;
if (!
getilongarrays
ize(args, 4, 0, &arg1))
if (!
PyArg_GetLongArrayS
ize(args, 4, 0, &arg1))
return NULL;
if ((arg2 = NEW(double, arg1 )) == NULL) {
return
err_nomem
();
if ((arg2 =
PyMem_
NEW(double, arg1 )) == NULL) {
return
PyErr_NoMemory
();
}
if (!
getidoublea
rray(args, 4, 0, arg1 , arg2))
if (!
PyArg_GetDoubleA
rray(args, 4, 0, arg1 , arg2))
return NULL;
if (!
getilongar
g(args, 4, 2, &arg5))
if (!
PyArg_GetLon
g(args, 4, 2, &arg5))
return NULL;
if (!
getilongar
g(args, 4, 3, &arg6))
if (!
PyArg_GetLon
g(args, 4, 3, &arg6))
return NULL;
if (arg6 == N_ST)
ncoords = 2;
else if (arg6 == N_STW)
ncoords = 3;
else {
err_badarg
();
PyErr_BadArgument
();
return NULL;
}
npoints = arg1 - arg5;
if (!
getiobjectarg
(args, 4, 1, &v))
if (!
PyArg_GetObject
(args, 4, 1, &v))
return NULL;
if (!
is_listobject(v) || getlists
ize(v) != npoints) {
err_badarg
();
if (!
PyList_Check(v) || PyList_S
ize(v) != npoints) {
PyErr_BadArgument
();
return NULL;
}
if ((arg4 = NEW(double, npoints*ncoords )) == NULL) {
return
err_nomem
();
if ((arg4 =
PyMem_
NEW(double, npoints*ncoords )) == NULL) {
return
PyErr_NoMemory
();
}
pnext = arg4;
for (i = 0; i < npoints; i++) {
if (!
getidoublearray(getlisti
tem(v, i), 1, 0, ncoords, pnext))
if (!
PyArg_GetDoubleArray(PyList_GetI
tem(v, i), 1, 0, ncoords, pnext))
return NULL;
pnext += ncoords;
}
arg3 = (sizeof(double)) * ncoords;
nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 );
DEL(arg2);
DEL(arg4);
INCREF(
None);
return None;
PyMem_
DEL(arg2);
PyMem_
DEL(arg4);
Py_INCREF(Py_
None);
return
Py_
None;
}
/* pwlcurve(points, type).
...
...
@@ -432,44 +429,44 @@ gl_nurbscurve(self, args)
%pwlcurve
static
o
bject *
static
PyO
bject *
gl_pwlcurve(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
o
bject *v;
PyO
bject *v;
long type;
double *data, *pnext;
long npoints, ncoords;
int i;
if (!
getiobjectarg
(args, 2, 0, &v))
if (!
PyArg_GetObject
(args, 2, 0, &v))
return NULL;
if (!
getilongar
g(args, 2, 1, &type))
if (!
PyArg_GetLon
g(args, 2, 1, &type))
return NULL;
if (!
is_listobject
(v)) {
err_badarg
();
if (!
PyList_Check
(v)) {
PyErr_BadArgument
();
return NULL;
}
npoints =
getlists
ize(v);
npoints =
PyList_S
ize(v);
if (type == N_ST)
ncoords = 2;
else {
err_badarg
();
PyErr_BadArgument
();
return NULL;
}
if ((data = NEW(double, npoints*ncoords)) == NULL) {
return
err_nomem
();
if ((data =
PyMem_
NEW(double, npoints*ncoords)) == NULL) {
return
PyErr_NoMemory
();
}
pnext = data;
for (i = 0; i < npoints; i++) {
if (!
getidoublearray(getlisti
tem(v, i), 1, 0, ncoords, pnext))
if (!
PyArg_GetDoubleArray(PyList_GetI
tem(v, i), 1, 0, ncoords, pnext))
return NULL;
pnext += ncoords;
}
pwlcurve(npoints, data, sizeof(double)*ncoords, type);
DEL(data);
INCREF(
None);
return None;
PyMem_
DEL(data);
Py_INCREF(Py_
None);
return
Py_
None;
}
...
...
@@ -478,37 +475,37 @@ gl_pwlcurve(self, args)
static short *pickbuffer = NULL;
static long pickbuffersize;
static
o
bject *
static
PyO
bject *
pick_select(args, func)
o
bject *args;
PyO
bject *args;
void (*func)();
{
if (!
getilongar
g(args, 1, 0, &pickbuffersize))
if (!
PyArg_GetLon
g(args, 1, 0, &pickbuffersize))
return NULL;
if (pickbuffer != NULL) {
err_setstr(
RuntimeError,
PyErr_SetString(PyExc_
RuntimeError,
"pick/gselect: already picking/selecting");
return NULL;
}
if ((pickbuffer = NEW(short, pickbuffersize)) == NULL) {
return
err_nomem
();
if ((pickbuffer =
PyMem_
NEW(short, pickbuffersize)) == NULL) {
return
PyErr_NoMemory
();
}
(*func)(pickbuffer, pickbuffersize);
INCREF(
None);
return None;
Py_INCREF(Py_
None);
return
Py_
None;
}
static
o
bject *
static
PyO
bject *
endpick_select(args, func)
o
bject *args;
PyO
bject *args;
long (*func)();
{
o
bject *v, *w;
PyO
bject *v, *w;
int i, nhits, n;
if (!
getnoarg
(args))
if (!
PyArg_NoArgs
(args))
return NULL;
if (pickbuffer == NULL) {
err_setstr(
RuntimeError,
PyErr_SetString(PyExc_
RuntimeError,
"endpick/endselect: not in pick/select mode");
return NULL;
}
...
...
@@ -521,20 +518,20 @@ endpick_select(args, func)
for (; nhits > 0; nhits--) {
n += 1 + pickbuffer[n];
}
v =
newlistobject
(n);
v =
PyList_New
(n);
if (v == NULL)
return NULL;
/* XXX Could do it nicer and interpret the data structure here,
returning a list of lists. But this can be done in Python... */
for (i = 0; i < n; i++) {
w =
newintobject
((long)pickbuffer[i]);
w =
PyInt_FromLong
((long)pickbuffer[i]);
if (w == NULL) {
DECREF(v);
Py_
DECREF(v);
return NULL;
}
setlisti
tem(v, i, w);
PyList_SetI
tem(v, i, w);
}
DEL(pickbuffer);
PyMem_
DEL(pickbuffer);
pickbuffer = NULL;
return v;
}
...
...
@@ -543,22 +540,22 @@ extern void pick(), gselect();
extern long endpick(), endselect();
%pick
static
object *gl_pick(self, args) o
bject *self, *args; {
static
PyObject *gl_pick(self, args) PyO
bject *self, *args; {
return pick_select(args, pick);
}
%endpick
static
object *gl_endpick(self, args) o
bject *self, *args; {
static
PyObject *gl_endpick(self, args) PyO
bject *self, *args; {
return endpick_select(args, endpick);
}
%gselect
static
object *gl_gselect(self, args) o
bject *self, *args; {
static
PyObject *gl_gselect(self, args) PyO
bject *self, *args; {
return pick_select(args, gselect);
}
%endselect
static
object *gl_endselect(self, args) o
bject *self, *args; {
static
PyObject *gl_endselect(self, args) PyO
bject *self, *args; {
return endpick_select(args, endselect);
}
...
...
@@ -569,26 +566,26 @@ static object *gl_endselect(self, args) object *self, *args; {
% getmatrix float r[16]
static
o
bject *
static
PyO
bject *
gl_getmatrix(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
Matrix arg1;
o
bject *v, *w;
PyO
bject *v, *w;
int i, j;
getmatrix( arg1 );
v =
newlistobject
(16);
v =
PyList_New
(16);
if (v == NULL) {
return
err_nomem
();
return
PyErr_NoMemory
();
}
for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) {
w = mknewfloatobject(arg1[i][j]);
if (w == NULL) {
DECREF(v);
Py_
DECREF(v);
return NULL;
}
setlisti
tem(v, i*4+j, w);
PyList_SetI
tem(v, i*4+j, w);
}
return v;
}
...
...
@@ -599,35 +596,35 @@ gl_getmatrix(self, args)
% altgetmatrix float r[4][4]
static
o
bject *
static
PyO
bject *
gl_altgetmatrix(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
Matrix arg1;
o
bject *v, *w;
PyO
bject *v, *w;
int i, j;
getmatrix( arg1 );
v =
newlistobject
(4);
v =
PyList_New
(4);
if (v == NULL) {
return NULL;
}
for (i = 0; i < 4; i++) {
w =
newlistobject
(4);
w =
PyList_New
(4);
if (w == NULL) {
DECREF(v);
Py_
DECREF(v);
return NULL;
}
setlisti
tem(v, i, w);
PyList_SetI
tem(v, i, w);
}
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
w = mknewfloatobject(arg1[i][j]);
if (w == NULL) {
DECREF(v);
Py_
DECREF(v);
return NULL;
}
setlistitem(getlisti
tem(v, i), j, w);
PyList_SetItem(PyList_GetI
tem(v, i), j, w);
}
}
return v;
...
...
@@ -635,99 +632,99 @@ gl_altgetmatrix(self, args)
% lrectwrite
static
o
bject *
static
PyO
bject *
gl_lrectwrite(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
short x1 ;
short y1 ;
short x2 ;
short y2 ;
string parray ;
o
bject *s;
PyO
bject *s;
#if 0
int pixcount;
#endif
if (!
getishortarg
(args, 5, 0, &x1))
if (!
PyArg_GetShort
(args, 5, 0, &x1))
return NULL;
if (!
getishortarg
(args, 5, 1, &y1))
if (!
PyArg_GetShort
(args, 5, 1, &y1))
return NULL;
if (!
getishortarg
(args, 5, 2, &x2))
if (!
PyArg_GetShort
(args, 5, 2, &x2))
return NULL;
if (!
getishortarg
(args, 5, 3, &y2))
if (!
PyArg_GetShort
(args, 5, 3, &y2))
return NULL;
if (!
getistringar
g(args, 5, 4, &parray))
if (!
PyArg_GetStrin
g(args, 5, 4, &parray))
return NULL;
if (!
getiobjectarg
(args, 5, 4, &s))
if (!
PyArg_GetObject
(args, 5, 4, &s))
return NULL;
#if 0
/* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */
pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
if (!
is_stringobject(s) || getstrings
ize(s) != pixcount*sizeof(long)) {
err_setstr(
RuntimeError,
if (!
PyString_Check(s) || PyString_S
ize(s) != pixcount*sizeof(long)) {
PyErr_SetString(PyExc_
RuntimeError,
"string arg to lrectwrite has wrong size");
return NULL;
}
#endif
lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray );
INCREF(
None);
return None;
Py_INCREF(Py_
None);
return
Py_
None;
}
% lrectread
static
o
bject *
static
PyO
bject *
gl_lrectread(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
short x1 ;
short y1 ;
short x2 ;
short y2 ;
o
bject *parray;
PyO
bject *parray;
int pixcount;
if (!
getishortarg
(args, 4, 0, &x1))
if (!
PyArg_GetShort
(args, 4, 0, &x1))
return NULL;
if (!
getishortarg
(args, 4, 1, &y1))
if (!
PyArg_GetShort
(args, 4, 1, &y1))
return NULL;
if (!
getishortarg
(args, 4, 2, &x2))
if (!
PyArg_GetShort
(args, 4, 2, &x2))
return NULL;
if (!
getishortarg
(args, 4, 3, &y2))
if (!
PyArg_GetShort
(args, 4, 3, &y2))
return NULL;
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)
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;
}
% readdisplay
static
o
bject *
static
PyO
bject *
gl_readdisplay(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
short x1, y1, x2, y2;
unsigned long *parray, hints;
long size, size_ret;
o
bject *rv;
PyO
bject *rv;
if ( !
getargs
(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) )
if ( !
PyArg_Parse
(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) )
return 0;
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 )
return NULL;
parray = (unsigned long *)
getstringvalue
(rv);
parray = (unsigned long *)
PyString_AsString
(rv);
size_ret = readdisplay(x1, y1, x2, y2, parray, hints);
if ( size_ret != size ) {
printf("gl_readdisplay: got %ld pixels, expected %ld\n",
size_ret, size);
err_setstr(
RuntimeError, "readdisplay returned unexpected length");
PyErr_SetString(PyExc_
RuntimeError, "readdisplay returned unexpected length");
return NULL;
}
return rv;
...
...
@@ -751,45 +748,45 @@ gl_readdisplay(self, args)
% packrect
static
o
bject *
static
PyO
bject *
gl_packrect(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
long width, height, packfactor;
char *s;
o
bject *unpacked, *packed;
PyO
bject *unpacked, *packed;
int pixcount, packedcount, x, y, r, g, b;
unsigned long pixel;
unsigned char *p;
unsigned long *parray;
if (!
getilongar
g(args, 4, 0, &width))
if (!
PyArg_GetLon
g(args, 4, 0, &width))
return NULL;
if (!
getilongar
g(args, 4, 1, &height))
if (!
PyArg_GetLon
g(args, 4, 1, &height))
return NULL;
if (!
getilongar
g(args, 4, 2, &packfactor))
if (!
PyArg_GetLon
g(args, 4, 2, &packfactor))
return NULL;
if (!
getistringar
g(args, 4, 3, &s)) /* For type checking only */
if (!
PyArg_GetStrin
g(args, 4, 3, &s)) /* For type checking only */
return NULL;
if (!
getiobjectarg
(args, 4, 3, &unpacked))
if (!
PyArg_GetObject
(args, 4, 3, &unpacked))
return NULL;
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;
}
pixcount = width*height;
packedcount = ((width+packfactor-1)/packfactor) *
((height+packfactor-1)/packfactor);
if (
getstrings
ize(unpacked) != pixcount*sizeof(long)) {
err_setstr(
RuntimeError,
if (
PyString_S
ize(unpacked) != pixcount*sizeof(long)) {
PyErr_SetString(PyExc_
RuntimeError,
"string arg to packrect has wrong size");
return NULL;
}
packed =
newsizedstringobject
((char *)NULL, packedcount);
packed =
PyString_FromStringAndSize
((char *)NULL, packedcount);
if (packed == NULL)
return NULL;
parray = (unsigned long *)
getstringvalue
(unpacked);
p = (unsigned char *)
getstringvalue
(packed);
parray = (unsigned long *)
PyString_AsString
(unpacked);
p = (unsigned char *)
PyString_AsString
(packed);
for (y = 0; y < height; y += packfactor, parray += packfactor*width) {
for (x = 0; x < width; x += packfactor) {
pixel = parray[x];
...
...
@@ -807,14 +804,14 @@ gl_packrect(self, args)
static unsigned long unpacktab[256];
static int unpacktab_inited = 0;
static
o
bject *
static
PyO
bject *
gl_unpackrect(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
long width, height, packfactor;
char *s;
o
bject *unpacked, *packed;
PyO
bject *unpacked, *packed;
int pixcount, packedcount;
register unsigned char *p;
register unsigned long *parray;
...
...
@@ -824,33 +821,33 @@ gl_unpackrect(self, args)
unpacktab[white] = white * 0x010101L;
unpacktab_inited++;
}
if (!
getilongar
g(args, 4, 0, &width))
if (!
PyArg_GetLon
g(args, 4, 0, &width))
return NULL;
if (!
getilongar
g(args, 4, 1, &height))
if (!
PyArg_GetLon
g(args, 4, 1, &height))
return NULL;
if (!
getilongar
g(args, 4, 2, &packfactor))
if (!
PyArg_GetLon
g(args, 4, 2, &packfactor))
return NULL;
if (!
getistringar
g(args, 4, 3, &s)) /* For type checking only */
if (!
PyArg_GetStrin
g(args, 4, 3, &s)) /* For type checking only */
return NULL;
if (!
getiobjectarg
(args, 4, 3, &packed))
if (!
PyArg_GetObject
(args, 4, 3, &packed))
return NULL;
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;
}
pixcount = width*height;
packedcount = ((width+packfactor-1)/packfactor) *
((height+packfactor-1)/packfactor);
if (
getstrings
ize(packed) != packedcount) {
err_setstr(
RuntimeError,
if (
PyString_S
ize(packed) != packedcount) {
PyErr_SetString(PyExc_
RuntimeError,
"string arg to unpackrect has wrong size");
return NULL;
}
unpacked =
newsizedstringobject
((char *)NULL, pixcount*sizeof(long));
unpacked =
PyString_FromStringAndSize
((char *)NULL, pixcount*sizeof(long));
if (unpacked == NULL)
return NULL;
parray = (unsigned long *)
getstringvalue
(unpacked);
p = (unsigned char *)
getstringvalue
(packed);
parray = (unsigned long *)
PyString_AsString
(unpacked);
p = (unsigned char *)
PyString_AsString
(packed);
if (packfactor == 1 && width*height > 0) {
/* Just expand bytes to longs */
register int x = width * height;
...
...
@@ -878,14 +875,14 @@ gl_unpackrect(self, args)
}
% gversion
static
o
bject *
static
PyO
bject *
gl_gversion(self, args)
o
bject *self;
o
bject *args;
PyO
bject *self;
PyO
bject *args;
{
char buf[20];
gversion(buf);
return
newstringobject
(buf);
return
PyString_FromString
(buf);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment