Add calling_conv.

Set win32 api to use CC_X86_STDCALL. (need testing)
This commit is contained in:
Siu Kwan Lam 2012-08-30 12:23:53 -07:00
commit a046685b2c

View file

@ -1334,6 +1334,9 @@ class CExternal(object):
All class attributes that are `llvm.core.FunctionType` are converted
to `CFunc` instance during instantiation.
'''
_calling_convention_ = None # default
def __init__(self, cbuilder):
is_func = lambda x: isinstance(x, lc.FunctionType)
non_magic = lambda s: not ( s.startswith('__') and s.endswith('__') )
@ -1347,6 +1350,9 @@ class CExternal(object):
mod = cbuilder.function.module
for fname, ftype in to_declare:
func = mod.get_or_insert_function(ftype, name=fname)
if self._calling_convention_:
func.calling_convention = self._calling_convention_
if func.type.pointee != ftype:
raise NameError("Function has already been declared "
"with a different type: %s != %s"