Commit a19500d3 authored by Robert Bradshaw's avatar Robert Bradshaw

comments, builtin objects

parent 33b0863c
......@@ -345,6 +345,8 @@ class CIntType(CNumericType):
class CBIntType(CIntType):
# TODO: this should be a macro "(__ ? Py_True : Py_False)"
# and no error checking should be needed (just an incref).
to_py_function = "PyBool_FromLong"
from_py_function = "PyObject_IsTrue"
......
......@@ -455,6 +455,9 @@ class BuiltinScope(Scope):
cname, type, arg_types, exception_value, exception_check = definition
function = CFuncType(type, [CFuncTypeArg("", t, None) for t in arg_types], False, exception_value, exception_check)
self.add_cfunction(name, function, None, cname, False)
for name, definition in self.builtin_entries.iteritems():
cname, type = definition
self.declare_var(name, type, None, cname)
self.cached_entries = []
self.undeclared_cached_entries = []
......@@ -474,6 +477,7 @@ class BuiltinScope(Scope):
return self
# TODO: built in functions conflict with built in types of same name...
# TODO: perhapse these should all be declared in some universal .pxi file?
builtin_functions = {
"hasattr": ["PyObject_HasAttrString", c_bint_type, (py_object_type, c_char_ptr_type)],
......@@ -500,6 +504,27 @@ class BuiltinScope(Scope):
}
builtin_entries = {
"int": ["PyInt_Type", py_object_type],
"long": ["PyLong_Type", py_object_type],
"float": ["PyFloat_Type", py_object_type],
"str": ["PyString_Type", py_object_type],
"tuple": ["PyTuple_Type", py_object_type],
"list": ["PyList_Type", py_object_type],
"dict": ["PyDict_Type", py_object_type],
"set": ["PySet_Type", py_object_type],
"frozenset": ["PyFrozenSet_Type", py_object_type],
"type": ["PyType_Type", py_object_type],
"slice": ["PySlice_Type", py_object_type],
"file": ["PyFile_Type", py_object_type],
"None": ["Py_None", py_object_type],
"False": ["Py_False", py_object_type],
"True": ["Py_True", py_object_type],
}
class ModuleScope(Scope):
# module_name string Python name of the module
# module_cname string C name of Python module object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment