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
2b65444b
Kaydet (Commit)
2b65444b
authored
Tem 30, 1996
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Converted to new style
üst
037b940c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
70 deletions
+70
-70
xxmodule.c
Modules/xxmodule.c
+70
-70
No files found.
Modules/xxmodule.c
Dosyayı görüntüle @
2b65444b
...
...
@@ -23,7 +23,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Use this file as a template to start implementing a module that
also declares objects types. All occurrences of '
x
xo' should be changed
also declares objects types. All occurrences of '
X
xo' should be changed
to something reasonable for your objects. After that, all other
occurrences of 'xx' should be changed to something reasonable for your
module. If your module is named foo your sourcefile should be named
...
...
@@ -37,25 +37,25 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Xxo objects */
#include "
allobjects
.h"
#include "
Python
.h"
static
o
bject
*
ErrorObject
;
static
PyO
bject
*
ErrorObject
;
typedef
struct
{
OB
_HEAD
o
bject
*
x_attr
;
/* Attributes dictionary */
}
xxoo
bject
;
PyObject
_HEAD
PyO
bject
*
x_attr
;
/* Attributes dictionary */
}
XxoO
bject
;
staticforward
typeobject
Xxot
ype
;
staticforward
PyTypeObject
Xxo_T
ype
;
#define
is_xxoobject(v) ((v)->ob_type == &Xxot
ype)
#define
XxoObject_Check(v) ((v)->ob_type == &Xxo_T
ype)
static
xxoo
bject
*
new
xxoo
bject
(
arg
)
o
bject
*
arg
;
static
XxoO
bject
*
new
XxoO
bject
(
arg
)
PyO
bject
*
arg
;
{
xxoo
bject
*
self
;
self
=
NEWOBJ
(
xxoobject
,
&
Xxot
ype
);
XxoO
bject
*
self
;
self
=
PyObject_NEW
(
XxoObject
,
&
Xxo_T
ype
);
if
(
self
==
NULL
)
return
NULL
;
self
->
x_attr
=
NULL
;
...
...
@@ -65,77 +65,77 @@ newxxoobject(arg)
/* Xxo methods */
static
void
x
xo_dealloc
(
self
)
xxoo
bject
*
self
;
X
xo_dealloc
(
self
)
XxoO
bject
*
self
;
{
XDECREF
(
self
->
x_attr
);
DEL
(
self
);
Py_
XDECREF
(
self
->
x_attr
);
PyMem_
DEL
(
self
);
}
static
o
bject
*
x
xo_demo
(
self
,
args
)
xxoo
bject
*
self
;
o
bject
*
args
;
static
PyO
bject
*
X
xo_demo
(
self
,
args
)
XxoO
bject
*
self
;
PyO
bject
*
args
;
{
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
INCREF
(
None
);
return
None
;
Py_INCREF
(
Py_
None
);
return
Py_
None
;
}
static
struct
methodlist
x
xo_methods
[]
=
{
{
"demo"
,
(
method
)
xxo_demo
},
static
PyMethodDef
X
xo_methods
[]
=
{
{
"demo"
,
(
PyCFunction
)
Xxo_demo
,
1
},
{
NULL
,
NULL
}
/* sentinel */
};
static
o
bject
*
x
xo_getattr
(
self
,
name
)
xxoo
bject
*
self
;
static
PyO
bject
*
X
xo_getattr
(
self
,
name
)
XxoO
bject
*
self
;
char
*
name
;
{
if
(
self
->
x_attr
!=
NULL
)
{
object
*
v
=
dictlookup
(
self
->
x_attr
,
name
);
PyObject
*
v
=
PyDict_GetItemString
(
self
->
x_attr
,
name
);
if
(
v
!=
NULL
)
{
INCREF
(
v
);
Py_
INCREF
(
v
);
return
v
;
}
}
return
findmethod
(
xxo_methods
,
(
o
bject
*
)
self
,
name
);
return
Py_FindMethod
(
Xxo_methods
,
(
PyO
bject
*
)
self
,
name
);
}
static
int
x
xo_setattr
(
self
,
name
,
v
)
xxoo
bject
*
self
;
X
xo_setattr
(
self
,
name
,
v
)
XxoO
bject
*
self
;
char
*
name
;
o
bject
*
v
;
PyO
bject
*
v
;
{
if
(
self
->
x_attr
==
NULL
)
{
self
->
x_attr
=
newdictobject
();
self
->
x_attr
=
PyDict_New
();
if
(
self
->
x_attr
==
NULL
)
return
-
1
;
}
if
(
v
==
NULL
)
{
int
rv
=
dictremove
(
self
->
x_attr
,
name
);
int
rv
=
PyDict_DelItemString
(
self
->
x_attr
,
name
);
if
(
rv
<
0
)
err_setstr
(
AttributeError
,
"delete non-existing
x
xo attribute"
);
PyErr_SetString
(
PyExc_
AttributeError
,
"delete non-existing
X
xo attribute"
);
return
rv
;
}
else
return
dictinsert
(
self
->
x_attr
,
name
,
v
);
return
PyDict_SetItemString
(
self
->
x_attr
,
name
,
v
);
}
staticforward
typeobject
Xxot
ype
=
{
OB_HEAD_INIT
(
&
Typet
ype
)
staticforward
PyTypeObject
Xxo_T
ype
=
{
PyObject_HEAD_INIT
(
&
PyType_T
ype
)
0
,
/*ob_size*/
"
x
xo"
,
/*tp_name*/
sizeof
(
xxoo
bject
),
/*tp_basicsize*/
"
X
xo"
,
/*tp_name*/
sizeof
(
XxoO
bject
),
/*tp_basicsize*/
0
,
/*tp_itemsize*/
/* methods */
(
destructor
)
x
xo_dealloc
,
/*tp_dealloc*/
(
destructor
)
X
xo_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print*/
(
getattrfunc
)
x
xo_getattr
,
/*tp_getattr*/
(
setattrfunc
)
x
xo_setattr
,
/*tp_setattr*/
(
getattrfunc
)
X
xo_getattr
,
/*tp_getattr*/
(
setattrfunc
)
X
xo_setattr
,
/*tp_setattr*/
0
,
/*tp_compare*/
0
,
/*tp_repr*/
0
,
/*tp_as_number*/
...
...
@@ -147,44 +147,44 @@ staticforward typeobject Xxotype = {
/* Function of two integers returning integer */
static
o
bject
*
static
PyO
bject
*
xx_foo
(
self
,
args
)
o
bject
*
self
;
/* Not used */
o
bject
*
args
;
PyO
bject
*
self
;
/* Not used */
PyO
bject
*
args
;
{
long
i
,
j
;
long
res
;
if
(
!
getargs
(
args
,
"(ll)
"
,
&
i
,
&
j
))
if
(
!
PyArg_ParseTuple
(
args
,
"ll
"
,
&
i
,
&
j
))
return
NULL
;
res
=
i
+
j
;
/* XXX Do something here */
return
newintobject
(
res
);
return
PyInt_FromLong
(
res
);
}
/* Function of no arguments returning new
x
xo object */
/* Function of no arguments returning new
X
xo object */
static
o
bject
*
static
PyO
bject
*
xx_new
(
self
,
args
)
o
bject
*
self
;
/* Not used */
o
bject
*
args
;
PyO
bject
*
self
;
/* Not used */
PyO
bject
*
args
;
{
int
i
,
j
;
xxoo
bject
*
rv
;
XxoO
bject
*
rv
;
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
rv
=
new
xxoo
bject
(
args
);
rv
=
new
XxoO
bject
(
args
);
if
(
rv
==
NULL
)
return
NULL
;
return
(
o
bject
*
)
rv
;
return
(
PyO
bject
*
)
rv
;
}
/* List of functions defined in the module */
static
struct
methodlist
xx_methods
[]
=
{
{
"foo"
,
xx_foo
},
{
"new"
,
xx_new
},
static
PyMethodDef
xx_methods
[]
=
{
{
"foo"
,
xx_foo
,
1
},
{
"new"
,
xx_new
,
1
},
{
NULL
,
NULL
}
/* sentinel */
};
...
...
@@ -194,17 +194,17 @@ static struct methodlist xx_methods[] = {
void
initxx
()
{
o
bject
*
m
,
*
d
;
PyO
bject
*
m
,
*
d
;
/* Create the module and add the functions */
m
=
initm
odule
(
"xx"
,
xx_methods
);
m
=
Py_InitM
odule
(
"xx"
,
xx_methods
);
/* Add some symbolic constants to the module */
d
=
getmoduled
ict
(
m
);
ErrorObject
=
newstringobject
(
"xx.error"
);
dictinsert
(
d
,
"error"
,
ErrorObject
);
d
=
PyModule_GetD
ict
(
m
);
ErrorObject
=
PyString_FromString
(
"xx.error"
);
PyDict_SetItemString
(
d
,
"error"
,
ErrorObject
);
/* Check for errors */
if
(
err_o
ccurred
())
fatal
(
"can't initialize module xx"
);
if
(
PyErr_O
ccurred
())
Py_FatalError
(
"can't initialize module xx"
);
}
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