Have a typemap for uint8_t*

This commit is contained in:
Dan Hirsch 2013-12-16 15:52:24 +01:00
parent cbdff5fbc0
commit a219ffc45d
2 changed files with 39 additions and 7 deletions

View file

@ -12,7 +12,8 @@ dotnetenv.Append(CCFLAGS=["-fpic", '-DSWIG', '-Wno-all',
LIBPATH=["../.."],
SWIGFLAGS=["-DHAMMER_INTERNAL__NO_STDARG_H",
"-Isrc/", "-csharp",
"-dllimport","hammer_dotnet"])
"-dllimport","hammer_dotnet",
"-namespace", "Hammer.Internal"])
import os
swig = ['hammer.i']
@ -25,23 +26,25 @@ csfiles = os.path.join(thisdir, "*.cs")
# This also generates a bunch of .cs files, which we'll just use this
# target to stand in for.
hammer_wrap = AlwaysBuild(dotnetenv.Command(['hammer_wrap.c'], swig,
["rm %s/*.cs" % (thisdir,),
["rm %s/*.cs || true" % (thisdir,),
"swig $SWIGFLAGS $SOURCE"]))
libhammer_dotnet = dotnetenv.SharedLibrary(['hammer_dotnet'], hammer_wrap)
hammer_dll = AlwaysBuild(dotnetenv.Command(['hammer.dll'], hammer_wrap,
'$CSC -t:library -out:$TARGET %s/*.cs' %(thisdir,)))
Depends(hammer_dll, hammer_wrap)
#hammer_dll = dotnetenv.CLILibrary('hammer.dll', dotnetenv.Glob('*.cs'))
hammer_dll = AlwaysBuild(dotnetenv.Command(['hammer.dll'], Glob('ext/*.cs'),
'$CSC -t:library -unsafe -out:$TARGET %s/*.cs $SOURCE' %(thisdir,)))
Depends(hammer_dll, hammer_wrap)
#hammer_dll = dotnetenv.CLILibrary('hammer.dll', hammer.cs)
Default(libhammer_dotnet, hammer_dll)
dotnettestenv = dotnetenv.Clone()
#dotnettestenv['ENV']['LD_LIBRARY_PATH'] = os.path.dirname(str(libhammer_shared[0]))
#dotnettests = ['t/hammer.t']
dotnettestenv.Append(CILLIBS=['/usr/lib/cli/nunit.core-2.6/nunit.core.dll','/usr/lib/cli/nunit.util-2.6/nunit.util.dll','/usr/lib/cli/nunit.framework-2.6/nunit.framework.dll','/usr/lib/cli/nunit.core.interfaces-2.6/nunit.core.interfaces.dll',str(hammer_dll[0])])
dotnettestlib = dotnettestenv.CLILibrary('hammer_test.dll', Glob('test/*.cs'))
#dotnettestexec = dotnettestenv.Command(None, dotnettests + libhammer_dotnet + libhammer_shared, "make test -C " + targetdir)
#dotnettest = Alias("testdotnet", [dotnettestexec], dotnettestexec)
#AlwaysBuild(dotnettestexec)
#testruns.append(dotnettest)
testruns.append(dotnettestlib)
#dotnetinstallexec = dotnetenv.Command(None, libhammer_dotnet, "make install -C " + targetdir)
#dotnetinstall = Alias("installdotnet", [dotnetinstallexec], dotnetinstallexec)

View file

@ -1,3 +1,32 @@
%module hammer;
%include "stdint.i"
// Special attention needs to be paid to:
// h_parse
// h_token
// h_in
// h_not_in
//%typemap(cstype) uint8_t* "byte[]"
%typemap(imtype) uint8_t* "IntPtr"
//%typemap(csin, pre="unsafe { fixed(byte* temp$csinput = &$csinput[0]) {", terminator="}}") uint8_t* "(IntPtr)temp$csinput"
//%typemap(csvarin) uint8_t
%typemap(cstype) uint8_t* "IntPtr"
%typemap(csin) uint8_t* "$csinput"
%typemap(csvarout) uint8_t* %{
get {
return $imcall;
}
%}
%ignore h_bit_writer_get_buffer;
%apply (char *STRING, size_t LENGTH) {(uint8_t* str, size_t len)};
%apply (uint8_t* str, size_t len) {(const uint8_t* input, size_t length)}
%apply (uint8_t* str, size_t len) {(const uint8_t* str, const size_t len)}
%apply (uint8_t* str, size_t len) {(const uint8_t* charset, size_t length)}
%typemap(csclassmodifiers) SWIGTYPE "internal class";
%csmethodmodifiers "internal";
%include "../swig/hammer.i";