Commit 5aab5520 authored by Robert Bradshaw's avatar Robert Bradshaw

Pyrex Official version 0.9.5.1a

parent 54ab11e7
...@@ -22,8 +22,9 @@ class CCodeWriter: ...@@ -22,8 +22,9 @@ class CCodeWriter:
in_try_finally = 0 in_try_finally = 0
def __init__(self, outfile_name): def __init__(self, f):
self.f = open_new_file(outfile_name) #self.f = open_new_file(outfile_name)
self.f = f
self.level = 0 self.level = 0
self.bol = 1 self.bol = 1
self.marker = None self.marker = None
...@@ -80,6 +81,7 @@ class CCodeWriter: ...@@ -80,6 +81,7 @@ class CCodeWriter:
def init_labels(self): def init_labels(self):
self.label_counter = 0 self.label_counter = 0
self.labels_used = {}
self.return_label = self.new_label() self.return_label = self.new_label()
self.new_error_label() self.new_error_label()
self.continue_label = None self.continue_label = None
...@@ -134,9 +136,17 @@ class CCodeWriter: ...@@ -134,9 +136,17 @@ class CCodeWriter:
new_labels.append(old_label) new_labels.append(old_label)
self.set_all_labels(new_labels) self.set_all_labels(new_labels)
return old_labels return old_labels
def use_label(self, lbl):
self.labels_used[lbl] = 1
def put_label(self, lbl): def put_label(self, lbl):
self.putln("%s:;" % lbl) if lbl in self.labels_used:
self.putln("%s:;" % lbl)
def put_goto(self, lbl):
self.use_label(lbl)
self.putln("goto %s;" % lbl)
def put_var_declarations(self, entries, static = 0, dll_linkage = None, def put_var_declarations(self, entries, static = 0, dll_linkage = None,
definition = True): definition = True):
...@@ -146,28 +156,23 @@ class CCodeWriter: ...@@ -146,28 +156,23 @@ class CCodeWriter:
def put_var_declaration(self, entry, static = 0, dll_linkage = None, def put_var_declaration(self, entry, static = 0, dll_linkage = None,
definition = True): definition = True):
#print "Code.put_var_declaration:", entry.name, "definition =", definition #print "Code.put_var_declaration:", entry.name, "definition =", definition ###
visibility = entry.visibility visibility = entry.visibility
if visibility == 'private' and not definition: if visibility == 'private' and not definition:
return return
if not entry.used and visibility == "private":
return
storage_class = ""
if visibility == 'extern': if visibility == 'extern':
storage_class = Naming.extern_c_macro storage_class = Naming.extern_c_macro
elif visibility == 'public': elif visibility == 'public':
if definition: if not definition:
storage_class = ""
else:
storage_class = Naming.extern_c_macro storage_class = Naming.extern_c_macro
elif visibility == 'private': elif visibility == 'private':
if static: if static:
storage_class = "static" storage_class = "static"
else:
storage_class = ""
if storage_class: if storage_class:
self.put("%s " % storage_class) self.put("%s " % storage_class)
#if visibility == 'extern' or visibility == 'public' and not definition:
# self.put("%s " % Naming.extern_c_macro)
#elif static and visibility <> 'public':
# self.put("static ")
if visibility <> 'public': if visibility <> 'public':
dll_linkage = None dll_linkage = None
self.put(entry.type.declaration_code(entry.cname, self.put(entry.type.declaration_code(entry.cname,
...@@ -186,10 +191,6 @@ class CCodeWriter: ...@@ -186,10 +191,6 @@ class CCodeWriter:
def as_pyobject(self, cname, type): def as_pyobject(self, cname, type):
return typecast(py_object_type, type, cname) return typecast(py_object_type, type, cname)
#if type.is_extension_type and type.base_type:
# return "(PyObject *)" + cname
#else:
# return cname
def put_incref(self, cname, type): def put_incref(self, cname, type):
self.putln("Py_INCREF(%s);" % self.as_pyobject(cname, type)) self.putln("Py_INCREF(%s);" % self.as_pyobject(cname, type))
...@@ -231,12 +232,13 @@ class CCodeWriter: ...@@ -231,12 +232,13 @@ class CCodeWriter:
self.putln("Py_XDECREF(%s); %s = 0;" % ( self.putln("Py_XDECREF(%s); %s = 0;" % (
self.entry_as_pyobject(entry), entry.cname)) self.entry_as_pyobject(entry), entry.cname))
def put_var_decrefs(self, entries): def put_var_decrefs(self, entries, used_only = 0):
for entry in entries: for entry in entries:
if entry.xdecref_cleanup: if not used_only or entry.used:
self.put_var_xdecref(entry) if entry.xdecref_cleanup:
else: self.put_var_xdecref(entry)
self.put_var_decref(entry) else:
self.put_var_decref(entry)
def put_var_xdecrefs(self, entries): def put_var_xdecrefs(self, entries):
for entry in entries: for entry in entries:
...@@ -269,13 +271,15 @@ class CCodeWriter: ...@@ -269,13 +271,15 @@ class CCodeWriter:
term)) term))
def error_goto(self, pos): def error_goto(self, pos):
lbl = self.error_label
self.use_label(lbl)
return "{%s = %s[%s]; %s = %s; goto %s;}" % ( return "{%s = %s[%s]; %s = %s; goto %s;}" % (
Naming.filename_cname, Naming.filename_cname,
Naming.filetable_cname, Naming.filetable_cname,
self.lookup_filename(pos[0]), self.lookup_filename(pos[0]),
Naming.lineno_cname, Naming.lineno_cname,
pos[1], pos[1],
self.error_label) lbl)
def lookup_filename(self, filename): def lookup_filename(self, filename):
try: try:
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -8,6 +8,7 @@ from types import ListType, TupleType ...@@ -8,6 +8,7 @@ from types import ListType, TupleType
from Scanning import PyrexScanner from Scanning import PyrexScanner
import Nodes import Nodes
import ExprNodes import ExprNodes
from ModuleNode import ModuleNode
from Errors import error, InternalError from Errors import error, InternalError
def p_ident(s, message = "Expected an identifier"): def p_ident(s, message = "Expected an identifier"):
...@@ -413,13 +414,7 @@ def p_atom(s): ...@@ -413,13 +414,7 @@ def p_atom(s):
elif sy == '`': elif sy == '`':
return p_backquote_expr(s) return p_backquote_expr(s)
elif sy == 'INT': elif sy == 'INT':
digits = s.systring value = s.systring
if digits[:2] == "0x":
value = long(digits[2:], 16)
elif digits[:1] == "0":
value = int(digits, 8)
else:
value = int(s.systring)
s.next() s.next()
return ExprNodes.IntNode(pos, value = value) return ExprNodes.IntNode(pos, value = value)
elif sy == 'LONG': elif sy == 'LONG':
...@@ -517,7 +512,7 @@ def p_string_literal(s): ...@@ -517,7 +512,7 @@ def p_string_literal(s):
elif c == '\n': elif c == '\n':
pass pass
else: else:
chars.append(systr[1:]) chars.append(r'\\' + systr[1:])
elif sy == 'NEWLINE': elif sy == 'NEWLINE':
chars.append(r'\n') chars.append(r'\n')
elif sy == 'END_STRING': elif sy == 'END_STRING':
...@@ -668,7 +663,6 @@ def p_expression_or_assignment(s): ...@@ -668,7 +663,6 @@ def p_expression_or_assignment(s):
if len(nodes) == 1: if len(nodes) == 1:
return nodes[0] return nodes[0]
else: else:
#return Nodes.StatListNode(nodes[0].pos, stats = nodes)
return Nodes.ParallelAssignmentNode(nodes[0].pos, stats = nodes) return Nodes.ParallelAssignmentNode(nodes[0].pos, stats = nodes)
def flatten_parallel_assignments(input, output): def flatten_parallel_assignments(input, output):
...@@ -1375,19 +1369,19 @@ def p_exception_value_clause(s): ...@@ -1375,19 +1369,19 @@ def p_exception_value_clause(s):
if s.sy == '?': if s.sy == '?':
exc_check = 1 exc_check = 1
s.next() s.next()
exc_val = p_exception_value(s) exc_val = p_simple_expr(s) #p_exception_value(s)
return exc_val, exc_check return exc_val, exc_check
def p_exception_value(s): #def p_exception_value(s):
sign = "" # sign = ""
if s.sy == "-": # if s.sy == "-":
sign = "-" # sign = "-"
s.next() # s.next()
if s.sy in ('INT', 'LONG', 'FLOAT', 'NULL'): # if s.sy in ('INT', 'LONG', 'FLOAT', 'NULL'):
s.systring = sign + s.systring # s.systring = sign + s.systring
return p_atom(s) # return p_atom(s)
else: # else:
s.error("Exception value must be an int or float literal or NULL") # s.error("Exception value must be an int or float literal or NULL")
c_arg_list_terminators = ('*', '**', '.', ')') c_arg_list_terminators = ('*', '**', '.', ')')
c_arg_list_trailers = ('.', '*', '**') c_arg_list_trailers = ('.', '*', '**')
...@@ -1780,7 +1774,7 @@ def p_module(s, pxd): ...@@ -1780,7 +1774,7 @@ def p_module(s, pxd):
if s.sy <> 'EOF': if s.sy <> 'EOF':
s.error("Syntax error in statement [%s,%s]" % ( s.error("Syntax error in statement [%s,%s]" % (
repr(s.sy), repr(s.systring))) repr(s.sy), repr(s.systring)))
return Nodes.ModuleNode(pos, doc = doc, body = body) return ModuleNode(pos, doc = doc, body = body)
#---------------------------------------------- #----------------------------------------------
# #
......
...@@ -259,14 +259,14 @@ class CType(PyrexType): ...@@ -259,14 +259,14 @@ class CType(PyrexType):
from_py_function = None from_py_function = None
class CSimpleType(CType): #class CSimpleType(CType):
# # #
# Base class for all unstructured C types. # # Base class for all unstructured C types.
# # #
pass # pass
class CVoidType(CSimpleType): class CVoidType(CType):
is_void = 1 is_void = 1
def __repr__(self): def __repr__(self):
...@@ -313,9 +313,6 @@ class CNumericType(CType): ...@@ -313,9 +313,6 @@ class CNumericType(CType):
u = "unsigned " u = "unsigned "
return "<CNumericType %s%s>" % (u, rank_to_type_name[self.rank]) return "<CNumericType %s%s>" % (u, rank_to_type_name[self.rank])
def assignable_from_resolved_type(self, src_type):
return src_type.is_numeric or src_type is error_type
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if self.signed: if self.signed:
...@@ -324,8 +321,6 @@ class CNumericType(CType): ...@@ -324,8 +321,6 @@ class CNumericType(CType):
u = "unsigned " u = "unsigned "
base = public_decl(u + rank_to_type_name[self.rank], dll_linkage) base = public_decl(u + rank_to_type_name[self.rank], dll_linkage)
return "%s %s" % (base, entity_code) return "%s %s" % (base, entity_code)
# return "%s%s %s" % (u, rank_to_type_name[self.rank], entity_code)
class CIntType(CNumericType): class CIntType(CNumericType):
...@@ -338,6 +333,9 @@ class CIntType(CNumericType): ...@@ -338,6 +333,9 @@ class CIntType(CNumericType):
def __init__(self, rank, signed, pymemberdef_typecode = None, is_returncode = 0): def __init__(self, rank, signed, pymemberdef_typecode = None, is_returncode = 0):
CNumericType.__init__(self, rank, signed, pymemberdef_typecode) CNumericType.__init__(self, rank, signed, pymemberdef_typecode)
self.is_returncode = is_returncode self.is_returncode = is_returncode
def assignable_from_resolved_type(self, src_type):
return src_type.is_int or src_type.is_enum or src_type is error_type
class CUIntType(CIntType): class CUIntType(CIntType):
...@@ -373,6 +371,9 @@ class CFloatType(CNumericType): ...@@ -373,6 +371,9 @@ class CFloatType(CNumericType):
def __init__(self, rank, pymemberdef_typecode = None): def __init__(self, rank, pymemberdef_typecode = None):
CNumericType.__init__(self, rank, 1, pymemberdef_typecode) CNumericType.__init__(self, rank, 1, pymemberdef_typecode)
def assignable_from_resolved_type(self, src_type):
return src_type.is_numeric or src_type is error_type
class CArrayType(CType): class CArrayType(CType):
# base_type CType Element type # base_type CType Element type
...@@ -447,6 +448,8 @@ class CPtrType(CType): ...@@ -447,6 +448,8 @@ class CPtrType(CType):
return 1 return 1
elif self.base_type.is_cfunction and other_type.is_cfunction: elif self.base_type.is_cfunction and other_type.is_cfunction:
return self.base_type.same_as(other_type) return self.base_type.same_as(other_type)
elif other_type.is_array:
return self.base_type.same_as(other_type.base_type)
elif not other_type.is_ptr: elif not other_type.is_ptr:
return 0 return 0
elif self.base_type.is_void: elif self.base_type.is_void:
...@@ -608,14 +611,16 @@ class CStructOrUnionType(CType): ...@@ -608,14 +611,16 @@ class CStructOrUnionType(CType):
return self.is_complete() return self.is_complete()
class CEnumType(CIntType): class CEnumType(CType):
# name string # name string
# cname string or None # cname string or None
# typedef_flag boolean # typedef_flag boolean
is_enum = 1 is_enum = 1
signed = 1 #signed = 1
rank = 2 #rank = 2
to_py_function = "PyInt_FromLong"
from_py_function = "PyInt_AsLong"
def __init__(self, name, cname, typedef_flag): def __init__(self, name, cname, typedef_flag):
self.name = name self.name = name
......
...@@ -61,6 +61,7 @@ class Entry: ...@@ -61,6 +61,7 @@ class Entry:
# interned_cname string C name of interned name string # interned_cname string C name of interned name string
# pystring_cname string C name of Python version of string literal # pystring_cname string C name of Python version of string literal
# is_interned boolean For string const entries, value is interned # is_interned boolean For string const entries, value is interned
# used boolean
borrowed = 0 borrowed = 0
init = "" init = ""
...@@ -91,6 +92,7 @@ class Entry: ...@@ -91,6 +92,7 @@ class Entry:
interned_cname = None interned_cname = None
pystring_cname = None pystring_cname = None
is_interned = 0 is_interned = 0
used = 0
def __init__(self, name, cname, type, pos = None, init = None): def __init__(self, name, cname, type, pos = None, init = None):
self.name = name self.name = name
...@@ -351,6 +353,7 @@ class Scope: ...@@ -351,6 +353,7 @@ class Scope:
# Add an entry for a string constant. # Add an entry for a string constant.
cname = self.new_const_cname() cname = self.new_const_cname()
entry = Entry("", cname, c_char_array_type, init = value) entry = Entry("", cname, c_char_array_type, init = value)
entry.used = 1
self.const_entries.append(entry) self.const_entries.append(entry)
return entry return entry
...@@ -395,6 +398,7 @@ class Scope: ...@@ -395,6 +398,7 @@ class Scope:
self.temp_counter = n + 1 self.temp_counter = n + 1
cname = "%s%d" % (Naming.pyrex_prefix, n) cname = "%s%d" % (Naming.pyrex_prefix, n)
entry = Entry("", cname, type) entry = Entry("", cname, type)
entry.used = 1
if type.is_pyobject: if type.is_pyobject:
entry.init = "0" entry.init = "0"
self.cname_to_entry[entry.cname] = entry self.cname_to_entry[entry.cname] = entry
...@@ -476,6 +480,7 @@ class ModuleScope(Scope): ...@@ -476,6 +480,7 @@ class ModuleScope(Scope):
# intern_map {string : string} Mapping from Python names to interned strs # intern_map {string : string} Mapping from Python names to interned strs
# interned_names [string] Interned names pending generation of declarations # interned_names [string] Interned names pending generation of declarations
# all_pystring_entries [Entry] Python string consts from all scopes # all_pystring_entries [Entry] Python string consts from all scopes
# types_imported {PyrexType : 1} Set of types for which import code generated
def __init__(self, name, parent_module, context): def __init__(self, name, parent_module, context):
self.parent_module = parent_module self.parent_module = parent_module
...@@ -500,6 +505,7 @@ class ModuleScope(Scope): ...@@ -500,6 +505,7 @@ class ModuleScope(Scope):
self.intern_map = {} self.intern_map = {}
self.interned_names = [] self.interned_names = []
self.all_pystring_entries = [] self.all_pystring_entries = []
self.types_imported = {}
def qualifying_scope(self): def qualifying_scope(self):
return self.parent_module return self.parent_module
...@@ -565,6 +571,8 @@ class ModuleScope(Scope): ...@@ -565,6 +571,8 @@ class ModuleScope(Scope):
# None if previously declared as something else. # None if previously declared as something else.
entry = self.lookup_here(name) entry = self.lookup_here(name)
if entry: if entry:
if entry.is_pyglobal and entry.as_module is scope:
return entry # Already declared as the same module
if not (entry.is_pyglobal and not entry.as_module): if not (entry.is_pyglobal and not entry.as_module):
error(pos, "'%s' redeclared" % name) error(pos, "'%s' redeclared" % name)
return None return None
...@@ -956,6 +964,8 @@ class CClassScope(ClassScope): ...@@ -956,6 +964,8 @@ class CClassScope(ClassScope):
if visibility in ('public', 'readonly'): if visibility in ('public', 'readonly'):
if type.pymemberdef_typecode: if type.pymemberdef_typecode:
self.public_attr_entries.append(entry) self.public_attr_entries.append(entry)
if name == "__weakref__":
error(pos, "Special attribute __weakref__ cannot be exposed to Python")
else: else:
error(pos, error(pos,
"C attribute of type '%s' cannot be accessed from Python" % type) "C attribute of type '%s' cannot be accessed from Python" % type)
......
version = '0.9.4.1' version = '0.9.5.1a'
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
verbose = 0 verbose = 0
gcc_pendantic = True gcc_pendantic = True
gcc_warnings_are_errors = False gcc_warnings_are_errors = True
gcc_all_warnings = True
import os import os
from Pyrex.Utils import replace_suffix from Pyrex.Utils import replace_suffix
...@@ -23,6 +24,9 @@ if gcc_pendantic: ...@@ -23,6 +24,9 @@ if gcc_pendantic:
compiler_options.extend(["-pedantic", "-Wno-long-long"]) compiler_options.extend(["-pedantic", "-Wno-long-long"])
if gcc_warnings_are_errors: if gcc_warnings_are_errors:
compiler_options.append("-Werror") compiler_options.append("-Werror")
if gcc_all_warnings:
compiler_options.append("-Wall")
compiler_options.append("-Wno-unused-function")
linkers = ["gcc", "g++"] linkers = ["gcc", "g++"]
linker_options = \ linker_options = \
...@@ -45,6 +49,7 @@ def c_compile(c_file, verbose_flag = 0, cplus = 0, obj_suffix = ".o"): ...@@ -45,6 +49,7 @@ def c_compile(c_file, verbose_flag = 0, cplus = 0, obj_suffix = ".o"):
args = [compiler] + compiler_options + include_options + [c_file, "-o", o_file] args = [compiler] + compiler_options + include_options + [c_file, "-o", o_file]
if verbose_flag or verbose: if verbose_flag or verbose:
print " ".join(args) print " ".join(args)
#print compiler, args ###
status = os.spawnvp(os.P_WAIT, compiler, args) status = os.spawnvp(os.P_WAIT, compiler, args)
if status <> 0: if status <> 0:
raise CCompilerError("C compiler returned status %s" % status) raise CCompilerError("C compiler returned status %s" % status)
......
This diff is collapsed.
"""Suite Misc Suite: Suite that adds additional features to the Application.
Level 1, version 1
Generated from MPW:MPW Shell
AETE/AEUT resource version 1/0, language 0, script 0
"""
import aetools
import MacOS
_code = 'misc'
class MPW_Misc_Suite:
def DoScript(self, _object, _attributes={}, **_arguments):
"""DoScript: Execute an MPW command, any command that could be executed from the command line can be sent as a script.
Required argument: The script to execute
Keyword argument _attributes: AppleEvent attribute dictionary
"""
_code = 'misc'
_subcode = 'dosc'
if _arguments: raise TypeError, 'No optional args expected'
_arguments['----'] = _object
_reply, _arguments, _attributes = self.send(_code, _subcode,
_arguments, _attributes)
if _arguments.has_key('errn'):
raise aetools.Error, aetools.decodeerror(_arguments)
# XXXX Optionally decode result
if _arguments.has_key('----'):
return _arguments['----']
#
# Indices of types declared in this module
#
_classdeclarations = {
}
_propdeclarations = {
}
_compdeclarations = {
}
_enumdeclarations = {
}
# Makefile for Darwin
# Change this to your Python source location
PYTHON := /Local/Build/Pythonic/python/2.3
INCLUDE := -I$(PYTHON) -I$(PYTHON)/Include -I$(PYTHON)/Mac/Include
CCOPTS := -fno-strict-aliasing -Wno-long-double -no-cpp-precomp \
-mno-fused-madd -fno-common -dynamic
LDOPTS := -Wl,-F.,-w -bundle -framework Python -framework Carbon
all: _File.so
_File.o: _Filemodule_patched.c
gcc -c $(INCLUDE) $(OPTS) $< -o $@
_File.so: _File.o
gcc $(LDOPTS) $< -o $@
"Apple Event suite for pyserver."
import aetools
import MacOS
_code = 'misc'
class PS_Misc_Suite:
def DoScript(self, _object, _attributes={}, **_arguments):
"""DoScript: Execute a Python file, optionally with command line args.
Required argument: filename.py or [filename.py, arg, ...]
Keyword argument _attributes: AppleEvent attribute dictionary
"""
_code = 'misc'
_subcode = 'dosc'
if _arguments: raise TypeError, 'No optional args expected'
_arguments['----'] = _object
_reply, _arguments, _attributes = self.send(_code, _subcode,
_arguments, _attributes)
if _arguments.has_key('errn'):
raise aetools.Error, aetools.decodeerror(_arguments)
# XXXX Optionally decode result
if _arguments.has_key('----'):
return _arguments['----']
#
# Indices of types declared in this module
#
_classdeclarations = {
}
_propdeclarations = {
}
_compdeclarations = {
}
_enumdeclarations = {
}
#
# Simple Apple-event driven Python interpreter
#
import os, sys, traceback
from cStringIO import StringIO
from MiniAEFrame import AEServer, MiniApplication
class PythonServer(AEServer, MiniApplication):
def __init__(self):
MiniApplication.__init__(self)
AEServer.__init__(self)
self.installaehandler('aevt', 'oapp', ignore)
self.installaehandler('aevt', 'quit', quit)
self.installaehandler('misc', 'dosc', doscript)
def ignore(**kwds):
pass
def quit(**kwds):
server._quit()
def doscript(args, **kwds):
print "doscript:", repr(args) ###
stat = 0
output = ""
errput = ""
#print "Normalising args" ###
if type(args) == type(""):
args = [args]
#print "Setting sys.argv" ###
sys.argv = args
#print "Finding script directory and module file" ###
dir = os.path.dirname(args[0])
dir = os.path.join(start_dir, dir)
pyfile = os.path.basename(args[0])
mod = os.path.splitext(pyfile)[0]
#print "dir:", repr(dir) ###
#print "mod:", repr(mod) ###
os.chdir(dir)
sys.path = start_path[:]
sys.path[0] = dir
#print "path:", sys.path ###
try:
sys.stdout = StringIO()
sys.stderr = StringIO()
try:
#sys.__stdout__.write("Path: %s\n" % sys.path) ###
#sys.__stdout__.write("Importing: %s\n" % mod) ###
try:
__import__(mod)
except KeyboardInterrupt:
raise
except SystemExit, exc:
#sys.__stdout__.write("Caught a SystemExit\n") ###
try:
stat = int(str(exc))
except ValueError:
stat = 1
#sys.__stdout__.write("stat = %s\n" % stat) ###
except:
traceback.print_exc()
stat = 1
#sys.__stdout__.write("Done the import\n") ###
finally:
output = sys.stdout.getvalue()
#sys.__stdout__.write("Output:\n%s" % output) ###
errput = sys.stderr.getvalue()
finally:
sys.stdout = sys.__stdout__
sys.stderr = sys.__stdout__
pass
return [stat, output, errput]
start_dir = os.getcwd()
start_path = sys.path[:]
server = PythonServer()
#print "Open for business"
try:
server.mainloop()
except:
traceback.print_exc()
#sys.exit(1)
#print "Closing shop"
...@@ -108,6 +108,15 @@ PyMac_BuildHFSUniStr255(HFSUniStr255 *itself) ...@@ -108,6 +108,15 @@ PyMac_BuildHFSUniStr255(HFSUniStr255 *itself)
static PyObject *File_Error; static PyObject *File_Error;
static PyTypeObject FInfo_Type;
#define FInfo_Check(x) ((x)->ob_type == &FInfo_Type || PyObject_TypeCheck((x), &FInfo_Type))
typedef struct FInfoObject {
PyObject_HEAD
FInfo ob_itself;
} FInfoObject;
/* ------------------- Object type FSCatalogInfo -------------------- */ /* ------------------- Object type FSCatalogInfo -------------------- */
static PyTypeObject FSCatalogInfo_Type; static PyTypeObject FSCatalogInfo_Type;
...@@ -338,16 +347,16 @@ static int FSCatalogInfo_set_userPrivileges(FSCatalogInfoObject *self, PyObject ...@@ -338,16 +347,16 @@ static int FSCatalogInfo_set_userPrivileges(FSCatalogInfoObject *self, PyObject
static PyObject *FSCatalogInfo_get_finderInfo(FSCatalogInfoObject *self, void *closure) static PyObject *FSCatalogInfo_get_finderInfo(FSCatalogInfoObject *self, void *closure)
{ {
return FInfo_New((FInfo *)self->finderInfo); return FInfo_New((FInfo *)self->ob_itself.finderInfo);
} }
static int FSCatalogInfo_set_finderInfo(FSCatalogInfoObject *self, PyObject *v, void *closure) static int FSCatalogInfo_set_finderInfo(FSCatalogInfoObject *self, PyObject *v, void *closure)
{ {
if (!FInfo_Check(v)) { if (!FInfo_Check(v)) {
PyErr_SetString(PyTypeError, "Expected an FInfo object"); PyErr_SetString(PyExc_TypeError, "Expected an FInfo object");
return -1; return -1;
} }
*(FInfo *)self->finderInfo = ((FInfoObject *)self)->ob_itself; *(FInfo *)self->ob_itself.finderInfo = ((FInfoObject *)v)->ob_itself;
return 0; return 0;
} }
...@@ -485,15 +494,6 @@ static PyTypeObject FSCatalogInfo_Type = { ...@@ -485,15 +494,6 @@ static PyTypeObject FSCatalogInfo_Type = {
/* ----------------------- Object type FInfo ------------------------ */ /* ----------------------- Object type FInfo ------------------------ */
static PyTypeObject FInfo_Type;
#define FInfo_Check(x) ((x)->ob_type == &FInfo_Type || PyObject_TypeCheck((x), &FInfo_Type))
typedef struct FInfoObject {
PyObject_HEAD
FInfo ob_itself;
} FInfoObject;
static PyObject *FInfo_New(FInfo *itself) static PyObject *FInfo_New(FInfo *itself)
{ {
FInfoObject *it; FInfoObject *it;
...@@ -3247,8 +3247,8 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr) ...@@ -3247,8 +3247,8 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr)
if ( PyString_Check(v) || PyUnicode_Check(v)) { if ( PyString_Check(v) || PyUnicode_Check(v)) {
char *path = NULL; char *path = NULL;
if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path)) if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path))
return NULL; return 0;
if ( (err=FSPathMakeRef(path, fsr, NULL)) ) { if ( (err=FSPathMakeRef((unsigned char *)path, fsr, NULL)) ) {
PyMac_Error(err); PyMac_Error(err);
return 0; return 0;
} }
......
#
# Pyrex - Linux system interface
#
verbose = 0
gcc_pendantic = True
gcc_warnings_are_errors = True
gcc_all_warnings = True
import os
from Pyrex.Utils import replace_suffix
from Pyrex.Compiler.Errors import PyrexError
version = "%s.%s" % sys.version[:2]
py_include_dirs = [
"%s/include/python%s" % (sys.prefix, version)
]
compilers = ["gcc", "g++"]
compiler_options = \
"-g -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp " \
"-mno-fused-madd -fno-common -dynamic " \
.split()
if gcc_pendantic:
compiler_options.extend(["-pedantic", "-Wno-long-long"])
if gcc_warnings_are_errors:
compiler_options.append("-Werror")
if gcc_all_warnings:
compiler_options.append("-Wall")
compiler_options.append("-Wno-unused-function")
linkers = ["gcc", "g++"]
linker_options = \
"-shared" \
.split()
class CCompilerError(PyrexError):
pass
def c_compile(c_file, verbose_flag = 0, cplus = 0, obj_suffix = ".o"):
# Compile the given C source file to produce
# an object file. Returns the pathname of the
# resulting file.
c_file = os.path.join(os.getcwd(), c_file)
o_file = replace_suffix(c_file, obj_suffix)
include_options = []
for dir in py_include_dirs:
include_options.append("-I%s" % dir)
compiler = compilers[bool(cplus)]
args = [compiler] + compiler_options + include_options + [c_file, "-o", o_file]
if verbose_flag or verbose:
print " ".join(args)
#print compiler, args ###
status = os.spawnvp(os.P_WAIT, compiler, args)
if status <> 0:
raise CCompilerError("C compiler returned status %s" % status)
return o_file
def c_link(obj_file, verbose_flag = 0, extra_objects = [], cplus = 0):
return c_link_list([obj_file] + extra_objects, verbose_flag, cplus)
def c_link_list(obj_files, verbose_flag = 0, cplus = 0):
# Link the given object files into a dynamically
# loadable extension file. Returns the pathname
# of the resulting file.
out_file = replace_suffix(obj_files[0], ".so")
linker = linkers[bool(cplus)]
args = [linker] + linker_options + obj_files + ["-o", out_file]
if verbose_flag or verbose:
print " ".join(args)
status = os.spawnvp(os.P_WAIT, linker, args)
if status <> 0:
raise CCompilerError("Linker returned status %s" % status)
return out_file
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