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
a6b7c714
Kaydet (Commit)
a6b7c714
authored
Ara 10, 1996
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Renamed.
üst
5de1f8da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
81 deletions
+84
-81
newmodule.c
Modules/newmodule.c
+84
-81
No files found.
Modules/newmodule.c
Dosyayı görüntüle @
a6b7c714
...
@@ -31,155 +31,158 @@ PERFORMANCE OF THIS SOFTWARE.
...
@@ -31,155 +31,158 @@ PERFORMANCE OF THIS SOFTWARE.
/* Module new -- create new objects of various types */
/* Module new -- create new objects of various types */
#include "
allobjects
.h"
#include "
Python
.h"
#include "compile.h"
#include "compile.h"
static
char
new_instance_doc
[]
=
static
char
new_instance_doc
[]
=
"Create an instance object from (CLASS, DICT) without calling its __init__()."
;
"Create an instance object from (CLASS, DICT) without calling its __init__()."
;
static
o
bject
*
static
PyO
bject
*
new_instance
(
unused
,
args
)
new_instance
(
unused
,
args
)
o
bject
*
unused
;
PyO
bject
*
unused
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
o
bject
*
klass
;
PyO
bject
*
klass
;
o
bject
*
dict
;
PyO
bject
*
dict
;
instanceo
bject
*
inst
;
PyInstanceO
bject
*
inst
;
if
(
!
newgetargs
(
args
,
"O!O!"
,
if
(
!
PyArg_ParseTuple
(
args
,
"O!O!"
,
&
Classt
ype
,
&
klass
,
&
PyClass_T
ype
,
&
klass
,
&
Dictt
ype
,
&
dict
))
&
PyDict_T
ype
,
&
dict
))
return
NULL
;
return
NULL
;
inst
=
NEWOBJ
(
instanceobject
,
&
Instancet
ype
);
inst
=
PyObject_NEW
(
PyInstanceObject
,
&
PyInstance_T
ype
);
if
(
inst
==
NULL
)
if
(
inst
==
NULL
)
return
NULL
;
return
NULL
;
INCREF
(
klass
);
Py_
INCREF
(
klass
);
INCREF
(
dict
);
Py_
INCREF
(
dict
);
inst
->
in_class
=
(
classo
bject
*
)
klass
;
inst
->
in_class
=
(
PyClassO
bject
*
)
klass
;
inst
->
in_dict
=
dict
;
inst
->
in_dict
=
dict
;
return
(
o
bject
*
)
inst
;
return
(
PyO
bject
*
)
inst
;
}
}
static
char
new_im_doc
[]
=
static
char
new_im_doc
[]
=
"Create a instance method object from (FUNCTION, INSTANCE, CLASS)."
;
"Create a instance method object from (FUNCTION, INSTANCE, CLASS)."
;
static
o
bject
*
static
PyO
bject
*
new_instancemethod
(
unused
,
args
)
new_instancemethod
(
unused
,
args
)
o
bject
*
unused
;
PyO
bject
*
unused
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
o
bject
*
func
;
PyO
bject
*
func
;
o
bject
*
self
;
PyO
bject
*
self
;
o
bject
*
classObj
;
PyO
bject
*
classObj
;
if
(
!
newgetargs
(
args
,
"O!O!O!"
,
if
(
!
PyArg_ParseTuple
(
args
,
"O!O!O!"
,
&
Funct
ype
,
&
func
,
&
PyFunction_T
ype
,
&
func
,
&
Instancet
ype
,
&
self
,
&
PyInstance_T
ype
,
&
self
,
&
Classt
ype
,
&
classObj
))
&
PyClass_T
ype
,
&
classObj
))
return
NULL
;
return
NULL
;
return
newinstancemethodobject
(
func
,
self
,
classObj
);
return
PyMethod_New
(
func
,
self
,
classObj
);
}
}
static
char
new_function_doc
[]
=
static
char
new_function_doc
[]
=
"Create a function object from (CODE, GLOBALS, [NAME, ARGDEFS])."
;
"Create a function object from (CODE, GLOBALS, [NAME, ARGDEFS])."
;
static
o
bject
*
static
PyO
bject
*
new_function
(
unused
,
args
)
new_function
(
unused
,
args
)
o
bject
*
unused
;
PyO
bject
*
unused
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
o
bject
*
code
;
PyO
bject
*
code
;
o
bject
*
globals
;
PyO
bject
*
globals
;
object
*
name
=
None
;
PyObject
*
name
=
Py_
None
;
object
*
defaults
=
None
;
PyObject
*
defaults
=
Py_
None
;
funco
bject
*
newfunc
;
PyFunctionO
bject
*
newfunc
;
if
(
!
newgetargs
(
args
,
"O!O!|SO!"
,
if
(
!
PyArg_ParseTuple
(
args
,
"O!O!|SO!"
,
&
Codet
ype
,
&
code
,
&
PyCode_T
ype
,
&
code
,
&
Mappingt
ype
,
&
globals
,
&
PyDict_T
ype
,
&
globals
,
&
name
,
&
name
,
&
Tuplet
ype
,
&
defaults
))
&
PyTuple_T
ype
,
&
defaults
))
return
NULL
;
return
NULL
;
newfunc
=
(
funcobject
*
)
newfuncobject
(
code
,
globals
);
newfunc
=
(
PyFunctionObject
*
)
PyFunction_New
(
code
,
globals
);
if
(
newfunc
==
NULL
)
if
(
newfunc
==
NULL
)
return
NULL
;
return
NULL
;
if
(
name
!=
None
)
{
if
(
name
!=
Py_
None
)
{
XINCREF
(
name
);
Py_
XINCREF
(
name
);
XDECREF
(
newfunc
->
func_name
);
Py_
XDECREF
(
newfunc
->
func_name
);
newfunc
->
func_name
=
name
;
newfunc
->
func_name
=
name
;
}
}
if
(
defaults
!=
NULL
)
{
if
(
defaults
!=
NULL
)
{
XINCREF
(
defaults
);
Py_
XINCREF
(
defaults
);
XDECREF
(
newfunc
->
func_defaults
);
Py_
XDECREF
(
newfunc
->
func_defaults
);
newfunc
->
func_defaults
=
defaults
;
newfunc
->
func_defaults
=
defaults
;
}
}
return
(
o
bject
*
)
newfunc
;
return
(
PyO
bject
*
)
newfunc
;
}
}
static
char
new_code_doc
[]
=
static
char
new_code_doc
[]
=
"Create a code object from (ARGCOUNT, NLOCALS, FLAGS, CODESTRING, CONSTANTS, NAMES, VARNAMES, FILENAME, NAME)."
;
"Create a code object from (ARGCOUNT, NLOCALS, FLAGS, CODESTRING, CONSTANTS, NAMES, VARNAMES, FILENAME, NAME)."
;
static
o
bject
*
static
PyO
bject
*
new_code
(
unused
,
args
)
new_code
(
unused
,
args
)
o
bject
*
unused
;
PyO
bject
*
unused
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
argcount
;
int
argcount
;
int
nlocals
;
int
nlocals
;
int
flags
;
int
flags
;
o
bject
*
code
;
PyO
bject
*
code
;
o
bject
*
consts
;
PyO
bject
*
consts
;
o
bject
*
names
;
PyO
bject
*
names
;
o
bject
*
varnames
;
PyO
bject
*
varnames
;
o
bject
*
filename
;
PyO
bject
*
filename
;
o
bject
*
name
;
PyO
bject
*
name
;
if
(
!
newgetargs
(
args
,
"iiiSO!O!O!SS"
,
if
(
!
PyArg_ParseTuple
(
args
,
"iiiSO!O!O!SS"
,
&
argcount
,
&
nlocals
,
&
flags
,
/* These are new */
&
argcount
,
&
nlocals
,
&
flags
,
/* These are new */
&
code
,
&
Tupletype
,
&
consts
,
&
Tupletype
,
&
names
,
&
code
,
&
Tupletype
,
&
varnames
,
/* These are new */
&
PyTuple_Type
,
&
consts
,
&
filename
,
&
name
))
&
PyTuple_Type
,
&
names
,
&
PyTuple_Type
,
&
varnames
,
/* These are new */
&
filename
,
&
name
))
return
NULL
;
return
NULL
;
return
(
object
*
)
newcodeobject
(
argcount
,
nlocals
,
flags
,
return
(
PyObject
*
)
PyCode_New
(
argcount
,
nlocals
,
flags
,
code
,
consts
,
names
,
varnames
,
filename
,
name
);
code
,
consts
,
names
,
varnames
,
filename
,
name
);
}
}
static
char
new_module_doc
[]
=
static
char
new_module_doc
[]
=
"Create a module object from (NAME)."
;
"Create a module object from (NAME)."
;
static
o
bject
*
static
PyO
bject
*
new_module
(
unused
,
args
)
new_module
(
unused
,
args
)
o
bject
*
unused
;
PyO
bject
*
unused
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
char
*
name
;
char
*
name
;
if
(
!
newgetargs
(
args
,
"s"
,
&
name
))
if
(
!
PyArg_ParseTuple
(
args
,
"s"
,
&
name
))
return
NULL
;
return
NULL
;
return
newmoduleobject
(
name
);
return
PyModule_New
(
name
);
}
}
static
char
new_class_doc
[]
=
static
char
new_class_doc
[]
=
"Create a class object from (NAME, BASE_CLASSES, DICT)."
;
"Create a class object from (NAME, BASE_CLASSES, DICT)."
;
static
o
bject
*
static
PyO
bject
*
new_class
(
unused
,
args
)
new_class
(
unused
,
args
)
o
bject
*
unused
;
PyO
bject
*
unused
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
o
bject
*
name
;
PyO
bject
*
name
;
o
bject
*
classes
;
PyO
bject
*
classes
;
o
bject
*
dict
;
PyO
bject
*
dict
;
if
(
!
newgetargs
(
args
,
"SO!O!"
,
&
name
,
&
Tuplet
ype
,
&
classes
,
if
(
!
PyArg_ParseTuple
(
args
,
"SO!O!"
,
&
name
,
&
PyTuple_T
ype
,
&
classes
,
&
Mappingt
ype
,
&
dict
))
&
PyDict_T
ype
,
&
dict
))
return
NULL
;
return
NULL
;
return
newclassobject
(
classes
,
dict
,
name
);
return
PyClass_New
(
classes
,
dict
,
name
);
}
}
static
struct
methodlist
new_methods
[]
=
{
static
PyMethodDef
new_methods
[]
=
{
{
"instance"
,
new_instance
,
1
,
new_instance_doc
},
{
"instance"
,
new_instance
,
1
,
new_instance_doc
},
{
"instancemethod"
,
new_instancemethod
,
1
,
new_im_doc
},
{
"instancemethod"
,
new_instancemethod
,
1
,
new_im_doc
},
{
"function"
,
new_function
,
1
,
new_function_doc
},
{
"function"
,
new_function
,
1
,
new_function_doc
},
...
@@ -197,6 +200,6 @@ You need to know a great deal about the interpreter to use this!";
...
@@ -197,6 +200,6 @@ You need to know a great deal about the interpreter to use this!";
void
void
initnew
()
initnew
()
{
{
initmodule4
(
"new"
,
new_methods
,
new_doc
,
(
o
bject
*
)
NULL
,
Py_InitModule4
(
"new"
,
new_methods
,
new_doc
,
(
PyO
bject
*
)
NULL
,
PYTHON_API_VERSION
);
PYTHON_API_VERSION
);
}
}
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