[IronPython] Takes at least 8 arguments (8 given)
Sanghyeon Seo
sanxiyn at gmail.com
Mon May 29 13:42:26 CEST 2006
I hate to reveal this, since I intended this one to be a surprise. :(
Anyway, attached script reports an error as in the title, and I can't
figure out why. Any idea? (You can guess what I am working on...)
Seo Sanghyeon
-------------- next part --------------
from System import AppDomain
from System.Reflection import AssemblyName
from System.Reflection.Emit import AssemblyBuilderAccess
pinvoke_module = None
def _define_pinvoke_module():
global pinvoke_module
if pinvoke_module is not None:
return
domain = AppDomain.CurrentDomain
name = AssemblyName('pinvoke')
flag = AssemblyBuilderAccess.Run
assembly = domain.DefineDynamicAssembly(name, flag)
pinvoke_module = assembly.DefineDynamicModule('pinvoke')
_define_pinvoke_module()
from System.Reflection import MethodAttributes
pinvoke_attributes = (
MethodAttributes.Public |
MethodAttributes.Static |
MethodAttributes.PinvokeImpl
)
from System import Int32, Double, String
import clr
c = clr.GetClrType
c_int = c(int)
c_float = c(float)
c_char_p = c(str)
from System.Reflection import CallingConventions
from System.Runtime.InteropServices import CharSet
pinvoke_module.DefinePInvokeMethod(
'strlen', 'msvcrt',
pinvoke_attributes, CallingConventions.Standard,
c_int, [c_char_p],
CallingConventions.Standard, CharSet.Ansi)
pinvoke_module.CreateGlobalFunctions()
strlen = pinvoke_module.GetMethod('strlen')
print strlen.Invoke(None, ['test'])
More information about the Ironpython-users
mailing list