From a046685b2c3499e6f1466058cd5f4c5ae63ff68d Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Thu, 30 Aug 2012 12:23:53 -0700 Subject: [PATCH] Add calling_conv. Set win32 api to use CC_X86_STDCALL. (need testing) --- builder.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder.py b/builder.py index b30c363..7aa5d93 100644 --- a/builder.py +++ b/builder.py @@ -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"