swig-3.0.8/0000775000175000017500000000000012641164620012355 5ustar williamwilliamswig-3.0.8/autogen.sh0000775000175000017500000000111212641054563014355 0ustar williamwilliam#! /bin/sh # Bootstrap the development environment - add extra files needed to run configure. # Note autoreconf should do what this file achieves, but it has a bug when working with automake! # The latest config.guess and config.sub should be copied into Tools/config. # This script will ensure the latest is copied from your autotool installation. set -e set -x test -d Tools/config || mkdir Tools/config ${ACLOCAL-aclocal} -I Tools/config ${AUTOHEADER-autoheader} ${AUTOMAKE-automake} --add-missing --copy --force-missing ${AUTOCONF-autoconf} cd CCache && ${AUTORECONF-autoreconf} swig-3.0.8/vms/0000775000175000017500000000000012641054563013166 5ustar williamwilliamswig-3.0.8/vms/logicals.com0000664000175000017500000000077212641054563015471 0ustar williamwilliam$! $! $! $ proc = f$environment("PROCEDURE") $ proc = f$parse(proc,"sys$disk:[]",,,"NO_CONCEAL") $ cur_dev = f$parse(proc,,,"DEVICE","SYNTAX_ONLY") $ cur_dir = f$parse(proc,,,"DIRECTORY","SYNTAX_ONLY") $ cur_dir = f$extract(1,f$length(cur_dir)-2,cur_dir) $ cur_dir = cur_dir - "[" $ cur_dir = cur_dir - "]" $ cur_dir = cur_dir - "<" $ cur_dir = cur_dir - ">" $ $! remove trealing .VMS $ root_dir = f$extract(0,f$length(cur_dir)-4,cur_dir) $ $ define 'p1' /trans=concealed swig_root 'cur_dev'['root_dir'.] swig-3.0.8/vms/build_init.com0000664000175000017500000000053212641054563016010 0ustar williamwilliam$ set def swig_root:[vms] $ $ swiglib = "swig_root:[vms.o_alpha]swig.olb $ $ if (f$search("swig_root:[vms]o_alpha.dir") .eqs. "") then $ - create/dir swig_root:[vms.o_alpha] $ $ copy swigconfig.h [-.source.include] $ copy swigver.h [-.source.include] $ $ if (f$search("''swiglib'") .eqs. "") then $ - library/create/object 'swiglib' $ swig-3.0.8/vms/aaareadme.txt0000664000175000017500000000064212641054563015631 0ustar williamwilliamPort on OpenVMS 7.3 using CC 6.5 and CXX 6.5 Building procedure: $ @logicals $ @build_all the logicals swig_root is defined by the procedure logicals.com. The logicals.com procedure can be invoke with an optional argument for the define command, for example: $ @logicals "/system/exec" genbuild.py is the python program use to generate all the procedures in the [vms.scripts] directory. jf.pieronne@laposte.net swig-3.0.8/vms/build_swig.com0000664000175000017500000000004412641054563016014 0ustar williamwilliam$ @swig_root:[vms.scripts]build_all swig-3.0.8/vms/scripts/0000775000175000017500000000000012641054563014655 5ustar williamwilliamswig-3.0.8/vms/scripts/compil_cparse.com0000664000175000017500000000451112641054563020176 0ustar williamwilliam$! $! Generated by genbuild.py $! $ libname = "swig_root:[vms.o_alpha]swig.olb" $ $ set default SWIG_ROOT:[SOURCE.CPARSE] $ $ idir := swig_root:[source.swig] $ idir = idir + ",swig_root:[source.doh.include]" $ idir = idir + ",swig_root:[source.include]" $ idir = idir + ",swig_root:[source.preprocessor]" $ $ iflags = "/include=(''idir', sys$disk:[])" $ oflags = "/object=swig_root:[vms.o_alpha] $ cflags = "''oflags'''iflags'''dflags'" $ cxxflags = "''oflags'''iflags'''dflags'" $ $ call make swig_root:[vms.o_alpha]cscanner.obj - "cc ''cflags'" cscanner.c $ call make swig_root:[vms.o_alpha]parser.obj - "cc ''cflags'" parser.c $ call make swig_root:[vms.o_alpha]templ.obj - "cc ''cflags'" templ.c $ call make swig_root:[vms.o_alpha]util.obj - "cc ''cflags'" util.c $ exit $! $! $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES $ V = 'F$Verify(0) $! P1 = What we are trying to make $! P2 = Command to make it $! P3 = Source file $! P4 - P8 What it depends on $ $ modname = f$parse(p3,,,"name") $ set noon $ set message/nofacility/noident/noseverity/notext $ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' $ set message/facility/ident/severity/text $ on error then exit $ open/read swigtmp swig_root:[vms]swiglib.tmp $! skip header $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $! $ $ read/end=module_not_found swigtmp r $ modfound = 1 $ Time = f$cvtime(f$extract(49, 20, r)) $ goto end_search_module $ module_not_found: $ modfound = 0 $ $ end_search_module: $ close swigtmp $ delete swig_root:[vms]swiglib.tmp;* $ $ if modfound .eq. 0 then $ goto Makeit $ $! Time = F$CvTime(F$File(P1,"RDT")) $arg=3 $Loop: $ Argument = P'arg $ If Argument .Eqs. "" Then Goto Exit $ El=0 $Loop2: $ File = F$Element(El," ",Argument) $ If File .Eqs. " " Then Goto Endl $ AFile = "" $Loop3: $ OFile = AFile $ AFile = F$Search(File) $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3 $NextEL: $ El = El + 1 $ Goto Loop2 $EndL: $ arg=arg+1 $ If arg .Le. 8 Then Goto Loop $ Goto Exit $ $Makeit: $ VV=F$VERIFY(1) $ 'P2' 'P3' $ VV='F$Verify(VV) $Exit: $ If V Then Set Verify $ENDSUBROUTINE swig-3.0.8/vms/scripts/build_all.com0000664000175000017500000000057612641054563017314 0ustar williamwilliam$! $! Generated by genbuild.py $! $ set default swig_root:[vms] $ $ @swig_root:[vms]build_init $ @swig_root:[vms.scripts]compil_cparse.com $ @swig_root:[vms.scripts]compil_doh.com $ @swig_root:[vms.scripts]compil_modules1_1.com $ @swig_root:[vms.scripts]compil_preprocessor.com $ @swig_root:[vms.scripts]compil_swig.com $ $ set default swig_root:[vms] $ $ @swig_root:[vms]build_end swig-3.0.8/vms/scripts/compil_swig.com0000664000175000017500000000626112641054563017676 0ustar williamwilliam$! $! Generated by genbuild.py $! $ libname = "swig_root:[vms.o_alpha]swig.olb" $ $ set default SWIG_ROOT:[SOURCE.SWIG] $ $ idir := swig_root:[source.swig] $ idir = idir + ",swig_root:[source.doh.include]" $ idir = idir + ",swig_root:[source.include]" $ idir = idir + ",swig_root:[source.preprocessor]" $ $ iflags = "/include=(''idir', sys$disk:[])" $ oflags = "/object=swig_root:[vms.o_alpha] $ cflags = "''oflags'''iflags'''dflags'" $ cxxflags = "''oflags'''iflags'''dflags'" $ $ call make swig_root:[vms.o_alpha]cwrap.obj - "cc ''cflags'" cwrap.c $ call make swig_root:[vms.o_alpha]error.obj - "cc ''cflags'" error.c $ call make swig_root:[vms.o_alpha]fragment.obj - "cc ''cflags'" fragment.c $ call make swig_root:[vms.o_alpha]getopt.obj - "cc ''cflags'" getopt.c $ call make swig_root:[vms.o_alpha]include.obj - "cc ''cflags'" include.c $ call make swig_root:[vms.o_alpha]misc.obj - "cc ''cflags'" misc.c $ call make swig_root:[vms.o_alpha]naming.obj - "cc ''cflags'" naming.c $ call make swig_root:[vms.o_alpha]parms.obj - "cc ''cflags'" parms.c $ call make swig_root:[vms.o_alpha]scanner.obj - "cc ''cflags'" scanner.c $ call make swig_root:[vms.o_alpha]stype.obj - "cc ''cflags'" stype.c $ call make swig_root:[vms.o_alpha]symbol.obj - "cc ''cflags'" symbol.c $ call make swig_root:[vms.o_alpha]tree.obj - "cc ''cflags'" tree.c $ call make swig_root:[vms.o_alpha]typemap.obj - "cc ''cflags'" typemap.c $ call make swig_root:[vms.o_alpha]typesys.obj - "cc ''cflags'" typesys.c $ call make swig_root:[vms.o_alpha]warn.obj - "cc ''cflags'" warn.c $ call make swig_root:[vms.o_alpha]wrapfunc.obj - "cc ''cflags'" wrapfunc.c $ exit $! $! $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES $ V = 'F$Verify(0) $! P1 = What we are trying to make $! P2 = Command to make it $! P3 = Source file $! P4 - P8 What it depends on $ $ modname = f$parse(p3,,,"name") $ set noon $ set message/nofacility/noident/noseverity/notext $ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' $ set message/facility/ident/severity/text $ on error then exit $ open/read swigtmp swig_root:[vms]swiglib.tmp $! skip header $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $! $ $ read/end=module_not_found swigtmp r $ modfound = 1 $ Time = f$cvtime(f$extract(49, 20, r)) $ goto end_search_module $ module_not_found: $ modfound = 0 $ $ end_search_module: $ close swigtmp $ delete swig_root:[vms]swiglib.tmp;* $ $ if modfound .eq. 0 then $ goto Makeit $ $! Time = F$CvTime(F$File(P1,"RDT")) $arg=3 $Loop: $ Argument = P'arg $ If Argument .Eqs. "" Then Goto Exit $ El=0 $Loop2: $ File = F$Element(El," ",Argument) $ If File .Eqs. " " Then Goto Endl $ AFile = "" $Loop3: $ OFile = AFile $ AFile = F$Search(File) $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3 $NextEL: $ El = El + 1 $ Goto Loop2 $EndL: $ arg=arg+1 $ If arg .Le. 8 Then Goto Loop $ Goto Exit $ $Makeit: $ VV=F$VERIFY(1) $ 'P2' 'P3' $ VV='F$Verify(VV) $Exit: $ If V Then Set Verify $ENDSUBROUTINE swig-3.0.8/vms/scripts/compil_preprocessor.com0000664000175000017500000000426512641054563021455 0ustar williamwilliam$! $! Generated by genbuild.py $! $ libname = "swig_root:[vms.o_alpha]swig.olb" $ $ set default SWIG_ROOT:[SOURCE.PREPROCESSOR] $ $ idir := swig_root:[source.swig] $ idir = idir + ",swig_root:[source.doh.include]" $ idir = idir + ",swig_root:[source.include]" $ idir = idir + ",swig_root:[source.preprocessor]" $ $ iflags = "/include=(''idir', sys$disk:[])" $ oflags = "/object=swig_root:[vms.o_alpha] $ cflags = "''oflags'''iflags'''dflags'" $ cxxflags = "''oflags'''iflags'''dflags'" $ $ call make swig_root:[vms.o_alpha]cpp.obj - "cc ''cflags'" cpp.c $ call make swig_root:[vms.o_alpha]expr.obj - "cc ''cflags'" expr.c $ exit $! $! $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES $ V = 'F$Verify(0) $! P1 = What we are trying to make $! P2 = Command to make it $! P3 = Source file $! P4 - P8 What it depends on $ $ modname = f$parse(p3,,,"name") $ set noon $ set message/nofacility/noident/noseverity/notext $ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' $ set message/facility/ident/severity/text $ on error then exit $ open/read swigtmp swig_root:[vms]swiglib.tmp $! skip header $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $! $ $ read/end=module_not_found swigtmp r $ modfound = 1 $ Time = f$cvtime(f$extract(49, 20, r)) $ goto end_search_module $ module_not_found: $ modfound = 0 $ $ end_search_module: $ close swigtmp $ delete swig_root:[vms]swiglib.tmp;* $ $ if modfound .eq. 0 then $ goto Makeit $ $! Time = F$CvTime(F$File(P1,"RDT")) $arg=3 $Loop: $ Argument = P'arg $ If Argument .Eqs. "" Then Goto Exit $ El=0 $Loop2: $ File = F$Element(El," ",Argument) $ If File .Eqs. " " Then Goto Endl $ AFile = "" $Loop3: $ OFile = AFile $ AFile = F$Search(File) $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3 $NextEL: $ El = El + 1 $ Goto Loop2 $EndL: $ arg=arg+1 $ If arg .Le. 8 Then Goto Loop $ Goto Exit $ $Makeit: $ VV=F$VERIFY(1) $ 'P2' 'P3' $ VV='F$Verify(VV) $Exit: $ If V Then Set Verify $ENDSUBROUTINE swig-3.0.8/vms/scripts/compil_modules1_1.com0000664000175000017500000000717712641054563020705 0ustar williamwilliam$! $! Generated by genbuild.py $! $ libname = "swig_root:[vms.o_alpha]swig.olb" $ $ set default SWIG_ROOT:[SOURCE.MODULES1_1] $ $ idir := swig_root:[source.swig] $ idir = idir + ",swig_root:[source.doh.include]" $ idir = idir + ",swig_root:[source.include]" $ idir = idir + ",swig_root:[source.preprocessor]" $ $ iflags = "/include=(''idir', sys$disk:[])" $ oflags = "/object=swig_root:[vms.o_alpha] $ cflags = "''oflags'''iflags'''dflags'" $ cxxflags = "''oflags'''iflags'''dflags'" $ $ call make swig_root:[vms.o_alpha]allocate.obj - "cxx ''cxxflags'" allocate.cxx $ call make swig_root:[vms.o_alpha]browser.obj - "cxx ''cxxflags'" browser.cxx $ call make swig_root:[vms.o_alpha]contract.obj - "cxx ''cxxflags'" contract.cxx $ call make swig_root:[vms.o_alpha]emit.obj - "cxx ''cxxflags'" emit.cxx $ call make swig_root:[vms.o_alpha]guile.obj - "cxx ''cxxflags'" guile.cxx $ call make swig_root:[vms.o_alpha]java.obj - "cxx ''cxxflags'" java.cxx $ call make swig_root:[vms.o_alpha]lang.obj - "cxx ''cxxflags'" lang.cxx $ call make swig_root:[vms.o_alpha]main.obj - "cxx ''cxxflags'" main.cxx $ call make swig_root:[vms.o_alpha]module.obj - "cxx ''cxxflags'" module.cxx $ call make swig_root:[vms.o_alpha]mzscheme.obj - "cxx ''cxxflags'" mzscheme.cxx $ call make swig_root:[vms.o_alpha]ocaml.obj - "cxx ''cxxflags'" ocaml.cxx $ call make swig_root:[vms.o_alpha]overload.obj - "cxx ''cxxflags'" overload.cxx $ call make swig_root:[vms.o_alpha]perl5.obj - "cxx ''cxxflags'" perl5.cxx $ call make swig_root:[vms.o_alpha]php4.obj - "cxx ''cxxflags'" php4.cxx $ call make swig_root:[vms.o_alpha]pike.obj - "cxx ''cxxflags'" pike.cxx $ call make swig_root:[vms.o_alpha]python.obj - "cxx ''cxxflags'" python.cxx $ call make swig_root:[vms.o_alpha]ruby.obj - "cxx ''cxxflags'" ruby.cxx $ call make swig_root:[vms.o_alpha]swigmain.obj - "cxx ''cxxflags'" swigmain.cxx $ call make swig_root:[vms.o_alpha]tcl8.obj - "cxx ''cxxflags'" tcl8.cxx $ call make swig_root:[vms.o_alpha]typepass.obj - "cxx ''cxxflags'" typepass.cxx $ call make swig_root:[vms.o_alpha]xml.obj - "cxx ''cxxflags'" xml.cxx $ exit $! $! $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES $ V = 'F$Verify(0) $! P1 = What we are trying to make $! P2 = Command to make it $! P3 = Source file $! P4 - P8 What it depends on $ $ modname = f$parse(p3,,,"name") $ set noon $ set message/nofacility/noident/noseverity/notext $ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' $ set message/facility/ident/severity/text $ on error then exit $ open/read swigtmp swig_root:[vms]swiglib.tmp $! skip header $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $! $ $ read/end=module_not_found swigtmp r $ modfound = 1 $ Time = f$cvtime(f$extract(49, 20, r)) $ goto end_search_module $ module_not_found: $ modfound = 0 $ $ end_search_module: $ close swigtmp $ delete swig_root:[vms]swiglib.tmp;* $ $ if modfound .eq. 0 then $ goto Makeit $ $! Time = F$CvTime(F$File(P1,"RDT")) $arg=3 $Loop: $ Argument = P'arg $ If Argument .Eqs. "" Then Goto Exit $ El=0 $Loop2: $ File = F$Element(El," ",Argument) $ If File .Eqs. " " Then Goto Endl $ AFile = "" $Loop3: $ OFile = AFile $ AFile = F$Search(File) $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3 $NextEL: $ El = El + 1 $ Goto Loop2 $EndL: $ arg=arg+1 $ If arg .Le. 8 Then Goto Loop $ Goto Exit $ $Makeit: $ VV=F$VERIFY(1) $ 'P2' 'P3' $ VV='F$Verify(VV) $Exit: $ If V Then Set Verify $ENDSUBROUTINE swig-3.0.8/vms/scripts/compil_doh.com0000664000175000017500000000512612641054563017476 0ustar williamwilliam$! $! Generated by genbuild.py $! $ libname = "swig_root:[vms.o_alpha]swig.olb" $ $ set default SWIG_ROOT:[SOURCE.DOH.DOH] $ $ idir := swig_root:[source.swig] $ idir = idir + ",swig_root:[source.doh.include]" $ idir = idir + ",swig_root:[source.include]" $ idir = idir + ",swig_root:[source.preprocessor]" $ $ iflags = "/include=(''idir', sys$disk:[])" $ oflags = "/object=swig_root:[vms.o_alpha] $ cflags = "''oflags'''iflags'''dflags'" $ cxxflags = "''oflags'''iflags'''dflags'" $ $ call make swig_root:[vms.o_alpha]base.obj - "cc ''cflags'" base.c $ call make swig_root:[vms.o_alpha]file.obj - "cc ''cflags'" file.c $ call make swig_root:[vms.o_alpha]fio.obj - "cc ''cflags'" fio.c $ call make swig_root:[vms.o_alpha]hash.obj - "cc ''cflags'" hash.c $ call make swig_root:[vms.o_alpha]list.obj - "cc ''cflags'" list.c $ call make swig_root:[vms.o_alpha]memory.obj - "cc ''cflags'" memory.c $ call make swig_root:[vms.o_alpha]string.obj - "cc ''cflags'" string.c $ call make swig_root:[vms.o_alpha]void.obj - "cc ''cflags'" void.c $ exit $! $! $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES $ V = 'F$Verify(0) $! P1 = What we are trying to make $! P2 = Command to make it $! P3 = Source file $! P4 - P8 What it depends on $ $ modname = f$parse(p3,,,"name") $ set noon $ set message/nofacility/noident/noseverity/notext $ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' $ set message/facility/ident/severity/text $ on error then exit $ open/read swigtmp swig_root:[vms]swiglib.tmp $! skip header $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $! $ $ read/end=module_not_found swigtmp r $ modfound = 1 $ Time = f$cvtime(f$extract(49, 20, r)) $ goto end_search_module $ module_not_found: $ modfound = 0 $ $ end_search_module: $ close swigtmp $ delete swig_root:[vms]swiglib.tmp;* $ $ if modfound .eq. 0 then $ goto Makeit $ $! Time = F$CvTime(F$File(P1,"RDT")) $arg=3 $Loop: $ Argument = P'arg $ If Argument .Eqs. "" Then Goto Exit $ El=0 $Loop2: $ File = F$Element(El," ",Argument) $ If File .Eqs. " " Then Goto Endl $ AFile = "" $Loop3: $ OFile = AFile $ AFile = F$Search(File) $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3 $NextEL: $ El = El + 1 $ Goto Loop2 $EndL: $ arg=arg+1 $ If arg .Le. 8 Then Goto Loop $ Goto Exit $ $Makeit: $ VV=F$VERIFY(1) $ 'P2' 'P3' $ VV='F$Verify(VV) $Exit: $ If V Then Set Verify $ENDSUBROUTINE swig-3.0.8/vms/genbuild.py0000664000175000017500000000772412641054563015343 0ustar williamwilliamimport os.path, string, posix, pyvms # # IDIR = ['swig_root:[source.swig]', 'swig_root:[source.doh.include]', 'swig_root:[source.include]', 'swig_root:[source.preprocessor]'] def new_file(fg, dirname): global IDIR fn = 'swig_root:[vms.scripts]compil_' + os.path.basename(dirname) + '.com' print >> fg, '$ @' + fn f = open(fn, 'w') print >> f, '$!' print >> f, '$! Generated by genbuild.py' print >> f, '$!' print >> f, '$ libname = "swig_root:[vms.o_alpha]swig.olb"' print >> f, '$' print >> f, '$ set default', pyvms.crtl_to_vms(dirname)[0][0] print >> f, '$' print >> f, "$ idir := ", IDIR[0] for i in range(1, len(IDIR)): print >> f, '$ idir = idir + ",' + IDIR[i] + '"' print >> f, '$' print >> f, "$ iflags = \"/include=(''idir', sys$disk:[])\"" print >> f, '$ oflags = \"/object=swig_root:[vms.o_alpha]' print >> f, "$ cflags = \"''oflags'''iflags'''dflags'\"" print >> f, "$ cxxflags = \"''oflags'''iflags'''dflags'\"" print >> f, '$' return f def end_file(f): print >>f,"""$ exit $! $! $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES $ V = 'F$Verify(0) $! P1 = What we are trying to make $! P2 = Command to make it $! P3 = Source file $! P4 - P8 What it depends on $ $ modname = f$parse(p3,,,"name") $ set noon $ set message/nofacility/noident/noseverity/notext $ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' $ set message/facility/ident/severity/text $ on error then exit $ open/read swigtmp swig_root:[vms]swiglib.tmp $! skip header $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $ read swigtmp r $! $ $ read/end=module_not_found swigtmp r $ modfound = 1 $ Time = f$cvtime(f$extract(49, 20, r)) $ goto end_search_module $ module_not_found: $ modfound = 0 $ $ end_search_module: $ close swigtmp $ delete swig_root:[vms]swiglib.tmp;* $ $ if modfound .eq. 0 then $ goto Makeit $ $! Time = F$CvTime(F$File(P1,"RDT")) $arg=3 $Loop: $ Argument = P'arg $ If Argument .Eqs. "" Then Goto Exit $ El=0 $Loop2: $ File = F$Element(El," ",Argument) $ If File .Eqs. " " Then Goto Endl $ AFile = "" $Loop3: $ OFile = AFile $ AFile = F$Search(File) $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3 $NextEL: $ El = El + 1 $ Goto Loop2 $EndL: $ arg=arg+1 $ If arg .Le. 8 Then Goto Loop $ Goto Exit $ $Makeit: $ VV=F$VERIFY(1) $ 'P2' 'P3' $ VV='F$Verify(VV) $Exit: $ If V Then Set Verify $ENDSUBROUTINE""" def listRep(args, dirname, filenames): fg = args[0] first = 1 for fn in filenames: if fn[-2:] == '.c': if first: first = 0 fc = new_file(fg, dirname) cstr = "\"cc ''cflags'\" " line = "$ call make swig_root:[vms.o_alpha]" line += fn[:-1] + 'obj -' print >> fc, line line = "\t" + cstr + fn print >> fc, line elif fn[-4:] == '.cxx': if first: first = 0 fc = new_file(fg, dirname) cstr = "\"cxx ''cxxflags'\" " line = "$ call make swig_root:[vms.o_alpha]" line += fn[:-3] + 'obj -' print >> fc, line line = "\t" + cstr + fn print >> fc, line if first == 0: end_file(fc) fc.close() # def genbuild(f, dir): os.path.walk(dir, listRep, (f,)) cmd = 'set default swig_root:[vms]' # f = open('swig_root:[vms.scripts]build_all.com','w') print >> f, '$!' print >> f, '$! Generated by genbuild.py' print >> f, '$!' print >> f, '$ set default swig_root:[vms]' print >> f, '$' print >> f, '$ @swig_root:[vms]build_init' # genbuild(f, '/swig_root/source') print >> f, '$' print >> f, '$ set default swig_root:[vms]' print >> f, '$' print >> f, '$ @swig_root:[vms]build_end' f.close swig-3.0.8/vms/build_end.com0000664000175000017500000000112412641054563015611 0ustar williamwilliam$ set def swig_root:[vms] $ $ file = f$search("swig_root:[vms.o_alpha]*.obj") $ newobj = 0 $ if file .nes. "" $ then $ v = f$verify(1) $ library/replace swig_root:[vms.o_alpha]swig.olb swig_root:[vms.o_alpha]*.obj $ delete swig_root:[vms.o_alpha]*.obj;* $ v = f$verify(v) $ newobj = 1 $ endif $ file = f$search("swig_root:[vms]swig.exe") $ if file .eqs. "" .or. newobj $ then $ v = f$verify(1) $ cxxlink/exe=swig_root:[vms]swig.exe - /repo=swig_root:[source.modules1_1.cxx_repository] - swig_root:[vms.o_alpha]swig.olb/include=swigmain $ v = f$verify(v) $ endif swig-3.0.8/vms/swigconfig.h0000664000175000017500000000012712641054563015476 0ustar williamwilliam /* Note that this file has changed. TODO Get the latest from the original version. */ swig-3.0.8/Lib/0000775000175000017500000000000012641164620013063 5ustar williamwilliamswig-3.0.8/Lib/allkw.swg0000664000175000017500000000141112641054563014720 0ustar williamwilliam#ifndef __Lib_allkw_swg__ #define __Lib_allkw_swg__ /* Include all the known keyword warnings. Very useful for adding test files to the test-suite, or checking if your own library is ok for all the swig supported languages. Use as swig -Wallkw ... If you add a new language, remember to create a separate languagekw.swg file, and add it here. */ %include %include %include %include %include %include %include %include %include %include %include %include %include %include #endif //__Lib_allkw_swg__ swig-3.0.8/Lib/runtime.swg0000664000175000017500000000232412641054563015275 0ustar williamwilliam/* -----------------------------------------------------------------------------* Standard SWIG API for use inside user code. Don't include this file directly, run the command swig -python -external-runtime Also, read the Modules chapter of the SWIG Manual. * -----------------------------------------------------------------------------*/ #ifdef SWIG_MODULE_CLIENTDATA_TYPE SWIGRUNTIMEINLINE swig_type_info * SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { swig_module_info *module = SWIG_GetModule(clientdata); return SWIG_TypeQueryModule(module, module, name); } SWIGRUNTIMEINLINE swig_type_info * SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { swig_module_info *module = SWIG_GetModule(clientdata); return SWIG_MangledTypeQueryModule(module, module, name); } #else SWIGRUNTIMEINLINE swig_type_info * SWIG_TypeQuery(const char *name) { swig_module_info *module = SWIG_GetModule(NULL); return SWIG_TypeQueryModule(module, module, name); } SWIGRUNTIMEINLINE swig_type_info * SWIG_MangledTypeQuery(const char *name) { swig_module_info *module = SWIG_GetModule(NULL); return SWIG_MangledTypeQueryModule(module, module, name); } #endif swig-3.0.8/Lib/perl5/0000775000175000017500000000000012641054563014116 5ustar williamwilliamswig-3.0.8/Lib/perl5/perlmacros.swg0000664000175000017500000000004412641054563017005 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/std_pair.i0000664000175000017500000000127712641054563016104 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T t, U u); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/perl5/perlmain.i0000664000175000017500000000370212641054563016101 0ustar williamwilliam/* ----------------------------------------------------------------------------- * perlmain.i * * Code to statically rebuild perl5. * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %subsection "perlmain.i" %text %{ This module provides support for building a new version of the Perl executable. This will be necessary on systems that do not support shared libraries and may be necessary with C++ extensions. This module may only build a stripped down version of the Perl executable. Thus, it may be necessary (or desirable) to hand-edit this file for your particular application. To do this, simply copy this file from swig_lib/perl5/perlmain.i to your working directory and make the appropriate modifications. This library file works with Perl 5.003. It may work with earlier versions, but it hasn't been tested. As far as I know, this library is C++ safe. %} #endif %{ static void xs_init _((pTHX)); static PerlInterpreter *my_perl; int perl_eval(char *string) { char *argv[2]; argv[0] = string; argv[1] = (char *) 0; return perl_call_argv("eval",0,argv); } int main(int argc, char **argv, char **env) { int exitstatus; my_perl = perl_alloc(); if (!my_perl) exit(1); perl_construct( my_perl ); exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL ); if (exitstatus) exit( exitstatus ); /* Initialize all of the module variables */ exitstatus = perl_run( my_perl ); perl_destruct( my_perl ); perl_free( my_perl ); exit( exitstatus ); } /* Register any extra external extensions */ /* Do not delete this line--writemain depends on it */ /* EXTERN_C void boot_DynaLoader _((CV* cv)); */ static void xs_init(pTHX) { /* dXSUB_SYS; */ char *file = __FILE__; { /* newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); */ newXS(SWIG_name, SWIG_init, file); #ifdef SWIGMODINIT SWIGMODINIT #endif } } %} swig-3.0.8/Lib/perl5/noembed.h0000664000175000017500000000311412641054563015677 0ustar williamwilliam/* Workaround perl5 global namespace pollution. Note that undefining library * functions like fopen will not solve the problem on all platforms as fopen * might be a macro on Windows but not necessarily on other operating systems. */ #ifdef do_open #undef do_open #endif #ifdef do_close #undef do_close #endif #ifdef do_exec #undef do_exec #endif #ifdef scalar #undef scalar #endif #ifdef list #undef list #endif #ifdef apply #undef apply #endif #ifdef convert #undef convert #endif #ifdef Error #undef Error #endif #ifdef form #undef form #endif #ifdef vform #undef vform #endif #ifdef LABEL #undef LABEL #endif #ifdef METHOD #undef METHOD #endif #ifdef Move #undef Move #endif #ifdef yylex #undef yylex #endif #ifdef yyparse #undef yyparse #endif #ifdef yyerror #undef yyerror #endif #ifdef invert #undef invert #endif #ifdef ref #undef ref #endif #ifdef read #undef read #endif #ifdef write #undef write #endif #ifdef eof #undef eof #endif #ifdef close #undef close #endif #ifdef rewind #undef rewind #endif #ifdef free #undef free #endif #ifdef malloc #undef malloc #endif #ifdef calloc #undef calloc #endif #ifdef Stat #undef Stat #endif #ifdef check #undef check #endif #ifdef seekdir #undef seekdir #endif #ifdef open #undef open #endif #ifdef readdir #undef readdir #endif #ifdef bind #undef bind #endif #ifdef access #undef access #endif #ifdef stat #undef stat #endif #ifdef seed #undef seed #endif #ifdef bool /* Leave if macro is from C99 stdbool.h */ #ifndef __bool_true_false_are_defined #undef bool #endif #endif swig-3.0.8/Lib/perl5/perl5.swg0000664000175000017500000000270412641054563015672 0ustar williamwilliam/* ------------------------------------------------------------ * perl.swg * * Perl configuration module. * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Inner macros * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The runtime part * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Special user directives * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Typemap specializations * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Warnings for Perl keywords * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Perl initialization function * ------------------------------------------------------------ */ %include swig-3.0.8/Lib/perl5/std_except.i0000664000175000017500000000004312641054563016427 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/cdata.i0000664000175000017500000000003612641054563015343 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/carrays.i0000664000175000017500000000004112641054563015727 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/perlhead.swg0000664000175000017500000000506612641054563016433 0ustar williamwilliam#ifdef __cplusplus /* Needed on some windows machines---since MS plays funny games with the header files under C++ */ #include #include extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" /* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ /* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION # endif #endif #if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) #define PerlIO_exportFILE(fh,fl) (FILE*)(fh) #endif #ifndef SvIOK_UV # define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) #endif #ifndef SvUOK # define SvUOK(sv) SvIOK_UV(sv) #endif #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) # define PL_sv_undef sv_undef # define PL_na na # define PL_errgv errgv # define PL_sv_no sv_no # define PL_sv_yes sv_yes # define PL_markstack_ptr markstack_ptr #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif # define NUM2PTR(any,d) (any)(PTRV)(d) # define PTR2IV(p) INT2PTR(IV,p) # define PTR2UV(p) INT2PTR(UV,p) # define PTR2NV(p) NUM2PTR(NV,p) # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif /* !INT2PTR */ #ifndef SvPV_nolen # define SvPV_nolen(x) SvPV(x,PL_na) #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif #ifndef pTHX_ #define pTHX_ #endif #include #ifdef __cplusplus } #endif swig-3.0.8/Lib/perl5/exception.i0000664000175000017500000000021212641054563016261 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-3.0.8/Lib/perl5/perlstrings.swg0000664000175000017500000000262112641054563017215 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) { if (SvMAGICAL(obj)) { SV *tmp = sv_newmortal(); SvSetSV(tmp, obj); obj = tmp; } if (SvPOK(obj)) { STRLEN len = 0; char *cstr = SvPV(obj, len); size_t size = len + 1; if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { *cptr = %new_copy_array(cstr, size, char); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } } if (psize) *psize = size; return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { char* vptr = 0; if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = vptr; if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header") { SWIGINTERNINLINE SV * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { SV *obj = sv_newmortal(); if (carray) { sv_setpvn(obj, carray, size); } else { sv_setsv(obj, &PL_sv_undef); } return obj; } } swig-3.0.8/Lib/perl5/std_deque.i0000664000175000017500000000003412641054563016242 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/std_common.i0000664000175000017500000000115512641054563016434 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; %fragment(""); %{ double SwigSvToNumber(SV* sv) { return SvIOK(sv) ? double(SvIVX(sv)) : SvNVX(sv); } std::string SwigSvToString(SV* sv) { STRLEN len; char *ptr = SvPV(sv, len); return std::string(ptr, len); } void SwigSvFromString(SV* sv, const std::string& s) { sv_setpvn(sv,s.data(),s.size()); } %} swig-3.0.8/Lib/perl5/extra-install.list0000664000175000017500000000006212641054563017600 0ustar williamwilliam# see top-level Makefile.in Makefile.pl noembed.h swig-3.0.8/Lib/perl5/perlinit.swg0000664000175000017500000000374012641054563016472 0ustar williamwilliam /* Export the SWIG initialization function */ %header %{ #ifdef __cplusplus extern "C" #endif #ifndef PERL_OBJECT #ifndef MULTIPLICITY SWIGEXPORT void SWIG_init (CV* cv); #else SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); #endif #else SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); #endif %} /* Module initialization function */ %insert(init) "swiginit.swg" %init %{ #if defined(__cplusplus) && ! defined(XSPROTO) extern "C" #endif XS(SWIG_init) { dXSARGS; int i; SWIG_InitializeModule(0); /* Install commands */ for (i = 0; swig_commands[i].name; i++) { /* Casts only needed for Perl < 5.10. */ #ifdef __cplusplus newXS(const_cast(swig_commands[i].name), swig_commands[i].wrapper, const_cast(__FILE__)); #else newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__); #endif } /* Install variables */ for (i = 0; swig_variables[i].name; i++) { SV *sv; sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); if (swig_variables[i].type) { SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); } else { sv_setiv(sv,(IV) 0); } swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); } /* Install constant */ for (i = 0; swig_constants[i].type; i++) { SV *sv; sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); switch(swig_constants[i].type) { case SWIG_INT: sv_setiv(sv, (IV) swig_constants[i].lvalue); break; case SWIG_FLOAT: sv_setnv(sv, (double) swig_constants[i].dvalue); break; case SWIG_STRING: sv_setpv(sv, (const char *) swig_constants[i].pvalue); break; case SWIG_POINTER: SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); break; case SWIG_BINARY: SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); break; default: break; } SvREADONLY_on(sv); } %} swig-3.0.8/Lib/perl5/cni.i0000664000175000017500000000022612641054563015041 0ustar williamwilliam%warnfilter(SWIGWARN_PARSE_KEYWORD) java::lang::ref; %{ #undef STATIC %} %include %{ #undef TRUE #define TRUE 1 %} %include swig-3.0.8/Lib/perl5/factory.i0000664000175000017500000000004012641054563015731 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/perlruntime.swg0000664000175000017500000000050612641054563017207 0ustar williamwilliam %runtime "swigrun.swg" // Common C API type-checking code %runtime "swigerrors.swg" // SWIG errors %runtime "perlhead.swg" // Perl includes and fixes %runtime "perlerrors.swg" // Perl errors %runtime "perlrun.swg" // Perl runtime functions %runtime "noembed.h" // undefine Perl5 macros swig-3.0.8/Lib/perl5/std_list.i0000664000175000017500000003407712641054563016130 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_list.i * * SWIG typemaps for std::list types * ----------------------------------------------------------------------------- */ %include %include // containers // ------------------------------------------------------------------------ // std::list // // The aim of all that follows would be to integrate std::list with // Perl as much as possible, namely, to allow the user to pass and // be returned Perl arrays. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::list), f(const std::list&), f(const std::list*): // the parameter being read-only, either a Perl sequence or a // previously wrapped std::list can be passed. // -- f(std::list&), f(std::list*): // the parameter must be modified; therefore, only a wrapped std::list // can be passed. // -- std::list f(): // the list is returned by copy; therefore, a Perl sequence of T:s // is returned which is most easily used in other Perl functions // -- std::list& f(), std::list* f(), const std::list& f(), // const std::list* f(): // the list is returned by reference; therefore, a wrapped std::list // is returned // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template class list { %typemap(in) list (std::list* v) { if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,1) != -1) { $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i& (std::list temp, std::list* v), const list* (std::list temp, std::list* v) { if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,1) != -1) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i { std::list< T >::const_iterator i; unsigned int j; int len = $1.size(); SV **svs = new SV*[len]; for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { T* ptr = new T(*i); svs[j] = sv_newmortal(); SWIG_MakePtr(svs[j], (void*) ptr, $descriptor(T *), $shadow|$owner); } AV *myav = av_make(len, svs); delete[] svs; $result = newRV_noinc((SV*) myav); sv_2mortal($result); argvi++; } %typecheck(SWIG_TYPECHECK_LIST) list { { /* wrapped list? */ std::list< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_&descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { SV **tv; I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* obj; tv = av_fetch(av, 0, 0); if (SWIG_ConvertPtr(*tv, (void **)&obj, $descriptor(T *),0) != -1) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_LIST) const list&, const list* { { /* wrapped list? */ std::list< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { SV **tv; I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* obj; tv = av_fetch(av, 0, 0); if (SWIG_ConvertPtr(*tv, (void **)&obj, $descriptor(T *),0) != -1) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; list(); list(const list &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(const T& x); }; // specializations for built-ins %define specialize_std_list(T,CHECK_T,TO_T,FROM_T) template<> class list { %typemap(in) list (std::list* v) { if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,1) != -1){ $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; for (int i=0; i& (std::list temp, std::list* v), const list* (std::list temp, std::list* v) { if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,1) != -1) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i { std::list< T >::const_iterator i; unsigned int j; int len = $1.size(); SV **svs = new SV*[len]; for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { svs[j] = sv_newmortal(); FROM_T(svs[j], *i); } AV *myav = av_make(len, svs); delete[] svs; $result = newRV_noinc((SV*) myav); sv_2mortal($result); argvi++; } %typecheck(SWIG_TYPECHECK_LIST) list { { /* wrapped list? */ std::list< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_&descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { SV **tv; I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ tv = av_fetch(av, 0, 0); if (CHECK_T(*tv)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_LIST) const list&, const list* { { /* wrapped list? */ std::list< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { SV **tv; I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ tv = av_fetch(av, 0, 0); if (CHECK_T(*tv)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; list(); list(const list &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(T x); }; %enddef specialize_std_list(bool,SvIOK,SvIVX,sv_setiv); specialize_std_list(char,SvIOK,SvIVX,sv_setiv); specialize_std_list(int,SvIOK,SvIVX,sv_setiv); specialize_std_list(short,SvIOK,SvIVX,sv_setiv); specialize_std_list(long,SvIOK,SvIVX,sv_setiv); specialize_std_list(unsigned char,SvIOK,SvIVX,sv_setiv); specialize_std_list(unsigned int,SvIOK,SvIVX,sv_setiv); specialize_std_list(unsigned short,SvIOK,SvIVX,sv_setiv); specialize_std_list(unsigned long,SvIOK,SvIVX,sv_setiv); specialize_std_list(float,SvNIOK,SwigSvToNumber,sv_setnv); specialize_std_list(double,SvNIOK,SwigSvToNumber,sv_setnv); specialize_std_list(std::string,SvPOK,SvPVX,SwigSvFromString); } swig-3.0.8/Lib/perl5/perlprimtypes.swg0000664000175000017500000001773612641054563017575 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* bool */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(bool)(bool value) { return boolSV(value); } } %fragment(SWIG_AsVal_frag(bool),"header") { SWIGINTERN int SWIG_AsVal_dec(bool)(SV *obj, bool* val) { if (obj == &PL_sv_yes) { if (val) *val = true; return SWIG_OK; } else if (obj == &PL_sv_no) { if (val) *val = false; return SWIG_OK; } else { if (val) *val = SvTRUE(obj) ? true : false; return SWIG_AddCast(SWIG_OK); } } } /* long */ %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(long)(long value) { SV *sv; if (IVSIZE >= sizeof(value) || (value >= IV_MIN && value <= IV_MAX)) sv = newSViv(value); else sv = newSVpvf("%ld", value); return sv_2mortal(sv); } } %fragment(SWIG_AsVal_frag(long),"header", fragment="", fragment="", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long)(SV *obj, long* val) { if (SvUOK(obj)) { UV v = SvUV(obj); if (UVSIZE < sizeof(*val) || v <= LONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); if (IVSIZE <= sizeof(*val) || (v >= LONG_MIN && v <= LONG_MAX)) { if(val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; long v; errno = 0; v = strtol(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { if (val) *val = (long)(d); return res; } } } return SWIG_TypeError; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(unsigned long)(unsigned long value) { SV *sv; if (UVSIZE >= sizeof(value) || value <= UV_MAX) sv = newSVuv(value); else sv = newSVpvf("%lu", value); return sv_2mortal(sv); } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="", fragment="", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val) { if (SvUOK(obj)) { UV v = SvUV(obj); if (UVSIZE <= sizeof(*val) || v <= ULONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULONG_MAX)) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; unsigned long v; errno = 0; v = strtoul(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { if (val) *val = (unsigned long)(d); return res; } } } return SWIG_TypeError; } } /* long long */ %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE SV * SWIG_From_dec(long long)(long long value) { SV *sv; if (IVSIZE >= sizeof(value) || (value >= IV_MIN && value <= IV_MAX)) sv = newSViv((IV)(value)); else { //sv = newSVpvf("%lld", value); doesn't work in non 64bit Perl char temp[256]; sprintf(temp, "%lld", value); sv = newSVpv(temp, 0); } return sv_2mortal(sv); } } %fragment(SWIG_AsVal_frag(long long),"header", fragment="", fragment="", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long long)(SV *obj, long long *val) { if (SvUOK(obj)) { UV v = SvUV(obj); /* pretty sure this could allow v == LLONG MAX */ if (UVSIZE < sizeof(*val) || v < LLONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); if (IVSIZE <= sizeof(*val) || (v >= LLONG_MIN && v <= LLONG_MAX)) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; long long v; errno = 0; v = strtoll(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } if (!dispatch) { const double mant_max = 1LL << DBL_MANT_DIG; const double mant_min = -mant_max; double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { if (val) *val = (long long)(d); return res; } } } return SWIG_TypeError; } } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERNINLINE SV * SWIG_From_dec(unsigned long long)(unsigned long long value) { SV *sv; if (UVSIZE >= sizeof(value) || value <= UV_MAX) sv = newSVuv((UV)(value)); else { //sv = newSVpvf("%llu", value); doesn't work in non 64bit Perl char temp[256]; sprintf(temp, "%llu", value); sv = newSVpv(temp, 0); } return sv_2mortal(sv); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment="", fragment="", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val) { if (SvUOK(obj)) { /* pretty sure this should be conditional on * (UVSIZE <= sizeof(*val) || v <= ULLONG_MAX) */ if (val) *val = SvUV(obj); return SWIG_OK; } else if (SvIOK(obj)) { IV v = SvIV(obj); if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULLONG_MAX)) { if (val) *val = v; return SWIG_OK; } else { return SWIG_OverflowError; } } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; unsigned long long v; errno = 0; v = strtoull(nptr, &endptr,0); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } if (!dispatch) { const double mant_max = 1LL << DBL_MANT_DIG; double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { if (val) *val = (unsigned long long)(d); return res; } } } return SWIG_TypeError; } } /* double */ %fragment(SWIG_From_frag(double),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(double)(double value) { return sv_2mortal(newSVnv(value)); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(SV *obj, double *val) { if (SvNIOK(obj)) { if (val) *val = SvNV(obj); return SWIG_OK; } else if (SvIOK(obj)) { if (val) *val = (double) SvIV(obj); return SWIG_AddCast(SWIG_OK); } else { const char *nptr = SvPV_nolen(obj); if (nptr) { char *endptr; double v; errno = 0; v = strtod(nptr, &endptr); if (errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_Str2NumCast(SWIG_OK); } } } } return SWIG_TypeError; } } swig-3.0.8/Lib/perl5/jstring.i0000664000175000017500000000202612641054563015750 0ustar williamwilliam%include %fragment(SWIG_AsVal_frag(jstring),"header") { SWIGINTERN int SWIG_AsVal_dec(jstring)(SV *obj, jstring *val) { if (SvPOK(obj)) { if (val) { STRLEN len = 0; char *cstr = SvPV(obj, len); *val = JvNewStringLatin1(cstr, len); } return SWIG_OK; } return SWIG_ERROR; } } %fragment(SWIG_From_frag(jstring),"header") { SWIGINTERNINLINE SV * SWIG_From_dec(jstring)(jstring val) { SV *obj = sv_newmortal(); if (!val) { sv_setsv(obj, &PL_sv_undef); } else { jsize len = JvGetStringUTFLength(val); if (!len) { sv_setsv(obj, &PL_sv_undef); } else { char *tmp = %new_array(len, char); JvGetStringUTFRegion(val, 0, len, tmp); sv_setpvn(obj, tmp, len); SvUTF8_on(obj); %delete_array(tmp); } } return obj; } } %typemaps_asvalfrom(%checkcode(STRING), %arg(SWIG_AsVal(jstring)), %arg(SWIG_From(jstring)), %arg(SWIG_AsVal_frag(jstring)), %arg(SWIG_From_frag(jstring)), java::lang::String *); swig-3.0.8/Lib/perl5/perlrun.swg0000664000175000017500000003462112641054563016335 0ustar williamwilliam/* ----------------------------------------------------------------------------- * perlrun.swg * * This file contains the runtime support for Perl modules * and includes code for managing global variables and pointer * type checking. * ----------------------------------------------------------------------------- */ #ifdef PERL_OBJECT #define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), #define SWIG_PERL_OBJECT_CALL pPerl, #else #define SWIG_PERL_OBJECT_DECL #define SWIG_PERL_OBJECT_CALL #endif /* Common SWIG API */ /* for raw pointers */ #define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) #define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own) #define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) #define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) #define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Perl_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) #define SWIG_Error(code, msg) sv_setpvf(get_sv("@", GV_ADD), "%s %s", SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Perl-specific SWIG API */ #define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) #define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) #define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) #define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) #define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) #define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) #define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #ifdef __cplusplus extern "C" { #endif #define SWIG_OWNER SWIG_POINTER_OWN #define SWIG_SHADOW SWIG_OWNER << 1 #define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL /* SWIG Perl macros */ /* Macro to declare an XS function */ #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif /* Macro to call an XS function */ #ifdef PERL_OBJECT # define SWIG_CALLXS(_name) _name(cv,pPerl) #else # ifndef MULTIPLICITY # define SWIG_CALLXS(_name) _name(cv) # else # define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) # endif #endif #ifdef PERL_OBJECT #define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; #ifdef __cplusplus extern "C" { #endif typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus } #endif #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) #define SWIGCLASS_STATIC #else /* PERL_OBJECT */ #define MAGIC_PPERL #define SWIGCLASS_STATIC static SWIGUNUSED #ifndef MULTIPLICITY #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) #ifdef __cplusplus extern "C" { #endif typedef int (*SwigMagicFunc)(SV *, MAGIC *); #ifdef __cplusplus } #endif #else /* MULTIPLICITY */ #define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) #ifdef __cplusplus extern "C" { #endif typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); #ifdef __cplusplus } #endif #endif /* MULTIPLICITY */ #endif /* PERL_OBJECT */ # ifdef PERL_OBJECT # define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) static void SWIG_Perl_croak_null(CPerlObj *pPerl) # else static void SWIG_croak_null() # endif { SV *err = get_sv("@", GV_ADD); # if (PERL_VERSION < 6) croak("%_", err); # else if (sv_isobject(err)) croak(0); else croak("%s", SvPV_nolen(err)); # endif } /* Define how strict is the cast between strings and integers/doubles when overloading between these types occurs. The default is making it as strict as possible by using SWIG_AddCast when needed. You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to disable the SWIG_AddCast, making the casting between string and numbers less strict. In the end, we try to solve the overloading between strings and numerical types in the more natural way, but if you can avoid it, well, avoid it using %rename, for example. */ #ifndef SWIG_PERL_NO_STRICT_STR2NUM # ifndef SWIG_PERL_STRICT_STR2NUM # define SWIG_PERL_STRICT_STR2NUM # endif #endif #ifdef SWIG_PERL_STRICT_STR2NUM /* string takes precedence */ #define SWIG_Str2NumCast(x) SWIG_AddCast(x) #else /* number takes precedence */ #define SWIG_Str2NumCast(x) x #endif #include SWIGRUNTIME const char * SWIG_Perl_TypeProxyName(const swig_type_info *type) { if (!type) return NULL; if (type->clientdata != NULL) { return (const char*) type->clientdata; } else { return type->name; } } /* Identical to SWIG_TypeCheck, except for strcmp comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (strcmp(SWIG_Perl_TypeProxyName(iter->type), c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Function for getting a pointer value */ SWIGRUNTIME int SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags, int *own) { swig_cast_info *tc; void *voidptr = (void *)0; SV *tsv = 0; if (own) *own = 0; /* If magical, apply more magic */ if (SvGMAGICAL(sv)) mg_get(sv); /* Check to see if this is an object */ if (sv_isobject(sv)) { IV tmp = 0; tsv = (SV*) SvRV(sv); if ((SvTYPE(tsv) == SVt_PVHV)) { MAGIC *mg; if (SvMAGICAL(tsv)) { mg = mg_find(tsv,'P'); if (mg) { sv = mg->mg_obj; if (sv_isobject(sv)) { tsv = (SV*)SvRV(sv); tmp = SvIV(tsv); } } } else { return SWIG_ERROR; } } else { tmp = SvIV(tsv); } voidptr = INT2PTR(void *,tmp); } else if (! SvOK(sv)) { /* Check for undef */ *(ptr) = (void *) 0; return SWIG_OK; } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ if (!SvROK(sv)) { /* In Perl 5.12 and later, SVt_RV == SVt_IV, so sv could be a valid integer value. */ if (SvIOK(sv)) { return SWIG_ERROR; } else { /* NULL pointer (reference to undef). */ *(ptr) = (void *) 0; return SWIG_OK; } } else { return SWIG_ERROR; } } else { /* Don't know what it is */ return SWIG_ERROR; } if (_t) { /* Now see if the types match */ char *_c = HvNAME(SvSTASH(SvRV(sv))); tc = SWIG_TypeProxyCheck(_c,_t); #ifdef SWIG_DIRECTORS if (!tc && !sv_derived_from(sv,SWIG_Perl_TypeProxyName(_t))) { #else if (!tc) { #endif return SWIG_ERROR; } { int newmemory = 0; *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } } } else { *ptr = voidptr; } /* * DISOWN implementation: we need a perl guru to check this one. */ if (tsv && (flags & SWIG_POINTER_DISOWN)) { /* * almost copy paste code from below SWIG_POINTER_OWN setting */ SV *obj = sv; HV *stash = SvSTASH(SvRV(obj)); GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE); if (isGV(gv)) { HV *hv = GvHVn(gv); /* * To set ownership (see below), a newSViv(1) entry is added. * Hence, to remove ownership, we delete the entry. */ if (hv_exists_ent(hv, obj, 0)) { hv_delete_ent(hv, obj, 0, 0); } } } return SWIG_OK; } SWIGRUNTIME int SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { return SWIG_Perl_ConvertPtrAndOwn(sv, ptr, _t, flags, 0); } SWIGRUNTIME void SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) { SV *self; SV *obj=newSV(0); HV *hash=newHV(); HV *stash; sv_setref_pv(obj, SWIG_Perl_TypeProxyName(t), ptr); stash=SvSTASH(SvRV(obj)); if (flags & SWIG_POINTER_OWN) { HV *hv; GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE); if (!isGV(gv)) gv_init(gv, stash, "OWNER", 5, FALSE); hv=GvHVn(gv); hv_store_ent(hv, obj, newSViv(1), 0); } sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); SvREFCNT_dec(obj); self=newRV_noinc((SV *)hash); sv_setsv(sv, self); SvREFCNT_dec((SV *)self); sv_bless(sv, stash); } else { sv_setref_pv(sv, SWIG_Perl_TypeProxyName(t), ptr); } } SWIGRUNTIMEINLINE SV * SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { SV *result = sv_newmortal(); SWIG_MakePtr(result, ptr, t, flags); return result; } SWIGRUNTIME void SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); strcpy(r,SWIG_Perl_TypeProxyName(type)); sv_setpv(sv, result); } SWIGRUNTIME SV * SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { SV *result = sv_newmortal(); SWIG_Perl_MakePackedObj(result, ptr, sz, type); return result; } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; const char *c = 0; if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; c = SvPV_nolen(obj); /* Pointer values must start with leading underscore */ if (*c != '_') return SWIG_ERROR; c++; c = SWIG_UnpackData(c,ptr,sz); if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) return SWIG_ERROR; } return SWIG_OK; } /* Macros for low-level exception handling */ #define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } typedef XSPROTO(SwigPerlWrapper); typedef SwigPerlWrapper *SwigPerlWrapperPtr; /* Structure for command table */ typedef struct { const char *name; SwigPerlWrapperPtr wrapper; } swig_command_info; /* Information for constant table */ #define SWIG_INT 1 #define SWIG_FLOAT 2 #define SWIG_STRING 3 #define SWIG_POINTER 4 #define SWIG_BINARY 5 /* Constant information structure */ typedef struct swig_constant_info { int type; const char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_constant_info; /* Structure for variable table */ typedef struct { const char *name; SwigMagicFunc set; SwigMagicFunc get; swig_type_info **type; } swig_variable_info; /* Magic variable code */ #ifndef PERL_OBJECT # ifdef __cplusplus # define swig_create_magic(s,a,b,c) _swig_create_magic(s,const_cast(a),b,c) # else # define swig_create_magic(s,a,b,c) _swig_create_magic(s,(char*)(a),b,c) # endif # ifndef MULTIPLICITY SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) # else SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) # endif #else # define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) #endif { MAGIC *mg; sv_magic(sv,sv,'U',name,strlen(name)); mg = mg_find(sv,'U'); mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); mg->mg_virtual->svt_get = (SwigMagicFunc) get; mg->mg_virtual->svt_set = (SwigMagicFunc) set; mg->mg_virtual->svt_len = 0; mg->mg_virtual->svt_clear = 0; mg->mg_virtual->svt_free = 0; } SWIGRUNTIME swig_module_info * SWIG_Perl_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; SV *pointer; /* first check if pointer already created */ if (!type_pointer) { pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI); if (pointer && SvOK(pointer)) { type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); } } return (swig_module_info *) type_pointer; } SWIGRUNTIME void SWIG_Perl_SetModule(swig_module_info *module) { SV *pointer; /* create a new pointer */ pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI); sv_setiv(pointer, PTR2IV(module)); } #ifdef __cplusplus } #endif swig-3.0.8/Lib/perl5/std_map.i0000664000175000017500000000446112641054563015724 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map< K, T >::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.8/Lib/perl5/attribute.i0000664000175000017500000000004212641054563016267 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/Makefile.pl0000664000175000017500000000126012641054563016167 0ustar williamwilliam# File : Makefile.pl # MakeMaker file for a SWIG module. Use this file if you are # producing a module for general use or distribution. # # 1. Modify the file as appropriate. Replace $module with the # real name of your module and wrapper file. # 2. Run perl as 'perl Makefile.pl' # 3. Type 'make' to build your module # 4. Type 'make install' to install your module. # # See "Programming Perl", 2nd. Ed, for more gory details than # you ever wanted to know. use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => '$module', # Name of your module 'LIBS' => [''], # Custom libraries (if any) 'OBJECT' => '$module_wrap.o' # Object files ); swig-3.0.8/Lib/perl5/perlfragments.swg0000664000175000017500000000105412641054563017511 0ustar williamwilliam/* Create a file with this name, 'perlfragments.swg', in your working directory and add all the %fragments you want to take precedence over the ones defined by default by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(PyObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.8/Lib/perl5/Makefile.in0000664000175000017500000000664412641054563016175 0ustar williamwilliam# --------------------------------------------------------------- # SWIG Perl5 Makefile # # This file can be used to build various Perl5 extensions with SWIG. # By default this file is set up for dynamic loading, but it can # be easily customized for static extensions by modifying various # portions of the file. # # SRCS = C source files # CXXSRCS = C++ source files # OBJCSRCS = Objective-C source files # OBJS = Additional .o files (compiled previously) # INTERFACE = SWIG interface file # TARGET = Name of target module or executable # # Many portions of this file were created by the SWIG configure # script and should already reflect your machine. #---------------------------------------------------------------- SRCS = CXXSRCS = OBJCSRCS = OBJS = INTERFACE = WRAPFILE = $(INTERFACE:.i=_wrap.c) WRAPOBJ = $(INTERFACE:.i=_wrap.o) TARGET = module@SO@ # Use this kind of target for dynamic loading #TARGET = myperl # Use this target for static linking prefix = @prefix@ exec_prefix = @exec_prefix@ CC = @CC@ CXX = @CXX@ OBJC = @CC@ -Wno-import # -Wno-import needed for gcc CFLAGS = INCLUDES = LIBS = # SWIG Options # SWIG = location of the SWIG executable # SWIGOPT = SWIG compiler options # SWIGCC = Compiler used to compile the wrapper file SWIG = $(exec_prefix)/bin/swig SWIGOPT = -perl5 SWIGCC = $(CC) # SWIG Library files. Uncomment this to statically rebuild Perl #SWIGLIBS = -static -lperlmain.i # Rules for creating .o files from source. COBJS = $(SRCS:.c=.o) CXXOBJS = $(CXXSRCS:.cxx=.o) OBJCOBJS = $(OBJCSRCS:.m=.o) ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) # Command that will be used to build the final extension. BUILD = $(SWIGCC) # Uncomment the following if you are using dynamic loading CCSHARED = @CCSHARED@ BUILD = @LDSHARED@ # Uncomment the following if you are using dynamic loading with C++ and # need to provide additional link libraries (this is not always required). #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc # Perl installation PERL_INCLUDE = -I@PERL5EXT@ PERL_LIB = -L@PERL5EXT@ -lperl PERL_FLAGS = -Dbool=char -Dexplicit= # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ # Build options BUILD_LIBS = $(LIBS) # Dynamic loading # Compilation rules for non-SWIG components .SUFFIXES: .c .cxx .m .c.o: $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< .cxx.o: $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< .m.o: $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< # ---------------------------------------------------------------------- # Rules for building the extension # ---------------------------------------------------------------------- all: $(TARGET) # Convert the wrapper file into an object file $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(PERL_INCLUDE) $(PERL_FLAGS) $(WRAPFILE) $(WRAPFILE) : $(INTERFACE) $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-3.0.8/Lib/perl5/std_string.i0000664000175000017500000000007612641054563016453 0ustar williamwilliam%include %include swig-3.0.8/Lib/perl5/stl.i0000664000175000017500000000054412641054563015075 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/perl5/director.swg0000664000175000017500000001613312641054563016457 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Perl proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PERL_HEADER_ #define SWIG_DIRECTOR_PERL_HEADER_ #include #include #include #include #include /* Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the native C++ RTTI and dynamic_cast<>. But be aware that directors could stop working when using this option. */ #ifdef SWIG_DIRECTOR_NORTTI /* When we don't use the native C++ RTTI, we implement a minimal one only for Directors. */ # ifndef SWIG_DIRECTOR_RTDIR # define SWIG_DIRECTOR_RTDIR namespace Swig { class Director; SWIGINTERN std::map& get_rtdir_map() { static std::map rtdir_map; return rtdir_map; } SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) { get_rtdir_map()[vptr] = rtdir; } SWIGINTERNINLINE Director *get_rtdir(void *vptr) { std::map::const_iterator pos = get_rtdir_map().find(vptr); Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0; return rtdir; } } # endif /* SWIG_DIRECTOR_RTDIR */ # define SWIG_DIRECTOR_CAST(ARG) Swig::get_rtdir(static_cast(ARG)) # define SWIG_DIRECTOR_RGTR(ARG1, ARG2) Swig::set_rtdir(static_cast(ARG1), ARG2) #else # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) # define SWIG_DIRECTOR_RGTR(ARG1, ARG2) #endif /* SWIG_DIRECTOR_NORTTI */ extern "C" { struct swig_type_info; } namespace Swig { /* memory handler */ struct GCItem { virtual ~GCItem() {} virtual int get_own() const { return 0; } }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem *operator->() const { return _item; } private: GCItem *_item; }; struct GCItem_Object : GCItem { GCItem_Object(int own) : _own(own) { } virtual ~GCItem_Object() { } int get_own() const { return _own; } private: int _own; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; template struct GCArray_T : GCItem { GCArray_T(Type *ptr) : _ptr(ptr) { } virtual ~GCArray_T() { delete[] _ptr; } private: Type *_ptr; }; /* base class for director exceptions */ class DirectorException : public std::exception { public: virtual SV *getNative() const = 0; }; /* exceptions emitted by Perl */ class DirectorMethodException : public DirectorException { protected: SV *err; public: DirectorMethodException(SV *sv = sv_mortalcopy(ERRSV)) : err(sv) { SvREFCNT_inc(err); } const char *what() const throw() { return SvPV_nolen(err); } SV *getNative() const { return sv_2mortal(newSVsv(err)); } static void raise(SV *sv) { throw DirectorMethodException(sv); } }; /* exceptions emitted by wrap code */ class DirectorWrapException : public DirectorException { protected: std::string msg; DirectorWrapException(const char *str) : msg(str) { } public: virtual ~DirectorWrapException() throw() { } const char *what() const throw() { return msg.c_str(); } virtual SV *getNative() const { return sv_2mortal(newSVpvn(msg.data(), msg.size())); } }; class DirectorTypeMismatchException : public DirectorWrapException { public: DirectorTypeMismatchException(const char *str) : DirectorWrapException(str) { } static void raise(const char *type, const char *msg) { std::string err = std::string(type); err += ": "; err += msg; throw DirectorTypeMismatchException(err.c_str()); } }; class DirectorPureVirtualException : public DirectorWrapException { public: DirectorPureVirtualException(const char *name) : DirectorWrapException("SWIG director pure virtual method called: ") { msg += name; } static void raise(const char *name) { throw DirectorPureVirtualException(name); } }; /* director base class */ class Director { private: /* pointer to the wrapped perl object */ SV *swig_self; /* class of wrapped perl object */ std::string swig_class; /* flag indicating whether the object is owned by perl or c++ */ mutable bool swig_disown_flag; /* decrement the reference count of the wrapped perl object */ void swig_decref() const { if (swig_disown_flag) { SvREFCNT_dec(swig_self); } } public: /* wrap a Perl object. */ Director(SV *pkg) : swig_disown_flag(false) { STRLEN len; char *str = SvPV(pkg, len); swig_class = std::string(str, len); swig_self = newRV_inc((SV *)newHV()); } /* discard our reference at destruction */ virtual ~Director() { swig_decref(); } /* return a pointer to the wrapped Perl object */ SV *swig_get_self() const { return swig_self; } const char *swig_get_class() const { return swig_class.c_str(); } /* acquire ownership of the wrapped Perl object (the sense of "disown" is from perl) */ void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag=true; swig_incref(); } } /* increase the reference count of the wrapped Perl object */ void swig_incref() const { if (swig_disown_flag) { SvREFCNT_inc(swig_self); } } /* methods to implement pseudo protected director members */ virtual bool swig_get_inner(const char * /* swig_protected_method_name */) const { return true; } virtual void swig_set_inner(const char * /* swig_protected_method_name */, bool /* swig_val */) const { } /* ownership management */ private: typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; public: template void swig_acquire_ownership_array(Type *vptr) const { if (vptr) { swig_owner[vptr] = new GCArray_T(vptr); } } template void swig_acquire_ownership(Type *vptr) const { if (vptr) { swig_owner[vptr] = new GCItem_T(vptr); } } void swig_acquire_ownership_obj(void *vptr, int own) const { if (vptr && own) { swig_owner[vptr] = new GCItem_Object(own); } } int swig_release_ownership(void *vptr) const { int own = 0; if (vptr) { swig_ownership_map::iterator iter = swig_owner.find(vptr); if (iter != swig_owner.end()) { own = iter->second->get_own(); swig_owner.erase(iter); } } return own; } }; } #endif swig-3.0.8/Lib/perl5/typemaps.i0000664000175000017500000003075712641054563016146 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * The SWIG typemap library provides a language independent mechanism for * supporting output arguments, input values, and other C function * calling mechanisms. The primary use of the library is to provide a * better interface to certain C function--especially those involving * pointers. * ----------------------------------------------------------------------------- */ #if !defined(SWIG_USE_OLD_TYPEMAPS) %include #else // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include typemaps.i double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include typemaps.i %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ %define INPUT_TYPEMAP(type, converter) %typemap(in) type *INPUT(type temp), type &INPUT(type temp) { temp = (type) converter($input); $1 = &temp; } %typemap(typecheck) type *INPUT = type; %typemap(typecheck) type &INPUT = type; %enddef INPUT_TYPEMAP(float, SvNV); INPUT_TYPEMAP(double, SvNV); INPUT_TYPEMAP(int, SvIV); INPUT_TYPEMAP(long, SvIV); INPUT_TYPEMAP(short, SvIV); INPUT_TYPEMAP(signed char, SvIV); INPUT_TYPEMAP(unsigned int, SvUV); INPUT_TYPEMAP(unsigned long, SvUV); INPUT_TYPEMAP(unsigned short, SvUV); INPUT_TYPEMAP(unsigned char, SvUV); %typemap(in) bool *INPUT(bool temp), bool &INPUT(bool temp) { temp = SvIV($input) ? true : false; $1 = &temp; } %typemap(typecheck) bool *INPUT = bool; %typemap(typecheck) bool &INPUT = bool; %typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) { temp = strtoll(SvPV_nolen($input), 0, 0); $1 = &temp; } %typemap(typecheck) long long *INPUT = long long; %typemap(typecheck) long long &INPUT = long long; %typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { temp = strtoull(SvPV_nolen($input), 0, 0); $1 = &temp; } %typemap(typecheck) unsigned long long *INPUT = unsigned long long; %typemap(typecheck) unsigned long long &INPUT = unsigned long long; #undef INPUT_TYPEMAP // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, functions will return a Perl array. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include typemaps.i double modf(double x, double *OUTPUT); or you can use the %apply directive : %include typemaps.i %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Perl output of the function would be an array containing both output values. */ // Force the argument to be ignored. %typemap(in,numinputs=0) int *OUTPUT(int temp), int &OUTPUT(int temp), short *OUTPUT(short temp), short &OUTPUT(short temp), long *OUTPUT(long temp), long &OUTPUT(long temp), unsigned int *OUTPUT(unsigned int temp), unsigned int &OUTPUT(unsigned int temp), unsigned short *OUTPUT(unsigned short temp), unsigned short &OUTPUT(unsigned short temp), unsigned long *OUTPUT(unsigned long temp), unsigned long &OUTPUT(unsigned long temp), unsigned char *OUTPUT(unsigned char temp), unsigned char &OUTPUT(unsigned char temp), signed char *OUTPUT(signed char temp), signed char &OUTPUT(signed char temp), bool *OUTPUT(bool temp), bool &OUTPUT(bool temp), float *OUTPUT(float temp), float &OUTPUT(float temp), double *OUTPUT(double temp), double &OUTPUT(double temp), long long *OUTPUT($*1_ltype temp), long long &OUTPUT($*1_ltype temp), unsigned long long *OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp) "$1 = &temp;"; %typemap(argout) int *OUTPUT, int &OUTPUT, short *OUTPUT, short &OUTPUT, long *OUTPUT, long &OUTPUT, signed char *OUTPUT, signed char &OUTPUT, bool *OUTPUT, bool &OUTPUT { if (argvi >= items) { EXTEND(sp,1); } $result = sv_newmortal(); sv_setiv($result,(IV) *($1)); argvi++; } %typemap(argout) unsigned int *OUTPUT, unsigned int &OUTPUT, unsigned short *OUTPUT, unsigned short &OUTPUT, unsigned long *OUTPUT, unsigned long &OUTPUT, unsigned char *OUTPUT, unsigned char &OUTPUT { if (argvi >= items) { EXTEND(sp,1); } $result = sv_newmortal(); sv_setuv($result,(UV) *($1)); argvi++; } %typemap(argout) float *OUTPUT, float &OUTPUT, double *OUTPUT, double &OUTPUT { if (argvi >= items) { EXTEND(sp,1); } $result = sv_newmortal(); sv_setnv($result,(double) *($1)); argvi++; } %typemap(argout) long long *OUTPUT, long long &OUTPUT { char temp[256]; if (argvi >= items) { EXTEND(sp,1); } sprintf(temp,"%lld", (long long)*($1)); $result = sv_newmortal(); sv_setpv($result,temp); argvi++; } %typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { char temp[256]; if (argvi >= items) { EXTEND(sp,1); } sprintf(temp,"%llu", (unsigned long long)*($1)); $result = sv_newmortal(); sv_setpv($result,temp); argvi++; } // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Perl array. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include typemaps.i void neg(double *INOUT); or you can use the %apply directive : %include typemaps.i %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value. Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Perl variable you might do this : $x = neg($x); */ %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) signed char *INOUT = signed char *INPUT; %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) int &INOUT = int &INPUT; %typemap(in) short &INOUT = short &INPUT; %typemap(in) long &INOUT = long &INPUT; %typemap(in) unsigned &INOUT = unsigned &INPUT; %typemap(in) unsigned short &INOUT = unsigned short &INPUT; %typemap(in) unsigned long &INOUT = unsigned long &INPUT; %typemap(in) unsigned char &INOUT = unsigned char &INPUT; %typemap(in) signed char &INOUT = signed char &INPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(in) float &INOUT = float &INPUT; %typemap(in) double &INOUT = double &INPUT; %typemap(in) long long &INOUT = long long &INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT = long *OUTPUT; %typemap(argout) unsigned *INOUT = unsigned *OUTPUT; %typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) signed char *INOUT = signed char *OUTPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT = double *OUTPUT; %typemap(argout) long long *INOUT = long long *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) int &INOUT = int &OUTPUT; %typemap(argout) short &INOUT = short &OUTPUT; %typemap(argout) long &INOUT = long &OUTPUT; %typemap(argout) unsigned &INOUT = unsigned &OUTPUT; %typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; %typemap(argout) signed char &INOUT = signed char &OUTPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; %typemap(argout) float &INOUT = float &OUTPUT; %typemap(argout) double &INOUT = double &OUTPUT; %typemap(argout) long long &INOUT = long long &OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; /* Overloading information */ %typemap(typecheck) double *INOUT = double; %typemap(typecheck) bool *INOUT = bool; %typemap(typecheck) signed char *INOUT = signed char; %typemap(typecheck) unsigned char *INOUT = unsigned char; %typemap(typecheck) unsigned long *INOUT = unsigned long; %typemap(typecheck) unsigned short *INOUT = unsigned short; %typemap(typecheck) unsigned int *INOUT = unsigned int; %typemap(typecheck) long *INOUT = long; %typemap(typecheck) short *INOUT = short; %typemap(typecheck) int *INOUT = int; %typemap(typecheck) float *INOUT = float; %typemap(typecheck) long long *INOUT = long long; %typemap(typecheck) unsigned long long *INOUT = unsigned long long; %typemap(typecheck) double &INOUT = double; %typemap(typecheck) bool &INOUT = bool; %typemap(typecheck) signed char &INOUT = signed char; %typemap(typecheck) unsigned char &INOUT = unsigned char; %typemap(typecheck) unsigned long &INOUT = unsigned long; %typemap(typecheck) unsigned short &INOUT = unsigned short; %typemap(typecheck) unsigned int &INOUT = unsigned int; %typemap(typecheck) long &INOUT = long; %typemap(typecheck) short &INOUT = short; %typemap(typecheck) int &INOUT = int; %typemap(typecheck) float &INOUT = float; %typemap(typecheck) long long &INOUT = long long; %typemap(typecheck) unsigned long long &INOUT = unsigned long long; #endif // -------------------------------------------------------------------- // Special types // -------------------------------------------------------------------- %include swig-3.0.8/Lib/perl5/std_vector.i0000664000175000017500000005450212641054563016452 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector types * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // Perl as much as possible, namely, to allow the user to pass and // be returned Perl arrays. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&), f(const std::vector*): // the parameter being read-only, either a Perl sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(): // the vector is returned by copy; therefore, a Perl sequence of T:s // is returned which is most easily used in other Perl functions // -- std::vector& f(), std::vector* f(), const std::vector& f(), // const std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template class vector { %typemap(in) vector (std::vector* v) { if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,1) != -1) { $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i& (std::vector temp, std::vector* v), const vector* (std::vector temp, std::vector* v) { if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,1) != -1) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; T* obj; for (int i=0; i { size_t len = $1.size(); SV **svs = new SV*[len]; for (size_t i=0; i { { /* wrapped vector? */ std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* obj; SV **tv = av_fetch(av, 0, 0); if (SWIG_ConvertPtr(*tv, (void **)&obj, $descriptor(T *),0) != -1) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { { /* wrapped vector? */ std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* obj; SV **tv = av_fetch(av, 0, 0); if (SWIG_ConvertPtr(*tv, (void **)&obj, $descriptor(T *),0) != -1) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(const T& x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T& get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { %typemap(in) vector (std::vector* v) { int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); if (SWIG_IsOK(res)){ $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); I32 len = av_len(av) + 1; for (int i=0; i& (std::vector temp,std::vector* v), const vector* (std::vector temp,std::vector* v) { int res = SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0); if (SWIG_IsOK(res)) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); I32 len = av_len(av) + 1; for (int i=0; i { size_t len = $1.size(); SV **svs = new SV*[len]; for (size_t i=0; i { { /* wrapped vector? */ std::vector< T *>* v; int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); if (SWIG_IsOK(res)) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ void *v; SV **tv = av_fetch(av, 0, 0); int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); if (SWIG_IsOK(res)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&,const vector* { { /* wrapped vector? */ std::vector< T *> *v; int res = SWIG_ConvertPtr($input,%as_voidptrptr(&v), $1_descriptor,0); if (SWIG_IsOK(res)) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ void *v; SV **tv = av_fetch(av, 0, 0); int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); if (SWIG_IsOK(res)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, T *value); vector(const vector &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(T *x); %extend { T *pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T *x = self->back(); self->pop_back(); return x; } T *get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { %typemap(in) vector (std::vector* v) { if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,1) != -1){ $1 = *v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; for (int i=0; i& (std::vector temp, std::vector* v), const vector* (std::vector temp, std::vector* v) { if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,1) != -1) { $1 = v; } else if (SvROK($input)) { AV *av = (AV *)SvRV($input); if (SvTYPE(av) != SVt_PVAV) SWIG_croak("Type error in argument $argnum of $symname. " "Expected an array of " #T); SV **tv; I32 len = av_len(av) + 1; for (int i=0; i { size_t len = $1.size(); SV **svs = new SV*[len]; for (size_t i=0; i { { /* wrapped vector? */ std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SV **tv = av_fetch(av, 0, 0); if (CHECK_T(*tv)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { { /* wrapped vector? */ std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; } else if (SvROK($input)) { /* native sequence? */ AV *av = (AV *)SvRV($input); if (SvTYPE(av) == SVt_PVAV) { I32 len = av_len(av) + 1; if (len == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SV **tv = av_fetch(av, 0, 0); if (CHECK_T(*tv)) $1 = 1; else $1 = 0; } } } else { $1 = 0; } } } public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, T value); vector(const vector &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(T x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i swig-3.0.8/Lib/perl5/cstring.i0000664000175000017500000000004012641054563015733 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/perltypemaps.swg0000664000175000017500000000553712641054563017377 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Perl * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* in Perl we need to pass the CPerlObj value, sometimes, so, we define the decl/call macros as needed. */ #define SWIG_AS_DECL_ARGS SWIG_PERL_DECL_ARGS_2 #define SWIG_AS_CALL_ARGS SWIG_PERL_CALL_ARGS_2 #define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1 #define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1 /* Include fundamental fragment definitions */ %include /* Look for user fragments file. */ %include /* Perl fragments for primitive types */ %include /* Perl fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* director support in Perl is experimental */ #ifndef SWIG_DIRECTOR_TYPEMAPS #define SWIG_DIRECTOR_TYPEMAPS #endif /* Perl types */ #define SWIG_Object SV * #define VOID_Object sv_newmortal() /* Perl $shadow flag */ #define %newpointer_flags $shadow #define %newinstance_flags $shadow /* Complete overload of the output/constant/exception macros */ /* output */ %define %set_output(obj) $result = obj; argvi++ %enddef /* append output */ %define %append_output(obj) if (argvi >= items) EXTEND(sp,1); %set_output(obj) %enddef /* variable output */ %define %set_varoutput(obj) sv_setsv($result,obj) %enddef /* constant */ %define %set_constant(name, obj) %begin_block SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, obj); SvREADONLY_on(sv); %end_block %enddef /* raise exception */ %define %raise(obj, type, desc) sv_setsv(get_sv("@", GV_ADD), obj); SWIG_fail %enddef /* Include the unified typemap library */ %include /* ------------------------------------------------------------ * Perl extra typemaps / typemap overrides * ------------------------------------------------------------ */ %typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE [] "sv_setiv(SvRV($result),PTR2IV($1));"; %typemap(varout,type="$1_descriptor") SWIGTYPE & "sv_setiv(SvRV($result),PTR2IV(&$1));"; %typemap(varout,type="$1_descriptor") SWIGTYPE && "sv_setiv(SvRV($result),PTR2IV(&$1));"; %typemap(varout,type="$&1_descriptor") SWIGTYPE "sv_setiv(SvRV($result), PTR2IV(&$1));"; %typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) { SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor); } %typemap(varout) SWIGTYPE *const = SWIGTYPE *; swig-3.0.8/Lib/perl5/cpointer.i0000664000175000017500000000004112641054563016106 0ustar williamwilliam%include swig-3.0.8/Lib/perl5/perlopers.swg0000664000175000017500000000352012641054563016653 0ustar williamwilliam/* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus // These are auto-supported by the Perl-module %rename(__plusplus__) *::operator++; %rename(__minmin__) *::operator--; %rename(__add__) *::operator+; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-(); %rename(__neg__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__mod__) *::operator%; %rename(__gt__) *::operator>; %rename(__lt__) *::operator<; %rename(__not__) *::operator!; %rename(__le__) *::operator<=; %rename(__ge__) *::operator>=; %rename(__and__) *::operator&; %rename(__or__) *::operator|; %rename(__iadd__) *::operator+=; %rename(__isub__) *::operator-=; // These are renamed, but no test exists in operator_overload_runme.pl %ignoreoperator(EQ) operator=; // These are renamed, but no 'use overload...' is added %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__call__) *::operator(); /* Ignored operators */ %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; %ignoreoperator(MULEQ) operator*=; %ignoreoperator(DIVEQ) operator/=; %ignoreoperator(MODEQ) operator%=; %ignoreoperator(LSHIFTEQ) operator<<=; %ignoreoperator(RSHIFTEQ) operator>>=; %ignoreoperator(ANDEQ) operator&=; %ignoreoperator(OREQ) operator|=; %ignoreoperator(XOREQ) operator^=; %ignoreoperator(ARROWSTAR) operator->*; %ignoreoperator(INDEX) operator[]; #endif /* __cplusplus */ swig-3.0.8/Lib/swigerrors.swg0000664000175000017500000000076312641054563016025 0ustar williamwilliam/* Errors in SWIG */ #define SWIG_UnknownError -1 #define SWIG_IOError -2 #define SWIG_RuntimeError -3 #define SWIG_IndexError -4 #define SWIG_TypeError -5 #define SWIG_DivisionByZero -6 #define SWIG_OverflowError -7 #define SWIG_SyntaxError -8 #define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 #define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 swig-3.0.8/Lib/stdint.i0000664000175000017500000000450012641054563014545 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stdint.i * * SWIG library file for ISO C99 types: 7.18 Integer types * ----------------------------------------------------------------------------- */ %{ #include // Use the C99 official header %} %include /* Exact integral types. */ /* Signed. */ typedef signed char int8_t; typedef short int int16_t; typedef int int32_t; #if defined(SWIGWORDSIZE64) typedef long int int64_t; #else typedef long long int int64_t; #endif /* Unsigned. */ typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; #if defined(SWIGWORDSIZE64) typedef unsigned long int uint64_t; #else typedef unsigned long long int uint64_t; #endif /* Small types. */ /* Signed. */ typedef signed char int_least8_t; typedef short int int_least16_t; typedef int int_least32_t; #if defined(SWIGWORDSIZE64) typedef long int int_least64_t; #else typedef long long int int_least64_t; #endif /* Unsigned. */ typedef unsigned char uint_least8_t; typedef unsigned short int uint_least16_t; typedef unsigned int uint_least32_t; #if defined(SWIGWORDSIZE64) typedef unsigned long int uint_least64_t; #else typedef unsigned long long int uint_least64_t; #endif /* Fast types. */ /* Signed. */ typedef signed char int_fast8_t; #if defined(SWIGWORDSIZE64) typedef long int int_fast16_t; typedef long int int_fast32_t; typedef long int int_fast64_t; #else typedef int int_fast16_t; typedef int int_fast32_t; typedef long long int int_fast64_t; #endif /* Unsigned. */ typedef unsigned char uint_fast8_t; #if defined(SWIGWORDSIZE64) typedef unsigned long int uint_fast16_t; typedef unsigned long int uint_fast32_t; typedef unsigned long int uint_fast64_t; #else typedef unsigned int uint_fast16_t; typedef unsigned int uint_fast32_t; typedef unsigned long long int uint_fast64_t; #endif /* Types for `void *' pointers. */ #if defined(SWIGWORDSIZE64) typedef long int intptr_t; typedef unsigned long int uintptr_t; #else typedef int intptr_t; typedef unsigned int uintptr_t; #endif /* Largest integral types. */ #if defined(SWIGWORDSIZE64) typedef long int intmax_t; typedef unsigned long int uintmax_t; #else typedef long long int intmax_t; typedef unsigned long long int uintmax_t; #endif swig-3.0.8/Lib/inttypes.i0000664000175000017500000000451412641054563015124 0ustar williamwilliam/* ----------------------------------------------------------------------------- * inttypes.i * * SWIG library file for ISO C99 types: 7.8 Format conversion of integer types * ----------------------------------------------------------------------------- */ %{ #include %} %include %include #ifdef __cplusplus extern "C" { #endif #ifdef SWIGWORDSIZE64 /* We have to define the `uintmax_t' type using `ldiv_t'. */ typedef struct { long int quot; /* Quotient. */ long int rem; /* Remainder. */ } imaxdiv_t; #else /* We have to define the `uintmax_t' type using `lldiv_t'. */ typedef struct { long long int quot; /* Quotient. */ long long int rem; /* Remainder. */ } imaxdiv_t; #endif /* Compute absolute value of N. */ extern intmax_t imaxabs (intmax_t n); /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ extern imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom); #ifdef SWIG_WCHAR /* Like `wcstol' but convert to `intmax_t'. */ extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base); /* Like `wcstoul' but convert to `uintmax_t'. */ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t ** endptr, int base); #endif #ifdef SWIGWORDSIZE64 /* Like `strtol' but convert to `intmax_t'. */ extern intmax_t strtoimax (const char *nptr, char **endptr, int base); /* Like `strtoul' but convert to `uintmax_t'. */ extern uintmax_t strtoumax (const char *nptr, char **endptr,int base); #ifdef SWIG_WCHAR /* Like `wcstol' but convert to `intmax_t'. */ extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base); /* Like `wcstoul' but convert to `uintmax_t'. */ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base); #endif #else /* SWIGWORDSIZE32 */ /* Like `strtol' but convert to `intmax_t'. */ extern intmax_t strtoimax (const char *nptr, char **endptr, int base); /* Like `strtoul' but convert to `uintmax_t'. */ extern uintmax_t strtoumax (const char *nptr, char **endptr, int base); #ifdef SWIG_WCHAR /* Like `wcstol' but convert to `intmax_t'. */ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base); #endif #endif /* SWIGWORDSIZE64 */ #ifdef __cplusplus } #endif swig-3.0.8/Lib/php/0000775000175000017500000000000012641054563013656 5ustar williamwilliamswig-3.0.8/Lib/php/php.swg0000664000175000017500000003313712641054563015176 0ustar williamwilliam/* ----------------------------------------------------------------------------- * php.swg * * PHP configuration file * ----------------------------------------------------------------------------- */ %runtime "swigrun.swg" // Common C API type-checking code %runtime "phprun.swg" // PHP runtime functions %include // PHP initialization routine. %include // Global variables. %include // use %init %{ "/*code goes here*/ " %} // or %minit %{ "/* code goes here*/ " %} to // insert code in the PHP_MINIT_FUNCTION #define %minit %insert("init") // use %rinit %{ "/* code goes here*/ " %} to // insert code in the PHP_RINIT_FUNCTION #define %rinit %insert("rinit") // use %shutdown %{ " /*code goes here*/ " %} to // insert code in the PHP_MSHUTDOWN_FUNCTION #define %shutdown %insert("shutdown") #define %mshutdown %insert("shutdown") // use %rshutdown %{ " /*code goes here*/" %} to // insert code in the PHP_RSHUTDOWN_FUNCTION #define %rshutdown %insert("rshutdown") /* Typemaps for input parameters by value */ %include %pass_by_val(bool,CONVERT_BOOL_IN); %pass_by_val(size_t, CONVERT_INT_IN); %pass_by_val(enum SWIGTYPE, CONVERT_INT_IN); %pass_by_val(signed int, CONVERT_INT_IN); %pass_by_val(int,CONVERT_INT_IN); %pass_by_val(unsigned int,CONVERT_INT_IN); %pass_by_val(signed short, CONVERT_INT_IN); %pass_by_val(short,CONVERT_INT_IN); %pass_by_val(unsigned short, CONVERT_INT_IN); %pass_by_val(signed long, CONVERT_INT_IN); %pass_by_val(long, CONVERT_INT_IN); %pass_by_val(unsigned long, CONVERT_INT_IN); %pass_by_val(signed long long, CONVERT_LONG_LONG_IN); %pass_by_val(long long, CONVERT_LONG_LONG_IN); %pass_by_val(unsigned long long, CONVERT_UNSIGNED_LONG_LONG_IN); %pass_by_val(signed char, CONVERT_INT_IN); %pass_by_val(char, CONVERT_CHAR_IN); %pass_by_val(unsigned char, CONVERT_INT_IN); %pass_by_val(float, CONVERT_FLOAT_IN); %pass_by_val(double, CONVERT_FLOAT_IN); %pass_by_val(char *, CONVERT_STRING_IN); %typemap(in) char *& = const char *&; %typemap(directorout) char *& = const char *&; // char array can be in/out, though the passed string may not be big enough... // so we have to size it %typemap(in) char[ANY] { convert_to_string_ex($input); $1 = ($1_ltype) Z_STRVAL_PP($input); } %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { convert_to_string_ex($input); $1 = ($1_ltype) Z_STRVAL_PP($input); $2 = ($2_ltype) Z_STRLEN_PP($input); } /* Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_ltype tmp) { if(SWIG_ConvertPtr(*$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } $1 = *tmp; } %typemap(directorout) SWIGTYPE ($&1_ltype tmp) { /* If exit was via exception, PHP NULL is returned so skip the conversion. */ if (!EG(exception)) { if(SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); $result = *tmp; } } %typemap(in) SWIGTYPE *, SWIGTYPE [] { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } } %typemap(in) SWIGTYPE & { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } } %typemap(in) SWIGTYPE && { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } } %typemap(in) SWIGTYPE *const& ($*ltype temp) { if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor"); } $1 = ($1_ltype)&temp; } %typemap(in) SWIGTYPE *DISOWN { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) { SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } } %typemap(argout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE &&; %typemap(in) void * { if(SWIG_ConvertPtr(*$input, (void **) &$1, 0, 0) < 0) { /* Allow NULL from php for void* */ if ((*$input)->type==IS_NULL) $1=0; else SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } } /* Special case when void* is passed by reference so it can be made to point to opaque api structs */ %typemap(in) void ** ($*1_ltype ptr, int force), void *& ($*1_ltype ptr, int force) { /* If they pass NULL by reference, make it into a void* This bit should go in arginit if arginit support init-ing scripting args */ if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { /* wasn't a pre/ref/thing, OR anything like an int thing */ SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); } } force=0; if (arg1==NULL) { #ifdef __cplusplus ptr=new $*1_ltype(); #else ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); #endif $1=&ptr; /* have to passback arg$arg too */ force=1; } } %typemap(argout) void **, void *& { if (force$argnum) { SWIG_SetPointerZval( *$input, (void*) ptr$argnum, $*1_descriptor, 1); } } /* Typemap for output values */ %typemap(out) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, bool, size_t { ZVAL_LONG(return_value,$1); } %typemap(out) enum SWIGTYPE { ZVAL_LONG(return_value, (long)$1); } %typemap(out) long long %{ if ((long long)LONG_MIN <= $1 && $1 <= (long long)LONG_MAX) { return_value->value.lval = (long)($1); return_value->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%lld", (long long)$1); ZVAL_STRING(return_value, temp, 1); } %} %typemap(out) unsigned long long %{ if ($1 <= (unsigned long long)LONG_MAX) { return_value->value.lval = (long)($1); return_value->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)$1); ZVAL_STRING(return_value, temp, 1); } %} %typemap(out) const int &, const unsigned int &, const short &, const unsigned short &, const long &, const unsigned long &, const signed char &, const unsigned char &, const bool &, const size_t & { ZVAL_LONG(return_value,*$1); } %typemap(out) const enum SWIGTYPE & { ZVAL_LONG(return_value, (long)*$1); } %typemap(out) const enum SWIGTYPE && { ZVAL_LONG(return_value, (long)*$1); } %typemap(out) const long long & %{ if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) { return_value->value.lval = (long)(*$1); return_value->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%lld", (long long)(*$1)); ZVAL_STRING(return_value, temp, 1); } %} %typemap(out) const unsigned long long & %{ if (*$1 <= (unsigned long long)LONG_MAX) { return_value->value.lval = (long)(*$1); return_value->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)(*$1)); ZVAL_STRING(return_value, temp, 1); } %} %typemap(directorin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, size_t, enum SWIGTYPE { ZVAL_LONG($input,$1); } %typemap(directorin) enum SWIGTYPE { ZVAL_LONG($input, (long)$1_name); } %typemap(directorin) char *, char [] { if(!$1) { ZVAL_NULL($input); } else { ZVAL_STRING($input, (char *)$1, 1); } } %typemap(out) bool { ZVAL_BOOL(return_value,($1)?1:0); } %typemap(out) const bool & { ZVAL_BOOL(return_value,(*$1)?1:0); } %typemap(directorin) bool { ZVAL_BOOL($input,($1)?1:0); } %typemap(out) float, double { ZVAL_DOUBLE(return_value,$1); } %typemap(out) const float &, const double & { ZVAL_DOUBLE(return_value,*$1); } %typemap(directorin) float, double { ZVAL_DOUBLE($input,$1); } %typemap(out) char { ZVAL_STRINGL(return_value,&$1, 1, 1); } %typemap(out) const char & { ZVAL_STRINGL(return_value,&*$1, 1, 1); } %typemap(out) char *, char [] { if(!$1) { ZVAL_NULL(return_value); } else { ZVAL_STRING(return_value, (char *)$1, 1); } } %typemap(out) char *& { if(!*$1) { ZVAL_NULL(return_value); } else { ZVAL_STRING(return_value, (char *)*$1, 1); } } %typemap(out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && %{ SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); %} %typemap(out) SWIGTYPE *const& %{ SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner); %} %typemap(directorin) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && %{ SWIG_SetPointerZval($input, (void *)&$1, $1_descriptor, ($owner)|2); %} %typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner); } %typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr); memcpy(&$1, p, sizeof($1)); } %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner); } %typemap(out) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1); SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); } #else { $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type)); memcpy(resultobj, &$1, sizeof($1_type)); SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); } #endif %typemap(directorin) SWIGTYPE { SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1), $&1_descriptor, 2); } %typemap(out) void ""; %typemap(out) char [ANY] { int len = 0; while (len < $1_dim0 && $1[len]) ++len; RETVAL_STRINGL($1, len, 1); } // This typecheck does hard checking for proper argument type. If you want // an argument to be converted from a different PHP type, you must convert // it yourself before passing it (e.g. (string)4.7 or (int)"6"). %define %php_typecheck(_type,_prec,is) %typemap(typecheck,precedence=_prec) _type, const _type & " $1 = (Z_TYPE_PP($input) == is); " %enddef %php_typecheck(int,SWIG_TYPECHECK_INTEGER,IS_LONG) %php_typecheck(unsigned int,SWIG_TYPECHECK_UINT32,IS_LONG) %php_typecheck(short,SWIG_TYPECHECK_INT16,IS_LONG) %php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG) %php_typecheck(long,SWIG_TYPECHECK_INT32,IS_LONG) %php_typecheck(unsigned long,SWIG_TYPECHECK_UINT32,IS_LONG) %php_typecheck(long long,SWIG_TYPECHECK_INT64,IS_LONG) %php_typecheck(unsigned long long,SWIG_TYPECHECK_UINT64,IS_LONG) %php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG) %php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG) %php_typecheck(size_t,SWIG_TYPECHECK_SIZE,IS_LONG) %php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INTEGER,IS_LONG) %php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL) %php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE) %php_typecheck(double,SWIG_TYPECHECK_DOUBLE,IS_DOUBLE) %php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING) %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char [] " $1 = (Z_TYPE_PP($input) == IS_STRING); " %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *const& { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $*1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, 0, 0) >= 0); } /* Exception handling */ %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short { zend_throw_exception(NULL, const_cast("C++ $1_type exception thrown"), $1 TSRMLS_CC); return; } %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ (void)$1; zend_throw_exception(NULL, const_cast("C++ $1_type exception thrown"), 0 TSRMLS_CC); return; %} %typemap(throws) char * %{ zend_throw_exception(NULL, const_cast($1), 0 TSRMLS_CC); return; %} /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* php keywords */ %include swig-3.0.8/Lib/php/std_pair.i0000664000175000017500000000131012641054563015630 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/php/std_deque.i0000664000175000017500000000003412641054563016002 0ustar williamwilliam%include swig-3.0.8/Lib/php/std_common.i0000664000175000017500000000044212641054563016172 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; swig-3.0.8/Lib/php/const.i0000664000175000017500000000272412641054563015163 0ustar williamwilliam/* ----------------------------------------------------------------------------- * const.i * * Typemaps for constants * ----------------------------------------------------------------------------- */ %typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE "SWIG_LONG_CONSTANT($symname, ($1_type)$value);"; %typemap(consttab) float, double "SWIG_DOUBLE_CONSTANT($symname, $value);"; %typemap(consttab) char "SWIG_CHAR_CONSTANT($symname, $value);"; %typemap(consttab) char *, const char *, char [], const char [] "SWIG_STRING_CONSTANT($symname, $value);"; %typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { zval *z_var; zend_constant c; size_t len = sizeof("$symname") - 1; MAKE_STD_ZVAL(z_var); SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0); c.value = *z_var; zval_copy_ctor(&c.value); c.name = zend_strndup("$symname", len); c.name_len = len+1; c.flags = CONST_CS | CONST_PERSISTENT; c.module_number = module_number; zend_register_constant( &c TSRMLS_CC ); } /* Handled as a global variable. */ %typemap(consttab) SWIGTYPE (CLASS::*) ""; swig-3.0.8/Lib/php/factory.i0000664000175000017500000000604512641054563015504 0ustar williamwilliam/* Implement a more natural wrap for factory methods, for example, if you have: ---- geometry.h -------- struct Geometry { enum GeomType{ POINT, CIRCLE }; virtual ~Geometry() {} virtual int draw() = 0; // // Factory method for all the Geometry objects // static Geometry *create(GeomType i); }; struct Point : Geometry { int draw() { return 1; } double width() { return 1.0; } }; struct Circle : Geometry { int draw() { return 2; } double radius() { return 1.5; } }; // // Factory method for all the Geometry objects // Geometry *Geometry::create(GeomType type) { switch (type) { case POINT: return new Point(); case CIRCLE: return new Circle(); default: return 0; } } ---- geometry.h -------- You can use the %factory with the Geometry::create method as follows: %newobject Geometry::create; %factory(Geometry *Geometry::create, Point, Circle); %include "geometry.h" and Geometry::create will return a 'Point' or 'Circle' instance instead of the plain 'Geometry' type. For example, in python: circle = Geometry.create(Geometry.CIRCLE) r = circle.radius() where circle is a Circle proxy instance. NOTES: remember to fully qualify all the type names and don't use %factory inside a namespace declaration, ie, instead of namespace Foo { %factory(Geometry *Geometry::create, Point, Circle); } use %factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle); */ /* for loop for macro with one argument */ %define %_formacro_1(macro, arg1,...)macro(arg1) #if #__VA_ARGS__ != "__fordone__" %_formacro_1(macro, __VA_ARGS__) #endif %enddef /* for loop for macro with one argument */ %define %formacro_1(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef %define %formacro(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef /* for loop for macro with two arguments */ %define %_formacro_2(macro, arg1, arg2, ...)macro(arg1, arg2) #if #__VA_ARGS__ != "__fordone__" %_formacro_2(macro, __VA_ARGS__) #endif %enddef /* for loop for macro with two arguments */ %define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef %define %_factory_dispatch(Type) if (!dcast) { Type *dobj = dynamic_cast($1); if (dobj) { dcast = 1; SWIG_SetPointerZval(return_value, SWIG_as_voidptr(dobj),$descriptor(Type *), $owner); } }%enddef %define %factory(Method,Types...) %typemap(out) Method { int dcast = 0; %formacro(%_factory_dispatch, Types) if (!dcast) { SWIG_SetPointerZval(return_value, SWIG_as_voidptr($1),$descriptor, $owner); } }%enddef swig-3.0.8/Lib/php/globalvar.i0000664000175000017500000002141712641054563016006 0ustar williamwilliam/* ----------------------------------------------------------------------------- * globalvar.i * * Global variables - add the variable to PHP * ----------------------------------------------------------------------------- */ %typemap(varinit) char *, char [] { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_STRING; if($1) { z_var->value.str.val = estrdup($1); z_var->value.str.len = strlen($1); } else { z_var->value.str.val = 0; z_var->value.str.len = 0; } zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) int, unsigned int, unsigned short, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_LONG; z_var->value.lval = (long)$1; zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) bool { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_BOOL; z_var->value.lval = ($1)?1:0; zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) float, double { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_DOUBLE; z_var->value.dval = $1; zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) char { zval *z_var; char c[2]; MAKE_STD_ZVAL(z_var); c[0] = $1; c[1] = 0; z_var->type = IS_STRING; z_var->value.str.val = estrndup(c, 1); z_var->value.str.len = 1; zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) SWIGTYPE *, SWIGTYPE [] { zval *z_var; MAKE_STD_ZVAL(z_var); SWIG_SetPointerZval(z_var, (void*)$1, $1_descriptor, 0); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); } %typemap(varinit) SWIGTYPE, SWIGTYPE &, SWIGTYPE && { zval *z_var; MAKE_STD_ZVAL(z_var); SWIG_SetPointerZval(z_var, (void*)&$1, $&1_descriptor, 0); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); } %typemap(varinit) char [ANY] { zval *z_var; MAKE_STD_ZVAL(z_var); z_var->type = IS_STRING; if ($1) { /* varinit char [ANY] */ ZVAL_STRINGL(z_var,(char*)$1, $1_dim0, 1); } zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); } %typemap(varinit, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); } %typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_long_ex(z_var); if ($1 != ($1_ltype)((*z_var)->value.lval)) { $1 = Z_LVAL_PP(z_var); } } %typemap(varin) bool { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_boolean_ex(z_var); if ($1 != ($1_ltype)((*z_var)->value.lval)) { $1 = Z_LVAL_PP(z_var); } } %typemap(varin) double,float { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_double_ex(z_var); if ($1 != ($1_ltype)((*z_var)->value.dval)) { $1 = Z_DVAL_PP(z_var); } } %typemap(varin) char { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_string_ex(z_var); if ($1 != *((*z_var)->value.str.val)) { $1 = *((*z_var)->value.str.val); } } %typemap(varin) char * { zval **z_var; char *s1; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); convert_to_string_ex(z_var); s1 = Z_STRVAL_PP(z_var); if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { if (s1) $1 = estrdup(s1); else $1 = NULL; } } %typemap(varin) SWIGTYPE [] { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1) { SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, $owner); } } %typemap(varin) char [ANY] { zval **z_var; char *s1; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); s1 = Z_STRVAL_PP(z_var); if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { if (s1) strncpy($1, s1, $1_dim0); } } %typemap(varin) SWIGTYPE { zval **z_var; $&1_ltype _temp; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if (SWIG_ConvertPtr(*z_var, (void**)&_temp, $&1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor"); } $1 = *($&1_ltype)_temp; } %typemap(varin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE && { zval **z_var; $1_ltype _temp; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if (SWIG_ConvertPtr(*z_var, (void **)&_temp, $1_descriptor, 0) < 0) { SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor"); } $1 = ($1_ltype)_temp; } %typemap(varin, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); void * p = (void*)zend_fetch_resource(*z_var TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr); memcpy(&$1, p, sizeof($1)); } %typemap(varout) int, unsigned int, unsigned short, short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1 != ($1_ltype)((*z_var)->value.lval)) { (*z_var)->value.lval = (long)$1; } } //SAMFIX need to cast zval->type, what if zend-hash_find fails? etc? %typemap(varout) bool { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1 != ($1_ltype)((*z_var)->value.lval)) { (*z_var)->value.lval = (long)$1; } } %typemap(varout) double, float { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1 != ($1_ltype)((*z_var)->value.dval)) { (*z_var)->value.dval = (double)$1; } } %typemap(varout) char { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1 != *((*z_var)->value.str.val)) { char c[2]; efree((*z_var)->value.str.val); c[0] = $1; c[1] = 0; (*z_var)->value.str.val = estrdup(c); } } %typemap(varout) char * { zval **z_var; char *s1; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); s1 = Z_STRVAL_PP(z_var); if((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { if(s1) efree(s1); if($1) { (*z_var)->value.str.val = estrdup($1); (*z_var)->value.str.len = strlen($1) + 1; } else { (*z_var)->value.str.val = 0; (*z_var)->value.str.len = 0; } } } %typemap(varout) SWIGTYPE { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); SWIG_SetPointerZval(*z_var, (void*)&$1, $&1_descriptor, 0); } %typemap(varout) SWIGTYPE [] { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); if($1) SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); } %typemap(varout) char [ANY] { zval **z_var; char *s1; deliberate error cos this code looks bogus to me zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); s1 = Z_STRVAL_PP(z_var); if((s1 == NULL) || strcmp(s1, $1)) { if($1) { (*z_var)->value.str.val = estrdup($1); (*z_var)->value.str.len = strlen($1) + 1; } else { (*z_var)->value.str.val = 0; (*z_var)->value.str.len = 0; } } } %typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE && { zval **z_var; zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); } %typemap(varout, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) { void * p = emalloc(sizeof($1)); memcpy(p, &$1, sizeof($1)); zval * resource; MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); } swig-3.0.8/Lib/php/phpkw.swg0000664000175000017500000005353412641054563015543 0ustar williamwilliam/* ----------------------------------------------------------------------------- * phpkw.swg * ----------------------------------------------------------------------------- */ /* Keyword (case insensitive) */ #define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",rename="c_%s") `x` /* Class (case insensitive) */ #define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, renaming to 'c_" `x` "'",%$isclass,sourcefmt="%(lower)s",rename="c_%s") `x` /* Constant (case insensitive) */ #define PHPBN1a(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "enum conflicts with a built-in constant '"`x`"' in PHP"),%$isenumitem,sourcefmt="%(lower)s") `x` #define PHPBN1b(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "constant conflicts with a built-in constant '"`x`"' in PHP"),%$isconstant,sourcefmt="%(lower)s") `x` %define PHPBN1(X) PHPBN1a(X); PHPBN1b(X) %enddef /* Constant (case sensitive) */ #define PHPBN2a(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "enum conflicts with a built-in constant '"`x`"' in PHP"),%$isenumitem) `x` #define PHPBN2b(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "constant conflicts with a built-in constant '"`x`"' in PHP"),%$isconstant) `x` %define PHPBN2(X) PHPBN2a(X); PHPBN2b(X) %enddef #define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x` /* From: http://php.net/manual/en/reserved.keywords.php * "You cannot use any of the following words as constants, class names, * function or method names. Using them as variable names is generally OK, but * could lead to confusion." */ /* Check is case insensitive - these *MUST* be listed in lower case here */ PHPKW(__halt_compiler); PHPKW(abstract); PHPKW(and); PHPKW(array); PHPKW(as); PHPKW(break); PHPKW(callable); // As of PHP 5.4 PHPKW(case); PHPKW(catch); PHPKW(class); PHPKW(clone); PHPKW(const); PHPKW(continue); PHPKW(declare); PHPKW(default); PHPKW(die); // "Language construct" PHPKW(do); PHPKW(echo); // "Language construct" PHPKW(else); PHPKW(elseif); PHPKW(empty); // "Language construct" PHPKW(enddeclare); PHPKW(endfor); PHPKW(endforeach); PHPKW(endif); PHPKW(endswitch); PHPKW(endwhile); PHPKW(eval); // "Language construct" PHPKW(exit); // "Language construct" PHPKW(extends); PHPKW(final); PHPKW(finally); // As of PHP 5.5 PHPKW(for); PHPKW(foreach); PHPKW(function); PHPKW(global); PHPKW(goto); // As of PHP 5.3 PHPKW(if); PHPKW(implements); PHPKW(include); // "Language construct" PHPKW(include_once); // "Language construct" PHPKW(instanceof); PHPKW(insteadof); // As of PHP 5.4 PHPKW(interface); PHPKW(isset); // "Language construct" PHPKW(list); // "Language construct" PHPKW(namespace); // As of PHP 5.3 PHPKW(new); PHPKW(or); PHPKW(print); // "Language construct" PHPKW(private); PHPKW(protected); PHPKW(public); PHPKW(require); // "Language construct" PHPKW(require_once); // "Language construct" PHPKW(return); // "Language construct" PHPKW(static); PHPKW(switch); PHPKW(throw); PHPKW(trait); // As of PHP 5.4 PHPKW(try); PHPKW(unset); // "Language construct" PHPKW(use); PHPKW(var); PHPKW(while); PHPKW(xor); PHPKW(yield); // As of PHP 5.5 // Compile-time "magic" constants // From: http://php.net/manual/en/reserved.keywords.php // also at: http://php.net/manual/en/language.constants.predefined.php /* These *MUST* be listed in lower case here */ PHPKW(__class__); PHPKW(__dir__); // As of PHP 5.3 PHPKW(__file__); PHPKW(__function__); PHPKW(__line__); PHPKW(__method__); PHPKW(__namespace__); // As of PHP 5.3 PHPKW(__trait__); // As of PHP 5.4 /* We classify these as built-in names since they conflict, but PHP still runs */ /* Predefined case-insensitive constants */ /* These *MUST* be listed in lower case here */ PHPBN1(null); PHPBN1(true); PHPBN1(false); /* "Core Predefined Constants" from http://php.net/manual/en/reserved.constants.php */ /* These are case sensitive */ PHPBN2(PHP_VERSION); PHPBN2(PHP_MAJOR_VERSION); // As of PHP 5.2.7 PHPBN2(PHP_MINOR_VERSION); // As of PHP 5.2.7 PHPBN2(PHP_RELEASE_VERSION); // As of PHP 5.2.7 PHPBN2(PHP_VERSION_ID); // As of PHP 5.2.7 PHPBN2(PHP_EXTRA_VERSION); // As of PHP 5.2.7 PHPBN2(PHP_ZTS); // As of PHP 5.2.7 PHPBN2(PHP_DEBUG); // As of PHP 5.2.7 PHPBN2(PHP_MAXPATHLEN); // As of PHP 5.3.0 PHPBN2(PHP_OS); PHPBN2(PHP_SAPI); PHPBN2(PHP_EOL); // As of PHP 5.0.2 PHPBN2(PHP_INT_MAX); // As of PHP 5.0.5 PHPBN2(PHP_INT_SIZE); // As of PHP 5.0.5 PHPBN2(DEFAULT_INCLUDE_PATH); PHPBN2(PEAR_INSTALL_DIR); PHPBN2(PEAR_EXTENSION_DIR); PHPBN2(PHP_EXTENSION_DIR); PHPBN2(PHP_PREFIX); PHPBN2(PHP_BINDIR); PHPBN2(PHP_BINARY); // As of PHP 5.4 PHPBN2(PHP_MANDIR); // As of PHP 5.3.7 PHPBN2(PHP_LIBDIR); PHPBN2(PHP_DATADIR); PHPBN2(PHP_SYSCONFDIR); PHPBN2(PHP_LOCALSTATEDIR); PHPBN2(PHP_CONFIG_FILE_PATH); PHPBN2(PHP_CONFIG_FILE_SCAN_DIR); PHPBN2(PHP_SHLIB_SUFFIX); PHPBN2(E_ERROR); PHPBN2(E_WARNING); PHPBN2(E_PARSE); PHPBN2(E_NOTICE); PHPBN2(E_CORE_ERROR); PHPBN2(E_CORE_WARNING); PHPBN2(E_COMPILE_ERROR); PHPBN2(E_COMPILE_WARNING); PHPBN2(E_USER_ERROR); PHPBN2(E_USER_WARNING); PHPBN2(E_USER_NOTICE); PHPBN2(E_DEPRECATED); // As of PHP 5.3.0 PHPBN2(E_USER_DEPRECATED); // As of PHP 5.3.0 PHPBN2(E_ALL); PHPBN2(E_STRICT); PHPBN2(__COMPILER_HALT_OFFSET__); // As of PHP 5.1.0 // TRUE, FALSE, NULL are listed on the same page, but are actually // case-insensitive, whereas all the other constants listed there seem to be // case-sensitive, so we handle TRUE, FALSE, NULL in PHPBN1. PHPBN2(PHP_OUTPUT_HANDLER_START); PHPBN2(PHP_OUTPUT_HANDLER_CONT); PHPBN2(PHP_OUTPUT_HANDLER_END); /* These don't actually seem to be set (tested on Linux, I guess they're * Windows only?) */ PHPBN2(PHP_WINDOWS_NT_DOMAIN_CONTROLLER); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_NT_SERVER); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_NT_WORKSTATION); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_BUILD); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_MAJOR); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_MINOR); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_PLATFORM); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_PRODUCTTYPE); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_SP_MAJOR); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_SP_MINOR); // As of PHP 5.3 PHPBN2(PHP_WINDOWS_VERSION_SUITEMASK); // As of PHP 5.3 /* "Standard Predefined Constants" from http://php.net/manual/en/reserved.constants.php */ PHPBN2(EXTR_OVERWRITE); PHPBN2(EXTR_SKIP); PHPBN2(EXTR_PREFIX_SAME); PHPBN2(EXTR_PREFIX_ALL); PHPBN2(EXTR_PREFIX_INVALID); PHPBN2(EXTR_PREFIX_IF_EXISTS); PHPBN2(EXTR_IF_EXISTS); PHPBN2(SORT_ASC); PHPBN2(SORT_DESC); PHPBN2(SORT_REGULAR); PHPBN2(SORT_NUMERIC); PHPBN2(SORT_STRING); PHPBN2(CASE_LOWER); PHPBN2(CASE_UPPER); PHPBN2(COUNT_NORMAL); PHPBN2(COUNT_RECURSIVE); PHPBN2(ASSERT_ACTIVE); PHPBN2(ASSERT_CALLBACK); PHPBN2(ASSERT_BAIL); PHPBN2(ASSERT_WARNING); PHPBN2(ASSERT_QUIET_EVAL); PHPBN2(CONNECTION_ABORTED); PHPBN2(CONNECTION_NORMAL); PHPBN2(CONNECTION_TIMEOUT); PHPBN2(INI_USER); PHPBN2(INI_PERDIR); PHPBN2(INI_SYSTEM); PHPBN2(INI_ALL); PHPBN2(INI_SCANNER_NORMAL); // As of PHP 5.3 PHPBN2(INI_SCANNER_RAW); // As of PHP 5.3 PHPBN2(M_E); PHPBN2(M_LOG2E); PHPBN2(M_LOG10E); PHPBN2(M_LN2); PHPBN2(M_LN10); PHPBN2(M_PI); PHPBN2(M_PI_2); PHPBN2(M_PI_4); PHPBN2(M_1_PI); PHPBN2(M_2_PI); PHPBN2(M_2_SQRTPI); PHPBN2(M_SQRT2); PHPBN2(M_SQRT1_2); PHPBN2(M_EULER); // As of PHP 5.2 PHPBN2(M_LNPI); // As of PHP 5.2 PHPBN2(M_SQRT3); // As of PHP 5.2 PHPBN2(M_SQRTPI); // As of PHP 5.2 PHPBN2(CRYPT_SALT_LENGTH); PHPBN2(CRYPT_STD_DES); PHPBN2(CRYPT_EXT_DES); PHPBN2(CRYPT_MD5); PHPBN2(CRYPT_BLOWFISH); PHPBN2(DIRECTORY_SEPARATOR); PHPBN2(SEEK_SET); PHPBN2(SEEK_CUR); PHPBN2(SEEK_END); PHPBN2(LOCK_SH); PHPBN2(LOCK_EX); PHPBN2(LOCK_UN); PHPBN2(LOCK_NB); PHPBN2(HTML_SPECIALCHARS); PHPBN2(HTML_ENTITIES); PHPBN2(ENT_COMPAT); PHPBN2(ENT_QUOTES); PHPBN2(ENT_NOQUOTES); PHPBN2(INFO_GENERAL); PHPBN2(INFO_CREDITS); PHPBN2(INFO_CONFIGURATION); PHPBN2(INFO_MODULES); PHPBN2(INFO_ENVIRONMENT); PHPBN2(INFO_VARIABLES); PHPBN2(INFO_LICENSE); PHPBN2(INFO_ALL); PHPBN2(CREDITS_GROUP); PHPBN2(CREDITS_GENERAL); PHPBN2(CREDITS_SAPI); PHPBN2(CREDITS_MODULES); PHPBN2(CREDITS_DOCS); PHPBN2(CREDITS_FULLPAGE); PHPBN2(CREDITS_QA); PHPBN2(CREDITS_ALL); PHPBN2(STR_PAD_LEFT); PHPBN2(STR_PAD_RIGHT); PHPBN2(STR_PAD_BOTH); PHPBN2(PATHINFO_DIRNAME); PHPBN2(PATHINFO_BASENAME); PHPBN2(PATHINFO_EXTENSION); PHPBN2(PATHINFO_FILENAME); // As of PHP 5.2 PHPBN2(PATH_SEPARATOR); PHPBN2(CHAR_MAX); PHPBN2(LC_CTYPE); PHPBN2(LC_NUMERIC); PHPBN2(LC_TIME); PHPBN2(LC_COLLATE); PHPBN2(LC_MONETARY); PHPBN2(LC_ALL); PHPBN2(LC_MESSAGES); PHPBN2(ABDAY_1); PHPBN2(ABDAY_2); PHPBN2(ABDAY_3); PHPBN2(ABDAY_4); PHPBN2(ABDAY_5); PHPBN2(ABDAY_6); PHPBN2(ABDAY_7); PHPBN2(DAY_1); PHPBN2(DAY_2); PHPBN2(DAY_3); PHPBN2(DAY_4); PHPBN2(DAY_5); PHPBN2(DAY_6); PHPBN2(DAY_7); PHPBN2(ABMON_1); PHPBN2(ABMON_2); PHPBN2(ABMON_3); PHPBN2(ABMON_4); PHPBN2(ABMON_5); PHPBN2(ABMON_6); PHPBN2(ABMON_7); PHPBN2(ABMON_8); PHPBN2(ABMON_9); PHPBN2(ABMON_10); PHPBN2(ABMON_11); PHPBN2(ABMON_12); PHPBN2(MON_1); PHPBN2(MON_2); PHPBN2(MON_3); PHPBN2(MON_4); PHPBN2(MON_5); PHPBN2(MON_6); PHPBN2(MON_7); PHPBN2(MON_8); PHPBN2(MON_9); PHPBN2(MON_10); PHPBN2(MON_11); PHPBN2(MON_12); PHPBN2(AM_STR); PHPBN2(PM_STR); PHPBN2(D_T_FMT); PHPBN2(D_FMT); PHPBN2(T_FMT); PHPBN2(T_FMT_AMPM); PHPBN2(ERA); PHPBN2(ERA_YEAR); PHPBN2(ERA_D_T_FMT); PHPBN2(ERA_D_FMT); PHPBN2(ERA_T_FMT); PHPBN2(ALT_DIGITS); PHPBN2(INT_CURR_SYMBOL); PHPBN2(CURRENCY_SYMBOL); PHPBN2(CRNCYSTR); PHPBN2(MON_DECIMAL_POINT); PHPBN2(MON_THOUSANDS_SEP); PHPBN2(MON_GROUPING); PHPBN2(POSITIVE_SIGN); PHPBN2(NEGATIVE_SIGN); PHPBN2(INT_FRAC_DIGITS); PHPBN2(FRAC_DIGITS); PHPBN2(P_CS_PRECEDES); PHPBN2(P_SEP_BY_SPACE); PHPBN2(N_CS_PRECEDES); PHPBN2(N_SEP_BY_SPACE); PHPBN2(P_SIGN_POSN); PHPBN2(N_SIGN_POSN); PHPBN2(DECIMAL_POINT); PHPBN2(RADIXCHAR); PHPBN2(THOUSANDS_SEP); PHPBN2(THOUSEP); PHPBN2(GROUPING); PHPBN2(YESEXPR); PHPBN2(NOEXPR); PHPBN2(YESSTR); PHPBN2(NOSTR); PHPBN2(CODESET); PHPBN2(LOG_EMERG); PHPBN2(LOG_ALERT); PHPBN2(LOG_CRIT); PHPBN2(LOG_ERR); PHPBN2(LOG_WARNING); PHPBN2(LOG_NOTICE); PHPBN2(LOG_INFO); PHPBN2(LOG_DEBUG); PHPBN2(LOG_KERN); PHPBN2(LOG_USER); PHPBN2(LOG_MAIL); PHPBN2(LOG_DAEMON); PHPBN2(LOG_AUTH); PHPBN2(LOG_SYSLOG); PHPBN2(LOG_LPR); PHPBN2(LOG_NEWS); PHPBN2(LOG_UUCP); PHPBN2(LOG_CRON); PHPBN2(LOG_AUTHPRIV); PHPBN2(LOG_LOCAL0); PHPBN2(LOG_LOCAL1); PHPBN2(LOG_LOCAL2); PHPBN2(LOG_LOCAL3); PHPBN2(LOG_LOCAL4); PHPBN2(LOG_LOCAL5); PHPBN2(LOG_LOCAL6); PHPBN2(LOG_LOCAL7); PHPBN2(LOG_PID); PHPBN2(LOG_CONS); PHPBN2(LOG_ODELAY); PHPBN2(LOG_NDELAY); PHPBN2(LOG_NOWAIT); PHPBN2(LOG_PERROR); /* Added in PHP 5.2 */ PHPBN2(PREG_BACKTRACK_LIMIT_ERROR); PHPBN2(PREG_BAD_UTF8_ERROR); PHPBN2(PREG_INTERNAL_ERROR); PHPBN2(PREG_NO_ERROR); PHPBN2(PREG_RECURSION_LIMIT_ERROR); PHPBN2(UPLOAD_ERR_EXTENSION); PHPBN2(STREAM_SHUT_RD); PHPBN2(STREAM_SHUT_WR); PHPBN2(STREAM_SHUT_RDWR); PHPBN2(CURLE_FILESIZE_EXCEEDED); PHPBN2(CURLE_FTP_SSL_FAILED); PHPBN2(CURLE_LDAP_INVALID_URL); PHPBN2(CURLFTPAUTH_DEFAULT); PHPBN2(CURLFTPAUTH_SSL); PHPBN2(CURLFTPAUTH_TLS); PHPBN2(CURLFTPSSL_ALL); PHPBN2(CURLFTPSSL_CONTROL); PHPBN2(CURLFTPSSL_NONE); PHPBN2(CURLFTPSSL_TRY); PHPBN2(CURLOPT_FTP_SSL); PHPBN2(CURLOPT_FTPSSLAUTH); PHPBN2(CURLOPT_TCP_NODELAY); // Added in PHP 5.2.1 PHPBN2(CURLOPT_TIMEOUT_MS); // Added in PHP 5.2.3 PHPBN2(CURLOPT_CONNECTTIMEOUT_MS); // Added in PHP 5.2.3 PHPBN2(GMP_VERSION); // Added in PHP 5.2.2 PHPBN2(SWFTEXTFIELD_USEFONT); PHPBN2(SWFTEXTFIELD_AUTOSIZE); PHPBN2(SWF_SOUND_NOT_COMPRESSED); PHPBN2(SWF_SOUND_ADPCM_COMPRESSED); PHPBN2(SWF_SOUND_MP3_COMPRESSED); PHPBN2(SWF_SOUND_NOT_COMPRESSED_LE); PHPBN2(SWF_SOUND_NELLY_COMPRESSED); PHPBN2(SWF_SOUND_5KHZ); PHPBN2(SWF_SOUND_11KHZ); PHPBN2(SWF_SOUND_22KHZ); PHPBN2(SWF_SOUND_44KHZ); PHPBN2(SWF_SOUND_8BITS); PHPBN2(SWF_SOUND_16BITS); PHPBN2(SWF_SOUND_MONO); PHPBN2(SWF_SOUND_STEREO); PHPBN2(OPENSSL_VERSION_NUMBER); PHPBN2(SNMP_OID_OUTPUT_FULL); PHPBN2(SNMP_OID_OUTPUT_NUMERIC); PHPBN2(MSG_EAGAIN); PHPBN2(MSG_ENOMSG); /* Added in PHP 5.3 */ PHPBN2(CURLOPT_PROGRESSFUNCTION); PHPBN2(IMG_FILTER_PIXELATE); PHPBN2(JSON_ERROR_CTRL_CHAR); PHPBN2(JSON_ERROR_DEPTH); PHPBN2(JSON_ERROR_NONE); PHPBN2(JSON_ERROR_STATE_MISMATCH); PHPBN2(JSON_ERROR_SYNTAX); PHPBN2(JSON_FORCE_OBJECT); PHPBN2(JSON_HEX_TAG); PHPBN2(JSON_HEX_AMP); PHPBN2(JSON_HEX_APOS); PHPBN2(JSON_HEX_QUOT); PHPBN2(LDAP_OPT_NETWORK_TIMEOUT); PHPBN2(LIBXML_LOADED_VERSION); PHPBN2(PREG_BAD_UTF8_OFFSET_ERROR); PHPBN2(BUS_ADRALN); PHPBN2(BUS_ADRERR); PHPBN2(BUS_OBJERR); PHPBN2(CLD_CONTIUNED); PHPBN2(CLD_DUMPED); PHPBN2(CLD_EXITED); PHPBN2(CLD_KILLED); PHPBN2(CLD_STOPPED); PHPBN2(CLD_TRAPPED); PHPBN2(FPE_FLTDIV); PHPBN2(FPE_FLTINV); PHPBN2(FPE_FLTOVF); PHPBN2(FPE_FLTRES); PHPBN2(FPE_FLTSUB); PHPBN2(FPE_FLTUND); PHPBN2(FPE_INTDIV); PHPBN2(FPE_INTOVF); PHPBN2(ILL_BADSTK); PHPBN2(ILL_COPROC); PHPBN2(ILL_ILLADR); PHPBN2(ILL_ILLOPC); PHPBN2(ILL_ILLOPN); PHPBN2(ILL_ILLTRP); PHPBN2(ILL_PRVOPC); PHPBN2(ILL_PRVREG); PHPBN2(POLL_ERR); PHPBN2(POLL_HUP); PHPBN2(POLL_IN); PHPBN2(POLL_MSG); PHPBN2(POLL_OUT); PHPBN2(POLL_PRI); PHPBN2(SEGV_ACCERR); PHPBN2(SEGV_MAPERR); PHPBN2(SI_ASYNCIO); PHPBN2(SI_KERNEL); PHPBN2(SI_MESGQ); PHPBN2(SI_NOINFO); PHPBN2(SI_QUEUE); PHPBN2(SI_SIGIO); PHPBN2(SI_TIMER); PHPBN2(SI_TKILL); PHPBN2(SI_USER); PHPBN2(SIG_BLOCK); PHPBN2(SIG_SETMASK); PHPBN2(SIG_UNBLOCK); PHPBN2(TRAP_BRKPT); PHPBN2(TRAP_TRACE); /* Added in PHP 5.4 */ PHPBN2(ENT_DISALLOWED); PHPBN2(ENT_HTML401); PHPBN2(ENT_HTML5); PHPBN2(ENT_SUBSTITUTE); PHPBN2(ENT_XML1); PHPBN2(ENT_XHTML); PHPBN2(IPPROTO_IP); PHPBN2(IPPROTO_IPV6); PHPBN2(IPV6_MULTICAST_HOPS); PHPBN2(IPV6_MULTICAST_IF); PHPBN2(IPV6_MULTICAST_LOOP); PHPBN2(IP_MULTICAST_IF); PHPBN2(IP_MULTICAST_LOOP); PHPBN2(IP_MULTICAST_TTL); PHPBN2(MCAST_JOIN_GROUP); PHPBN2(MCAST_LEAVE_GROUP); PHPBN2(MCAST_BLOCK_SOURCE); PHPBN2(MCAST_UNBLOCK_SOURCE); PHPBN2(MCAST_JOIN_SOURCE_GROUP); PHPBN2(MCAST_LEAVE_SOURCE_GROUP); PHPBN2(CURLOPT_MAX_RECV_SPEED_LARGE); PHPBN2(CURLOPT_MAX_SEND_SPEED_LARGE); PHPBN2(LIBXML_HTML_NODEFDTD); PHPBN2(LIBXML_HTML_NOIMPLIED); PHPBN2(LIBXML_PEDANTIC); PHPBN2(OPENSSL_CIPHER_AES_128_CBC); PHPBN2(OPENSSL_CIPHER_AES_192_CBC); PHPBN2(OPENSSL_CIPHER_AES_256_CBC); PHPBN2(OPENSSL_RAW_DATA); PHPBN2(OPENSSL_ZERO_PADDING); PHPBN2(PHP_OUTPUT_HANDLER_CLEAN); PHPBN2(PHP_OUTPUT_HANDLER_CLEANABLE); PHPBN2(PHP_OUTPUT_HANDLER_DISABLED); PHPBN2(PHP_OUTPUT_HANDLER_FINAL); PHPBN2(PHP_OUTPUT_HANDLER_FLUSH); PHPBN2(PHP_OUTPUT_HANDLER_FLUSHABLE); PHPBN2(PHP_OUTPUT_HANDLER_REMOVABLE); PHPBN2(PHP_OUTPUT_HANDLER_STARTED); PHPBN2(PHP_OUTPUT_HANDLER_STDFLAGS); PHPBN2(PHP_OUTPUT_HANDLER_WRITE); PHPBN2(PHP_SESSION_ACTIVE); PHPBN2(PHP_SESSION_DISABLED); PHPBN2(PHP_SESSION_NONE); PHPBN2(STREAM_META_ACCESS); PHPBN2(STREAM_META_GROUP); PHPBN2(STREAM_META_GROUP_NAME); PHPBN2(STREAM_META_OWNER); PHPBN2(STREAM_META_OWNER_NAME); PHPBN2(STREAM_META_TOUCH); PHPBN2(ZLIB_ENCODING_DEFLATE); PHPBN2(ZLIB_ENCODING_GZIP); PHPBN2(ZLIB_ENCODING_RAW); PHPBN2(U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR); PHPBN2(IDNA_CHECK_BIDI); PHPBN2(IDNA_CHECK_CONTEXTJ); PHPBN2(IDNA_NONTRANSITIONAL_TO_ASCII); PHPBN2(IDNA_NONTRANSITIONAL_TO_UNICODE); PHPBN2(INTL_IDNA_VARIANT_2003); PHPBN2(INTL_IDNA_VARIANT_UTS46); PHPBN2(IDNA_ERROR_EMPTY_LABEL); PHPBN2(IDNA_ERROR_LABEL_TOO_LONG); PHPBN2(IDNA_ERROR_DOMAIN_NAME_TOO_LONG); PHPBN2(IDNA_ERROR_LEADING_HYPHEN); PHPBN2(IDNA_ERROR_TRAILING_HYPHEN); PHPBN2(IDNA_ERROR_HYPHEN_3_4); PHPBN2(IDNA_ERROR_LEADING_COMBINING_MARK); PHPBN2(IDNA_ERROR_DISALLOWED); PHPBN2(IDNA_ERROR_PUNYCODE); PHPBN2(IDNA_ERROR_LABEL_HAS_DOT); PHPBN2(IDNA_ERROR_INVALID_ACE_LABEL); PHPBN2(IDNA_ERROR_BIDI); PHPBN2(IDNA_ERROR_CONTEXTJ); PHPBN2(JSON_PRETTY_PRINT); PHPBN2(JSON_UNESCAPED_SLASHES); PHPBN2(JSON_NUMERIC_CHECK); PHPBN2(JSON_UNESCAPED_UNICODE); PHPBN2(JSON_BIGINT_AS_STRING); /* Added in PHP 5.5 */ PHPBN2(IMG_AFFINE_TRANSLATE); PHPBN2(IMG_AFFINE_SCALE); PHPBN2(IMG_AFFINE_ROTATE); PHPBN2(IMG_AFFINE_SHEAR_HORIZONTAL); PHPBN2(IMG_AFFINE_SHEAR_VERTICAL); PHPBN2(IMG_CROP_DEFAULT); PHPBN2(IMG_CROP_TRANSPARENT); PHPBN2(IMG_CROP_BLACK); PHPBN2(IMG_CROP_WHITE); PHPBN2(IMG_CROP_SIDES); PHPBN2(IMG_FLIP_BOTH); PHPBN2(IMG_FLIP_HORIZONTAL); PHPBN2(IMG_FLIP_VERTICAL); PHPBN2(IMG_BELL); PHPBN2(IMG_BESSEL); PHPBN2(IMG_BICUBIC); PHPBN2(IMG_BICUBIC_FIXED); PHPBN2(IMG_BLACKMAN); PHPBN2(IMG_BOX); PHPBN2(IMG_BSPLINE); PHPBN2(IMG_CATMULLROM); PHPBN2(IMG_GAUSSIAN); PHPBN2(IMG_GENERALIZED_CUBIC); PHPBN2(IMG_HERMITE); PHPBN2(IMG_HAMMING); PHPBN2(IMG_HANNING); PHPBN2(IMG_MITCHELL); PHPBN2(IMG_POWER); PHPBN2(IMG_QUADRATIC); PHPBN2(IMG_SINC); PHPBN2(IMG_NEAREST_NEIGHBOUR); PHPBN2(IMG_WEIGHTED4); PHPBN2(IMG_TRIANGLE); PHPBN2(JSON_ERROR_RECURSION); PHPBN2(JSON_ERROR_INF_OR_NAN); PHPBN2(JSON_ERROR_UNSUPPORTED_TYPE); PHPBN2(MYSQLI_SERVER_PUBLIC_KEY); /* Added in PHP 5.6 */ PHPBN2(LDAP_ESCAPE_DN); PHPBN2(LDAP_ESCAPE_FILTER); PHPBN2(OPENSSL_DEFAULT_STREAM_CIPHERS); PHPBN2(STREAM_CRYPTO_METHOD_ANY_CLIENT); PHPBN2(STREAM_CRYPTO_METHOD_ANY_SERVER); PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT); PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_0_SERVER); PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT); PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_1_SERVER); PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_2_SERVER); PHPBN2(PGSQL_CONNECT_ASYNC); PHPBN2(PGSQL_CONNECTION_AUTH_OK); PHPBN2(PGSQL_CONNECTION_AWAITING_RESPONSE); PHPBN2(PGSQL_CONNECTION_MADE); PHPBN2(PGSQL_CONNECTION_SETENV); PHPBN2(PGSQL_CONNECTION_SSL_STARTUP); PHPBN2(PGSQL_CONNECTION_STARTED); PHPBN2(PGSQL_DML_ESCAPE); PHPBN2(PGSQL_POLLING_ACTIVE); PHPBN2(PGSQL_POLLING_FAILED); PHPBN2(PGSQL_POLLING_OK); PHPBN2(PGSQL_POLLING_READING); PHPBN2(PGSQL_POLLING_WRITING); /* Class names reserved by PHP (case insensitive) */ PHPCN(directory); PHPCN(stdclass); PHPCN(__php_incomplete_class); /* Added in PHP5. */ PHPCN(exception); PHPCN(errorexception); // As of PHP 5.1 PHPCN(php_user_filter); PHPCN(closure); // As of PHP 5.3 PHPCN(generator); // As of PHP 5.5 PHPCN(self); PHPCN(static); PHPCN(parent); /* From extensions (which of these are actually predefined depends which * extensions are loaded by default). */ PHPCN(xmlwriter); PHPCN(libxmlerror); PHPCN(simplexmlelement); PHPCN(soapclient); PHPCN(soapvar); PHPCN(soapserver); PHPCN(soapfault); PHPCN(soapparam); PHPCN(soapheader); PHPCN(recursiveiteratoriterator); PHPCN(filteriterator); PHPCN(recursivefilteriterator); PHPCN(parentiterator); PHPCN(limititerator); PHPCN(cachingiterator); PHPCN(recursivecachingiterator); PHPCN(iteratoriterator); PHPCN(norewinditerator); PHPCN(appenditerator); PHPCN(infiniteiterator); PHPCN(emptyiterator); PHPCN(arrayobject); PHPCN(arrayiterator); PHPCN(recursivearrayiterator); PHPCN(splfileinfo); PHPCN(directoryiterator); PHPCN(recursivedirectoryiterator); PHPCN(splfileobject); PHPCN(spltempfileobject); PHPCN(simplexmliterator); PHPCN(logicexception); PHPCN(badfunctioncallexception); PHPCN(badmethodcallexception); PHPCN(domainexception); PHPCN(invalidargumentexception); PHPCN(lengthexception); PHPCN(outofrangeexception); PHPCN(runtimeexception); PHPCN(outofboundsexception); PHPCN(overflowexception); PHPCN(rangeexception); PHPCN(underflowexception); PHPCN(unexpectedvalueexception); PHPCN(splobjectstorage); PHPCN(reflectionexception); PHPCN(reflection); PHPCN(reflectionfunction); PHPCN(reflectionparameter); PHPCN(reflectionmethod); PHPCN(reflectionclass); PHPCN(reflectionobject); PHPCN(reflectionproperty); PHPCN(reflectionextension); PHPCN(domexception); PHPCN(domstringlist); PHPCN(domnamelist); PHPCN(domimplementationlist); PHPCN(domimplementationsource); PHPCN(domimplementation); PHPCN(domnode); PHPCN(domnamespacenode); PHPCN(domdocumentfragment); PHPCN(domdocument); PHPCN(domnodelist); PHPCN(domnamednodemap); PHPCN(domcharacterdata); PHPCN(domattr); PHPCN(domelement); PHPCN(domtext); PHPCN(domcomment); PHPCN(domtypeinfo); PHPCN(domuserdatahandler); PHPCN(domdomerror); PHPCN(domerrorhandler); PHPCN(domlocator); PHPCN(domconfiguration); PHPCN(domcdatasection); PHPCN(domdocumenttype); PHPCN(domnotation); PHPCN(domentity); PHPCN(domentityreference); PHPCN(domprocessinginstruction); PHPCN(domstringextend); PHPCN(domxpath); PHPCN(xmlreader); PHPCN(sqlitedatabase); PHPCN(sqliteresult); PHPCN(sqliteunbuffered); PHPCN(sqliteexception); PHPCN(datetime); /* Built-in PHP functions (incomplete). */ /* Includes Array Functions - http://php.net/manual/en/ref.array.php */ /* Check is case insensitive - these *MUST* be listed in lower case here */ PHPFN(acos); PHPFN(array_change_key_case); PHPFN(array_chunk); PHPFN(array_column); PHPFN(array_combine); PHPFN(array_count_values); PHPFN(array_diff); PHPFN(array_diff_assoc); PHPFN(array_diff_key); PHPFN(array_diff_uassoc); PHPFN(array_diff_ukey); PHPFN(array_fill); PHPFN(array_fill_keys); PHPFN(array_filter); PHPFN(array_flip); PHPFN(array_intersect); PHPFN(array_intersect_assoc); PHPFN(array_intersect_key); PHPFN(array_intersect_uassoc); PHPFN(array_intersect_ukey); PHPFN(array_key_exists); PHPFN(array_keys); PHPFN(array_map); PHPFN(array_merge); PHPFN(array_merge_recursive); PHPFN(array_multisort); PHPFN(array_pad); PHPFN(array_pop); PHPFN(array_product); PHPFN(array_push); PHPFN(array_rand); PHPFN(array_reduce); PHPFN(array_replace); PHPFN(array_replace_recursive); PHPFN(array_reverse); PHPFN(array_search); PHPFN(array_shift); PHPFN(array_slice); PHPFN(array_splice); PHPFN(array_sum); PHPFN(array_udiff); PHPFN(array_udiff_assoc); PHPFN(array_udiff_uassoc); PHPFN(array_uintersect); PHPFN(array_uintersect_assoc); PHPFN(array_uintersect_uassoc); PHPFN(array_unique); PHPFN(array_unshift); PHPFN(array_values); PHPFN(array_walk); PHPFN(array_walk_recursive); PHPFN(arsort); PHPFN(asin); PHPFN(asort); PHPFN(atan); PHPFN(atan2); PHPFN(ceil); PHPFN(compact); PHPFN(cos); PHPFN(cosh); PHPFN(count); PHPFN(current); PHPFN(each); PHPFN(end); PHPFN(exp); PHPFN(extract); PHPFN(floor); PHPFN(fmod); PHPFN(in_array); PHPFN(key); PHPFN(key_exists); PHPFN(krsort); PHPFN(ksort); PHPFN(log); PHPFN(log10); PHPFN(max); PHPFN(min); PHPFN(natcasesort); PHPFN(natsort); PHPFN(next); PHPFN(pos); PHPFN(pow); PHPFN(prev); PHPFN(range); PHPFN(reset); PHPFN(rsort); PHPFN(shuffle); PHPFN(sin); PHPFN(sinh); PHPFN(sizeof); PHPFN(sort); PHPFN(sqrt); PHPFN(tan); PHPFN(tanh); PHPFN(uasort); PHPFN(uksort); PHPFN(usort); #undef PHPKW #undef PHPBN1a #undef PHPBN1b #undef PHPBN1 #undef PHPBN2a #undef PHPBN2b #undef PHPBN2 #undef PHPCN #undef PHPFN swig-3.0.8/Lib/php/phpinit.swg0000664000175000017500000000130212641054563016047 0ustar williamwilliam /* ------------------------------------------------------------ * The start of the PHP initialization function * ------------------------------------------------------------ */ %insert(init) "swiginit.swg" %init %{ SWIG_php_minit { SWIG_InitializeModule(0); %} %fragment("swig_php_init_member_ptr2", "header") { #define SWIG_MEMBER_PTR ((char*)"CLASS::*") static void swig_member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { efree(rsrc->ptr); } static int swig_member_ptr = 0; } %fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") { swig_member_ptr = zend_register_list_destructors_ex(swig_member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); } swig-3.0.8/Lib/php/std_map.i0000664000175000017500000000453512641054563015466 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } bool is_empty() const { return self->empty(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.8/Lib/php/std_string.i0000664000175000017500000000457612641054563016224 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string types * ----------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ // std::string is typemapped by value // This can prevent exporting methods which return a string // in order for the user to modify it. // However, I think I'll wait until someone asks for it... // ------------------------------------------------------------------------ %include %{ #include %} namespace std { %naturalvar string; class string; %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string, const string& %{ $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; %} %typemap(in) string %{ convert_to_string_ex($input); $1.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); %} %typemap(directorout) string %{ convert_to_string_ex(&$input); $result.assign(Z_STRVAL_P($input), Z_STRLEN_P($input)); %} %typemap(out) string %{ ZVAL_STRINGL($result, const_cast($1.data()), $1.size(), 1); %} %typemap(directorin) string, const string& %{ ZVAL_STRINGL($input, const_cast($1.data()), $1.size(), 1); %} %typemap(out) const string & %{ ZVAL_STRINGL($result, const_cast($1->data()), $1->size(), 1); %} %typemap(throws) string, const string& %{ zend_throw_exception(NULL, const_cast($1.c_str()), 0 TSRMLS_CC); return; %} /* These next two handle a function which takes a non-const reference to * a std::string and modifies the string. */ %typemap(in) string & ($*1_ltype temp) %{ convert_to_string_ex($input); temp.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); $1 = &temp; %} %typemap(directorout) string & ($*1_ltype *temp) %{ convert_to_string_ex(&$input); temp = new $*1_ltype(Z_STRVAL_P($input), Z_STRLEN_P($input)); swig_acquire_ownership(temp); $result = temp; %} %typemap(argout) string & %{ ZVAL_STRINGL(*($input), const_cast($1->data()), $1->size(), 1); %} /* SWIG will apply the non-const typemap above to const string& without * this more specific typemap. */ %typemap(argout) const string & ""; } swig-3.0.8/Lib/php/stl.i0000664000175000017500000000054512641054563014636 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/php/phprun.swg0000664000175000017500000002166412641054563015725 0ustar williamwilliam/* ----------------------------------------------------------------------------- * phprun.swg * * PHP runtime library * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif #include "zend.h" #include "zend_API.h" #include "zend_exceptions.h" #include "php.h" #include "ext/standard/php_string.h" #include /* for abort(), used in generated code. */ #ifdef ZEND_RAW_FENTRY /* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */ # define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_RAW_FENTRY((char*)#ZN, N, A, 0) #else /* This causes warnings from GCC >= 4.2 (assigning a string literal to char*). * But this seems to be unavoidable without directly assuming knowledge of * the structure, which changed between PHP4 and PHP5. */ # define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A) #endif #ifndef ZEND_FE_END # define ZEND_FE_END { NULL, NULL, NULL } #endif #ifndef Z_SET_ISREF_P /* For PHP < 5.3 */ # define Z_SET_ISREF_P(z) (z)->is_ref = 1 #endif #ifndef Z_SET_REFCOUNT_P /* For PHP < 5.3 */ # define Z_SET_REFCOUNT_P(z, rc) (z)->refcount = (rc) #endif #define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), (char*)(V), strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_CHAR_CONSTANT(N, V) do {\ static char swig_char = (V);\ zend_register_stringl_constant((char*)#N, sizeof(#N), &swig_char, 1, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);\ } while (0) /* These TSRMLS_ stuff should already be defined now, but with older php under redhat are not... */ #ifndef TSRMLS_D #define TSRMLS_D #endif #ifndef TSRMLS_DC #define TSRMLS_DC #endif #ifndef TSRMLS_C #define TSRMLS_C #endif #ifndef TSRMLS_CC #define TSRMLS_CC #endif #ifdef __cplusplus } #endif /* But in fact SWIG_ConvertPtr is the native interface for getting typed pointer values out of zvals. We need the TSRMLS_ macros for when we make PHP type calls later as we handle php resources */ #define SWIG_ConvertPtr(obj,pp,type,flags) SWIG_ZTS_ConvertPtr(obj,pp,type,flags TSRMLS_CC) #define SWIG_fail goto fail static const char *default_error_msg = "Unknown error occurred"; static int default_error_code = E_ERROR; #define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg #define SWIG_PHP_Error(code,msg) do { SWIG_ErrorCode() = code; SWIG_ErrorMsg() = msg; SWIG_fail; } while (0) #define SWIG_contract_assert(expr,msg) \ if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else /* Standard SWIG API */ #define SWIG_GetModule(clientdata) SWIG_Php_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer) /* used to wrap returned objects in so we know whether they are newobject and need freeing, or not */ typedef struct { void * ptr; int newobject; } swig_object_wrapper; /* empty zend destructor for types without one */ static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) { (void)rsrc; } #define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC) #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) static void SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) { /* * First test for Null pointers. Return those as PHP native NULL */ if (!ptr ) { ZVAL_NULL(z); return; } if (type->clientdata) { swig_object_wrapper *value; if (! (*(int *)(type->clientdata))) zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); value->ptr=ptr; value->newobject=(newobject & 1); if ((newobject & 2) == 0) { /* Just register the pointer as a resource. */ ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); } else { /* * Wrap the resource in an object, the resource will be accessible * via the "_cPtr" member. This is currently only used by * directorin typemaps. */ zval *resource; zend_class_entry **ce = NULL; const char *type_name = type->name+3; /* +3 so: _p_Foo -> Foo */ size_t type_name_len; int result; const char * p; /* Namespace__Foo -> Foo */ /* FIXME: ugly and goes wrong for classes with __ in their names. */ while ((p = strstr(type_name, "__")) != NULL) { type_name = p + 2; } type_name_len = strlen(type_name); MAKE_STD_ZVAL(resource); ZEND_REGISTER_RESOURCE(resource, value, *(int *)(type->clientdata)); if (SWIG_PREFIX_LEN > 0) { char * classname = (char*)emalloc(SWIG_PREFIX_LEN + type_name_len + 1); strcpy(classname, SWIG_PREFIX); strcpy(classname + SWIG_PREFIX_LEN, type_name); result = zend_lookup_class(classname, SWIG_PREFIX_LEN + type_name_len, &ce TSRMLS_CC); efree(classname); } else { result = zend_lookup_class((char *)type_name, type_name_len, &ce TSRMLS_CC); } if (result != SUCCESS) { /* class does not exist */ object_init(z); } else { object_init_ex(z, *ce); } Z_SET_REFCOUNT_P(z, 1); Z_SET_ISREF_P(z); zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval*), NULL); } return; } zend_error(E_ERROR, "Type: %s not registered with zend",type->name); } /* This pointer conversion routine takes the native pointer p (along with its type name) and converts it by calling appropriate casting functions according to ty. The resultant pointer is returned, or NULL is returned if the pointer can't be cast. Sadly PHP has no API to find a type name from a type id, only from an instance of a resource of the type id, so we have to pass type_name as well. The two functions which might call this are: SWIG_ZTS_ConvertResourcePtr which gets the type name from the resource and the registered zend destructors for which we have one per type each with the type name hard wired in. */ static void * SWIG_ZTS_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty TSRMLS_DC) { swig_cast_info *tc; void *result = 0; if (!ty) { /* They don't care about the target type, so just pass on the pointer! */ return p; } if (! type_name) { /* can't convert p to ptr type ty if we don't know what type p is */ return NULL; } /* convert and cast p from type_name to ptr as ty. */ tc = SWIG_TypeCheck(type_name, ty); if (tc) { int newmemory = 0; result = SWIG_TypeCast(tc, p, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } return result; } /* This function returns a pointer of type ty by extracting the pointer and type info from the resource in z. z must be a resource. If it fails, NULL is returned. It uses SWIG_ZTS_ConvertResourceData to do the real work. */ static void * SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) { swig_object_wrapper *value; void *p; int type; const char *type_name; value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type); if (type==-1) return NULL; if (flags & SWIG_POINTER_DISOWN) { value->newobject = 0; } p = value->ptr; type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); return SWIG_ZTS_ConvertResourceData(p, type_name, ty TSRMLS_CC); } /* We allow passing of a RESOURCE pointing to the object or an OBJECT whose _cPtr is a resource pointing to the object */ static int SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { if (z == NULL) { *ptr = 0; return 0; } switch (z->type) { case IS_OBJECT: { zval ** _cPtr; if (zend_hash_find(HASH_OF(z),(char*)"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) { if ((*_cPtr)->type==IS_RESOURCE) { *ptr = SWIG_ZTS_ConvertResourcePtr(*_cPtr, ty, flags TSRMLS_CC); return (*ptr == NULL ? -1 : 0); } } break; } case IS_RESOURCE: *ptr = SWIG_ZTS_ConvertResourcePtr(z, ty, flags TSRMLS_CC); return (*ptr == NULL ? -1 : 0); case IS_NULL: *ptr = 0; return 0; } return -1; } static char const_name[] = "swig_runtime_data_type_pointer"; static swig_module_info *SWIG_Php_GetModule() { zval *pointer; swig_module_info *ret = 0; TSRMLS_FETCH(); MAKE_STD_ZVAL(pointer); if (zend_get_constant(const_name, sizeof(const_name) - 1, pointer TSRMLS_CC)) { if (pointer->type == IS_LONG) { ret = (swig_module_info *) pointer->value.lval; } } FREE_ZVAL(pointer); return ret; } static void SWIG_Php_SetModule(swig_module_info *pointer) { TSRMLS_FETCH(); REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); } swig-3.0.8/Lib/php/director.swg0000664000175000017500000001007712641054563016220 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that PHP proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PHP_HEADER_ #define SWIG_DIRECTOR_PHP_HEADER_ #include #include #include namespace Swig { /* memory handler */ struct GCItem { virtual ~GCItem() { } virtual int get_own() const { return 0; } }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem * operator->() const { return _item; } private: GCItem *_item; }; struct GCItem_Object : GCItem { GCItem_Object(int own) : _own(own) { } virtual ~GCItem_Object() { } int get_own() const { return _own; } private: int _own; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; class Director { protected: zval *swig_self; typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; #ifdef ZTS // Store the ZTS context so it's available when C++ calls back to PHP. void *** swig_zts_ctx; #endif public: Director(zval *self TSRMLS_DC) : swig_self(self) { TSRMLS_SET_CTX(swig_zts_ctx); } static bool swig_is_overridden_method(char *cname, char *lc_fname TSRMLS_DC) { zend_class_entry **ce; zend_function *mptr; if (zend_lookup_class(cname, strlen(cname), &ce TSRMLS_CC) != SUCCESS) { return false; } if (zend_hash_find(&(*ce)->function_table, lc_fname, strlen(lc_fname) + 1, (void **) &mptr) != SUCCESS) { return false; } // common.scope points to the declaring class return strcmp(mptr->common.scope->name, cname); } template void swig_acquire_ownership(Type *vptr) const { if (vptr) { swig_owner[vptr] = new GCItem_T(vptr); } } }; /* base class for director exceptions */ class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(int code, const char *hdr, const char *msg TSRMLS_DC) : swig_msg(hdr) { if (msg[0]) { swig_msg += " "; swig_msg += msg; } SWIG_ErrorCode() = code; SWIG_ErrorMsg() = swig_msg.c_str(); } virtual ~DirectorException() throw() { } const char *what() const throw() { return swig_msg.c_str(); } static void raise(int code, const char *hdr, const char *msg TSRMLS_DC) { throw DirectorException(code, hdr, msg TSRMLS_CC); } }; /* attempt to call a pure virtual method via a director method */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg TSRMLS_DC) : DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC) { } static void raise(const char *msg TSRMLS_DC) { throw DirectorPureVirtualException(msg TSRMLS_CC); } }; /* any php exception that occurs during a director method call */ class DirectorMethodException : public DirectorException { public: DirectorMethodException(const char *msg TSRMLS_DC) : DirectorException(E_ERROR, "SWIG director method error", msg TSRMLS_CC) { } static void raise(const char *msg TSRMLS_DC) { throw DirectorMethodException(msg TSRMLS_CC); } }; } // DirectorMethodException() is documented to be callable with no parameters // so use a macro to insert TSRMLS_CC so any ZTS context gets passed. #define DirectorMethodException() DirectorMethodException("" TSRMLS_CC) #endif swig-3.0.8/Lib/php/typemaps.i0000664000175000017500000002427312641054563015702 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i. * * SWIG Typemap library for PHP. * * This library provides standard typemaps for modifying SWIG's behavior. * With enough entries in this file, I hope that very few people actually * ever need to write a typemap. * * Define macros to define the following typemaps: * * TYPE *INPUT. Argument is passed in as native variable by value. * TYPE *OUTPUT. Argument is returned as an array from the function call. * TYPE *INOUT. Argument is passed in by value, and out as part of returned list * TYPE *REFERENCE. Argument is passed in as native variable with value * semantics. Variable value is changed with result. * Use like this: * int foo(int *REFERENCE); * * $a = 0; * $rc = foo($a); * * Even though $a looks like it's passed by value, * its value can be changed by foo(). * ----------------------------------------------------------------------------- */ %define BOOL_TYPEMAP(TYPE) %typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) %{ convert_to_boolean_ex($input); temp = Z_LVAL_PP($input) ? true : false; $1 = &temp; %} %typemap(argout) TYPE *INPUT, TYPE &INPUT ""; %typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; %typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT { zval *o; MAKE_STD_ZVAL(o); ZVAL_BOOL(o,temp$argnum); t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue) %{ convert_to_boolean_ex($input); lvalue = (*$input)->value.lval ? true : false; $1 = &lvalue; %} %typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE %{ (*$arg)->value.lval = lvalue$argnum ? true : false; (*$arg)->type = IS_BOOL; %} %enddef %define DOUBLE_TYPEMAP(TYPE) %typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) %{ convert_to_double_ex($input); temp = (TYPE) Z_DVAL_PP($input); $1 = &temp; %} %typemap(argout) TYPE *INPUT, TYPE &INPUT ""; %typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; %typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT { zval *o; MAKE_STD_ZVAL(o); ZVAL_DOUBLE(o,temp$argnum); t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (TYPE dvalue), TYPE &REFERENCE (TYPE dvalue) %{ convert_to_double_ex($input); dvalue = (TYPE) (*$input)->value.dval; $1 = &dvalue; %} %typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE %{ $1->value.dval = (double)(lvalue$argnum); $1->type = IS_DOUBLE; %} %enddef %define INT_TYPEMAP(TYPE) %typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) %{ convert_to_long_ex($input); temp = (TYPE) Z_LVAL_PP($input); $1 = &temp; %} %typemap(argout) TYPE *INPUT, TYPE &INPUT ""; %typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; %typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT { zval *o; MAKE_STD_ZVAL(o); ZVAL_LONG(o,temp$argnum); t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue) %{ convert_to_long_ex($input); lvalue = (TYPE) (*$input)->value.lval; $1 = &lvalue; %} %typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE %{ (*$arg)->value.lval = (long)(lvalue$argnum); (*$arg)->type = IS_LONG; %} %enddef BOOL_TYPEMAP(bool); DOUBLE_TYPEMAP(float); DOUBLE_TYPEMAP(double); INT_TYPEMAP(int); INT_TYPEMAP(short); INT_TYPEMAP(long); INT_TYPEMAP(unsigned int); INT_TYPEMAP(unsigned short); INT_TYPEMAP(unsigned long); INT_TYPEMAP(unsigned char); INT_TYPEMAP(signed char); INT_TYPEMAP(long long); %typemap(argout,fragment="t_output_helper") long long *OUTPUT { zval *o; MAKE_STD_ZVAL(o); if ((long long)LONG_MIN <= temp$argnum && temp$argnum <= (long long)LONG_MAX) { ZVAL_LONG(o, temp$argnum); } else { char temp[256]; sprintf(temp, "%lld", (long long)temp$argnum); ZVAL_STRING(o, temp, 1); } t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (long long lvalue) %{ CONVERT_LONG_LONG_IN(lvalue, long long, $input) $1 = &lvalue; %} %typemap(argout) long long *REFERENCE %{ if ((long long)LONG_MIN <= lvalue$argnum && lvalue$argnum <= (long long)LONG_MAX) { (*$arg)->value.lval = (long)(lvalue$argnum); (*$arg)->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%lld", (long long)lvalue$argnum); ZVAL_STRING((*$arg), temp, 1); } %} %typemap(argout) long long &OUTPUT %{ if ((long long)LONG_MIN <= *arg$argnum && *arg$argnum <= (long long)LONG_MAX) { ($result)->value.lval = (long)(*arg$argnum); ($result)->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%lld", (long long)(*arg$argnum)); ZVAL_STRING($result, temp, 1); } %} INT_TYPEMAP(unsigned long long); %typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT { zval *o; MAKE_STD_ZVAL(o); if (temp$argnum <= (unsigned long long)LONG_MAX) { ZVAL_LONG(o, temp$argnum); } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)temp$argnum); ZVAL_STRING(o, temp, 1); } t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in) TYPE *REFERENCE (unsigned long long lvalue) %{ CONVERT_UNSIGNED_LONG_LONG_IN(lvalue, unsigned long long, $input) $1 = &lvalue; %} %typemap(argout) unsigned long long *REFERENCE %{ if (lvalue$argnum <= (unsigned long long)LONG_MAX) { (*$arg)->value.lval = (long)(lvalue$argnum); (*$arg)->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)lvalue$argnum); ZVAL_STRING((*$arg), temp, 1); } %} %typemap(argout) unsigned long long &OUTPUT %{ if (*arg$argnum <= (unsigned long long)LONG_MAX) { ($result)->value.lval = (long)(*arg$argnum); ($result)->type = IS_LONG; } else { char temp[256]; sprintf(temp, "%llu", (unsigned long long)(*arg$argnum)); ZVAL_STRING($result, temp, 1); } %} %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) signed char *INOUT = signed char *INPUT; %typemap(in) bool &INOUT = bool *INPUT; %typemap(in) float &INOUT = float *INPUT; %typemap(in) double &INOUT = double *INPUT; %typemap(in) int &INOUT = int *INPUT; %typemap(in) short &INOUT = short *INPUT; %typemap(in) long &INOUT = long *INPUT; %typemap(in) long long &INOUT = long long *INPUT; %typemap(in) long long &INPUT = long long *INPUT; %typemap(in) unsigned &INOUT = unsigned *INPUT; %typemap(in) unsigned short &INOUT = unsigned short *INPUT; %typemap(in) unsigned long &INOUT = unsigned long *INPUT; %typemap(in) unsigned char &INOUT = unsigned char *INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long *INPUT; %typemap(in) unsigned long long &INPUT = unsigned long long *INPUT; %typemap(in) signed char &INOUT = signed char *INPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT= double *OUTPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT= long *OUTPUT; %typemap(argout) long long *INOUT= long long *OUTPUT; %typemap(argout) unsigned short *INOUT= unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) signed char *INOUT = signed char *OUTPUT; %typemap(argout) bool &INOUT = bool *OUTPUT; %typemap(argout) float &INOUT = float *OUTPUT; %typemap(argout) double &INOUT= double *OUTPUT; %typemap(argout) int &INOUT = int *OUTPUT; %typemap(argout) short &INOUT = short *OUTPUT; %typemap(argout) long &INOUT= long *OUTPUT; %typemap(argout) long long &INOUT= long long *OUTPUT; %typemap(argout) unsigned short &INOUT= unsigned short *OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char *OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long *OUTPUT; %typemap(argout) signed char &INOUT = signed char *OUTPUT; %typemap(in) char INPUT[ANY] ( char temp[$1_dim0] ) %{ convert_to_string_ex($input); strncpy(temp,Z_LVAL_PP($input),$1_dim0); $1 = temp; %} %typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] ) "$1 = temp;"; %typemap(argout,fragment="t_output_helper") char OUTPUT[ANY] { zval *o; MAKE_STD_ZVAL(o); ZVAL_STRINGL(o,temp$argnum,$1_dim0); t_output_helper( &$result, o TSRMLS_CC ); } %typemap(in,numinputs=0) void **OUTPUT (int force), void *&OUTPUT (int force) %{ /* If they pass NULL by reference, make it into a void* This bit should go in arginit if arginit support init-ing scripting args */ if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { /* wasn't a pre/ref/thing, OR anything like an int thing */ SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); } } force=0; if (arg1==NULL) { #ifdef __cplusplus ptr=new $*1_ltype(); #else ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); #endif $1=&ptr; /* have to passback arg$arg too */ force=1; } %} %typemap(argout) void **OUTPUT, void *&OUTPUT %{ if (force$argnum) { /* pass back arg$argnum through params ($arg) if we can */ if (!PZVAL_IS_REF(*$arg)) { SWIG_PHP_Error(E_WARNING, "Parameter $argnum of $symname wasn't passed by reference"); } else { SWIG_SetPointerZval(*$arg, (void *) ptr$argnum, $*1_descriptor, 1); } } %} swig-3.0.8/Lib/php/std_vector.i0000664000175000017500000000526012641054563016207 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); void clear(); %rename(push) push_back; void push_back(const value_type& x); %extend { bool is_empty() const { return $self->empty(); } T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); void clear(); %rename(push) push_back; void push_back(const value_type& x); %extend { bool is_empty() const { return $self->empty(); } bool pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); bool x = self->back(); self->pop_back(); return x; } bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && itype) { case IS_DOUBLE: lvar = (t) (*(invar))->value.dval; break; case IS_STRING: { char * endptr; errno = 0; lvar = (t) strtoll((*(invar))->value.str.val, &endptr, 10); if (*endptr && !errno) break; /* FALL THRU */ } default: convert_to_long_ex(invar); lvar = (t) (*(invar))->value.lval; } %enddef %define CONVERT_UNSIGNED_LONG_LONG_IN(lvar,t,invar) switch ((*(invar))->type) { case IS_DOUBLE: lvar = (t) (*(invar))->value.dval; break; case IS_STRING: { char * endptr; errno = 0; lvar = (t) strtoull((*(invar))->value.str.val, &endptr, 10); if (*endptr && !errno) break; /* FALL THRU */ } default: convert_to_long_ex(invar); lvar = (t) (*(invar))->value.lval; } %enddef %define CONVERT_INT_OUT(lvar,invar) lvar = (t) Z_LVAL_PP(invar); %enddef %define CONVERT_FLOAT_IN(lvar,t,invar) convert_to_double_ex(invar); lvar = (t) Z_DVAL_PP(invar); %enddef %define CONVERT_CHAR_IN(lvar,t,invar) convert_to_string_ex(invar); lvar = (t) *Z_STRVAL_PP(invar); %enddef %define CONVERT_STRING_IN(lvar,t,invar) if ((*invar)->type==IS_NULL) { lvar = (t) 0; } else { convert_to_string_ex(invar); lvar = (t) Z_STRVAL_PP(invar); } %enddef %define %pass_by_val( TYPE, CONVERT_IN ) %typemap(in) TYPE %{ CONVERT_IN($1,$1_ltype,$input); %} %typemap(in) const TYPE & ($*1_ltype temp) %{ CONVERT_IN(temp,$*1_ltype,$input); $1 = &temp; %} %typemap(directorout) TYPE %{ CONVERT_IN($result,$1_ltype,&$input); %} %typemap(directorout) const TYPE & ($*1_ltype temp) %{ CONVERT_IN(temp,$*1_ltype,&$input); $result = &temp; %} %enddef %fragment("t_output_helper","header") %{ static void t_output_helper(zval **target, zval *o TSRMLS_DC) { zval *tmp; if ( (*target)->type == IS_ARRAY ) { /* it's already an array, just append */ add_next_index_zval( *target, o ); return; } if ( (*target)->type == IS_NULL ) { REPLACE_ZVAL_VALUE(target,o,1); FREE_ZVAL(o); return; } ALLOC_INIT_ZVAL(tmp); *tmp = **target; zval_copy_ctor(tmp); array_init(*target); add_next_index_zval( *target, tmp); add_next_index_zval( *target, o); } %} swig-3.0.8/Lib/php/phppointers.i0000664000175000017500000000273412641054563016411 0ustar williamwilliam%define %pass_by_ref( TYPE, CONVERT_IN, CONVERT_OUT ) %typemap(in, byref=1) TYPE *REF ($*1_ltype tmp), TYPE &REF ($*1_ltype tmp) %{ /* First Check for SWIG wrapped type */ if ( ZVAL_IS_NULL( *$input ) ) { $1 = 0; } else if ( PZVAL_IS_REF( *$input ) ) { /* Not swig wrapped type, so we check if it's a PHP reference type */ CONVERT_IN( tmp, $*1_ltype, $input ); $1 = &tmp; } else { SWIG_PHP_Error( E_ERROR, SWIG_PHP_Arg_Error_Msg($argnum, Expected a reference) ); } %} %typemap(argout) TYPE *REF, TYPE &REF "CONVERT_OUT(*$input, tmp$argnum );"; %enddef %pass_by_ref( size_t, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( signed int, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( int, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( unsigned int, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( signed short, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( short, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( unsigned short, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( signed long, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( long, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( unsigned long, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( signed char, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( char, CONVERT_CHAR_IN, ZVAL_STRING ); %pass_by_ref( unsigned char, CONVERT_INT_IN, ZVAL_LONG ); %pass_by_ref( float, CONVERT_FLOAT_IN, ZVAL_DOUBLE ); %pass_by_ref( double, CONVERT_FLOAT_IN, ZVAL_DOUBLE ); %pass_by_ref( char *, CONVERT_CHAR_IN, ZVAL_STRING ); swig-3.0.8/Lib/std_except.i0000664000175000017500000000371712641054563015413 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * SWIG library file with typemaps to handle and throw STD exceptions in a * language and STL independent way, i.e., the target language doesn't * require to support STL but only the 'exception.i' mechanism. * * These typemaps are used when methods are declared with an STD * exception specification, such as * * size_t at() const throw (std::out_of_range); * * The typemaps here are based on the language independent * 'exception.i' library. If that is working in your target language, * this file will work. * * If the target language doesn't implement a robust 'exception.i' * mechanism, or you prefer other ways to map the STD exceptions, write * a new std_except.i file in the target library directory. * ----------------------------------------------------------------------------- */ #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL) || defined(SWIGD) #error "This version of std_except.i should not be used" #endif %{ #include %} %include %define %std_exception_map(Exception, Code) %typemap(throws,noblock=1) Exception { SWIG_exception(Code, $1.what()); } %ignore Exception; struct Exception { }; %enddef namespace std { %std_exception_map(bad_exception, SWIG_SystemError); %std_exception_map(domain_error, SWIG_ValueError); %std_exception_map(exception, SWIG_SystemError); %std_exception_map(invalid_argument, SWIG_ValueError); %std_exception_map(length_error, SWIG_IndexError); %std_exception_map(logic_error, SWIG_RuntimeError); %std_exception_map(out_of_range, SWIG_IndexError); %std_exception_map(overflow_error, SWIG_OverflowError); %std_exception_map(range_error, SWIG_OverflowError); %std_exception_map(runtime_error, SWIG_RuntimeError); %std_exception_map(underflow_error, SWIG_OverflowError); } swig-3.0.8/Lib/python/0000775000175000017500000000000012641054563014410 5ustar williamwilliamswig-3.0.8/Lib/python/pyopers.swg0000664000175000017500000002262212641054563016637 0ustar williamwilliam/* ------------------------------------------------------------ * Overloaded operator support The directives in this file apply whether or not you use the -builtin option to SWIG, but operator overloads are particularly attractive when using -builtin, because they are much faster than named methods. If you're using the -builtin option to SWIG, and you want to define python operator overloads beyond the defaults defined in this file, here's what you need to know: There are two ways to define a python slot function: dispatch to a statically defined function; or dispatch to a method defined on the operand. To dispatch to a statically defined function, use %feature("python:"), where is the name of a field in a PyTypeObject, PyNumberMethods, PyMappingMethods, PySequenceMethods, or PyBufferProcs. For example: %{ static long myHashFunc (PyObject *pyobj) { MyClass *cobj; // Convert pyobj to cobj return (cobj->field1 * (cobj->field2 << 7)); } %} %feature("python:tp_hash") MyClass "myHashFunc"; NOTE: It is the responsibility of the programmer (that's you) to ensure that a statically defined slot function has the correct signature. If, instead, you want to dispatch to an instance method, you can use %feature("python:slot"). For example: class MyClass { public: long myHashFunc () const; ... }; %feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc; NOTE: Some python slots use a method signature which does not match the signature of SWIG-wrapped methods. For those slots, SWIG will automatically generate a "closure" function to re-marshall the arguments before dispatching to the wrapped method. Setting the "functype" attribute of the feature enables SWIG to generate a correct closure function. -------------------------------------------------------------- The tp_richcompare slot is a special case: SWIG automatically generates a rich compare function for all wrapped types. If a type defines C++ operator overloads for comparison (operator==, operator<, etc.), they will be called from the generated rich compare function. If you want to explicitly choose a method to handle a certain comparison operation, you may use %feature("python:slot") like this: class MyClass { public: bool lessThan (const MyClass& x) const; ... }; %feature("python:slot", "Py_LT") MyClass::lessThan; ... where "Py_LT" is one of the rich comparison opcodes defined in the python header file object.h. If there's no method defined to handle a particular comparsion operation, the default behavior is to compare pointer values of the wrapped C++ objects. -------------------------------------------------------------- For more information about python slots, including their names and signatures, you may refer to the python documentation : http://docs.python.org/c-api/typeobj.html * ------------------------------------------------------------ */ #ifdef __cplusplus #if defined(SWIGPYTHON_BUILTIN) #define %pybinoperator(pyname,oper,functp,slt) %rename(pyname) oper; %pythonmaybecall oper; %feature("python:slot", #slt, functype=#functp) oper; %feature("python:slot", #slt, functype=#functp) pyname; #define %pycompare(pyname,oper,comptype) %rename(pyname) oper; %pythonmaybecall oper; %feature("python:compare", #comptype) oper; %feature("python:compare", #comptype) pyname; #else #define %pybinoperator(pyname,oper,functp,slt) %rename(pyname) oper; %pythonmaybecall oper #define %pycompare(pyname,oper,comptype) %pybinoperator(pyname,oper,,comptype) #endif %pybinoperator(__add__, *::operator+, binaryfunc, nb_add); %pybinoperator(__pos__, *::operator+(), unaryfunc, nb_positive); %pybinoperator(__pos__, *::operator+() const, unaryfunc, nb_positive); %pybinoperator(__sub__, *::operator-, binaryfunc, nb_subtract); %pybinoperator(__neg__, *::operator-(), unaryfunc, nb_negative); %pybinoperator(__neg__, *::operator-() const, unaryfunc, nb_negative); %pybinoperator(__mul__, *::operator*, binaryfunc, nb_multiply); %pybinoperator(__div__, *::operator/, binaryfunc, nb_div); %pybinoperator(__mod__, *::operator%, binaryfunc, nb_remainder); %pybinoperator(__lshift__, *::operator<<, binaryfunc, nb_lshift); %pybinoperator(__rshift__, *::operator>>, binaryfunc, nb_rshift); %pybinoperator(__and__, *::operator&, binaryfunc, nb_and); %pybinoperator(__or__, *::operator|, binaryfunc, nb_or); %pybinoperator(__xor__, *::operator^, binaryfunc, nb_xor); %pycompare(__lt__, *::operator<, Py_LT); %pycompare(__le__, *::operator<=, Py_LE); %pycompare(__gt__, *::operator>, Py_GT); %pycompare(__ge__, *::operator>=, Py_GE); %pycompare(__eq__, *::operator==, Py_EQ); %pycompare(__ne__, *::operator!=, Py_NE); %feature("python:slot", "nb_truediv", functype="binaryfunc") *::operator/; /* Special cases */ %rename(__invert__) *::operator~; %feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~; %rename(__call__) *::operator(); %feature("python:slot", "tp_call", functype="ternarycallfunc") *::operator(); #if defined(SWIGPYTHON_BUILTIN) %pybinoperator(__nonzero__, *::operator bool, inquiry, nb_nonzero); #else %feature("shadow") *::operator bool %{ def __nonzero__(self): return $action(self) __bool__ = __nonzero__ %}; %rename(__nonzero__) *::operator bool; #endif /* Ignored operators */ %ignoreoperator(LNOT) operator!; %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; %ignoreoperator(EQ) *::operator=; %ignoreoperator(PLUSPLUS) *::operator++; %ignoreoperator(MINUSMINUS) *::operator--; %ignoreoperator(ARROWSTAR) *::operator->*; %ignoreoperator(INDEX) *::operator[]; /* Inplace operator declarations. They translate the inplace C++ operators (+=, -=, ...) into the corresponding python equivalents(__iadd__,__isub__), etc, disabling the ownership of the input 'this' pointer, and assigning it to the returning object: %feature("del") *::Operator; // disables ownership by generating SWIG_POINTER_DISOWN %feature("new") *::Operator; // claims ownership by generating SWIG_POINTER_OWN This makes the most common case safe, ie: A& A::operator+=(int i) { ...; return *this; } ^^^^ ^^^^^^ will work fine, even when the resulting python object shares the 'this' pointer with the input one. The input object is usually deleted after the operation, including the shared 'this' pointer, producing 'strange' seg faults, as reported by Lucriz (lucriz@sitilandia.it). If you have an interface that already takes care of that, ie, you already are using inplace operators and you are not getting seg. faults, with the new scheme you could end with 'free' elements that never get deleted (maybe, not sure, it depends). But if that is the case, you could recover the old behaviour using %feature("del","0") A::operator+=; %feature("new","0") A::operator+=; which recovers the old behaviour for the class 'A', or if you are 100% sure your entire system works fine in the old way, use: %feature("del","") *::operator+=; %feature("new","") *::operator+=; The default behaviour assumes that the 'this' pointer's memory is already owned by the SWIG object; it relinquishes ownership then takes it back. This may not be the case though as the SWIG object might be owned by memory managed elsewhere, eg after calling a function that returns a C++ reference. In such case you will need to use the features above to recover the old behaviour too. */ #if defined(SWIGPYTHON_BUILTIN) #define %pyinplaceoper(SwigPyOper, Oper, functp, slt) %delobject Oper; %newobject Oper; %feature("python:slot", #slt, functype=#functp) Oper; %rename(SwigPyOper) Oper #else #define %pyinplaceoper(SwigPyOper, Oper, functp, slt) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper #endif %pyinplaceoper(__iadd__ , *::operator +=, binaryfunc, nb_inplace_add); %pyinplaceoper(__isub__ , *::operator -=, binaryfunc, nb_inplace_subtract); %pyinplaceoper(__imul__ , *::operator *=, binaryfunc, nb_inplace_multiply); %pyinplaceoper(__idiv__ , *::operator /=, binaryfunc, nb_inplace_divide); %pyinplaceoper(__imod__ , *::operator %=, binaryfunc, nb_inplace_remainder); %pyinplaceoper(__iand__ , *::operator &=, binaryfunc, nb_inplace_and); %pyinplaceoper(__ior__ , *::operator |=, binaryfunc, nb_inplace_or); %pyinplaceoper(__ixor__ , *::operator ^=, binaryfunc, nb_inplace_xor); %pyinplaceoper(__ilshift__, *::operator <<=, binaryfunc, nb_inplace_lshift); %pyinplaceoper(__irshift__, *::operator >>=, binaryfunc, nb_inplace_rshift); /* Finally, in python we need to mark the binary operations to fail as 'maybecall' methods */ #define %pybinopermaybecall(oper) %pythonmaybecall __ ## oper ## __; %pythonmaybecall __r ## oper ## __ %pybinopermaybecall(add); %pybinopermaybecall(pos); %pybinopermaybecall(pos); %pybinopermaybecall(sub); %pybinopermaybecall(neg); %pybinopermaybecall(neg); %pybinopermaybecall(mul); %pybinopermaybecall(div); %pybinopermaybecall(mod); %pybinopermaybecall(lshift); %pybinopermaybecall(rshift); %pybinopermaybecall(and); %pybinopermaybecall(or); %pybinopermaybecall(xor); %pybinopermaybecall(lt); %pybinopermaybecall(le); %pybinopermaybecall(gt); %pybinopermaybecall(ge); %pybinopermaybecall(eq); %pybinopermaybecall(ne); #endif swig-3.0.8/Lib/python/pymacros.swg0000664000175000017500000000004612641054563016767 0ustar williamwilliam%include swig-3.0.8/Lib/python/pybuffer.i0000664000175000017500000000533612641054563016413 0ustar williamwilliam/* Implementing buffer protocol typemaps */ /* %pybuffer_mutable_binary(TYPEMAP, SIZE) * * Macro for functions accept mutable buffer pointer with a size. * This can be used for both input and output. For example: * * %pybuffer_mutable_binary(char *buff, int size); * void foo(char *buff, int size) { * for(int i=0; i %fragment("SwigPyIterator","header",fragment="") { namespace swig { struct stop_iteration { }; struct SwigPyIterator { private: SwigPtr_PyObject _seq; protected: SwigPyIterator(PyObject *seq) : _seq(seq) { } public: virtual ~SwigPyIterator() {} // Access iterator method, required by Python virtual PyObject *value() const = 0; // Forward iterator method, required by Python virtual SwigPyIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python virtual SwigPyIterator *decr(size_t /*n*/ = 1) { throw stop_iteration(); } // Random access iterator methods, but not required in Python virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } virtual bool equal (const SwigPyIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } // C++ common/needed methods virtual SwigPyIterator *copy() const = 0; PyObject *next() { SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads PyObject *obj = value(); incr(); SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads return obj; } /* Make an alias for Python 3.x */ PyObject *__next__() { return next(); } PyObject *previous() { SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads decr(); PyObject *obj = value(); SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads return obj; } SwigPyIterator *advance(ptrdiff_t n) { return (n > 0) ? incr(n) : decr(-n); } bool operator == (const SwigPyIterator& x) const { return equal(x); } bool operator != (const SwigPyIterator& x) const { return ! operator==(x); } SwigPyIterator& operator += (ptrdiff_t n) { return *advance(n); } SwigPyIterator& operator -= (ptrdiff_t n) { return *advance(-n); } SwigPyIterator* operator + (ptrdiff_t n) const { return copy()->advance(n); } SwigPyIterator* operator - (ptrdiff_t n) const { return copy()->advance(-n); } ptrdiff_t operator - (const SwigPyIterator& x) const { return x.distance(*this); } static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::SwigPyIterator *"); init = 1; } return desc; } }; %#if defined(SWIGPYTHON_BUILTIN) inline PyObject* make_output_iterator_builtin (PyObject *pyself) { Py_INCREF(pyself); return pyself; } %#endif } } %fragment("SwigPyIterator_T","header",fragment="",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { template class SwigPyIterator_T : public SwigPyIterator { public: typedef OutIterator out_iterator; typedef typename std::iterator_traits::value_type value_type; typedef SwigPyIterator_T self_type; SwigPyIterator_T(out_iterator curr, PyObject *seq) : SwigPyIterator(seq), current(curr) { } const out_iterator& get_current() const { return current; } bool equal (const SwigPyIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } ptrdiff_t distance(const SwigPyIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } protected: out_iterator current; }; template struct from_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v); } }; template::value_type, typename FromOper = from_oper > class SwigPyIteratorOpen_T : public SwigPyIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef SwigPyIterator_T base; typedef SwigPyIteratorOpen_T self_type; SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq) : SwigPyIterator_T(curr, seq) { } PyObject *value() const { return from(static_cast(*(base::current))); } SwigPyIterator *copy() const { return new self_type(*this); } SwigPyIterator *incr(size_t n = 1) { while (n--) { ++base::current; } return this; } SwigPyIterator *decr(size_t n = 1) { while (n--) { --base::current; } return this; } }; template::value_type, typename FromOper = from_oper > class SwigPyIteratorClosed_T : public SwigPyIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef SwigPyIterator_T base; typedef SwigPyIteratorClosed_T self_type; SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) : SwigPyIterator_T(curr, seq), begin(first), end(last) { } PyObject *value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } SwigPyIterator *copy() const { return new self_type(*this); } SwigPyIterator *incr(size_t n = 1) { while (n--) { if (base::current == end) { throw stop_iteration(); } else { ++base::current; } } return this; } SwigPyIterator *decr(size_t n = 1) { while (n--) { if (base::current == begin) { throw stop_iteration(); } else { --base::current; } } return this; } private: out_iterator begin; out_iterator end; }; template inline SwigPyIterator* make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0) { return new SwigPyIteratorClosed_T(current, begin, end, seq); } template inline SwigPyIterator* make_output_iterator(const OutIter& current, PyObject *seq = 0) { return new SwigPyIteratorOpen_T(current, seq); } } } %fragment("SwigPyIterator"); namespace swig { /* Throw a StopIteration exception */ %ignore stop_iteration; struct stop_iteration {}; %typemap(throws) stop_iteration { (void)$1; SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void()); SWIG_fail; } /* Mark methods that return new objects */ %newobject SwigPyIterator::copy; %newobject SwigPyIterator::operator + (ptrdiff_t n) const; %newobject SwigPyIterator::operator - (ptrdiff_t n) const; %nodirector SwigPyIterator; #if defined(SWIGPYTHON_BUILTIN) %feature("python:tp_iter") SwigPyIterator "&swig::make_output_iterator_builtin"; %feature("python:slot", "tp_iternext", functype="iternextfunc") SwigPyIterator::__next__; #else %extend SwigPyIterator { %pythoncode %{def __iter__(self): return self%} } #endif %catches(swig::stop_iteration) SwigPyIterator::value() const; %catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1); %catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1); %catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const; %catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const; %catches(swig::stop_iteration) SwigPyIterator::__next__(); %catches(swig::stop_iteration) SwigPyIterator::next(); %catches(swig::stop_iteration) SwigPyIterator::previous(); %catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n); %catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n); %catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n); %catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const; %catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const; struct SwigPyIterator { protected: SwigPyIterator(PyObject *seq); public: virtual ~SwigPyIterator(); // Access iterator method, required by Python virtual PyObject *value() const = 0; // Forward iterator method, required by Python virtual SwigPyIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python virtual SwigPyIterator *decr(size_t n = 1); // Random access iterator methods, but not required in Python virtual ptrdiff_t distance(const SwigPyIterator &x) const; virtual bool equal (const SwigPyIterator &x) const; // C++ common/needed methods virtual SwigPyIterator *copy() const = 0; PyObject *next(); PyObject *__next__(); PyObject *previous(); SwigPyIterator *advance(ptrdiff_t n); bool operator == (const SwigPyIterator& x) const; bool operator != (const SwigPyIterator& x) const; SwigPyIterator& operator += (ptrdiff_t n); SwigPyIterator& operator -= (ptrdiff_t n); SwigPyIterator* operator + (ptrdiff_t n) const; SwigPyIterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const SwigPyIterator& x) const; }; } swig-3.0.8/Lib/python/std_unordered_set.i0000664000175000017500000000273612641054563020306 0ustar williamwilliam/* Unordered Sets */ %fragment("StdUnorderedSetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::unordered_set* seq) { // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(PyObject *obj, std::unordered_set **s) { return traits_asptr_stdseq >::asptr(obj, s); } }; template struct traits_from > { static PyObject *from(const std::unordered_set& vec) { return traits_from_stdseq >::from(vec); } }; } %} %define %swig_unordered_set_methods(unordered_set...) %swig_sequence_iterator(unordered_set); %swig_container_methods(unordered_set); %extend { void append(value_type x) { self->insert(x); } bool __contains__(value_type x) { return self->find(x) != self->end(); } value_type __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } }; %enddef %include swig-3.0.8/Lib/python/std_pair.i0000664000175000017500000001351112641054563016370 0ustar williamwilliam/* Pairs */ %include //#define SWIG_STD_PAIR_ASVAL %fragment("StdPairTraits","header",fragment="StdTraits") { namespace swig { #ifdef SWIG_STD_PAIR_ASVAL template struct traits_asval > { typedef std::pair value_type; static int get_pair(PyObject* first, PyObject* second, std::pair *val) { if (val) { T *pfirst = &(val->first); int res1 = swig::asval((PyObject*)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(val->second); int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } else { T *pfirst = 0; int res1 = swig::asval((PyObject*)first, 0); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asval(PyObject *obj, std::pair *val) { int res = SWIG_ERROR; if (PyTuple_Check(obj)) { if (PyTuple_GET_SIZE(obj) == 2) { res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); } } else if (PySequence_Check(obj)) { if (PySequence_Size(obj) == 2) { swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); res = get_pair(first, second, val); } } else { value_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = *p; } return res; } }; #else template struct traits_asptr > { typedef std::pair value_type; static int get_pair(PyObject* first, PyObject* second, std::pair **val) { if (val) { value_type *vp = %new_instance(std::pair); T *pfirst = &(vp->first); int res1 = swig::asval((PyObject*)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(vp->second); int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; *val = vp; return SWIG_AddNewMask(res1 > res2 ? res1 : res2); } else { T *pfirst = 0; int res1 = swig::asval((PyObject*)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asptr(PyObject *obj, std::pair **val) { int res = SWIG_ERROR; if (PyTuple_Check(obj)) { if (PyTuple_GET_SIZE(obj) == 2) { res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); } } else if (PySequence_Check(obj)) { if (PySequence_Size(obj) == 2) { swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); res = get_pair(first, second, val); } } else { value_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; #endif template struct traits_from > { static PyObject *from(const std::pair& val) { PyObject* obj = PyTuple_New(2); PyTuple_SetItem(obj,0,swig::from(val.first)); PyTuple_SetItem(obj,1,swig::from(val.second)); return obj; } }; } #if defined(SWIGPYTHON_BUILTIN) SWIGINTERN Py_ssize_t SwigPython_std_pair_len (PyObject *a) { return 2; } SWIGINTERN PyObject* SwigPython_std_pair_repr (PyObject *o) { PyObject *tuple = PyTuple_New(2); assert(tuple); PyTuple_SET_ITEM(tuple, 0, PyObject_GetAttrString(o, (char*) "first")); PyTuple_SET_ITEM(tuple, 1, PyObject_GetAttrString(o, (char*) "second")); PyObject *result = PyObject_Repr(tuple); Py_DECREF(tuple); return result; } SWIGINTERN PyObject* SwigPython_std_pair_getitem (PyObject *a, Py_ssize_t b) { PyObject *result = PyObject_GetAttrString(a, b % 2 ? (char*) "second" : (char*) "first"); return result; } SWIGINTERN int SwigPython_std_pair_setitem (PyObject *a, Py_ssize_t b, PyObject *c) { int result = PyObject_SetAttrString(a, b % 2 ? (char*) "second" : (char*) "first", c); return result; } #endif } %feature("python:sq_length") std::pair "SwigPython_std_pair_len"; %feature("python:sq_length") std::pair "SwigPython_std_pair_len"; %feature("python:sq_length") std::pair "SwigPython_std_pair_len"; %feature("python:sq_length") std::pair "SwigPython_std_pair_len"; %feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; %feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; %feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; %feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; %feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; %feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; %feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; %feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; %feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; %feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; %feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; %feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; %define %swig_pair_methods(pair...) #if !defined(SWIGPYTHON_BUILTIN) %extend { %pythoncode %{def __len__(self): return 2 def __repr__(self): return str((self.first, self.second)) def __getitem__(self, index): if not (index % 2): return self.first else: return self.second def __setitem__(self, index, val): if not (index % 2): self.first = val else: self.second = val%} } #endif %enddef %include swig-3.0.8/Lib/python/std_unordered_multiset.i0000664000175000017500000000226412641054563021355 0ustar williamwilliam/* Unordered Multisets */ %include %fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::unordered_multiset* seq) { // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(PyObject *obj, std::unordered_multiset **m) { return traits_asptr_stdseq >::asptr(obj, m); } }; template struct traits_from > { static PyObject *from(const std::unordered_multiset& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_unordered_multiset_methods(Set...) %swig_set_methods(Set) %include swig-3.0.8/Lib/python/pybackward.swg0000664000175000017500000000221212641054563017256 0ustar williamwilliam/* adding backward compatibility macros */ #define SWIG_arg(x...) %arg(x) #define SWIG_Mangle(x...) %mangle(x) #define SWIG_As_frag(Type...) %fragment_name(As, Type) #define SWIG_As_name(Type...) %symbol_name(As, Type) #define SWIG_As(Type...) SWIG_As_name(Type) SWIG_AS_CALL_ARGS #define SWIG_Check_frag(Type...) %fragment_name(Check, Type) #define SWIG_Check_name(Type...) %symbol_name(Check, Type) #define SWIG_Check(Type...) SWIG_Check_name(Type) SWIG_AS_CALL_ARGS %define %ascheck_methods(Code, Type...) %fragment(SWIG_As_frag(Type),"header", fragment=SWIG_AsVal_frag(Type)) { SWIGINTERNINLINE Type SWIG_As(Type)(PyObject* obj) { Type v; int res = SWIG_AsVal(Type)(obj, &v); if (!SWIG_IsOK(res)) { /* this is needed to make valgrind/purify happier. */ memset((void*)&v, 0, sizeof(Type)); SWIG_Error(res, ""); } return v; } } %fragment(SWIG_Check_frag(Type),"header",fragment=SWIG_AsVal_frag(Type)) { SWIGINTERNINLINE int SWIG_Check(Type)(PyObject* obj) { int res = SWIG_AsVal(Type)(obj, (Type*)0); return SWIG_IsOK(res); } } %enddef %apply_checkctypes(%ascheck_methods) swig-3.0.8/Lib/python/std_container.i0000664000175000017500000000007212641054563017415 0ustar williamwilliam%include %include swig-3.0.8/Lib/python/std_except.i0000664000175000017500000000004312641054563016721 0ustar williamwilliam%include swig-3.0.8/Lib/python/cdata.i0000664000175000017500000000003612641054563015635 0ustar williamwilliam%include swig-3.0.8/Lib/python/std_unordered_multimap.i0000664000175000017500000000535212641054563021340 0ustar williamwilliam/* Unordered Multimaps */ %include %fragment("StdUnorderedMultimapTraits","header",fragment="StdSequenceTraits") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::unordered_multimap *unordered_multimap) { typedef typename std::unordered_multimap::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { unordered_multimap->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::unordered_multimap unordered_multimap_type; static int asptr(PyObject *obj, std::unordered_multimap **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { unordered_multimap_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::unordered_multimap unordered_multimap_type; typedef typename unordered_multimap_type::const_iterator const_iterator; typedef typename unordered_multimap_type::size_type size_type; static PyObject *from(const unordered_multimap_type& unordered_multimap) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN); } else { size_type size = unordered_multimap.size(); Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_multimap size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= unordered_multimap.begin(); i!= unordered_multimap.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; } } }; } } %define %swig_unordered_multimap_methods(Type...) %swig_map_common(Type); %extend { void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { self->insert(Type::value_type(key,x)); } } %enddef %include swig-3.0.8/Lib/python/carrays.i0000664000175000017500000000164412641054563016233 0ustar williamwilliam%define %array_class(TYPE,NAME) #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "sq_item", functype="ssizeargfunc") NAME::__getitem__; %feature("python:slot", "sq_ass_item", functype="ssizeobjargproc") NAME::__setitem__; %inline %{ typedef struct { TYPE *el; } NAME; %} %extend NAME { NAME(size_t nelements) { NAME *arr = %new_instance(NAME); arr->el = %new_array(nelements, TYPE); return arr; } ~NAME() { %delete_array(self->el); %delete(self); } TYPE __getitem__(size_t index) { return self->el[index]; } void __setitem__(size_t index, TYPE value) { self->el[index] = value; } TYPE * cast() { return self->el; } static NAME *frompointer(TYPE *t) { return %reinterpret_cast(t, NAME *); } }; %types(NAME = TYPE); #else %array_class_wrap(TYPE,NAME,__getitem__,__setitem__) #endif %enddef %include swig-3.0.8/Lib/python/std_auto_ptr.i0000664000175000017500000000111112641054563017263 0ustar williamwilliam/* The typemaps here allow to handle functions returning std::auto_ptr<>, which is the most common use of this type. If you have functions taking it as parameter, these typemaps can't be used for them and you need to do something else (e.g. use shared_ptr<> which SWIG supports fully). */ %define %auto_ptr(TYPE) %typemap (out) std::auto_ptr %{ %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags)); %} %template() std::auto_ptr; %enddef namespace std { template class auto_ptr {}; } swig-3.0.8/Lib/python/std_iostream.i0000664000175000017500000000015312641054563017256 0ustar williamwilliamnamespace std { %callback(1) endl; %callback(1) ends; %callback(1) flush; } %include swig-3.0.8/Lib/python/exception.i0000664000175000017500000000021312641054563016554 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-3.0.8/Lib/python/std_alloc.i0000664000175000017500000000003312641054563016522 0ustar williamwilliam%include swig-3.0.8/Lib/python/std_deque.i0000664000175000017500000000124612641054563016542 0ustar williamwilliam/* Deques */ %fragment("StdDequeTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::deque **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static PyObject *from(const std::deque & vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_deque_methods(Type...) %swig_sequence_methods(Type) #define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/python/std_ios.i0000664000175000017500000000010212641054563016217 0ustar williamwilliam%rename(ios_base_in) std::ios_base::in; %include swig-3.0.8/Lib/python/std_common.i0000664000175000017500000000441712641054563016732 0ustar williamwilliam%include %include /* Generate the traits for a 'primitive' type, such as 'double', for which the SWIG_AsVal and SWIG_From methods are already defined. */ %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval< Type > { typedef Type value_type; static int asval(PyObject *obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from< Type > { typedef Type value_type; static PyObject *from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval< Type > { typedef Type value_type; static int asval(PyObject *obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from< Type > { typedef Type value_type; static PyObject *from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.8/Lib/python/complex.i0000664000175000017500000000012012641054563016222 0ustar williamwilliam#ifdef __cplusplus %include #else %include #endif swig-3.0.8/Lib/python/pyerrors.swg0000664000175000017500000000312212641054563017015 0ustar williamwilliam/* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIME PyObject* SWIG_Python_ErrorType(int code) { PyObject* type = 0; switch(code) { case SWIG_MemoryError: type = PyExc_MemoryError; break; case SWIG_IOError: type = PyExc_IOError; break; case SWIG_RuntimeError: type = PyExc_RuntimeError; break; case SWIG_IndexError: type = PyExc_IndexError; break; case SWIG_TypeError: type = PyExc_TypeError; break; case SWIG_DivisionByZero: type = PyExc_ZeroDivisionError; break; case SWIG_OverflowError: type = PyExc_OverflowError; break; case SWIG_SyntaxError: type = PyExc_SyntaxError; break; case SWIG_ValueError: type = PyExc_ValueError; break; case SWIG_SystemError: type = PyExc_SystemError; break; case SWIG_AttributeError: type = PyExc_AttributeError; break; default: type = PyExc_RuntimeError; } return type; } SWIGRUNTIME void SWIG_Python_AddErrorMsg(const char* mesg) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } swig-3.0.8/Lib/python/std_vectora.i0000664000175000017500000000147512641054563017106 0ustar williamwilliam/* Vectors + allocators */ %fragment("StdVectorATraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { typedef std::vector vector_type; typedef T value_type; static int asptr(PyObject *obj, vector_type **vec) { return traits_asptr_stdseq::asptr(obj, vec); } }; template struct traits_from > { typedef std::vector vector_type; static PyObject *from(const vector_type& vec) { return traits_from_stdseq::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/python/cni.i0000664000175000017500000000005212641054563015330 0ustar williamwilliam%include %include swig-3.0.8/Lib/python/factory.i0000664000175000017500000000004012641054563016223 0ustar williamwilliam%include swig-3.0.8/Lib/python/pyabc.i0000664000175000017500000000064212641054563015662 0ustar williamwilliam%define %pythonabc(Type, Abc) %feature("python:abc", #Abc) Type; %enddef %pythoncode %{import collections%} %pythonabc(std::vector, collections.MutableSequence); %pythonabc(std::list, collections.MutableSequence); %pythonabc(std::map, collections.MutableMapping); %pythonabc(std::multimap, collections.MutableMapping); %pythonabc(std::set, collections.MutableSet); %pythonabc(std::multiset, collections.MutableSet); swig-3.0.8/Lib/python/std_multimap.i0000664000175000017500000000471012641054563017266 0ustar williamwilliam/* Multimaps */ %include %fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::multimap *multimap) { typedef typename std::multimap::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { multimap->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::multimap multimap_type; static int asptr(PyObject *obj, std::multimap **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::multimap multimap_type; typedef typename multimap_type::const_iterator const_iterator; typedef typename multimap_type::size_type size_type; static PyObject *from(const multimap_type& multimap) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_InternalNewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); } else { size_type size = multimap.size(); Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "multimap size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; } } }; } } %define %swig_multimap_methods(Type...) %swig_map_common(Type); %extend { void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { self->insert(Type::value_type(key,x)); } } %enddef %include swig-3.0.8/Lib/python/pycomplex.swg0000664000175000017500000000430312641054563017152 0ustar williamwilliam/* Defines the As/From converters for double/float complex, you need to provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex accessor methods. See the std_complex.i and ccomplex.i for concrete examples. */ /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header") { SWIGINTERNINLINE PyObject* SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) { return PyComplex_FromDoubles(Real(c), Imag(c)); } } %enddef /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal(Type) (PyObject *o, Type* val) { if (PyComplex_Check(o)) { if (val) *val = Constructor(PyComplex_RealAsDouble(o), PyComplex_ImagAsDouble(o)); return SWIG_OK; } else { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef /* the float case */ %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int SWIG_AsVal(Type)(PyObject *o, Type *val) { if (PyComplex_Check(o)) { double re = PyComplex_RealAsDouble(o); double im = PyComplex_ImagAsDouble(o); if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else { return SWIG_OverflowError; } } else { float re; int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(re, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.8/Lib/python/pyclasses.swg0000664000175000017500000000662212641054563017146 0ustar williamwilliam#ifdef __cplusplus /* SwigPtr_PyObject is used as a replacement of PyObject *, where the INCREF/DECREF are applied as needed. You can use SwigPtr_PyObject in a container, such as std::vector; or as a member variable: struct A { SwigPtr_PyObject obj; A(PyObject *o) : _obj(o) { } }; or as a input/output value SwigPtr_PyObject func(SwigPtr_PyObject obj) { SwigPtr_PyObject out = PyString_FromFormat("hello %s", PyObject_AsString(obj)); Py_DECREF(out); return out; } just remember to pair the object creation with the proper DECREF, the same as with plain PyObject *ptr, since SwigPtr_PyObject always add one reference at construction. SwigPtr_PyObject is 'visible' at the wrapped side, so you can do: %template(pyvector) std::vector; and all the proper typemaps will be used. */ namespace swig { %ignore SwigPtr_PyObject; struct SwigPtr_PyObject {}; %apply PyObject * {SwigPtr_PyObject}; %apply PyObject * const& {SwigPtr_PyObject const&}; %typemap(typecheck,precedence=SWIG_TYPECHECK_SWIGOBJECT,noblock=1) SwigPtr_PyObject const& "$1 = ($input != 0);"; /* For output */ %typemap(out,noblock=1) SwigPtr_PyObject { $result = (PyObject *)$1; Py_INCREF($result); } %typemap(out,noblock=1) SwigPtr_PyObject const & { $result = (PyObject *)*$1; Py_INCREF($result); } } %{ namespace swig { class SwigPtr_PyObject { protected: PyObject *_obj; public: SwigPtr_PyObject() :_obj(0) { } SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_XINCREF(_obj); SWIG_PYTHON_THREAD_END_BLOCK; } SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) { if (initial_ref) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_XINCREF(_obj); SWIG_PYTHON_THREAD_END_BLOCK; } } SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_XINCREF(item._obj); Py_XDECREF(_obj); _obj = item._obj; SWIG_PYTHON_THREAD_END_BLOCK; return *this; } ~SwigPtr_PyObject() { SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_XDECREF(_obj); SWIG_PYTHON_THREAD_END_BLOCK; } operator PyObject *() const { return _obj; } PyObject *operator->() const { return _obj; } }; } %} /* SwigVar_PyObject is used to manage 'in the scope' PyObject * variables, as in int func () { SwigVar_PyObject obj = PyString_FromString("hello"); } ie, 'obj' is created and destructed in the same scope from a python object that carries at least one reference value. SwigVar_PyObject just take care of applying the proper Py_DECREF. Hence, this class is purely internal and not visible at the wrapped side. */ namespace swig { %ignore SwigVar_PyObject; struct SwigVar_PyObject {}; %apply PyObject * {SwigVar_PyObject}; %apply PyObject * const& {SwigVar_PyObject const&}; } %{ namespace swig { struct SwigVar_PyObject : SwigPtr_PyObject { SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } SwigVar_PyObject & operator = (PyObject* obj) { Py_XDECREF(_obj); _obj = obj; return *this; } }; } %} #endif swig-3.0.8/Lib/python/embed.i0000664000175000017500000000521712641054563015643 0ustar williamwilliam// // embed.i // SWIG file embedding the Python interpreter in something else. // This file is based on Python-1.5. It will not work with // earlier versions. // // This file makes it possible to extend Python and all of its // built-in functions without having to hack its setup script. // #ifdef AUTODOC %subsection "embed.i" %text %{ This module provides support for building a new version of the Python executable. This will be necessary on systems that do not support shared libraries and may be necessary with C++ extensions. This file contains everything you need to build a new version of Python from include files and libraries normally installed with the Python language. This module will automatically grab all of the Python modules present in your current Python executable (including any special purpose modules you have enabled such as Tkinter). Thus, you may need to provide additional link libraries when compiling. This library file only works with Python 1.5. A version compatible with Python 1.4 is available as embed14.i and a Python1.3 version is available as embed13.i. As far as I know, this module is C++ safe. %} #else %echo "embed.i : Using Python 1.5" #endif %wrapper %{ #include #ifdef __cplusplus extern "C" #endif void SWIG_init(); /* Forward reference */ #define _PyImport_Inittab swig_inittab /* Grab Python's inittab[] structure */ #ifdef __cplusplus extern "C" { #endif #include #undef _PyImport_Inittab /* Now define our own version of it. Hopefully someone does not have more than 1000 built-in modules */ struct _inittab SWIG_Import_Inittab[1000]; static int swig_num_modules = 0; /* Function for adding modules to Python */ static void swig_add_module(char *name, void (*initfunc)()) { SWIG_Import_Inittab[swig_num_modules].name = name; SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; swig_num_modules++; SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; SWIG_Import_Inittab[swig_num_modules].initfunc = 0; } /* Function to add all of Python's build in modules to our interpreter */ static void swig_add_builtin() { int i = 0; while (swig_inittab[i].name) { swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); i++; } #ifdef SWIGMODINIT SWIGMODINIT #endif /* Add SWIG builtin function */ swig_add_module(SWIG_name, SWIG_init); } #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" { #endif extern int Py_Main(int, char **); #ifdef __cplusplus } #endif extern struct _inittab *PyImport_Inittab; int main(int argc, char **argv) { swig_add_builtin(); PyImport_Inittab = SWIG_Import_Inittab; return Py_Main(argc,argv); } %} swig-3.0.8/Lib/python/pystdcommon.swg0000664000175000017500000001556412641054563017521 0ustar williamwilliam%fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { /* Traits that provides the from method */ template struct traits_from_ptr { static PyObject *from(Type *val, int owner = 0) { return SWIG_InternalNewPointerObj(val, type_info(), owner); } }; template struct traits_from { static PyObject *from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static PyObject *from(Type* val) { return traits_from_ptr::from(val, 0); } }; template struct traits_from { static PyObject *from(const Type* val) { return traits_from_ptr::from(const_cast(val), 0); } }; template inline PyObject *from(const Type& val) { return traits_from::from(val); } template inline PyObject *from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } /* Traits that provides the asval/as/check method */ template struct traits_asptr { static int asptr(PyObject *obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(PyObject *obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(PyObject *obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(PyObject *obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(PyObject *obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(PyObject *obj, bool throw_error) { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { if (!PyErr_Occurred()) { ::%type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); } return v; } }; template struct traits_as { static Type as(PyObject *obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); if (!PyErr_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(PyObject *obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res)) { return v; } else { if (!PyErr_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); return 0; } } }; template inline Type as(PyObject *obj, bool te = false) { return traits_as::category>::as(obj, te); } template struct traits_check { static bool check(PyObject *obj) { int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(PyObject *obj) { int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template inline bool check(PyObject *obj) { return traits_check::category>::check(obj); } } } // // Backward compatibility // #ifdef SWIG_PYTHON_BACKWARD_COMP %fragment(""); %{ PyObject* SwigInt_FromBool(bool b) { return PyInt_FromLong(b ? 1L : 0L); } double SwigNumber_Check(PyObject* o) { return PyFloat_Check(o) || PyInt_Check(o) || PyLong_Check(o); } double SwigNumber_AsDouble(PyObject* o) { return PyFloat_Check(o) ? PyFloat_AsDouble(o) : (PyInt_Check(o) ? double(PyInt_AsLong(o)) : double(PyLong_AsLong(o))); } PyObject* SwigString_FromString(const std::string& s) { return PyString_FromStringAndSize(s.data(),s.size()); } std::string SwigString_AsString(PyObject* o) { return std::string(PyString_AsString(o)); } %} #endif %define %specialize_std_container(Type,Check,As,From) %{ namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(PyObject *obj, value_type *val) { if (Check(obj)) { if (val) *val = As(obj); return SWIG_OK; } return SWIG_ERROR; } }; template <> struct traits_from { typedef Type value_type; static PyObject *from(const value_type& val) { return From(val); } }; template <> struct traits_check { static int check(PyObject *obj) { int res = Check(obj); return obj && res ? res : 0; } }; } %} %enddef #define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_unordered_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_unordered_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) swig-3.0.8/Lib/python/wchar.i0000664000175000017500000000027212641054563015667 0ustar williamwilliam#ifdef __cplusplus %{ #include %} #else %{ #include %} #endif %types(wchar_t *); %include /* Enable swig wchar support. */ #define SWIG_WCHAR swig-3.0.8/Lib/python/std_list.i0000664000175000017500000000123412641054563016407 0ustar williamwilliam/* Lists */ %fragment("StdListTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::list **lis) { return traits_asptr_stdseq >::asptr(obj, lis); } }; template struct traits_from > { static PyObject *from(const std::list & vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/python/std_basic_string.i0000664000175000017500000000540112641054563020103 0ustar williamwilliam#if !defined(SWIG_STD_STRING) #define SWIG_STD_BASIC_STRING %include #define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(PyObject* obj, std::string **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::string *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { PyErr_Clear(); char* buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::string(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } else { PyErr_Clear(); } if (val) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_TypeError,"a string is expected"); SWIG_PYTHON_THREAD_END_BLOCK; } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE PyObject* SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } %include %typemaps_asptrfromn(%checkcode(STRING), std::basic_string); #endif #if !defined(SWIG_STD_WSTRING) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(PyObject* obj, std::wstring **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::wstring *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { PyErr_Clear(); wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::wstring(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } else { PyErr_Clear(); } if (val) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_TypeError,"a wstring is expected"); SWIG_PYTHON_THREAD_END_BLOCK; } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE PyObject* SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } %typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string); #endif swig-3.0.8/Lib/python/defarg.swg0000664000175000017500000000220212641054563016356 0ustar williamwilliam/* This file defines an internal function for processing default arguments with proxy classes. There seems to be no straightforward way to write proxy functions involving default arguments. For example : def foo(arg1,arg2,*args): proxyc.foo(arg1,arg2,args) This fails because args is now a tuple and SWIG doesn't know what to do with it. This file allows a different approach : def foo(arg1,arg2,*args): proxyc.__call_defarg(proxyc.foo,(arg1,arg2,)+args) Basically, we form a new tuple from the object, call this special __call_defarg method and it passes control to the real wrapper function. An ugly hack, but it works. */ SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) { PyObject *func; PyObject *parms; if (!PyArg_ParseTuple(args,"OO",&func,&parms)) return NULL; if (!PyCallable_Check(func)) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_TypeError, "__call_defarg : Need a callable object!"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } return PyEval_CallObject(func,parms); } swig-3.0.8/Lib/python/pytuplehlp.swg0000664000175000017500000000046412641054563017344 0ustar williamwilliam/* Helper function to return output types, now we need to use a list instead of a tuple since all the other types (std::pair,std::vector,std::list,etc) return tuples. */ #warning "Deprecated file: Don't use t_output_helper anymore," #warning "use SWIG_Python_AppendOutput or %append_output instead." swig-3.0.8/Lib/python/pyfragments.swg0000664000175000017500000000104712641054563017473 0ustar williamwilliam/* Create a file with this name, 'pyfragments.swg', in your working directory and add all the %fragments you want to take precedence over the default ones defined by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(PyObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.8/Lib/python/pyruntime.swg0000664000175000017500000000143312641054563017167 0ustar williamwilliam%insert(runtime) %{ #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ # undef _DEBUG # include # define _DEBUG #else # include #endif %} %insert(runtime) "swigrun.swg"; /* SWIG API */ %insert(runtime) "swigerrors.swg"; /* SWIG errors */ %insert(runtime) "pyhead.swg"; /* Python includes and fixes */ %insert(runtime) "pyerrors.swg"; /* Python errors */ %insert(runtime) "pythreads.swg"; /* Python thread code */ %insert(runtime) "pyapi.swg"; /* Python API */ %insert(runtime) "pyrun.swg"; /* Python run-time code */ #if defined(SWIGPYTHON_BUILTIN) %insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */ #endif swig-3.0.8/Lib/python/std_wstring.i0000664000175000017500000000007712641054563017135 0ustar williamwilliam%include %include swig-3.0.8/Lib/python/pyinit.swg0000664000175000017500000003277112641054563016460 0ustar williamwilliam/* ------------------------------------------------------------ * The start of the Python initialization function * ------------------------------------------------------------ */ %insert(init) "swiginit.swg" #if defined(SWIGPYTHON_BUILTIN) %fragment(""); // For offsetof #endif %init %{ #ifdef __cplusplus extern "C" { #endif /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(void); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; SWIGINTERN PyObject * swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_InternFromString(""); #else return PyString_FromString(""); #endif } SWIGINTERN PyObject * swig_varlink_str(swig_varlinkobject *v) { #if PY_VERSION_HEX >= 0x03000000 PyObject *str = PyUnicode_InternFromString("("); PyObject *tail; PyObject *joined; swig_globalvar *var; for (var = v->vars; var; var=var->next) { tail = PyUnicode_FromString(var->name); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; if (var->next) { tail = PyUnicode_InternFromString(", "); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; } } tail = PyUnicode_InternFromString(")"); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; #else PyObject *str = PyString_FromString("("); swig_globalvar *var; for (var = v->vars; var; var=var->next) { PyString_ConcatAndDel(&str,PyString_FromString(var->name)); if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); } PyString_ConcatAndDel(&str,PyString_FromString(")")); #endif return str; } SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char *tmp; PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(str); return 0; } SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; while (var) { swig_globalvar *n = var->next; free(var->name); free(var); var = n; } } SWIGINTERN PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { PyObject *res = NULL; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->get_attr)(); break; } var = var->next; } if (res == NULL && !PyErr_Occurred()) { PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } SWIGINTERN int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { int res = 1; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->set_attr)(p); break; } var = var->next; } if (res == 1 && !PyErr_Occurred()) { PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } SWIGINTERN PyTypeObject* swig_varlink_type(void) { static char varlink__doc__[] = "Swig var link object"; static PyTypeObject varlink_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ (printfunc) swig_varlink_print, /* tp_print */ (getattrfunc) swig_varlink_getattr, /* tp_getattr */ (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ (reprfunc) swig_varlink_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ varlink__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ #if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ #endif 0 /* tp_next */ #endif }; varlink_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 varlink_type.ob_type = &PyType_Type; #else if (PyType_Ready(&varlink_type) < 0) return NULL; #endif } return &varlink_type; } /* Create a variable linking object for use later */ SWIGINTERN PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); if (result) { result->vars = 0; } return ((PyObject*) result); } SWIGINTERN void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { strncpy(gv->name,name,size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; } } v->vars = gv; } SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ SWIGINTERN void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { PyObject *obj = 0; size_t i; for (i = 0; constants[i].type; ++i) { switch(constants[i].type) { case SWIG_PY_POINTER: obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d, constants[i].name, obj); Py_DECREF(obj); } } } /* -----------------------------------------------------------------------------*/ /* Fix SwigMethods to carry the callback ptrs when needed */ /* -----------------------------------------------------------------------------*/ SWIGINTERN void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { const char *c = methods[i].ml_doc; if (!c) continue; c = strstr(c, "swig_ptr: "); if (c) { int j; swig_const_info *ci = 0; const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; if (ptr) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } } } #ifdef __cplusplus } #endif /* -----------------------------------------------------------------------------* * Partial Init method * -----------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" #endif SWIGEXPORT #if PY_VERSION_HEX >= 0x03000000 PyObject* #else void #endif SWIG_init(void) { PyObject *m, *d, *md; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { # if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, # else { PyObject_HEAD_INIT(NULL) NULL, /* m_init */ 0, /* m_index */ NULL, /* m_copy */ }, # endif (char *) SWIG_name, NULL, -1, SwigMethods, NULL, NULL, NULL, NULL }; #endif #if defined(SWIGPYTHON_BUILTIN) static SwigPyClientData SwigPyObject_clientdata = {0, 0, 0, 0, 0, 0, 0}; static PyGetSetDef this_getset_def = { (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL }; static SwigPyGetSet thisown_getset_closure = { (PyCFunction) SwigPyObject_own, (PyCFunction) SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure }; PyObject *metatype_args; PyTypeObject *builtin_pytype; int builtin_base_count; swig_type_info *builtin_basetype; PyObject *tuple; PyGetSetDescrObject *static_getset; PyTypeObject *metatype; SwigPyClientData *cd; PyObject *public_interface, *public_symbol; PyObject *this_descr; PyObject *thisown_descr; PyObject *self = 0; int i; (void)builtin_pytype; (void)builtin_base_count; (void)builtin_basetype; (void)tuple; (void)static_getset; (void)self; /* metatype is used to implement static member variables. */ metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); assert(metatype_args); metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); assert(metatype); Py_DECREF(metatype_args); metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; assert(PyType_Ready(metatype) >= 0); #endif /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); #if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else m = Py_InitModule((char *) SWIG_name, SwigMethods); #endif md = d = PyModule_GetDict(m); (void)md; SWIG_InitializeModule(0); #ifdef SWIGPYTHON_BUILTIN SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; if (!cd) { SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce(); } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) { PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); # if PY_VERSION_HEX >= 0x03000000 return NULL; # else return; # endif } /* All objects have a 'this' attribute */ this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); (void)this_descr; /* All objects have a 'thisown' attribute */ thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); (void)thisown_descr; public_interface = PyList_New(0); public_symbol = 0; (void)public_symbol; PyDict_SetItemString(md, "__all__", public_interface); Py_DECREF(public_interface); for (i = 0; SwigMethods[i].ml_name != NULL; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); for (i = 0; swig_const_table[i].name != 0; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); #endif SWIG_InstallConstants(d,swig_const_table); %} swig-3.0.8/Lib/python/std_unordered_map.i0000664000175000017500000002023412641054563020261 0ustar williamwilliam/* Unordered Maps */ %fragment("StdMapTraits","header",fragment="StdSequenceTraits") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::unordered_map *unordered_map) { typedef typename std::unordered_map::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { unordered_map->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::unordered_map unordered_map_type; static int asptr(PyObject *obj, unordered_map_type **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); %#if PY_VERSION_HEX >= 0x03000000 /* In Python 3.x the ".items()" method return a dict_items object */ items = PySequence_Fast(items, ".items() havn't returned a sequence!"); %#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { unordered_map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::unordered_map unordered_map_type; typedef typename unordered_map_type::const_iterator const_iterator; typedef typename unordered_map_type::size_type size_type; static PyObject *from(const unordered_map_type& unordered_map) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN); } else { size_type size = unordered_map.size(); Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= unordered_map.begin(); i!= unordered_map.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; } } }; template struct from_key_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v.first); } }; template struct from_value_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v.second); } }; template struct SwigPyMapIterator_T : SwigPyIteratorClosed_T { SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyIteratorClosed_T(curr, first, last, seq) { } }; template > struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T { SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } }; template inline SwigPyIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { return new SwigPyMapKeyIterator_T(current, begin, end, seq); } template > struct SwigPyMapValueITerator_T : SwigPyMapIterator_T { SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } }; template inline SwigPyIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { return new SwigPyMapValueITerator_T(current, begin, end, seq); } } } %define %swig_unordered_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map) %extend { mapped_type __getitem__(const key_type& key) const throw (std::out_of_range) { Map::const_iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __delitem__(const key_type& key) throw (std::out_of_range) { Map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const key_type& key) const { Map::const_iterator i = self->find(key); return i != self->end(); } PyObject* keys() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* keyList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(keyList, j, swig::from(i->first)); } return keyList; } PyObject* values() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* valList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(valList, j, swig::from(i->second)); } return valList; } PyObject* items() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* itemList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(itemList, j, swig::from(*i)); } return itemList; } // Python 2.2 methods bool __contains__(const key_type& key) { return self->find(key) != self->end(); } %newobject key_iterator(PyObject **PYTHON_SELF); swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject value_iterator(PyObject **PYTHON_SELF); swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %pythoncode %{def __iter__(self): return self.key_iterator()%} %pythoncode %{def iterkeys(self): return self.key_iterator()%} %pythoncode %{def itervalues(self): return self.value_iterator()%} %pythoncode %{def iteritems(self): return self.iterator()%} } %enddef %define %swig_unordered_map_methods(Map...) %swig_unordered_map_common(Map) %extend { void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { (*self)[key] = x; } } %enddef %include swig-3.0.8/Lib/python/pystrings.swg0000664000175000017500000000714112641054563017177 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { %#if PY_VERSION_HEX>=0x03000000 if (PyUnicode_Check(obj)) %#else if (PyString_Check(obj)) %#endif { char *cstr; Py_ssize_t len; %#if PY_VERSION_HEX>=0x03000000 if (!alloc && cptr) { /* We can't allow converting without allocation, since the internal representation of string in Python 3 is UCS-2/UCS-4 but we require a UTF-8 representation. TODO(bhy) More detailed explanation */ return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); PyBytes_AsStringAndSize(obj, &cstr, &len); if(alloc) *alloc = SWIG_NEWOBJ; %#else PyString_AsStringAndSize(obj, &cstr, &len); %#endif if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner string representation. To warranty that, if you define SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string buffer is always returned. The default behavior is just to return the pointer value, so, be careful. */ %#if defined(SWIG_PYTHON_SAFE_CSTRINGS) if (*alloc != SWIG_OLDOBJ) %#else if (*alloc == SWIG_NEWOBJ) %#endif { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { %#if PY_VERSION_HEX>=0x03000000 assert(0); /* Should never reach here in Python 3 */ %#endif *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; %#if PY_VERSION_HEX>=0x03000000 Py_XDECREF(obj); %#endif return SWIG_OK; } else { %#if defined(SWIG_PYTHON_2_UNICODE) %#if PY_VERSION_HEX<0x03000000 if (PyUnicode_Check(obj)) { char *cstr; Py_ssize_t len; if (!alloc && cptr) { return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { if (cptr) { if (alloc) *alloc = SWIG_NEWOBJ; *cptr = %new_copy_array(cstr, len + 1, char); } if (psize) *psize = len + 1; Py_XDECREF(obj); return SWIG_OK; } else { Py_XDECREF(obj); } } %#endif %#endif swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); } else { %#if PY_VERSION_HEX >= 0x03000000 %#if PY_VERSION_HEX >= 0x03010000 return PyUnicode_DecodeUTF8(carray, %numeric_cast(size, Py_ssize_t), "surrogateescape"); %#else return PyUnicode_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); %#endif %#else return PyString_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); %#endif } } else { return SWIG_Py_Void(); } } } swig-3.0.8/Lib/python/std_char_traits.i0000664000175000017500000000004112641054563017732 0ustar williamwilliam%include swig-3.0.8/Lib/python/pytypemaps.swg0000664000175000017500000000600112641054563017342 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Python * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ #ifdef SWIG_PYTHON_LEGACY_BOOL // Default prior to SWIG 3.0.0 #undef SWIG_TYPECHECK_BOOL %define SWIG_TYPECHECK_BOOL 10000 %enddef #endif /* Include fundamental fragment definitions */ %include /* Look for user fragments file. */ %include /* Python fragments for fundamental types */ %include /* Python fragments for char* strings */ %include /* Backward compatibility output helper */ %fragment("t_output_helper","header") %{ #define t_output_helper SWIG_Python_AppendOutput %} /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* directors are supported in Python */ #ifndef SWIG_DIRECTOR_TYPEMAPS #define SWIG_DIRECTOR_TYPEMAPS #endif /* Python types */ #define SWIG_Object PyObject * #define VOID_Object SWIG_Py_Void() /* Python allows implicit conversion */ #define %implicitconv_flag $implicitconv /* Overload of the output/constant/exception/dirout handling */ /* append output */ #define SWIG_AppendOutput(result, obj) SWIG_Python_AppendOutput(result, obj) /* set constant */ #if defined(SWIGPYTHON_BUILTIN) #define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, name,obj) #else #define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj) #endif /* raise */ #define SWIG_Raise(obj, type, desc) SWIG_Python_Raise(obj, type, desc) /* Include the unified typemap library */ %include /* ------------------------------------------------------------ * Python extra typemaps / typemap overrides * ------------------------------------------------------------ */ /* Get the address of the 'python self' object */ %typemap(in,numinputs=0,noblock=1) PyObject **PYTHON_SELF { $1 = &$self; } /* Consttab, needed for callbacks, it should be removed later */ %typemap(consttab) SWIGTYPE ((*)(ANY)) { SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor } %typemap(constcode) SWIGTYPE ((*)(ANY)) ""; /* Smart Pointers */ %typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags); } %typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { if ($result) { PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL); if (robj && !PyErr_Occurred()) { SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result), (PyObject *) SWIG_Python_GetSwigThis(robj)); Py_DECREF(robj); } } } swig-3.0.8/Lib/python/jstring.i0000664000175000017500000000333712641054563016250 0ustar williamwilliam%include %fragment(SWIG_AsVal_frag(jstring),"header") { SWIGINTERN int SWIG_AsVal(jstring)(PyObject *obj, jstring *val) { if (obj == Py_None) { if (val) *val = 0; return SWIG_OK; } PyObject *tmp = 0; int isunicode = PyUnicode_Check(obj); if (!isunicode && PyString_Check(obj)) { if (val) { obj = tmp = PyUnicode_FromObject(obj); } isunicode = 1; } if (isunicode) { if (val) { if (sizeof(Py_UNICODE) == sizeof(jchar)) { *val = JvNewString((const jchar *) PyUnicode_AS_UNICODE(obj),PyUnicode_GET_SIZE(obj)); return SWIG_NEWOBJ; } else { int len = PyUnicode_GET_SIZE(obj); Py_UNICODE *pchars = PyUnicode_AS_UNICODE(obj); *val = JvAllocString (len); jchar *jchars = JvGetStringChars (*val); for (int i = 0; i < len; ++i) { jchars[i] = pchars[i]; } return SWIG_NEWOBJ; } } Py_XDECREF(tmp); return SWIG_OK; } return SWIG_TypeError; } } %fragment(SWIG_From_frag(jstring),"header") { SWIGINTERNINLINE PyObject * SWIG_From(jstring)(jstring val) { if (!val) { return SWIG_Py_Void(); } if (sizeof(Py_UNICODE) == sizeof(jchar)) { return PyUnicode_FromUnicode((const Py_UNICODE *) JvGetStringChars(val), JvGetStringUTFLength(val)); } else { int len = JvGetStringUTFLength(val); Py_UNICODE pchars[len]; jchar *jchars = JvGetStringChars(val); for (int i = 0; i < len; i++) { pchars[i] = jchars[i]; } return PyUnicode_FromUnicode((const Py_UNICODE *) pchars, len); } } } %typemaps_asvalfrom(%checkcode(STRING), %arg(SWIG_AsVal(jstring)), %arg(SWIG_From(jstring)), %arg(SWIG_AsVal_frag(jstring)), %arg(SWIG_From_frag(jstring)), java::lang::String *); swig-3.0.8/Lib/python/pycontainer.swg0000664000175000017500000007156712641054563017505 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pycontainer.swg * * Python sequence <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of * the mapping between C++ and Python, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should * be the case. * ----------------------------------------------------------------------------- */ %{ #include #if PY_VERSION_HEX >= 0x03020000 # define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj)) #else # define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj)) #endif %} #if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) # if !defined(SWIG_EXPORT_ITERATOR_METHODS) # define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS # endif #endif %include /**** The PySequence C++ Wrap ***/ %fragment(""); %include %fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "SwigPtr_PyObject"; } }; template <> struct traits_from { typedef SwigPtr_PyObject value_type; static PyObject *from(const value_type& val) { PyObject *obj = static_cast(val); Py_XINCREF(obj); return obj; } }; template <> struct traits_check { static bool check(SwigPtr_PyObject) { return true; } }; template <> struct traits_asval { typedef SwigPtr_PyObject value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; } } %fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "SwigVar_PyObject"; } }; template <> struct traits_from { typedef SwigVar_PyObject value_type; static PyObject *from(const value_type& val) { PyObject *obj = static_cast(val); Py_XINCREF(obj); return obj; } }; template <> struct traits_check { static bool check(SwigVar_PyObject) { return true; } }; template <> struct traits_asval { typedef SwigVar_PyObject value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; } } %fragment("SwigPySequence_Base","header",fragment="") { %#include namespace std { template <> struct less : public binary_function { bool operator()(PyObject * v, PyObject *w) const { bool res; SWIG_PYTHON_THREAD_BEGIN_BLOCK; res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false; /* This may fall into a case of inconsistent eg. ObjA > ObjX > ObjB but ObjA < ObjB */ if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) ) { /* Objects can't be compared, this mostly occurred in Python 3.0 */ /* Compare their ptr directly for a workaround */ res = (v < w); PyErr_Clear(); } SWIG_PYTHON_THREAD_END_BLOCK; return res; } }; template <> struct less : public binary_function { bool operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const { return std::less()(v, w); } }; template <> struct less : public binary_function { bool operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const { return std::less()(v, w); } }; } namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "PyObject *"; } }; template <> struct traits_asval { typedef PyObject * value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; template <> struct traits_check { static bool check(PyObject *) { return true; } }; template <> struct traits_from { typedef PyObject * value_type; static PyObject *from(const value_type& val) { Py_XINCREF(val); return val; } }; } namespace swig { template inline size_t check_index(Difference i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); } else if ( (size_t) i < size ) { return (size_t) i; } else if (insert && ((size_t) i == size)) { return size; } throw std::out_of_range("index out of range"); } template void slice_adjust(Difference i, Difference j, Py_ssize_t step, size_t size, Difference &ii, Difference &jj, bool insert = false) { if (step == 0) { throw std::invalid_argument("slice step cannot be zero"); } else if (step > 0) { // Required range: 0 <= i < size, 0 <= j < size if (i < 0) { ii = 0; } else if (i < (Difference)size) { ii = i; } else if (insert && (i >= (Difference)size)) { ii = (Difference)size; } if ( j < 0 ) { jj = 0; } else { jj = (j < (Difference)size) ? j : (Difference)size; } } else { // Required range: -1 <= i < size-1, -1 <= j < size-1 if (i < -1) { ii = -1; } else if (i < (Difference) size) { ii = i; } else if (i >= (Difference)(size-1)) { ii = (Difference)(size-1); } if (j < -1) { jj = -1; } else { jj = (j < (Difference)size ) ? j : (Difference)(size-1); } } } template inline typename Sequence::iterator getpos(Sequence* self, Difference i) { typename Sequence::iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline typename Sequence::const_iterator cgetpos(const Sequence* self, Difference i) { typename Sequence::const_iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline void erase(Sequence* seq, const typename Sequence::iterator& position) { seq->erase(position); } template inline Sequence* getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) { typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; swig::slice_adjust(i, j, step, size, ii, jj); if (step > 0) { typename Sequence::const_iterator sb = self->begin(); typename Sequence::const_iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); if (step == 1) { return new Sequence(sb, se); } else { Sequence *sequence = new Sequence(); typename Sequence::const_iterator it = sb; while (it!=se) { sequence->push_back(*it); for (Py_ssize_t c=0; c jj) { typename Sequence::const_reverse_iterator sb = self->rbegin(); typename Sequence::const_reverse_iterator se = self->rbegin(); std::advance(sb,size-ii-1); std::advance(se,size-jj-1); typename Sequence::const_reverse_iterator it = sb; while (it!=se) { sequence->push_back(*it); for (Py_ssize_t c=0; c<-step && it!=se; ++c) it++; } } return sequence; } } template inline void setslice(Sequence* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) { typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; swig::slice_adjust(i, j, step, size, ii, jj, true); if (step > 0) { if (jj < ii) jj = ii; if (step == 1) { size_t ssize = jj - ii; if (ssize <= is.size()) { // expanding/staying the same size typename Sequence::iterator sb = self->begin(); typename InputSeq::const_iterator isit = is.begin(); std::advance(sb,ii); std::advance(isit, jj - ii); self->insert(std::copy(is.begin(), isit, sb), isit, is.end()); } else { // shrinking typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); sb = self->begin(); std::advance(sb,ii); self->insert(sb, is.begin(), is.end()); } } else { size_t replacecount = (jj - ii + step - 1) / step; if (is.size() != replacecount) { char msg[1024]; sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); throw std::invalid_argument(msg); } typename Sequence::const_iterator isit = is.begin(); typename Sequence::iterator it = self->begin(); std::advance(it,ii); for (size_t rc=0; rcend(); ++c) it++; } } } else { if (jj > ii) jj = ii; size_t replacecount = (ii - jj - step - 1) / -step; if (is.size() != replacecount) { char msg[1024]; sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); throw std::invalid_argument(msg); } typename Sequence::const_iterator isit = is.begin(); typename Sequence::reverse_iterator it = self->rbegin(); std::advance(it,size-ii-1); for (size_t rc=0; rcrend(); ++c) it++; } } } template inline void delslice(Sequence* self, Difference i, Difference j, Py_ssize_t step) { typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; swig::slice_adjust(i, j, step, size, ii, jj, true); if (step > 0) { if (jj > ii) { typename Sequence::iterator sb = self->begin(); std::advance(sb,ii); if (step == 1) { typename Sequence::iterator se = self->begin(); std::advance(se,jj); self->erase(sb,se); } else { typename Sequence::iterator it = sb; size_t delcount = (jj - ii + step - 1) / step; while (delcount) { it = self->erase(it); for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) it++; delcount--; } } } } else { if (ii > jj) { typename Sequence::reverse_iterator sb = self->rbegin(); std::advance(sb,size-ii-1); typename Sequence::reverse_iterator it = sb; size_t delcount = (ii - jj - step - 1) / -step; while (delcount) { it = typename Sequence::reverse_iterator(self->erase((++it).base())); for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) it++; delcount--; } } } } } } %fragment("SwigPySequence_Cont","header", fragment="StdTraits", fragment="SwigPySequence_Base", fragment="SwigPyIterator_T") { namespace swig { template struct SwigPySequence_Ref { SwigPySequence_Ref(PyObject* seq, Py_ssize_t index) : _seq(seq), _index(index) { } operator T () const { swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index); try { return swig::as(item, true); } catch (std::exception& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", (int)_index); if (!PyErr_Occurred()) { ::%type_error(swig::type_name()); } SWIG_Python_AddErrorMsg(msg); SWIG_Python_AddErrorMsg(e.what()); throw; } } SwigPySequence_Ref& operator=(const T& v) { PySequence_SetItem(_seq, _index, swig::from(v)); return *this; } private: PyObject* _seq; Py_ssize_t _index; }; template struct SwigPySequence_ArrowProxy { SwigPySequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; template struct SwigPySequence_InputIterator { typedef SwigPySequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; typedef T value_type; typedef T* pointer; typedef Py_ssize_t difference_type; SwigPySequence_InputIterator() { } SwigPySequence_InputIterator(PyObject* seq, Py_ssize_t index) : _seq(seq), _index(index) { } reference operator*() const { return reference(_seq, _index); } SwigPySequence_ArrowProxy operator->() const { return SwigPySequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const { return (_index == ri._index) && (_seq == ri._seq); } bool operator!=(const self& ri) const { return !(operator==(ri)); } self& operator ++ () { ++_index; return *this; } self& operator -- () { --_index; return *this; } self& operator += (difference_type n) { _index += n; return *this; } self operator +(difference_type n) const { return self(_seq, _index + n); } self& operator -= (difference_type n) { _index -= n; return *this; } self operator -(difference_type n) const { return self(_seq, _index - n); } difference_type operator - (const self& ri) const { return _index - ri._index; } bool operator < (const self& ri) const { return _index < ri._index; } reference operator[](difference_type n) const { return reference(_seq, _index + n); } private: PyObject* _seq; difference_type _index; }; // STL container wrapper around a Python sequence template struct SwigPySequence_Cont { typedef SwigPySequence_Ref reference; typedef const SwigPySequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef Py_ssize_t difference_type; typedef size_t size_type; typedef const pointer const_pointer; typedef SwigPySequence_InputIterator iterator; typedef SwigPySequence_InputIterator const_iterator; SwigPySequence_Cont(PyObject* seq) : _seq(0) { if (!PySequence_Check(seq)) { throw std::invalid_argument("a sequence is expected"); } _seq = seq; Py_INCREF(_seq); } ~SwigPySequence_Cont() { Py_XDECREF(_seq); } size_type size() const { return static_cast(PySequence_Size(_seq)); } bool empty() const { return size() == 0; } iterator begin() { return iterator(_seq, 0); } const_iterator begin() const { return const_iterator(_seq, 0); } iterator end() { return iterator(_seq, size()); } const_iterator end() const { return const_iterator(_seq, size()); } reference operator[](difference_type n) { return reference(_seq, n); } const_reference operator[](difference_type n) const { return const_reference(_seq, n); } bool check(bool set_err = true) const { Py_ssize_t s = size(); for (Py_ssize_t i = 0; i < s; ++i) { swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i); if (!swig::check(item)) { if (set_err) { char msg[1024]; sprintf(msg, "in sequence element %d", (int)i); SWIG_Error(SWIG_RuntimeError, msg); } return false; } } return true; } private: PyObject* _seq; }; } } %define %swig_sequence_iterator(Sequence...) #if defined(SWIG_EXPORT_ITERATOR_METHODS) class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; %typemap(out,noblock=1,fragment="SwigPySequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); } %typemap(out,noblock=1,fragment="SwigPySequence_Cont") std::pair, std::pair { $result = PyTuple_New(2); PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); } %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPySequence_Cont") {} %typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator") std::pair, std::pair { $result = PyTuple_New(2); PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second)); } %typemap(in,noblock=1,fragment="SwigPySequence_Cont") iterator(swig::SwigPyIterator *iter = 0, int res), reverse_iterator(swig::SwigPyIterator *iter = 0, int res), const_iterator(swig::SwigPyIterator *iter = 0, int res), const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPySequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { swig::SwigPyIterator *iter = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %fragment("SwigPySequence_Cont"); %newobject iterator(PyObject **PYTHON_SELF); %extend { swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "tp_iter", functype="getiterfunc") iterator; #else %pythoncode %{def __iter__(self): return self.iterator()%} #endif } #endif //SWIG_EXPORT_ITERATOR_METHODS %enddef /**** The python container methods ****/ %define %swig_container_methods(Container...) /* deprecated in Python 2 */ #if 1 %newobject __getslice__; #endif %newobject __getitem__(PySliceObject *slice); #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "nb_nonzero", functype="inquiry") __nonzero__; %feature("python:slot", "sq_length", functype="lenfunc") __len__; #endif // SWIGPYTHON_BUILTIN %extend { bool __nonzero__() const { return !(self->empty()); } /* Alias for Python 3 compatibility */ bool __bool__() const { return !(self->empty()); } size_type __len__() const { return self->size(); } } %enddef %define %swig_sequence_methods_common(Sequence...) %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) %fragment("SwigPySequence_Base"); #if defined(SWIGPYTHON_BUILTIN) //%feature("python:slot", "sq_item", functype="ssizeargfunc") __getitem__; //%feature("python:slot", "sq_slice", functype="ssizessizeargfunc") __getslice__; //%feature("python:slot", "sq_ass_item", functype="ssizeobjargproc") __setitem__; //%feature("python:slot", "sq_ass_slice", functype="ssizessizeobjargproc") __setslice__; %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; #endif // SWIGPYTHON_BUILTIN %extend { /* typemap for slice object support */ %typemap(in) PySliceObject* { if (!PySlice_Check($input)) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } $1 = (PySliceObject *) $input; } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* { $1 = PySlice_Check($input); } /* deprecated in Python 2 */ #if 1 Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { return swig::getslice(self, i, j, 1); } void __setslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { swig::setslice(self, i, j, 1, Sequence()); } void __setslice__(difference_type i, difference_type j, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { swig::setslice(self, i, j, 1, v); } void __delslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { swig::delslice(self, i, j, 1); } #endif void __delitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { swig::erase(self, swig::getpos(self, i)); } /* Overloaded methods for Python 3 compatibility * (Also useful in Python 2.x) */ Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return NULL; } PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); Sequence::difference_type id = i; Sequence::difference_type jd = j; return swig::getslice(self, id, jd, step); } void __setitem__(PySliceObject *slice, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); Sequence::difference_type id = i; Sequence::difference_type jd = j; swig::setslice(self, id, jd, step, v); } void __setitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); Sequence::difference_type id = i; Sequence::difference_type jd = j; swig::delslice(self, id, jd, step); } void __delitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); Sequence::difference_type id = i; Sequence::difference_type jd = j; swig::delslice(self, id, jd, step); } } %enddef %define %swig_sequence_methods_non_resizable(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } #if defined(SWIGPYTHON_BUILTIN) // This will be called through the mp_ass_subscript slot to delete an entry. void __setitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { swig::erase(self, swig::getpos(self, i)); } #endif } %enddef %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_non_resizable(%arg(Sequence)) %extend { value_type pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty container"); Sequence::value_type x = self->back(); self->pop_back(); return x; } void append(const value_type& x) { self->push_back(x); } } %enddef %define %swig_sequence_methods_non_resizable_val(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { value_type __getitem__(difference_type i) throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __setitem__(difference_type i, value_type x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } #if defined(SWIGPYTHON_BUILTIN) // This will be called through the mp_ass_subscript slot to delete an entry. void __setitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { swig::erase(self, swig::getpos(self, i)); } #endif } %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods_non_resizable_val(%arg(Sequence)) %extend { value_type pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty container"); Sequence::value_type x = self->back(); self->pop_back(); return x; } void append(value_type x) { self->push_back(x); } } %enddef // // Common fragments // %fragment("StdSequenceTraits","header", fragment="StdTraits", fragment="SwigPySequence_Cont") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, Seq* seq) { // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr_stdseq { typedef Seq sequence; typedef T value_type; static int asptr(PyObject *obj, sequence **seq) { if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) { sequence *p; if (::SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } else if (PySequence_Check(obj)) { try { SwigPySequence_Cont swigpyseq(obj); if (seq) { sequence *pseq = new sequence(); assign(swigpyseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { return swigpyseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, e.what()); } } return SWIG_ERROR; } } return SWIG_ERROR; } }; template struct traits_from_stdseq { typedef Seq sequence; typedef T value_type; typedef typename Seq::size_type size_type; typedef typename sequence::const_iterator const_iterator; static PyObject *from(const sequence& seq) { %#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } %#endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { PyObject *obj = PyTuple_New((Py_ssize_t)size); Py_ssize_t i = 0; for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { PyTuple_SetItem(obj,i,swig::from(*it)); } return obj; } else { PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python"); return NULL; } } }; } } swig-3.0.8/Lib/python/cwstring.i0000664000175000017500000000007412641054563016423 0ustar williamwilliam%include %include swig-3.0.8/Lib/python/pythonkw.swg0000664000175000017500000000442612641054563017023 0ustar williamwilliam/* Warnings for Python keywords, built-in names and bad names. */ #define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword, renaming to '_" `x` "'", rename="_%s") `x` #define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") `x` /* Warnings for Python keywords http://www.fnorb.org/docs/1.2/Fnorb-Guide/node62.html */ PYTHONKW(and); PYTHONKW(assert); PYTHONKW(break); PYTHONKW(class); PYTHONKW(continue); PYTHONKW(def); PYTHONKW(del); PYTHONKW(elif); PYTHONKW(else); PYTHONKW(except); PYTHONKW(exec); PYTHONKW(finally); PYTHONKW(for); PYTHONKW(from); PYTHONKW(global); PYTHONKW(if); PYTHONKW(import); PYTHONKW(in); PYTHONKW(is); PYTHONKW(lambda); PYTHONKW(not); PYTHONKW(or); PYTHONKW(pass); PYTHONKW(print); PYTHONKW(raise); PYTHONKW(return); PYTHONKW(try); PYTHONKW(while); PYTHONKW(yield); /* built-in functions http://www.zvon.org/other/python/doc21/lib/built-in-funcs.html */ PYTHONBN(abs); PYTHONBN(apply); PYTHONBN(bool); PYTHONBN(buffer); PYTHONBN(callable); PYTHONBN(chr); PYTHONBN(classmethod); PYTHONBN(cmp); PYTHONBN(coerce); PYTHONBN(compile); PYTHONBN(complex); PYTHONBN(delattr); PYTHONBN(dict); PYTHONBN(dir); PYTHONBN(divmod); PYTHONBN(enumerate); PYTHONBN(eval); PYTHONBN(execfile); PYTHONBN(file); PYTHONBN(filter); PYTHONBN(float); PYTHONBN(frozenset); PYTHONBN(getattr); PYTHONBN(globals); PYTHONBN(hasattr); PYTHONBN(hash); PYTHONBN(hex); PYTHONBN(id); PYTHONBN(input); PYTHONBN(int); PYTHONBN(intern); PYTHONBN(isinstance); PYTHONBN(issubclass); PYTHONBN(iter); PYTHONBN(len); PYTHONBN(list); PYTHONBN(locals); PYTHONBN(long); PYTHONBN(map); PYTHONBN(max); PYTHONBN(min); PYTHONBN(object); PYTHONBN(oct); PYTHONBN(open); PYTHONBN(ord); PYTHONBN(pow); PYTHONBN(property); PYTHONBN(range); PYTHONBN(raw_input); PYTHONBN(reduce); PYTHONBN(reload); PYTHONBN(repr); PYTHONBN(reversed); PYTHONBN(round); PYTHONBN(set); PYTHONBN(setattr); PYTHONBN(slice); PYTHONBN(sorted); PYTHONBN(staticmethod); PYTHONBN(str); PYTHONBN(sum); PYTHONBN(super); PYTHONBN(tuple); PYTHONBN(type); PYTHONBN(unichr); PYTHONBN(unicode); PYTHONBN(vars); PYTHONBN(xrange); PYTHONBN(zip); /* built-in names boolean type and None */ PYTHONBN(True); PYTHONBN(False); PYTHONKW(None); /* 'self' is also a bad Name */ PYTHONKW(self); #undef PYTHONBN #undef PYTHONKW swig-3.0.8/Lib/python/std_wstreambuf.i0000664000175000017500000000004012641054563017605 0ustar williamwilliam%include swig-3.0.8/Lib/python/embed15.i0000664000175000017500000000546212641054563016013 0ustar williamwilliam/* ----------------------------------------------------------------------------- * embed15.i * * SWIG file embedding the Python interpreter in something else. * This file is based on Python-1.5. It will not work with * earlier versions. * * This file makes it possible to extend Python and all of its * built-in functions without having to hack its setup script. * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %subsection "embed.i" %text %{ This module provides support for building a new version of the Python executable. This will be necessary on systems that do not support shared libraries and may be necessary with C++ extensions. This file contains everything you need to build a new version of Python from include files and libraries normally installed with the Python language. This module will automatically grab all of the Python modules present in your current Python executable (including any special purpose modules you have enabled such as Tkinter). Thus, you may need to provide additional link libraries when compiling. This library file only works with Python 1.5. A version compatible with Python 1.4 is available as embed14.i and a Python1.3 version is available as embed13.i. As far as I know, this module is C++ safe. %} #else %echo "embed.i : Using Python 1.5" #endif %wrapper %{ #include #ifdef __cplusplus extern "C" #endif void SWIG_init(); /* Forward reference */ #define _PyImport_Inittab swig_inittab /* Grab Python's inittab[] structure */ #ifdef __cplusplus extern "C" { #endif #include #undef _PyImport_Inittab /* Now define our own version of it. Hopefully someone does not have more than 1000 built-in modules */ struct _inittab SWIG_Import_Inittab[1000]; static int swig_num_modules = 0; /* Function for adding modules to Python */ static void swig_add_module(char *name, void (*initfunc)()) { SWIG_Import_Inittab[swig_num_modules].name = name; SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; swig_num_modules++; SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; SWIG_Import_Inittab[swig_num_modules].initfunc = 0; } /* Function to add all of Python's build in modules to our interpreter */ static void swig_add_builtin() { int i = 0; while (swig_inittab[i].name) { swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); i++; } #ifdef SWIGMODINIT SWIGMODINIT #endif /* Add SWIG builtin function */ swig_add_module(SWIG_name, SWIG_init); } #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" { #endif extern int Py_Main(int, char **); #ifdef __cplusplus } #endif extern struct _inittab *PyImport_Inittab; int main(int argc, char **argv) { swig_add_builtin(); PyImport_Inittab = SWIG_Import_Inittab; return Py_Main(argc,argv); } %} swig-3.0.8/Lib/python/std_map.i0000664000175000017500000002325512641054563016220 0ustar williamwilliam/* Maps */ %fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { template struct from_key_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v.first); } }; template struct from_value_oper { typedef const ValueType& argument_type; typedef PyObject *result_type; result_type operator()(argument_type v) const { return swig::from(v.second); } }; template struct SwigPyMapIterator_T : SwigPyIteratorClosed_T { SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyIteratorClosed_T(curr, first, last, seq) { } }; template > struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T { SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } }; template inline SwigPyIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { return new SwigPyMapKeyIterator_T(current, begin, end, seq); } template > struct SwigPyMapValueITerator_T : SwigPyMapIterator_T { SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } }; template inline SwigPyIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { return new SwigPyMapValueITerator_T(current, begin, end, seq); } } } %fragment("StdMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::map *map) { typedef typename std::map::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::map map_type; static int asptr(PyObject *obj, map_type **val) { int res = SWIG_ERROR; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); %#if PY_VERSION_HEX >= 0x03000000 /* In Python 3.x the ".items()" method returns a dict_items object */ items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif res = traits_asptr_stdseq >::asptr(items, val); } else { map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } SWIG_PYTHON_THREAD_END_BLOCK; return res; } }; template struct traits_from > { typedef std::map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; static PyObject *asdict(const map_type& map) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; size_type size = map.size(); Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } SWIG_PYTHON_THREAD_END_BLOCK; return obj; } static PyObject *from(const map_type& map) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_InternalNewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); } else { return asdict(map); } } }; } } %define %swig_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map) #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "mp_length", functype="lenfunc") __len__; %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; %feature("python:slot", "tp_iter", functype="getiterfunc") key_iterator; %extend { %newobject iterkeys(PyObject **PYTHON_SELF); swig::SwigPyIterator* iterkeys(PyObject **PYTHON_SELF) { return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject itervalues(PyObject **PYTHON_SELF); swig::SwigPyIterator* itervalues(PyObject **PYTHON_SELF) { return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject iteritems(PyObject **PYTHON_SELF); swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } #else %extend { %pythoncode %{def __iter__(self): return self.key_iterator()%} %pythoncode %{def iterkeys(self): return self.key_iterator()%} %pythoncode %{def itervalues(self): return self.value_iterator()%} %pythoncode %{def iteritems(self): return self.iterator()%} } #endif %extend { mapped_type const & __getitem__(const key_type& key) throw (std::out_of_range) { Map::const_iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __delitem__(const key_type& key) throw (std::out_of_range) { Map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const key_type& key) const { Map::const_iterator i = self->find(key); return i != self->end(); } PyObject* keys() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* keyList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(keyList, j, swig::from(i->first)); } SWIG_PYTHON_THREAD_END_BLOCK; return keyList; } PyObject* values() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* valList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(valList, j, swig::from(i->second)); } SWIG_PYTHON_THREAD_END_BLOCK; return valList; } PyObject* items() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* itemList = PyList_New(pysize); Map::const_iterator i = self->begin(); for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(itemList, j, swig::from(*i)); } SWIG_PYTHON_THREAD_END_BLOCK; return itemList; } // Python 2.2 methods bool __contains__(const key_type& key) { return self->find(key) != self->end(); } %newobject key_iterator(PyObject **PYTHON_SELF); swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject value_iterator(PyObject **PYTHON_SELF); swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } %enddef %define %swig_map_methods(Map...) %swig_map_common(Map) #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; #endif %extend { // This will be called through the mp_ass_subscript slot to delete an entry. void __setitem__(const key_type& key) { self->erase(key); } void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { (*self)[key] = x; } PyObject* asdict() { return swig::traits_from< Map >::asdict(*self); } } %enddef %include swig-3.0.8/Lib/python/std_array.i0000664000175000017500000000670112641054563016556 0ustar williamwilliam/* std::array */ %fragment("StdArrayTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::array **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static PyObject *from(const std::array& vec) { return traits_from_stdseq >::from(vec); } }; template inline void assign(const SwigPySeq& swigpyseq, std::array* seq) { if (swigpyseq.size() < seq->size()) throw std::invalid_argument("std::array cannot be expanded in size"); else if (swigpyseq.size() > seq->size()) throw std::invalid_argument("std::array cannot be reduced in size"); std::copy(swigpyseq.begin(), swigpyseq.end(), seq->begin()); } template inline void erase(std::array* SWIGUNUSEDPARM(seq), const typename std::array::iterator& SWIGUNUSEDPARM(position)) { throw std::invalid_argument("std::array object does not support item deletion"); } // Only limited slicing is supported as std::array is fixed in size template inline std::array* getslice(const std::array* self, Difference i, Difference j, Py_ssize_t step) { typedef std::array Sequence; typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; swig::slice_adjust(i, j, step, size, ii, jj); if (step == 1 && ii == 0 && jj == size) { Sequence *sequence = new Sequence(); std::copy(self->begin(), self->end(), sequence->begin()); return sequence; } else if (step == -1 && ii == (size - 1) && jj == -1) { Sequence *sequence = new Sequence(); std::copy(self->rbegin(), self->rend(), sequence->begin()); return sequence; } else { throw std::invalid_argument("std::array object only supports getting a slice that is the size of the array"); } } template inline void setslice(std::array* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) { typedef std::array Sequence; typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; swig::slice_adjust(i, j, step, size, ii, jj, true); if (step == 1 && ii == 0 && jj == size) { std::copy(is.begin(), is.end(), self->begin()); } else if (step == -1 && ii == (size - 1) && jj == -1) { std::copy(is.rbegin(), is.rend(), self->begin()); } else { throw std::invalid_argument("std::array object only supports setting a slice that is the size of the array"); } } template inline void delslice(std::array* SWIGUNUSEDPARM(self), Difference SWIGUNUSEDPARM(i), Difference SWIGUNUSEDPARM(j), Py_ssize_t SWIGUNUSEDPARM(step)) { throw std::invalid_argument("std::array object does not support item deletion"); } } %} #define %swig_array_methods(Type...) %swig_sequence_methods_non_resizable(Type) #define %swig_array_methods_val(Type...) %swig_sequence_methods_non_resizable_val(Type); %include swig-3.0.8/Lib/python/pywstrings.swg0000664000175000017500000000400312641054563017360 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for wchar_t strings * ------------------------------------------------------------ */ %{ #if PY_VERSION_HEX >= 0x03020000 # define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj)) #else # define SWIGPY_UNICODE_ARG(obj) ((PyUnicodeObject*) (obj)) #endif %} %fragment("SWIG_AsWCharPtrAndSize","header",fragment="",fragment="SWIG_pwchar_descriptor") { SWIGINTERN int SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) { PyObject *tmp = 0; int isunicode = PyUnicode_Check(obj); %#if PY_VERSION_HEX < 0x03000000 if (!isunicode && PyString_Check(obj)) { obj = tmp = PyUnicode_FromObject(obj); isunicode = 1; } %#endif if (isunicode) { Py_ssize_t len = PyUnicode_GetSize(obj); if (cptr) { *cptr = %new_array(len + 1, wchar_t); PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), *cptr, len); (*cptr)[len] = 0; } if (psize) *psize = (size_t) len + 1; if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; Py_XDECREF(tmp); return SWIG_OK; } else { swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); if (pwchar_descriptor) { void * vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (wchar_t *)vptr; if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromWCharPtrAndSize","header",fragment="",fragment="SWIG_pwchar_descriptor") { SWIGINTERNINLINE PyObject * SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); return pwchar_descriptor ? SWIG_InternalNewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void(); } else { return PyUnicode_FromWideChar(carray, %numeric_cast(size, Py_ssize_t)); } } else { return SWIG_Py_Void(); } } } swig-3.0.8/Lib/python/std_set.i0000664000175000017500000000272212641054563016232 0ustar williamwilliam/* Sets */ %fragment("StdSetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::set* seq) { // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(PyObject *obj, std::set **s) { return traits_asptr_stdseq >::asptr(obj, s); } }; template struct traits_from > { static PyObject *from(const std::set& vec) { return traits_from_stdseq >::from(vec); } }; } %} %define %swig_set_methods(set...) %swig_sequence_iterator(set); %swig_container_methods(set); %extend { void append(value_type x) { self->insert(x); } bool __contains__(value_type x) { return self->find(x) != self->end(); } value_type __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void add(value_type x) { self->insert(x); } void discard(value_type x) { self->erase(x); } }; %enddef %include swig-3.0.8/Lib/python/attribute.i0000664000175000017500000000004212641054563016561 0ustar williamwilliam%include swig-3.0.8/Lib/python/pyrun.swg0000664000175000017500000014765112641054563016325 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * ----------------------------------------------------------------------------- */ /* Common SWIG API */ /* for raw pointers */ #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) #ifdef SWIGPYTHON_BUILTIN #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) #else #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #endif #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) #define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Runtime API implementation */ /* Error manipulation */ SWIGINTERN void SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetObject(errtype, obj); Py_DECREF(obj); SWIG_PYTHON_THREAD_END_BLOCK; } SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(errtype, msg); SWIG_PYTHON_THREAD_END_BLOCK; } #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) /* Set a constant value */ #if defined(SWIGPYTHON_BUILTIN) SWIGINTERN void SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { PyObject *s = PyString_InternFromString(key); PyList_Append(seq, s); Py_DECREF(s); } SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { #if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); #else PyDict_SetItemString(d, name, obj); #endif Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); } #else SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { #if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); #else PyDict_SetItemString(d, name, obj); #endif Py_DECREF(obj); } #endif /* Append a value to the result obj */ SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { #if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyList_Check(result)) { PyObject *o2 = result; result = PyList_New(1); PyList_SetItem(result, 0, o2); } PyList_Append(result,obj); Py_DECREF(obj); } return result; #else PyObject* o2; PyObject* o3; if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyTuple_Check(result)) { o2 = result; result = PyTuple_New(1); PyTuple_SET_ITEM(result, 0, o2); } o3 = PyTuple_New(1); PyTuple_SET_ITEM(o3, 0, obj); o2 = result; result = PySequence_Concat(o2, o3); Py_DECREF(o2); Py_DECREF(o3); } return result; #endif } /* Unpack the argument tuple */ SWIGINTERN Py_ssize_t SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { return 1; } else { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", name, (min == max ? "" : "at least "), (int)min); return 0; } } if (!PyTuple_Check(args)) { if (min <= 1 && max >= 1) { Py_ssize_t i; objs[0] = args; for (i = 1; i < max; ++i) { objs[i] = 0; } return 2; } PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); return 0; } else if (l > max) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { Py_ssize_t i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } for (; l < max; ++l) { objs[l] = 0; } return i + 1; } } } /* A functor is a function object with one single object argument */ #if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); #else #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); #endif /* Helper for static pointer initialization for both C and C++ code, for example static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); */ #ifdef __cplusplus #define SWIG_STATIC_POINTER(var) var #else #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var #endif /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Flags for new pointer objects */ #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) #define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) #define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) #ifdef __cplusplus extern "C" { #endif /* How to access Py_None */ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # ifndef SWIG_PYTHON_NO_BUILD_NONE # ifndef SWIG_PYTHON_BUILD_NONE # define SWIG_PYTHON_BUILD_NONE # endif # endif #endif #ifdef SWIG_PYTHON_BUILD_NONE # ifdef Py_None # undef Py_None # define Py_None SWIG_Py_None() # endif SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } SWIGRUNTIME PyObject * SWIG_Py_None(void) { static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); return none; } #endif /* The python void return value */ SWIGRUNTIMEINLINE PyObject * SWIG_Py_Void(void) { PyObject *none = Py_None; Py_INCREF(none); return none; } /* SwigPyClientData */ typedef struct { PyObject *klass; PyObject *newraw; PyObject *newargs; PyObject *destroy; int delargs; int implicitconv; PyTypeObject *pytype; } SwigPyClientData; SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; PyObject *klass = data ? data->klass : 0; return (klass ? klass : PyExc_RuntimeError); } SWIGRUNTIME SwigPyClientData * SwigPyClientData_New(PyObject* obj) { if (!obj) { return 0; } else { SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); /* the klass element */ data->klass = obj; Py_INCREF(data->klass); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; data->newargs = obj; Py_INCREF(obj); } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; #else data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); #endif if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); PyTuple_SetItem(data->newargs, 0, obj); } else { data->newargs = obj; } Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; } if (data->destroy) { int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); #ifdef METH_O data->delargs = !(flags & (METH_O)); #else data->delargs = 0; #endif } else { data->delargs = 0; } data->implicitconv = 0; data->pytype = 0; return data; } } SWIGRUNTIME void SwigPyClientData_Del(SwigPyClientData *data) { Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); } /* =============== SwigPyObject =====================*/ typedef struct { PyObject_HEAD void *ptr; swig_type_info *ty; int own; PyObject *next; #ifdef SWIGPYTHON_BUILTIN PyObject *dict; #endif } SwigPyObject; #ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME PyObject * SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { SwigPyObject *sobj = (SwigPyObject *)v; if (!sobj->dict) sobj->dict = PyDict_New(); Py_INCREF(sobj->dict); return sobj->dict; } #endif SWIGRUNTIME PyObject * SwigPyObject_long(SwigPyObject *v) { return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * SwigPyObject_format(const char* fmt, SwigPyObject *v) { PyObject *res = NULL; PyObject *args = PyTuple_New(1); if (args) { if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { PyObject *ofmt = SWIG_Python_str_FromChar(fmt); if (ofmt) { #if PY_VERSION_HEX >= 0x03000000 res = PyUnicode_Format(ofmt,args); #else res = PyString_Format(ofmt,args); #endif Py_DECREF(ofmt); } Py_DECREF(args); } } return res; } SWIGRUNTIME PyObject * SwigPyObject_oct(SwigPyObject *v) { return SwigPyObject_format("%o",v); } SWIGRUNTIME PyObject * SwigPyObject_hex(SwigPyObject *v) { return SwigPyObject_format("%x",v); } SWIGRUNTIME PyObject * #ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) #else SwigPyObject_repr(SwigPyObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (v->next) { # ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); # else PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); # endif # if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); Py_DecRef(nrep); repr = joined; # else PyString_ConcatAndDel(&repr,nrep); # endif } return repr; } SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { void *i = v->ptr; void *j = w->ptr; return (i < j) ? -1 : ((i > j) ? 1 : 0); } /* Added for Python 3.x, would it also be useful for Python 2.x? */ SWIGRUNTIME PyObject* SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) { PyObject* res; if( op != Py_EQ && op != Py_NE ) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); return res; } SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); #ifdef SWIGPYTHON_BUILTIN static swig_type_info *SwigPyObject_stype = 0; SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { SwigPyClientData *cd; assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; assert(cd); assert(cd->pytype); return cd->pytype; } #else SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); return type; } #endif SWIGRUNTIMEINLINE int SwigPyObject_Check(PyObject *op) { #ifdef SWIGPYTHON_BUILTIN PyTypeObject *target_tp = SwigPyObject_type(); if (PyType_IsSubtype(op->ob_type, target_tp)) return 1; return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); #else return (Py_TYPE(op) == SwigPyObject_type()) || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); #endif } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own); SWIGRUNTIME void SwigPyObject_dealloc(PyObject *v) { SwigPyObject *sobj = (SwigPyObject *) v; PyObject *next = sobj->next; if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; /* PyObject_CallFunction() has the potential to silently drop the active active exception. In cases of unnamed temporary variable or where we just finished iterating over a generator StopIteration will be active right now, and this needs to remain true upon return from SwigPyObject_dealloc. So save and restore. */ PyObject *val = NULL, *type = NULL, *tb = NULL; PyErr_Fetch(&val, &type, &tb); if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); } else { PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); PyObject *mself = PyCFunction_GET_SELF(destroy); res = ((*meth)(mself, v)); } if (!res) PyErr_WriteUnraisable(destroy); PyErr_Restore(val, type, tb); Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) else { const char *name = SWIG_TypePrettyName(ty); printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } #endif } Py_XDECREF(next); PyObject_DEL(v); } SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; #ifndef METH_O PyObject *tmp = 0; if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; next = tmp; #endif if (!SwigPyObject_Check(next)) { PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); return NULL; } sobj->next = next; Py_INCREF(next); return SWIG_Py_Void(); } SWIGRUNTIME PyObject* #ifdef METH_NOARGS SwigPyObject_next(PyObject* v) #else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; } else { return SWIG_Py_Void(); } } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_disown(PyObject *v) #else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_acquire(PyObject *v) #else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; return SWIG_Py_Void(); } SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) #elif (PY_VERSION_HEX < 0x02050000) if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) #else if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) #endif { return NULL; } else { SwigPyObject *sobj = (SwigPyObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v); } else { SwigPyObject_disown(v); } #else if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v,args); } else { SwigPyObject_disown(v,args); } #endif } return obj; } } #ifdef METH_O static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif #if PY_VERSION_HEX < 0x02020000 SWIGINTERN PyObject * SwigPyObject_getattr(SwigPyObject *sobj,char *name) { return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); } #endif SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; static PyNumberMethods SwigPyObject_as_number = { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ /* nb_divide removed in Python 3 */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc)0, /*nb_divide*/ #endif (binaryfunc)0, /*nb_remainder*/ (binaryfunc)0, /*nb_divmod*/ (ternaryfunc)0,/*nb_power*/ (unaryfunc)0, /*nb_negative*/ (unaryfunc)0, /*nb_positive*/ (unaryfunc)0, /*nb_absolute*/ (inquiry)0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ #if PY_VERSION_HEX < 0x03000000 0, /*nb_coerce*/ #endif (unaryfunc)SwigPyObject_long, /*nb_int*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_long, /*nb_long*/ #else 0, /*nb_reserved*/ #endif (unaryfunc)0, /*nb_float*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif #if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ #elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; static PyTypeObject swigpyobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 0, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ #else (cmpfunc)SwigPyObject_compare, /* tp_compare */ #endif (reprfunc)SwigPyObject_repr, /* tp_repr */ &SwigPyObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ #if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ #endif 0 /* tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 swigpyobject_type.ob_type = &PyType_Type; #else if (PyType_Ready(&swigpyobject_type) < 0) return NULL; #endif } return &swigpyobject_type; } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own) { SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); if (sobj) { sobj->ptr = ptr; sobj->ty = ty; sobj->own = own; sobj->next = 0; } return (PyObject *)sobj; } /* ----------------------------------------------------------------------------- * Implements a simple Swig Packed type, and use it instead of string * ----------------------------------------------------------------------------- */ typedef struct { PyObject_HEAD void *pack; swig_type_info *ty; size_t size; } SwigPyPacked; SWIGRUNTIME int SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char result[SWIG_BUFFER_SIZE]; fputs("pack, v->size, 0, sizeof(result))) { fputs("at ", fp); fputs(result, fp); } fputs(v->ty->name,fp); fputs(">", fp); return 0; } SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { return SWIG_Python_str_FromFormat("", result, v->ty->name); } else { return SWIG_Python_str_FromFormat("", v->ty->name); } } SWIGRUNTIME PyObject * SwigPyPacked_str(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); } else { return SWIG_Python_str_FromChar(v->ty->name); } } SWIGRUNTIME int SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) { size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); return type; } SWIGRUNTIMEINLINE int SwigPyPacked_Check(PyObject *op) { return ((op)->ob_type == SwigPyPacked_TypeOnce()) || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); } SWIGRUNTIME void SwigPyPacked_dealloc(PyObject *v) { if (SwigPyPacked_Check(v)) { SwigPyPacked *sobj = (SwigPyPacked *) v; free(sobj->pack); } PyObject_DEL(v); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void) { static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; static PyTypeObject swigpypacked_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX>=0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ (printfunc)SwigPyPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 0, /* tp_reserved in 3.0.1 */ #else (cmpfunc)SwigPyPacked_compare, /* tp_compare */ #endif (reprfunc)SwigPyPacked_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)SwigPyPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigpacked_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ #if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ #endif 0 /* tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 swigpypacked_type.ob_type = &PyType_Type; #else if (PyType_Ready(&swigpypacked_type) < 0) return NULL; #endif } return &swigpypacked_type; } SWIGRUNTIME PyObject * SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) { SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); if (sobj) { void *pack = malloc(size); if (pack) { memcpy(pack, ptr, size); sobj->pack = pack; sobj->ty = ty; sobj->size = size; } else { PyObject_DEL((PyObject *) sobj); sobj = 0; } } return (PyObject *) sobj; } SWIGRUNTIME swig_type_info * SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { if (SwigPyPacked_Check(obj)) { SwigPyPacked *sobj = (SwigPyPacked *)obj; if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { return SWIG_Python_str_FromChar("this"); } static PyObject *swig_this = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { if (swig_this == NULL) swig_this = _SWIG_This(); return swig_this; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ /* TODO: I don't know how to implement the fast getset in Python 3 right now */ #if PY_VERSION_HEX>=0x03000000 #define SWIG_PYTHON_SLOW_GETSET_THIS #endif SWIGRUNTIME SwigPyObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { PyObject *obj; if (SwigPyObject_Check(pyobj)) return (SwigPyObject *) pyobj; #ifdef SWIGPYTHON_BUILTIN (void)obj; # ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { pyobj = PyWeakref_GET_OBJECT(pyobj); if (pyobj && SwigPyObject_Check(pyobj)) return (SwigPyObject*) pyobj; } # endif return NULL; #else obj = 0; #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { PyObject **dictptr = _PyObject_GetDictPtr(pyobj); if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; } else { #ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; } #endif obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } } } #else obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } #endif if (obj && !SwigPyObject_Check(obj)) { /* a PyObject is called 'this', try to get the 'real this' SwigPyObject from it */ return SWIG_Python_GetSwigThis(obj); } return (SwigPyObject *)obj; #endif } /* Acquire a pointer value */ SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { if (own == SWIG_POINTER_OWN) { SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; sobj->own = own; return oldown; } } return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { int res; SwigPyObject *sobj; int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; if (!obj) return SWIG_ERROR; if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; return SWIG_OK; } res = SWIG_ERROR; sobj = SWIG_Python_GetSwigThis(obj); if (own) *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { swig_type_info *to = sobj->ty; if (to == ty) { /* no type cast needed */ if (ptr) *ptr = vptr; break; } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) { sobj = (SwigPyObject *)sobj->next; } else { if (ptr) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } } break; } } } else { if (ptr) *ptr = vptr; break; } } if (sobj) { if (own) *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } res = SWIG_OK; } else { if (implicit_conv) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; if (klass) { PyObject *impconv; data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ impconv = SWIG_Python_CallFunctor(klass, obj); data->implicitconv = 0; if (PyErr_Occurred()) { PyErr_Clear(); impconv = 0; } if (impconv) { SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); if (iobj) { void *vptr; res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); if (SWIG_IsOK(res)) { if (ptr) { *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; res = SWIG_AddCast(res); res = SWIG_AddNewMask(res); } else { res = SWIG_AddCast(res); } } } Py_DECREF(impconv); } } } } if (!SWIG_IsOK(res) && obj == Py_None) { if (ptr) *ptr = 0; if (PyErr_Occurred()) PyErr_Clear(); res = SWIG_OK; } } return res; } /* Convert a function ptr value */ SWIGRUNTIME int SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { if (!PyCFunction_Check(obj)) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; if (!desc) return SWIG_ERROR; if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); if (tc) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } else { return SWIG_ERROR; } } else { *ptr = vptr; } return SWIG_OK; } } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } /* ----------------------------------------------------------------------------- * Create a new pointer object * ----------------------------------------------------------------------------- */ /* Create a new instance object, without calling __init__, and set the 'this' attribute. */ SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { #if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { inst = PyObject_Call(newraw, data->newargs, NULL); if (inst) { #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { PyObject *dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; PyDict_SetItem(dict, SWIG_This(), swig_this); } } #else PyObject *key = SWIG_This(); PyObject_SetAttr(inst, key, swig_this); #endif } } else { #if PY_VERSION_HEX >= 0x03000000 inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); if (inst) { PyObject_SetAttr(inst, SWIG_This(), swig_this); Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; } #else PyObject *dict = PyDict_New(); if (dict) { PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); } #endif } return inst; #else #if (PY_VERSION_HEX >= 0x02010000) PyObject *inst = 0; PyObject *dict = PyDict_New(); if (dict) { PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); } return (PyObject *) inst; #else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; } inst->in_class = (PyClassObject *)data->newargs; Py_INCREF(inst->in_class); inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { Py_DECREF(inst); return NULL; } #ifdef Py_TPFLAGS_HAVE_WEAKREFS inst->in_weakreflist = NULL; #endif #ifdef Py_TPFLAGS_GC PyObject_GC_Init(inst); #endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif #endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; } PyDict_SetItem(dict, SWIG_This(), swig_this); return; } #endif dict = PyObject_GetAttrString(inst, (char*)"__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { return NULL; } else { SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { SwigPyObject_append((PyObject*) sthis, obj[1]); } else { SWIG_Python_SetSwigThis(obj[0], obj[1]); } return SWIG_Py_Void(); } } /* Create a new pointer object */ SWIGRUNTIME PyObject * SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { SwigPyClientData *clientdata; PyObject * robj; int own; if (!ptr) return SWIG_Py_Void(); clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; if (clientdata && clientdata->pytype) { SwigPyObject *newobj; if (flags & SWIG_BUILTIN_TP_INIT) { newobj = (SwigPyObject*) self; if (newobj->ptr) { PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); while (newobj->next) newobj = (SwigPyObject *) newobj->next; newobj->next = next_self; newobj = (SwigPyObject *)next_self; #ifdef SWIGPYTHON_BUILTIN newobj->dict = 0; #endif } } else { newobj = PyObject_New(SwigPyObject, clientdata->pytype); #ifdef SWIGPYTHON_BUILTIN newobj->dict = 0; #endif } if (newobj) { newobj->ptr = ptr; newobj->ty = type; newobj->own = own; newobj->next = 0; return (PyObject*) newobj; } return SWIG_Py_Void(); } assert(!(flags & SWIG_BUILTIN_TP_INIT)); robj = SwigPyObject_New(ptr, type, own); if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); Py_DECREF(robj); robj = inst; } return robj; } /* Create a new packed object */ SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* * Get type list * -----------------------------------------------------------------------------*/ #ifdef SWIG_LINK_RUNTIME void *SWIG_ReturnGlobalTypeList(void *); #endif SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else # ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); # else type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); # endif if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; } #endif } return (swig_module_info *) type_pointer; } #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ SWIGINTERN int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return SWIG_ERROR; } if (PyDict_SetItemString(dict, name, o)) return SWIG_ERROR; Py_DECREF(o); return SWIG_OK; } #endif SWIGRUNTIME void #ifdef SWIGPY_USE_CAPSULE SWIG_Python_DestroyModule(PyObject *obj) #else SWIG_Python_DestroyModule(void *vptr) #endif { #ifdef SWIGPY_USE_CAPSULE swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); #else swig_module_info *swig_module = (swig_module_info *) vptr; #endif swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; if (data) SwigPyClientData_Del(data); } } Py_DECREF(SWIG_This()); swig_this = NULL; } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { #if PY_VERSION_HEX >= 0x03000000 /* Add a dummy module object into sys.modules */ PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); #else static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif #ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #else PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #endif } /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); return cache; } SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); PyObject *key = SWIG_Python_str_FromChar(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { #ifdef SWIGPY_USE_CAPSULE descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); #else descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); #endif } else { swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { #ifdef SWIGPY_USE_CAPSULE obj = PyCapsule_New((void*) descriptor, NULL, NULL); #else obj = PyCObject_FromVoidPtr(descriptor, NULL); #endif PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } } Py_DECREF(key); return descriptor; } /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) SWIGRUNTIME int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); } else { PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); } return 1; } else { return 0; } } SWIGRUNTIME int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } SWIGRUNTIMEINLINE const char * SwigPyObject_GetDesc(PyObject *self) { SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; return ty ? ty->str : ""; } SWIGRUNTIME void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { #if defined(SWIG_COBJECT_TYPES) if (obj && SwigPyObject_Check(obj)) { const char *otype = (const char *) SwigPyObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", type, otype); return; } } else #endif { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); SWIG_Python_str_DelForPy3(cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_XDECREF(str); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } /* Convert a pointer value, signal an exception on a type mismatch */ SWIGRUNTIME void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); #if SWIG_POINTER_EXCEPTION if (flags) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } #endif } return result; } #ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME int SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyTypeObject *tp = obj->ob_type; PyObject *descr; PyObject *encoded_name; descrsetfunc f; int res = -1; # ifdef Py_USING_UNICODE if (PyString_Check(name)) { name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); if (!name) return -1; } else if (!PyUnicode_Check(name)) # else if (!PyString_Check(name)) # endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); return -1; } else { Py_INCREF(name); } if (!tp->tp_dict) { if (PyType_Ready(tp) < 0) goto done; } descr = _PyType_Lookup(tp, name); f = NULL; if (descr != NULL) f = descr->ob_type->tp_descr_set; if (!f) { if (PyString_Check(name)) { encoded_name = name; Py_INCREF(name); } else { encoded_name = PyUnicode_AsUTF8String(name); } PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); Py_DECREF(encoded_name); } else { res = f(descr, obj, value); } done: Py_DECREF(name); return res; } #endif #ifdef __cplusplus } #endif swig-3.0.8/Lib/python/Makefile.in0000664000175000017500000000656012641054563016464 0ustar williamwilliam# --------------------------------------------------------------- # SWIG Python Makefile # # This file can be used to build various Python extensions with SWIG. # By default this file is set up for dynamic loading, but it can # be easily customized for static extensions by modifying various # portions of the file. # # SRCS = C source files # CXXSRCS = C++ source files # OBJCSRCS = Objective-C source files # OBJS = Additional .o files (compiled previously) # INTERFACE = SWIG interface file # TARGET = Name of target module or executable # # Many portions of this file were created by the SWIG configure # script and should already reflect your machine. #---------------------------------------------------------------- SRCS = CXXSRCS = OBJCSRCS = OBJS = INTERFACE = WRAPFILE = $(INTERFACE:.i=_wrap.c) WRAPOBJ = $(INTERFACE:.i=_wrap.o) TARGET = module@SO@ # Use this kind of target for dynamic loading #TARGET = mypython # Use this target for static linking prefix = @prefix@ exec_prefix = @exec_prefix@ CC = @CC@ CXX = @CXX@ OBJC = @CC@ -Wno-import # -Wno-import needed for gcc CFLAGS = INCLUDES = LIBS = # SWIG Options # SWIG = location of the SWIG executable # SWIGOPT = SWIG compiler options # SWIGCC = Compiler used to compile the wrapper file SWIG = $(exec_prefix)/bin/swig SWIGOPT = -python SWIGCC = $(CC) # SWIG Library files. Uncomment if rebuilding the Python interpreter #SWIGLIBS = -lembed.i # Rules for creating .o files from source. COBJS = $(SRCS:.c=.o) CXXOBJS = $(CXXSRCS:.cxx=.o) OBJCOBJS = $(OBJCSRCS:.m=.o) ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) # Command that will be used to build the final extension. BUILD = $(SWIGCC) # Uncomment the following if you are using dynamic loading CCSHARED = @CCSHARED@ BUILD = @LDSHARED@ # Uncomment the following if you are using dynamic loading with C++ and # need to provide additional link libraries (this is not always required). #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc # Python installation PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@ PY_LIB = @PYLIB@ # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ # Build options BUILD_LIBS = $(LIBS) # Dynamic loading # Compilation rules for non-SWIG components .SUFFIXES: .c .cxx .m .c.o: $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< .cxx.o: $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< .m.o: $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< # ---------------------------------------------------------------------- # Rules for building the extension # ---------------------------------------------------------------------- all: $(TARGET) # Convert the wrapper file into an object file $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE) $(WRAPFILE) : $(INTERFACE) $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-3.0.8/Lib/python/std_wios.i0000664000175000017500000000003212641054563016410 0ustar williamwilliam%include swig-3.0.8/Lib/python/std_wsstream.i0000664000175000017500000000003612641054563017300 0ustar williamwilliam%include swig-3.0.8/Lib/python/pydocs.swg0000664000175000017500000000212012641054563016426 0ustar williamwilliam // Documentation for use with the autodoc feature. #ifdef SWIG_DOC_DOXYGEN_STYLE %typemap(doc) SWIGTYPE "@param $1_name $1_type"; %typemap(doc) SWIGTYPE * "@param $1_name $1_type"; %typemap(doc) const SWIGTYPE & "@param $1_name $1_type"; %typemap(doc) const SWIGTYPE && "@param $1_name $1_type"; %typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type"; %typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "@param $1_name $1_type (input/output)"; %typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "@param $1_name $1_type (input)"; %typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "@param $1_name $1_type (output)"; #else %typemap(doc) SWIGTYPE "$1_name: $1_type"; %typemap(doc) SWIGTYPE * "$1_name: $1_type"; %typemap(doc) const SWIGTYPE & "$1_name: $1_type"; %typemap(doc) const SWIGTYPE && "$1_name: $1_type"; %typemap(doc) enum SWIGTYPE "$1_name: enum $1_type"; %typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "$1_name: $1_type (input/output)"; %typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "$1_name: $1_type (input)"; %typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "$1_name: $1_type (output)"; #endif swig-3.0.8/Lib/python/std_string.i0000664000175000017500000000004312641054563016737 0ustar williamwilliam%include swig-3.0.8/Lib/python/stl.i0000664000175000017500000000026612641054563015370 0ustar williamwilliam/* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-3.0.8/Lib/python/boost_shared_ptr.i0000664000175000017500000003764712641054563020144 0ustar williamwilliam%include // Set SHARED_PTR_DISOWN to $disown if required, for example // #define SHARED_PTR_DISOWN $disown #if !defined(SHARED_PTR_DISOWN) #define SHARED_PTR_DISOWN 0 #endif %fragment("SWIG_null_deleter_python", "header", fragment="SWIG_null_deleter") { %#define SWIG_NO_NULL_DELETER_SWIG_BUILTIN_INIT } // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(out) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(varout) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE * { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE & { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; if (!argp) { %variable_nullref("$type", "$name"); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = *%const_cast(tempshared.get(), $1_ltype); } else { $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer by reference // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); temp = %const_cast(tempshared.get(), $*1_ltype); } else { temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); } $1 = &temp; } %typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} %typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { int newmem = 0; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varout typemap not implemented" %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); if ($owner) delete $1; } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varout typemap not implemented" %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); temp = &tempshared; $1 = &temp; } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varout typemap not implemented" %} // Typecheck typemaps // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); $1 = SWIG_CheckState(res); } // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/python/pyapi.swg0000664000175000017500000000247312641054563016262 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Python API portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; /* ----------------------------------------------------------------------------- * Wrapper of PyInstanceMethod_New() used in Python 3 * It is exported to the generated module, used for -fastproxy * ----------------------------------------------------------------------------- */ #if PY_VERSION_HEX >= 0x03000000 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { return PyInstanceMethod_New(func); } #else SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) { return NULL; } #endif #ifdef __cplusplus } #endif swig-3.0.8/Lib/python/file.i0000664000175000017500000000201312641054563015475 0ustar williamwilliam/* ----------------------------------------------------------------------------- * file.i * * Typemaps for FILE* * ----------------------------------------------------------------------------- */ %types(FILE *); /* defining basic methods */ %fragment("SWIG_AsValFilePtr","header") { SWIGINTERN int SWIG_AsValFilePtr(PyObject *obj, FILE **val) { static swig_type_info* desc = 0; void *vptr = 0; if (!desc) desc = SWIG_TypeQuery("FILE *"); if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) { if (val) *val = (FILE *)vptr; return SWIG_OK; } %#if PY_VERSION_HEX < 0x03000000 if (PyFile_Check(obj)) { if (val) *val = PyFile_AsFile(obj); return SWIG_OK; } %#endif return SWIG_TypeError; } } %fragment("SWIG_AsFilePtr","header",fragment="SWIG_AsValFilePtr") { SWIGINTERNINLINE FILE* SWIG_AsFilePtr(PyObject *obj) { FILE *val = 0; SWIG_AsValFilePtr(obj, &val); return val; } } /* defining the typemaps */ %typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*); swig-3.0.8/Lib/python/pyname_compat.i0000664000175000017500000001003412641054563017414 0ustar williamwilliam/* * From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, * since they are inappropriate and discouraged in Python documentation * (from http://www.python.org/doc/2.5.2/api/includes.html): * * "All user visible names defined by Python.h (except those defined by the included * standard headers) have one of the prefixes "Py" or "_Py". Names beginning with * "_Py" are for internal use by the Python implementation and should not be used * by extension writers. Structure member names do not have a reserved prefix. * * Important: user code should never define names that begin with "Py" or "_Py". * This confuses the reader, and jeopardizes the portability of the user code to * future Python versions, which may define additional names beginning with one * of these prefixes." * * This file defined macros to provide backward compatibility for these deprecated * symbols. In the case you have these symbols in your interface file, you can simply * include this file at beginning of it. * * However, this file may be removed in future release of SWIG, so using this file to * keep these inappropriate names in your SWIG interface file is also not recommended. * Instead, we provide a simple tool for converting your interface files to * the new naming convention. You can get the tool from the SWIG distribution: * Tools/pyname_patch.py */ %fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {} %fragment("PySequence_Cont", "header", fragment="SwigPySequence_Cont") {} %fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} %fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {} %fragment("PySwigIterator", "header", fragment="SwigPyIterator") {} %fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} %inline %{ #define PyMapIterator_T SwigPyMapIterator_T #define PyMapKeyIterator_T SwigPyMapKeyIterator_T #define PyMapValueIterator_T SwigPyMapValueITerator_T #define PyObject_ptr SwigPtr_PyObject #define PyObject_var SwigVar_PyObject #define PyOper SwigPyOper #define PySeq SwigPySeq #define PySequence_ArrowProxy SwigPySequence_ArrowProxy #define PySequence_Cont SwigPySequence_Cont #define PySequence_InputIterator SwigPySequence_InputIterator #define PySequence_Ref SwigPySequence_Ref #define PySwigClientData SwigPyClientData #define PySwigClientData_Del SwigPyClientData_Del #define PySwigClientData_New SwigPyClientData_New #define PySwigIterator SwigPyIterator #define PySwigIteratorClosed_T SwigPyIteratorClosed_T #define PySwigIteratorOpen_T SwigPyIteratorOpen_T #define PySwigIterator_T SwigPyIterator_T #define PySwigObject SwigPyObject #define PySwigObject_Check SwigPyObject_Check #define PySwigObject_GetDesc SwigPyObject_GetDesc #define PySwigObject_New SwigPyObject_New #define PySwigObject_acquire SwigPyObject_acquire #define PySwigObject_append SwigPyObject_append #define PySwigObject_as_number SwigPyObject_as_number #define PySwigObject_compare SwigPyObject_compare #define PySwigObject_dealloc SwigPyObject_dealloc #define PySwigObject_disown SwigPyObject_disown #define PySwigObject_format SwigPyObject_format #define PySwigObject_getattr SwigPyObject_getattr #define PySwigObject_hex SwigPyObject_hex #define PySwigObject_long SwigPyObject_long #define PySwigObject_next SwigPyObject_next #define PySwigObject_oct SwigPyObject_oct #define PySwigObject_own SwigPyObject_own #define PySwigObject_repr SwigPyObject_repr #define PySwigObject_richcompare SwigPyObject_richcompare #define PySwigObject_type SwigPyObject_type #define PySwigPacked SwigPyPacked #define PySwigPacked_Check SwigPyPacked_Check #define PySwigPacked_New SwigPyPacked_New #define PySwigPacked_UnpackData SwigPyPacked_UnpackData #define PySwigPacked_compare SwigPyPacked_compare #define PySwigPacked_dealloc SwigPyPacked_dealloc #define PySwigPacked_print SwigPyPacked_print #define PySwigPacked_repr SwigPyPacked_repr #define PySwigPacked_str SwigPyPacked_str #define PySwigPacked_type SwigPyPacked_type #define pyseq swigpyseq #define pyswigobject_type swigpyobject_type #define pyswigpacked_type swigpypacked_type %} swig-3.0.8/Lib/python/director.swg0000664000175000017500000002461612641054563016756 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Python proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PYTHON_HEADER_ #define SWIG_DIRECTOR_PYTHON_HEADER_ #include #include #include #include #include /* Use -DSWIG_PYTHON_DIRECTOR_NO_VTABLE if you don't want to generate a 'virtual table', and avoid multiple GetAttr calls to retrieve the python methods. */ #ifndef SWIG_PYTHON_DIRECTOR_NO_VTABLE #ifndef SWIG_PYTHON_DIRECTOR_VTABLE #define SWIG_PYTHON_DIRECTOR_VTABLE #endif #endif /* Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the Undefined Exception Handler provided by swig. */ #ifndef SWIG_DIRECTOR_NO_UEH #ifndef SWIG_DIRECTOR_UEH #define SWIG_DIRECTOR_UEH #endif #endif /* Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the native C++ RTTI and dynamic_cast<>. But be aware that directors could stop working when using this option. */ #ifdef SWIG_DIRECTOR_NORTTI /* When we don't use the native C++ RTTI, we implement a minimal one only for Directors. */ # ifndef SWIG_DIRECTOR_RTDIR # define SWIG_DIRECTOR_RTDIR namespace Swig { class Director; SWIGINTERN std::map& get_rtdir_map() { static std::map rtdir_map; return rtdir_map; } SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) { get_rtdir_map()[vptr] = rtdir; } SWIGINTERNINLINE Director *get_rtdir(void *vptr) { std::map::const_iterator pos = get_rtdir_map().find(vptr); Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0; return rtdir; } } # endif /* SWIG_DIRECTOR_RTDIR */ # define SWIG_DIRECTOR_CAST(ARG) Swig::get_rtdir(static_cast(ARG)) # define SWIG_DIRECTOR_RGTR(ARG1, ARG2) Swig::set_rtdir(static_cast(ARG1), ARG2) #else # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) # define SWIG_DIRECTOR_RGTR(ARG1, ARG2) #endif /* SWIG_DIRECTOR_NORTTI */ extern "C" { struct swig_type_info; } namespace Swig { /* memory handler */ struct GCItem { virtual ~GCItem() {} virtual int get_own() const { return 0; } }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem * operator->() const { return _item; } private: GCItem *_item; }; struct GCItem_Object : GCItem { GCItem_Object(int own) : _own(own) { } virtual ~GCItem_Object() { } int get_own() const { return _own; } private: int _own; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; template struct GCArray_T : GCItem { GCArray_T(Type *ptr) : _ptr(ptr) { } virtual ~GCArray_T() { delete[] _ptr; } private: Type *_ptr; }; /* base class for director exceptions */ class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(PyObject *error, const char *hdr ="", const char *msg ="") : swig_msg(hdr) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (msg[0]) { swig_msg += " "; swig_msg += msg; } if (!PyErr_Occurred()) { PyErr_SetString(error, what()); } SWIG_PYTHON_THREAD_END_BLOCK; } virtual ~DirectorException() throw() { } /* Deprecated, use what() instead */ const char *getMessage() const { return what(); } const char *what() const throw() { return swig_msg.c_str(); } static void raise(PyObject *error, const char *msg) { throw DirectorException(error, msg); } static void raise(const char *msg) { raise(PyExc_RuntimeError, msg); } }; /* unknown exception handler */ class UnknownExceptionHandler { #ifdef SWIG_DIRECTOR_UEH static void handler() { try { throw; } catch (DirectorException& e) { std::cerr << "SWIG Director exception caught:" << std::endl << e.what() << std::endl; } catch (std::exception& e) { std::cerr << "std::exception caught: "<< e.what() << std::endl; } catch (...) { std::cerr << "Unknown exception caught." << std::endl; } std::cerr << std::endl << "Python interpreter traceback:" << std::endl; PyErr_Print(); std::cerr << std::endl; std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl << std::endl << "Exception is being re-thrown, program will likely abort/terminate." << std::endl; throw; } public: std::unexpected_handler old; UnknownExceptionHandler(std::unexpected_handler nh = handler) { old = std::set_unexpected(nh); } ~UnknownExceptionHandler() { std::set_unexpected(old); } #endif }; /* type mismatch in the return value from a python method call */ class DirectorTypeMismatchException : public DirectorException { public: DirectorTypeMismatchException(PyObject *error, const char *msg="") : DirectorException(error, "SWIG director type mismatch", msg) { } DirectorTypeMismatchException(const char *msg="") : DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg) { } static void raise(PyObject *error, const char *msg) { throw DirectorTypeMismatchException(error, msg); } static void raise(const char *msg) { throw DirectorTypeMismatchException(msg); } }; /* any python exception that occurs during a director method call */ class DirectorMethodException : public DirectorException { public: DirectorMethodException(const char *msg = "") : DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) { } static void raise(const char *msg) { throw DirectorMethodException(msg); } }; /* attempt to call a pure virtual method via a director method */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg = "") : DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg) { } static void raise(const char *msg) { throw DirectorPureVirtualException(msg); } }; #if defined(SWIG_PYTHON_THREADS) /* __THREAD__ is the old macro to activate some thread support */ # if !defined(__THREAD__) # define __THREAD__ 1 # endif #endif #ifdef __THREAD__ # include "pythread.h" class Guard { PyThread_type_lock &mutex_; public: Guard(PyThread_type_lock & mutex) : mutex_(mutex) { PyThread_acquire_lock(mutex_, WAIT_LOCK); } ~Guard() { PyThread_release_lock(mutex_); } }; # define SWIG_GUARD(mutex) Guard _guard(mutex) #else # define SWIG_GUARD(mutex) #endif /* director base class */ class Director { private: /* pointer to the wrapped python object */ PyObject *swig_self; /* flag indicating whether the object is owned by python or c++ */ mutable bool swig_disown_flag; /* decrement the reference count of the wrapped python object */ void swig_decref() const { if (swig_disown_flag) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_DECREF(swig_self); SWIG_PYTHON_THREAD_END_BLOCK; } } public: /* wrap a python object. */ Director(PyObject *self) : swig_self(self), swig_disown_flag(false) { } /* discard our reference at destruction */ virtual ~Director() { swig_decref(); } /* return a pointer to the wrapped python object */ PyObject *swig_get_self() const { return swig_self; } /* acquire ownership of the wrapped python object (the sense of "disown" is from python) */ void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag=true; swig_incref(); } } /* increase the reference count of the wrapped python object */ void swig_incref() const { if (swig_disown_flag) { Py_INCREF(swig_self); } } /* methods to implement pseudo protected director members */ virtual bool swig_get_inner(const char * /* swig_protected_method_name */) const { return true; } virtual void swig_set_inner(const char * /* swig_protected_method_name */, bool /* swig_val */) const { } /* ownership management */ private: typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; #ifdef __THREAD__ static PyThread_type_lock swig_mutex_own; #endif public: template void swig_acquire_ownership_array(Type *vptr) const { if (vptr) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCArray_T(vptr); } } template void swig_acquire_ownership(Type *vptr) const { if (vptr) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_T(vptr); } } void swig_acquire_ownership_obj(void *vptr, int own) const { if (vptr && own) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_Object(own); } } int swig_release_ownership(void *vptr) const { int own = 0; if (vptr) { SWIG_GUARD(swig_mutex_own); swig_ownership_map::iterator iter = swig_owner.find(vptr); if (iter != swig_owner.end()) { own = iter->second->get_own(); swig_owner.erase(iter); } } return own; } template static PyObject *swig_pyobj_disown(PyObject *pyobj, PyObject *SWIGUNUSEDPARM(args)) { SwigPyObject *sobj = (SwigPyObject *)pyobj; sobj->own = 0; Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast(sobj->ptr)); if (d) d->swig_disown(); return PyWeakref_NewProxy(pyobj, NULL); } }; #ifdef __THREAD__ PyThread_type_lock Director::swig_mutex_own = PyThread_allocate_lock(); #endif } #endif swig-3.0.8/Lib/python/std_multiset.i0000664000175000017500000000207512641054563017306 0ustar williamwilliam/* Multisets */ %include %fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const SwigPySeq& swigpyseq, std::multiset* seq) { // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented typedef typename SwigPySeq::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(PyObject *obj, std::multiset **m) { return traits_asptr_stdseq >::asptr(obj, m); } }; template struct traits_from > { static PyObject *from(const std::multiset& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_multiset_methods(Set...) %swig_set_methods(Set) %include swig-3.0.8/Lib/python/builtin.swg0000664000175000017500000004160112641054563016602 0ustar williamwilliam#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ return wrapper(a, NULL); \ } #define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \ SWIGINTERN void \ wrapper##_closure(PyObject *a) { \ SwigPyObject *sobj; \ sobj = (SwigPyObject *)a; \ Py_XDECREF(sobj->dict); \ if (sobj->own) { \ PyObject *o; \ PyObject *val = 0, *type = 0, *tb = 0; \ PyErr_Fetch(&val, &type, &tb); \ o = wrapper(a, NULL); \ if (!o) { \ PyObject *deallocname = PyString_FromString(#wrapper); \ PyErr_WriteUnraisable(deallocname); \ Py_DECREF(deallocname); \ } \ PyErr_Restore(val, type, tb); \ Py_XDECREF(o); \ } \ if (PyType_IS_GC(a->ob_type)) { \ PyObject_GC_Del(a); \ } else { \ PyObject_Del(a); \ } \ } #define SWIGPY_INQUIRY_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a) { \ PyObject *pyresult; \ int result; \ pyresult = wrapper(a, NULL); \ result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; \ Py_XDECREF(pyresult); \ return result; \ } #define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, PyObject *b) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ Py_XINCREF(b); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } typedef ternaryfunc ternarycallfunc; #define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(b); \ Py_XINCREF(c); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *callable_object, PyObject *args, PyObject *) { \ return wrapper(callable_object, args); \ } #define SWIGPY_LENFUNC_CLOSURE(wrapper) \ SWIGINTERN Py_ssize_t \ wrapper##_closure(PyObject *a) { \ PyObject *resultobj; \ Py_ssize_t result; \ resultobj = wrapper(a, NULL); \ result = PyNumber_AsSsize_t(resultobj, NULL); \ Py_DECREF(resultobj); \ return result; \ } #define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(d ? 3 : 2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); \ if (d) { \ PyTuple_SET_ITEM(tuple, 2, d); \ Py_INCREF(d); \ } \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_DECREF(tuple); \ Py_XDECREF(resultobj); \ return result; \ } #define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \ PyObject *tuple, *result; \ tuple = PyTuple_New(1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ result = wrapper(a, tuple); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \ PyObject *arg, *result; \ arg = _PyLong_FromSsize_t(b); \ result = wrapper(a, arg); \ Py_DECREF(arg); \ return result; \ } #define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(2); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(c); \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_XDECREF(resultobj); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ PyObject *tuple, *resultobj; \ int result; \ tuple = PyTuple_New(c ? 2 : 1); \ assert(tuple); \ PyTuple_SET_ITEM(tuple, 0, b); \ Py_XINCREF(b); \ if (c) { \ PyTuple_SET_ITEM(tuple, 1, c); \ Py_XINCREF(c); \ } \ resultobj = wrapper(a, tuple); \ result = resultobj ? 0 : -1; \ Py_XDECREF(resultobj); \ Py_DECREF(tuple); \ return result; \ } #define SWIGPY_REPRFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ return wrapper(a, NULL); \ } #define SWIGPY_HASHFUNC_CLOSURE(wrapper) \ SWIGINTERN long \ wrapper##_closure(PyObject *a) { \ PyObject *pyresult; \ long result; \ pyresult = wrapper(a, NULL); \ if (!pyresult || !PyLong_Check(pyresult)) \ return -1; \ result = PyLong_AsLong(pyresult); \ Py_DECREF(pyresult); \ return result; \ } #define SWIGPY_ITERNEXT_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a) { \ PyObject *result; \ result = wrapper(a, NULL); \ if (result && result == Py_None) { \ Py_DECREF(result); \ result = NULL; \ } \ return result; \ } #ifdef __cplusplus extern "C" { #endif SWIGINTERN int SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) { PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name); return -1; } SWIGINTERN void SwigPyBuiltin_BadDealloc(PyObject *pyobj) { SwigPyObject *sobj; sobj = (SwigPyObject *)pyobj; if (sobj->own) { PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->ob_type->tp_name); } } typedef struct { PyCFunction get; PyCFunction set; } SwigPyGetSet; SWIGINTERN PyObject * SwigPyBuiltin_GetterClosure (PyObject *obj, void *closure) { SwigPyGetSet *getset; PyObject *tuple, *result; if (!closure) return SWIG_Py_Void(); getset = (SwigPyGetSet *)closure; if (!getset->get) return SWIG_Py_Void(); tuple = PyTuple_New(0); assert(tuple); result = (*getset->get)(obj, tuple); Py_DECREF(tuple); return result; } SWIGINTERN PyObject * SwigPyBuiltin_FunpackGetterClosure (PyObject *obj, void *closure) { SwigPyGetSet *getset; PyObject *result; if (!closure) return SWIG_Py_Void(); getset = (SwigPyGetSet *)closure; if (!getset->get) return SWIG_Py_Void(); result = (*getset->get)(obj, NULL); return result; } SWIGINTERN int SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) { SwigPyGetSet *getset; PyObject *tuple, *result; if (!closure) { PyErr_Format(PyExc_TypeError, "Missing getset closure"); return -1; } getset = (SwigPyGetSet *)closure; if (!getset->set) { PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); return -1; } tuple = PyTuple_New(1); assert(tuple); PyTuple_SET_ITEM(tuple, 0, val); Py_XINCREF(val); result = (*getset->set)(obj, tuple); Py_DECREF(tuple); Py_XDECREF(result); return result ? 0 : -1; } SWIGINTERN int SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) { SwigPyGetSet *getset; PyObject *result; if (!closure) { PyErr_Format(PyExc_TypeError, "Missing getset closure"); return -1; } getset = (SwigPyGetSet *)closure; if (!getset->set) { PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); return -1; } result = (*getset->set)(obj, val); Py_XDECREF(result); return result ? 0 : -1; } SWIGINTERN void SwigPyStaticVar_dealloc(PyDescrObject *descr) { _PyObject_GC_UNTRACK(descr); Py_XDECREF(PyDescr_TYPE(descr)); Py_XDECREF(PyDescr_NAME(descr)); PyObject_GC_Del(descr); } SWIGINTERN PyObject * SwigPyStaticVar_repr(PyGetSetDescrObject *descr) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromFormat("", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else return PyString_FromFormat("", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif } SWIGINTERN int SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) { PyDescrObject *descr; descr = (PyDescrObject *)self; Py_VISIT((PyObject*) PyDescr_TYPE(descr)); return 0; } SWIGINTERN PyObject * SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNUSEDPARM(type)) { if (descr->d_getset->get != NULL) return descr->d_getset->get(obj, descr->d_getset->closure); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif return NULL; } SWIGINTERN int SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) { if (descr->d_getset->set != NULL) return descr->d_getset->set(obj, value, descr->d_getset->closure); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); #else PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); #endif return -1; } SWIGINTERN int SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) { PyObject *attribute; descrsetfunc local_set; attribute = _PyType_Lookup(type, name); if (attribute != NULL) { /* Implement descriptor functionality, if any */ local_set = attribute->ob_type->tp_descr_set; if (local_set != NULL) return local_set(attribute, (PyObject *)type, value); #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name); #else PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name)); #endif } else { #if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name); #else PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name)); #endif } return -1; } SWIGINTERN PyTypeObject* SwigPyStaticVar_Type(void) { static PyTypeObject staticvar_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(&PyType_Type, 0) #else PyObject_HEAD_INIT(&PyType_Type) 0, #endif "swig_static_var_getset_descriptor", sizeof(PyGetSetDescrObject), 0, (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ (reprfunc)SwigPyStaticVar_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ 0, /* tp_doc */ SwigPyStaticVar_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */ (descrsetfunc)SwigPyStaticVar_set, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ #if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ #endif 0 /* tp_next */ #endif }; staticvar_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 staticvar_type.ob_type = &PyType_Type; #else if (PyType_Ready(&staticvar_type) < 0) return NULL; #endif } return &staticvar_type; } SWIGINTERN PyGetSetDescrObject * SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) { PyGetSetDescrObject *descr; descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0); assert(descr); Py_XINCREF(type); PyDescr_TYPE(descr) = type; PyDescr_NAME(descr) = PyString_InternFromString(getset->name); descr->d_getset = getset; if (PyDescr_NAME(descr) == NULL) { Py_DECREF(descr); descr = NULL; } return descr; } SWIGINTERN void SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) { int base_count = 0; PyTypeObject **b; PyObject *tuple; int i; if (!bases[0]) { bases[0] = SwigPyObject_type(); bases[1] = NULL; } type->tp_base = bases[0]; Py_INCREF((PyObject *)bases[0]); for (b = bases; *b != NULL; ++b) ++base_count; tuple = PyTuple_New(base_count); for (i = 0; i < base_count; ++i) { PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); Py_INCREF((PyObject *)bases[i]); } type->tp_bases = tuple; } SWIGINTERN PyObject * SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) { PyObject *result; result = (PyObject *)SWIG_Python_GetSwigThis(self); Py_XINCREF(result); return result; } SWIGINTERN void SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) { #if PY_VERSION_HEX >= 0x03000000 type->ob_base.ob_base.ob_type = metatype; #else type->ob_type = metatype; #endif } #ifdef __cplusplus } #endif swig-3.0.8/Lib/python/pythreads.swg0000664000175000017500000000546012641054563017142 0ustar williamwilliam#if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS # endif #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) # if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ # define SWIG_PYTHON_USE_GIL # endif # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() # endif # ifdef __cplusplus /* C++ code */ class SWIG_Python_Thread_Block { bool status; PyGILState_STATE state; public: void end() { if (status) { PyGILState_Release(state); status = false;} } SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} ~SWIG_Python_Thread_Block() { end(); } }; class SWIG_Python_Thread_Allow { bool status; PyThreadState *save; public: void end() { if (status) { PyEval_RestoreThread(save); status = false; }} SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} ~SWIG_Python_Thread_Allow() { end(); } }; # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() # else /* C code */ # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) # endif # else /* Old thread way, not implemented, user must provide it */ # if !defined(SWIG_PYTHON_INITIALIZE_THREADS) # define SWIG_PYTHON_INITIALIZE_THREADS # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_END_BLOCK) # define SWIG_PYTHON_THREAD_END_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # endif # if !defined(SWIG_PYTHON_THREAD_END_ALLOW) # define SWIG_PYTHON_THREAD_END_ALLOW # endif # endif #else /* No thread support */ # define SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # define SWIG_PYTHON_THREAD_END_BLOCK # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # define SWIG_PYTHON_THREAD_END_ALLOW #endif swig-3.0.8/Lib/python/python.swg0000664000175000017500000000376312641054563016464 0ustar williamwilliam/* ------------------------------------------------------------ * python.swg * * Python configuration module. * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Inner macros * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The runtime part * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Special user directives * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Typemap specializations * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Warnings for Python keywords * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Python autodoc support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Python classes, for C++ * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Python initialization function * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * For backward compatibility * ------------------------------------------------------------ */ %include swig-3.0.8/Lib/python/std_shared_ptr.i0000664000175000017500000000010412641054563017562 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.8/Lib/python/std_streambuf.i0000664000175000017500000000003712641054563017424 0ustar williamwilliam%include swig-3.0.8/Lib/python/typemaps.i0000664000175000017500000001054512641054563016431 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * These mappings provide support for input/output arguments and common * uses for C/C++ pointers. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Python tuple. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Python output of the function would be a tuple containing both output values. */ // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Python tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Python). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Python variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %include swig-3.0.8/Lib/python/std_vector.i0000664000175000017500000000126312641054563016740 0ustar williamwilliam/* Vectors */ %fragment("StdVectorTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::vector **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static PyObject *from(const std::vector& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/python/README0000664000175000017500000000765612641054563015306 0ustar williamwilliam/* ----------------------------------------------------------------------------- * * User interfaces: include these ones as needed * * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * Special types and user helpers * ----------------------------------------------------------------------------- */ argcargv.i Handler for (int argc, char **argv) attribute.i Convert a pair of set/get methods into a "native" python attribute ccomplex.i C99 complex type complex.i C99 or C++ complex type cstring.i Various forms of C character string handling cwstring.i Various forms of C wchar_t string handling embed.i embedding the Python interpreter in something else embed15.i embedding the Python interpreter in something else file.i FILE C type implicit.i Allow the use of implicit C++ constructors wchar.i wchar_t C type /* ----------------------------------------------------------------------------- * C++ STD + STL * ----------------------------------------------------------------------------- */ std_alloc.i allocator std_basic_string.i basic string std_char_traits.i char traits std_complex.i complex std_deque.i deque std_except.i exceptions std_ios.i ios std_iostream.i istream/ostream std_list.i list std_map.i map std_multimap.i multimap std_multiset.i multiset std_pair.i pair std_set.i set std_sstream.i string stream std_streambuf.i streambuf std_string.i string std_vector.i vector std_wios.i wios std_wiostream.i wistream/wostream std_wsstream.i wstring stream std_wstreambuf.i wstreambuf std_wstring.i wstring /* ----------------------------------------------------------------------------- /* * Implementation files: don't look at them unless you are really drunk * * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * Basic files * ----------------------------------------------------------------------------- */ python.swg Main language file, it just includes what is needed. pyuserdir.swg User visible directives (%pythonnondynamic, etc) pymacros.swg Internal macros used for typemaps pyfragments.swg Allow the user to overload the default fragments pyopers.swg Python operations (+=, *=, etc) pythonkw.swg Python keywords and special names pyinit.swg Python Init method /* ----------------------------------------------------------------------------- * The runtime part * ----------------------------------------------------------------------------- */ pyruntime.swg Main runtime file definition pyapi.swg SWIG/Python API declarations pyrun.swg Python run-time code /* ----------------------------------------------------------------------------- * Internal typemap specializations * ----------------------------------------------------------------------------- */ pyswigtype.swg SWIGTYPE pystrings.swg Char strings (char *) pywstrings.swg Wchar Strings (wchar_t *) pyprimtypes.swg Primitive types (shot,int,double,etc) pycomplex.swg PyComplex and helper for C/C++ complex types pydocs.swg Typemaps documentation /* ----------------------------------------------------------------------------- * C++ STD + STL * ----------------------------------------------------------------------------- */ pycontainer.swg python container iterators std_common.i general common code for the STD/STL implementation std_container.i general common code for the STD/STL containers /*----------------------------------------------------------------------------- * Backward compatibility and deprecated * ----------------------------------------------------------------------------- */ std_vectora.i vector + allocator (allocators are now supported in STD/STL) typemaps.i old in/out typemaps (doesn't need to be included) defarg.swg for processing default arguments with shadow classes swig-3.0.8/Lib/python/ccomplex.i0000664000175000017500000000137312641054563016400 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ccomplex.i * * C complex typemaps * ISO C99: 7.3 Complex arithmetic * ----------------------------------------------------------------------------- */ %include %{ #include %} /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) %swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); swig-3.0.8/Lib/python/pyhead.swg0000664000175000017500000001325512641054563016412 0ustar williamwilliam/* Compatibility macros for Python 3 */ #if PY_VERSION_HEX >= 0x03000000 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) #define PyInt_FromLong(x) PyLong_FromLong(x) #define PyInt_FromSize_t(x) PyLong_FromSize_t(x) #define PyString_Check(name) PyBytes_Check(name) #define PyString_FromString(x) PyUnicode_FromString(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) #define PyString_AsString(str) PyBytes_AsString(str) #define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE #define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) #endif #ifndef Py_TYPE # define Py_TYPE(op) ((op)->ob_type) #endif /* SWIG APIs for compatibility of both Python 2 & 3 */ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_FromFormat PyUnicode_FromFormat #else # define SWIG_Python_str_FromFormat PyString_FromFormat #endif /* Warning: This function will allocate a new string in Python 3, * so please call SWIG_Python_str_DelForPy3(x) to free the space. */ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 char *cstr; char *newstr; Py_ssize_t len; str = PyUnicode_AsUTF8String(str); PyBytes_AsStringAndSize(str, &cstr, &len); newstr = (char *) malloc(len+1); memcpy(newstr, cstr, len+1); Py_XDECREF(str); return newstr; #else return PyString_AsString(str); #endif } #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) #else # define SWIG_Python_str_DelForPy3(x) #endif SWIGINTERN PyObject* SWIG_Python_str_FromChar(const char *c) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromString(c); #else return PyString_FromString(c); #endif } /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif #endif /* A crude PyString_FromFormat implementation for old Pythons */ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE # define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * PyString_FromFormat(const char *fmt, ...) { va_list ap; char buf[SWIG_PYBUFFER_SIZE * 2]; int res; va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 # define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # ifndef PyExc_StopIteration # define PyExc_StopIteration PyExc_RuntimeError # endif # ifndef PyObject_GenericGetAttr # define PyObject_GenericGetAttr 0 # endif #endif /* Py_NotImplemented is defined in 2.1 and up. */ #if PY_VERSION_HEX < 0x02010000 # ifndef Py_NotImplemented # define Py_NotImplemented PyExc_RuntimeError # endif #endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 # ifndef PyString_AsStringAndSize # define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} # endif #endif /* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 # ifndef PySequence_Size # define PySequence_Size PySequence_Length # endif #endif /* PyBool_FromLong for old Pythons */ #if PY_VERSION_HEX < 0x02030000 static PyObject *PyBool_FromLong(long ok) { PyObject *result = ok ? Py_True : Py_False; Py_INCREF(result); return result; } #endif /* Py_ssize_t for old Pythons */ /* This code is as recommended by: */ /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) typedef int Py_ssize_t; # define PY_SSIZE_T_MAX INT_MAX # define PY_SSIZE_T_MIN INT_MIN typedef inquiry lenfunc; typedef intargfunc ssizeargfunc; typedef intintargfunc ssizessizeargfunc; typedef intobjargproc ssizeobjargproc; typedef intintobjargproc ssizessizeobjargproc; typedef getreadbufferproc readbufferproc; typedef getwritebufferproc writebufferproc; typedef getsegcountproc segcountproc; typedef getcharbufferproc charbufferproc; static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) { long result = 0; PyObject *i = PyNumber_Int(x); if (i) { result = PyInt_AsLong(i); Py_DECREF(i); } return result; } #endif #if PY_VERSION_HEX < 0x02050000 #define PyInt_FromSize_t(x) PyInt_FromLong((long)x) #endif #if PY_VERSION_HEX < 0x02040000 #define Py_VISIT(op) \ do { \ if (op) { \ int vret = visit((op), arg); \ if (vret) \ return vret; \ } \ } while (0) #endif #if PY_VERSION_HEX < 0x02030000 typedef struct { PyTypeObject type; PyNumberMethods as_number; PyMappingMethods as_mapping; PySequenceMethods as_sequence; PyBufferProcs as_buffer; PyObject *name, *slots; } PyHeapTypeObject; #endif #if PY_VERSION_HEX < 0x02030000 typedef destructor freefunc; #endif #if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ (PY_MAJOR_VERSION > 3)) # define SWIGPY_USE_CAPSULE # define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) #endif #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) #endif swig-3.0.8/Lib/python/pyprimtypes.swg0000664000175000017500000001705212641054563017544 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE PyObject* SWIG_From_dec(bool)(bool value) { return PyBool_FromLong(value ? 1 : 0); } } #ifdef SWIG_PYTHON_LEGACY_BOOL // Default prior to SWIG 3.0.0 %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) { int r = PyObject_IsTrue(obj); if (r == -1) return SWIG_ERROR; if (val) *val = r ? true : false; return SWIG_OK; } } #else %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) { int r; if (!PyBool_Check(obj)) return SWIG_ERROR; r = PyObject_IsTrue(obj); if (r == -1) return SWIG_ERROR; if (val) *val = r ? true : false; return SWIG_OK; } } #endif /* int */ %fragment(SWIG_From_frag(int),"header") { SWIGINTERNINLINE PyObject* SWIG_From_dec(int)(int value) { return PyInt_FromLong((long) value); } } /* unsigned int */ %fragment(SWIG_From_frag(unsigned int),"header") { SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned int)(unsigned int value) { return PyInt_FromSize_t((size_t) value); } } /* long */ %fragment(SWIG_From_frag(long),"header") { %define_as(SWIG_From_dec(long), PyLong_FromLong) } %fragment(SWIG_AsVal_frag(long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long)(PyObject *obj, long* val) { %#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else %#endif if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); return SWIG_OverflowError; } } %#ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; long v = PyInt_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { if (val) *val = (long)(d); return res; } } } %#endif return SWIG_TypeError; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned long)(unsigned long value) { return (value > LONG_MAX) ? PyLong_FromUnsignedLong(value) : PyLong_FromLong(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) { %#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { long v = PyInt_AsLong(obj); if (v >= 0) { if (val) *val = v; return SWIG_OK; } else { return SWIG_OverflowError; } } else %#endif if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); return SWIG_OverflowError; } } %#ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { if (val) *val = (unsigned long)(d); return res; } } } %#endif return SWIG_TypeError; } } /* long long */ %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE PyObject* SWIG_From_dec(long long)(long long value) { return ((value < LONG_MIN) || (value > LONG_MAX)) ? PyLong_FromLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) { int res = SWIG_TypeError; if (PyLong_Check(obj)) { long long v = PyLong_AsLongLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); res = SWIG_OverflowError; } } else { long v; res = SWIG_AsVal(long)(obj,&v); if (SWIG_IsOK(res)) { if (val) *val = v; return res; } } %#ifdef SWIG_PYTHON_CAST_MODE { const double mant_max = 1LL << DBL_MANT_DIG; const double mant_min = -mant_max; double d; res = SWIG_AsVal(double)(obj,&d); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { if (val) *val = (long long)(d); return SWIG_AddCast(res); } res = SWIG_TypeError; } %#endif return res; } } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? PyLong_FromUnsignedLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) { int res = SWIG_TypeError; if (PyLong_Check(obj)) { unsigned long long v = PyLong_AsUnsignedLongLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); res = SWIG_OverflowError; } } else { unsigned long v; res = SWIG_AsVal(unsigned long)(obj,&v); if (SWIG_IsOK(res)) { if (val) *val = v; return res; } } %#ifdef SWIG_PYTHON_CAST_MODE { const double mant_max = 1LL << DBL_MANT_DIG; double d; res = SWIG_AsVal(double)(obj,&d); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { if (val) *val = (unsigned long long)(d); return SWIG_AddCast(res); } res = SWIG_TypeError; } %#endif return res; } } /* double */ %fragment(SWIG_From_frag(double),"header") { %define_as(SWIG_From_dec(double), PyFloat_FromDouble) } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(PyObject *obj, double *val) { int res = SWIG_TypeError; if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; %#if PY_VERSION_HEX < 0x03000000 } else if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; %#endif } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } %#ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; double d = PyFloat_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = d; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); } else { PyErr_Clear(); } } } %#endif return res; } } swig-3.0.8/Lib/python/std_carray.i0000664000175000017500000000305712641054563016722 0ustar williamwilliam%include %fragment("StdCarrayTraits","header",fragment="StdSequenceTraits") { namespace swig { template struct traits_asptr > { static int asptr(PyObject *obj, std::carray **array) { return traits_asptr_stdseq >::asptr(obj, array); } }; } } %warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[]; %extend std::carray { %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header", fragment="SwigPyIterator_T", fragment=SWIG_Traits_frag(_Type), fragment="StdCarrayTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::carray<" #_Type "," #_Size " >"; } }; } } %typemaps_asptr(SWIG_TYPECHECK_VECTOR, swig::asptr, SWIG_Traits_frag(std::carray<_Type, _Size >), std::carray<_Type, _Size >); %typemap(out,noblock=1) iterator, const_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); } inline size_t __len__() const { return self->size(); } inline const _Type& __getitem__(size_t i) const { return (*self)[i]; } inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; } swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } %include swig-3.0.8/Lib/python/std_sstream.i0000664000175000017500000000003512641054563017110 0ustar williamwilliam%include swig-3.0.8/Lib/python/std_wiostream.i0000664000175000017500000000024612641054563017450 0ustar williamwilliamnamespace std { %callback(1) wendl; %callback(1) wends; %callback(1) wflush; } %include %include %include swig-3.0.8/Lib/python/cmalloc.i0000664000175000017500000000004012641054563016166 0ustar williamwilliam%include swig-3.0.8/Lib/python/cstring.i0000664000175000017500000000004012641054563016225 0ustar williamwilliam%include swig-3.0.8/Lib/python/pyuserdir.swg0000664000175000017500000001426612641054563017171 0ustar williamwilliam/* ------------------------------------------------------------------------- * Special user directives * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ /* shadow code */ #define %shadow %insert("shadow") #define %pythoncode %insert("python") #define %pythonbegin %insert("pythonbegin") /* ------------------------------------------------------------------------- */ /* Use the "nondynamic" feature to make a wrapped class behave as a "nondynamic" one, ie, a python class that doesn't dynamically add new attributes. For example, for the class %pythonnondynamic A; struct A { int a; int b; }; you will get: aa = A() aa.a = 1 # Ok aa.b = 1 # Ok aa.c = 3 # error Since nondynamic is a feature, if you use it like %pythonnondynamic; it will make all the wrapped classes nondynamic ones. The implementation is based on this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158 and works for modern (-modern) and plain python. We do not use __slots__, so, it works with old python versions. */ #define %pythonnondynamic %feature("python:nondynamic", "1") #define %nopythonnondynamic %feature("python:nondynamic", "0") #define %clearpythonnondynamic %feature("python:nondynamic", "") #define %pythondynamic %nopythonnondynamic /* ------------------------------------------------------------------------- */ /* Use %pythonmaybecall to flag a method like __add__ or __radd__. These don't produce an error when called, they just return NotImplemented. These methods "may be called" if needed. */ #define %pythonmaybecall %feature("python:maybecall", "1") #define %nopythonmaybecall %feature("python:maybecall", "0") #define %clearpythonmaybecall %feature("python:maybecall", "") /* ------------------------------------------------------------------------- */ /* The %pythoncallback feature produce a more natural callback wrapper than the %callback mechanism, ie, it uses the original name for the callback and callable objects. Just use it as %pythoncallback(1) foo; int foo(int a); %pythoncallback(1) A::foo; struct A { static int foo(int a); }; int bar(int, int (*pf)(int)); then, you can use it as: a = foo(1) b = bar(2, foo) c = A.foo(3) d = bar(4, A.foo) If you use it with a member method %pythoncallback(1) A::foom; struct A { int foom(int a); }; then you can use it as r = a.foom(3) # eval the method mptr = A.foom_cb_ptr # returns the callback pointer where the '_cb_ptr' suffix is added for the callback pointer. */ #define %pythoncallback %feature("python:callback") #define %nopythoncallback %feature("python:callback","0") #define %clearpythoncallback %feature("python:callback","") /* ------------------------------------------------------------------------- */ /* Support for the old %callback directive name */ #ifdef %callback #undef %callback #endif #ifdef %nocallback #undef %nocallback #endif #ifdef %clearcallback #undef %clearcallback #endif #define %callback(x) %feature("python:callback",`x`) #define %nocallback %nopythoncallback #define %clearcallback %clearpythoncallback /* ------------------------------------------------------------------------- */ /* Thread support - Advance control */ #define %nothread %feature("nothread") #define %thread %feature("nothread","0") #define %clearnothread %feature("nothread","") #define %nothreadblock %feature("nothreadblock") #define %threadblock %feature("nothreadblock","0") #define %clearnothreadblock %feature("nothreadblock","") #define %nothreadallow %feature("nothreadallow") #define %threadallow %feature("nothreadallow","0") #define %clearnothreadallow %feature("nothreadallow","") /* ------------------------------------------------------------------------- */ /* Implicit Conversion using the C++ constructor mechanism */ #define %implicitconv %feature("implicitconv") #define %noimplicitconv %feature("implicitconv", "0") #define %clearimplicitconv %feature("implicitconv", "") /* ------------------------------------------------------------------------- */ /* Enable keywords paramaters */ #define %kwargs %feature("kwargs") #define %nokwargs %feature("kwargs", "0") #define %clearkwargs %feature("kwargs", "") /* ------------------------------------------------------------------------- */ /* Add python code to the proxy/shadow code %pythonprepend - Add code before the C++ function is called %pythonappend - Add code after the C++ function is called */ #define %pythonprepend %feature("pythonprepend") #define %clearpythonprepend %feature("pythonprepend","") #define %pythonappend %feature("pythonappend") #define %clearpythonappend %feature("pythonappend","") /* ------------------------------------------------------------------------- */ /* %extend_smart_pointer extend the smart pointer support. For example, if you have a smart pointer as: template class RCPtr { public: ... RCPtr(Type *p); Type * operator->() const; ... }; you use the %extend_smart_pointer directive as: %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; then, if you have something like: RCPtr make_ptr(); int foo(A *); you can do the following: a = make_ptr(); b = foo(a); ie, swig will accept a RCPtr object where a 'A *' is expected. Also, when using vectors %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; %template(vector_A) std::vector >; you can type a = A(); v = vector_A(2) v[0] = a ie, an 'A *' object is accepted, via implicit conversion, where a RCPtr object is expected. Additionally x = v[0] returns (and sets 'x' as) a copy of v[0], making reference counting possible and consistent. */ %define %extend_smart_pointer(Type...) %implicitconv Type; %apply const SWIGTYPE& SMARTPOINTER { const Type& }; %apply SWIGTYPE SMARTPOINTER { Type }; %enddef swig-3.0.8/Lib/python/implicit.i0000664000175000017500000000043712641054563016400 0ustar williamwilliam%include %include #warning "This file provides the %implicit directive, which is an old and fragile" #warning "way to implement the C++ implicit conversion mechanism." #warning "Try using the more robust '%implicitconv Type;' directive instead." swig-3.0.8/Lib/python/std_complex.i0000664000175000017500000000072512641054563017107 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.8/Lib/python/argcargv.i0000664000175000017500000000512212641054563016356 0ustar williamwilliam/* ------------------------------------------------------------ * --- Argc & Argv --- * ------------------------------------------------------------ */ %fragment("SWIG_AsArgcArgv","header",fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsArgcArgv(PyObject *input, swig_type_info *ppchar_info, size_t *argc, char ***argv, int *owner) { void *vptr; int res = SWIG_ConvertPtr(input, &vptr, ppchar_info, 0); if (!SWIG_IsOK(res)) { int list = 0; PyErr_Clear(); list = PyList_Check(input); if (list || PyTuple_Check(input)) { size_t i = 0; size_t size = list ? PyList_Size(input) : PyTuple_Size(input); if (argc) *argc = size; if (argv) { *argv = %new_array(size + 1, char*); for (; i < size; ++i) { PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); char *cptr = 0; size_t sz = 0; int alloc = 0; res = SWIG_AsCharPtrAndSize(obj, &cptr, &sz, &alloc); if (SWIG_IsOK(res)) { if (cptr && sz) { (*argv)[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, sz, char); } else { (*argv)[i] = 0; } } else { return SWIG_TypeError; } } (*argv)[i] = 0; if (owner) *owner = 1; } else { for (; i < size; ++i) { PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); res = SWIG_AsCharPtrAndSize(obj, 0, 0, 0); if (!SWIG_IsOK(res)) return SWIG_TypeError; } if (owner) *owner = 0; } return SWIG_OK; } else { return SWIG_TypeError; } } else { /* seems dangerous, but the user asked for it... */ size_t i = 0; if (argv) { while (*argv[i] != 0) ++i;} if (argc) *argc = i; if (owner) *owner = 0; return SWIG_OK; } } } /* This typemap works with either a char **, a python list or a python tuple */ %typemap(in,noblock=0,fragment="SWIG_AsArgcArgv") (int ARGC, char **ARGV) (int res,char **argv = 0, size_t argc = 0, int owner= 0) { res = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &argv, &owner); if (!SWIG_IsOK(res)) { $1 = 0; $2 = 0; %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum); } else { $1 = %static_cast(argc,$1_ltype); $2 = %static_cast(argv, $2_ltype); } } %typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { int res = SWIG_AsArgcArgv($input, $descriptor(char**), 0, 0, 0); $1 = SWIG_IsOK(res); } %typemap(freearg,noblock=1) (int ARGC, char **ARGV) { if (owner$argnum) { size_t i = argc$argnum; while (i) { %delete_array(argv$argnum[--i]); } %delete_array(argv$argnum); } } swig-3.0.8/Lib/python/cpointer.i0000664000175000017500000000004112641054563016400 0ustar williamwilliam%include swig-3.0.8/Lib/gcj/0000775000175000017500000000000012641054563013632 5ustar williamwilliamswig-3.0.8/Lib/gcj/javaprims.i0000664000175000017500000002670412641054563016011 0ustar williamwilliam%include typedef int8_t jbyte; typedef int16_t jshort; typedef int32_t jint; typedef int64_t jlong; typedef float jfloat; typedef double jdouble; typedef jint jsize; typedef int8_t jboolean; extern "Java" { namespace java { namespace io { class BufferedInputStream; class BufferedOutputStream; class BufferedReader; class BufferedWriter; class ByteArrayInputStream; class ByteArrayOutputStream; class CharArrayReader; class CharArrayWriter; class CharConversionException; class DataInput; class DataInputStream; class DataOutput; class DataOutputStream; class EOFException; class Externalizable; class File; class FileDescriptor; class FileFilter; class FileInputStream; class FileNotFoundException; class FileOutputStream; class FilePermission; class FileReader; class FileWriter; class FilenameFilter; class FilterInputStream; class FilterOutputStream; class FilterReader; class FilterWriter; class IOException; class InputStream; class InputStreamReader; class InterfaceComparator; class InterruptedIOException; class InvalidClassException; class InvalidObjectException; class LineNumberInputStream; class LineNumberReader; class MemberComparator; class NotActiveException; class NotSerializableException; class ObjectInput; class ObjectInputStream; class ObjectInputStream$GetField; class ObjectInputValidation; class ObjectOutput; class ObjectOutputStream; class ObjectOutputStream$PutField; class ObjectStreamClass; class ObjectStreamConstants; class ObjectStreamException; class ObjectStreamField; class OptionalDataException; class OutputStream; class OutputStreamWriter; class PipedInputStream; class PipedOutputStream; class PipedReader; class PipedWriter; class PrintStream; class PrintWriter; class PushbackInputStream; class PushbackReader; class RandomAccessFile; class Reader; class SequenceInputStream; class Serializable; class SerializablePermission; class StreamCorruptedException; class StreamTokenizer; class StringBufferInputStream; class StringReader; class StringWriter; class SyncFailedException; class UTFDataFormatException; class UnsupportedEncodingException; class VMObjectStreamClass; class ValidatorAndPriority; class WriteAbortedException; class Writer; } namespace lang { class AbstractMethodError; class ArithmeticException; class ArrayIndexOutOfBoundsException; class ArrayStoreException; class AssertionError; class Boolean; class Byte; class CharSequence; class Character; class Character$Subset; class Character$UnicodeBlock; class Class; class ClassCastException; class ClassCircularityError; class ClassFormatError; class ClassLoader; class ClassNotFoundException; class CloneNotSupportedException; class Cloneable; class Comparable; class Compiler; class ConcreteProcess; class Double; class Error; class Exception; class ExceptionInInitializerError; class Float; class IllegalAccessError; class IllegalAccessException; class IllegalArgumentException; class IllegalMonitorStateException; class IllegalStateException; class IllegalThreadStateException; class IncompatibleClassChangeError; class IndexOutOfBoundsException; class InheritableThreadLocal; class InstantiationError; class InstantiationException; class Integer; class InternalError; class InterruptedException; class LinkageError; class Long; class Math; class NegativeArraySizeException; class NoClassDefFoundError; class NoSuchFieldError; class NoSuchFieldException; class NoSuchMethodError; class NoSuchMethodException; class NullPointerException; class Number; class NumberFormatException; class Object; class OutOfMemoryError; class Package; class Process; class Runnable; class Runtime; class RuntimeException; class RuntimePermission; class SecurityContext; class SecurityException; class SecurityManager; class Short; class StackOverflowError; class StackTraceElement; class StrictMath; class String; class String$CaseInsensitiveComparator; class StringBuffer; class StringIndexOutOfBoundsException; class System; class Thread; class ThreadDeath; class ThreadGroup; class ThreadLocal; class Throwable; class UnknownError; class UnsatisfiedLinkError; class UnsupportedClassVersionError; class UnsupportedOperationException; class VMClassLoader; class VMSecurityManager; class VMThrowable; class VerifyError; class VirtualMachineError; class Void; namespace ref { class PhantomReference; class Reference; class ReferenceQueue; class SoftReference; class WeakReference; } namespace reflect { class AccessibleObject; class Array; class Constructor; class Field; class InvocationHandler; class InvocationTargetException; class Member; class Method; class Modifier; class Proxy; class Proxy$ClassFactory; class Proxy$ProxyData; class Proxy$ProxySignature; class Proxy$ProxyType; class ReflectPermission; class UndeclaredThrowableException; } } namespace util { class AbstractCollection; class AbstractList; class AbstractMap; class AbstractMap$BasicMapEntry; class AbstractSequentialList; class AbstractSet; class ArrayList; class Arrays; class Arrays$ArrayList; class BitSet; class Calendar; class Collection; class Collections; class Collections$CopiesList; class Collections$EmptyList; class Collections$EmptyMap; class Collections$EmptySet; class Collections$ReverseComparator; class Collections$SingletonList; class Collections$SingletonMap; class Collections$SingletonSet; class Collections$SynchronizedCollection; class Collections$SynchronizedIterator; class Collections$SynchronizedList; class Collections$SynchronizedListIterator; class Collections$SynchronizedMap; class Collections$SynchronizedMapEntry; class Collections$SynchronizedRandomAccessList; class Collections$SynchronizedSet; class Collections$SynchronizedSortedMap; class Collections$SynchronizedSortedSet; class Collections$UnmodifiableCollection; class Collections$UnmodifiableEntrySet; class Collections$UnmodifiableIterator; class Collections$UnmodifiableList; class Collections$UnmodifiableListIterator; class Collections$UnmodifiableMap; class Collections$UnmodifiableRandomAccessList; class Collections$UnmodifiableSet; class Collections$UnmodifiableSortedMap; class Collections$UnmodifiableSortedSet; class Comparator; class ConcurrentModificationException; class Currency; class Date; class Dictionary; class EmptyStackException; class Enumeration; class EventListener; class EventListenerProxy; class EventObject; class GregorianCalendar; class HashMap; class HashMap$HashEntry; class HashMap$HashIterator; class HashSet; class Hashtable; class Hashtable$Enumerator; class Hashtable$HashEntry; class Hashtable$HashIterator; class IdentityHashMap; class IdentityHashMap$IdentityEntry; class IdentityHashMap$IdentityIterator; class Iterator; class LinkedHashMap; class LinkedHashMap$LinkedHashEntry; class LinkedHashSet; class LinkedList; class LinkedList$Entry; class LinkedList$LinkedListItr; class List; class ListIterator; class ListResourceBundle; class Locale; class Map; class Map$Entry; class Map$Map; class MissingResourceException; class MyResources; class NoSuchElementException; class Observable; class Observer; class Properties; class PropertyPermission; class PropertyPermissionCollection; class PropertyResourceBundle; class Random; class RandomAccess; class RandomAccessSubList; class ResourceBundle; class Set; class SimpleTimeZone; class SortedMap; class SortedSet; class Stack; class StringTokenizer; class SubList; class TimeZone; class Timer; class Timer$Scheduler; class Timer$TaskQueue; class TimerTask; class TooManyListenersException; class TreeMap; class TreeMap$Node; class TreeMap$SubMap; class TreeMap$TreeIterator; class TreeSet; class Vector; class WeakHashMap; class WeakHashMap$WeakBucket; class WeakHashMap$WeakEntry; class WeakHashMap$WeakEntrySet; namespace jar { class Attributes; class Attributes$Name; class JarEntry; class JarException; class JarFile; class JarFile$JarEnumeration; class JarInputStream; class JarOutputStream; class Manifest; } namespace logging { class ConsoleHandler; class ErrorManager; class FileHandler; class Filter; class Formatter; class Handler; class Level; class LogManager; class LogRecord; class Logger; class LoggingPermission; class MemoryHandler; class SimpleFormatter; class SocketHandler; class StreamHandler; class XMLFormatter; } namespace prefs { class AbstractPreferences; class BackingStoreException; class InvalidPreferencesFormatException; class NodeChangeEvent; class NodeChangeListener; class PreferenceChangeEvent; class PreferenceChangeListener; class Preferences; class PreferencesFactory; } namespace regex { class Matcher; class Pattern; class PatternSyntaxException; } namespace zip { class Adler32; class CRC32; class CheckedInputStream; class CheckedOutputStream; class Checksum; class DataFormatException; class Deflater; class DeflaterOutputStream; class GZIPInputStream; class GZIPOutputStream; class Inflater; class InflaterInputStream; class ZipConstants; class ZipEntry; class ZipException; class ZipFile; class ZipFile$PartialInputStream; class ZipFile$ZipEntryEnumeration; class ZipInputStream; class ZipOutputStream; } } } } typedef class java::lang::Object* jobject; typedef class java::lang::Class* jclass; typedef class java::lang::Throwable* jthrowable; typedef class java::lang::String* jstring; %include swig-3.0.8/Lib/gcj/cni.i0000664000175000017500000000166712641054563014567 0ustar williamwilliam%{ #include %} %include extern void JvInitClass (jclass cls); extern jstring JvAllocString (jsize sz); extern jstring JvNewString (const jchar *chars, jsize len); extern jstring JvNewStringLatin1 (const char *bytes, jsize len); extern jstring JvNewStringLatin1 (const char *bytes); extern jchar* JvGetStringChars (jstring str); extern jsize JvGetStringUTFLength (jstring string); extern jsize JvGetStringUTFRegion (jstring str, jsize start, jsize len, char *buf); extern jstring JvNewStringUTF (const char *bytes); extern void *JvMalloc (jsize size); extern void JvFree (void *ptr); extern jint JvCreateJavaVM (JvVMInitArgs* vm_args); extern java::lang::Thread* JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group); extern java::lang::Thread* JvAttachCurrentThreadAsDaemon (jstring name, java::lang::ThreadGroup* group); extern jint JvDetachCurrentThread (void); %include swig-3.0.8/Lib/gcj/cni.swg0000664000175000017500000000043712641054563015131 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cni.swg * ----------------------------------------------------------------------------- */ #ifdef SWIG #define __attribute__(...) %ignore class$; #pragma SWIG nowarn=313,402 %nodefaultdtor; #endif swig-3.0.8/Lib/cdata.i0000664000175000017500000000576612641054563014333 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cdata.i * * SWIG library file containing macros for manipulating raw C data as strings. * ----------------------------------------------------------------------------- */ %{ typedef struct SWIGCDATA { char *data; int len; } SWIGCDATA; %} /* ----------------------------------------------------------------------------- * Typemaps for returning binary data * ----------------------------------------------------------------------------- */ #if SWIGGUILE %typemap(out) SWIGCDATA { $result = scm_from_locale_stringn($1.data,$1.len); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGCHICKEN %typemap(out) SWIGCDATA { C_word *string_space = C_alloc(C_SIZEOF_STRING($1.len)); $result = C_string(&string_space, $1.len, $1.data); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGPHP %typemap(out) SWIGCDATA { ZVAL_STRINGL($result, $1.data, $1.len, 1); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGJAVA %apply (char *STRING, int LENGTH) { (const void *indata, int inlen) } %typemap(jni) SWIGCDATA "jbyteArray" %typemap(jtype) SWIGCDATA "byte[]" %typemap(jstype) SWIGCDATA "byte[]" %fragment("SWIG_JavaArrayOutCDATA", "header") { static jbyteArray SWIG_JavaArrayOutCDATA(JNIEnv *jenv, char *result, jsize sz) { jbyte *arr; int i; jbyteArray jresult = JCALL1(NewByteArray, jenv, sz); if (!jresult) return NULL; arr = JCALL2(GetByteArrayElements, jenv, jresult, 0); if (!arr) return NULL; for (i=0; i %} %define SWIG_CATCH_STDEXCEPT /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception(SWIG_ValueError, e.what() ); } catch (std::domain_error& e) { SWIG_exception(SWIG_ValueError, e.what() ); } catch (std::overflow_error& e) { SWIG_exception(SWIG_OverflowError, e.what() ); } catch (std::out_of_range& e) { SWIG_exception(SWIG_IndexError, e.what() ); } catch (std::length_error& e) { SWIG_exception(SWIG_IndexError, e.what() ); } catch (std::runtime_error& e) { SWIG_exception(SWIG_RuntimeError, e.what() ); } catch (std::exception& e) { SWIG_exception(SWIG_SystemError, e.what() ); } %enddef %define SWIG_CATCH_UNKNOWN catch (std::exception& e) { SWIG_exception(SWIG_SystemError, e.what() ); } catch (...) { SWIG_exception(SWIG_UnknownError, "unknown exception"); } %enddef /* rethrow the unknown exception */ #if defined(SWIGCSHARP) || defined(SWIGD) %typemap(throws,noblock=1, canthrow=1) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } #else %typemap(throws,noblock=1) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } #endif #endif /* __cplusplus */ /* exception.i ends here */ swig-3.0.8/Lib/clisp/0000775000175000017500000000000012641054563014201 5ustar williamwilliamswig-3.0.8/Lib/clisp/clisp.swg0000664000175000017500000000163712641054563016044 0ustar williamwilliam/* ----------------------------------------------------------------------------- * clisp.swg * ----------------------------------------------------------------------------- */ /* Define a C preprocessor symbol that can be used in interface files to distinguish between the SWIG language modules. */ #define SWIG_CLISP /* Typespecs for basic types. */ %typemap(in) void "NIL"; %typemap(in) char "character"; %typemap(in) char * "ffi:c-string"; %typemap(in) unsigned char "ffi:uchar"; %typemap(in) signed char "ffi:char"; %typemap(in) short "ffi:short"; %typemap(in) signed short "ffi:short"; %typemap(in) unsigned short "ffi:ushort"; %typemap(in) int "ffi:int"; %typemap(in) signed int "ffi:int"; %typemap(in) unsigned int "ffi:uint"; %typemap(in) long "ffi:long"; %typemap(in) signed long "ffi:long"; %typemap(in) unsigned long "ffi:ulong"; %typemap(in) float "SINGLE-FLOAT"; %typemap(in) double "DOUBLE-FLOAT"; swig-3.0.8/Lib/uffi/0000775000175000017500000000000012641054563014020 5ustar williamwilliamswig-3.0.8/Lib/uffi/uffi.swg0000664000175000017500000000621612641054563015500 0ustar williamwilliam/* Define a C preprocessor symbol that can be used in interface files to distinguish between the SWIG language modules. */ #define SWIG_UFFI /* Typespecs for basic types. */ %typemap(ffitype) char ":char"; %typemap(ffitype) unsigned char ":unsigned-char"; %typemap(ffitype) signed char ":char"; %typemap(ffitype) short ":short"; %typemap(ffitype) signed short ":short"; %typemap(ffitype) unsigned short ":unsigned-short"; %typemap(ffitype) int ":int"; %typemap(ffitype) signed int ":int"; %typemap(ffitype) unsigned int ":unsigned-int"; %typemap(ffitype) long ":long"; %typemap(ffitype) signed long ":long"; %typemap(ffitype) unsigned long ":unsigned-long"; %typemap(ffitype) float ":float"; %typemap(ffitype) double ":double"; %typemap(ffitype) char * ":cstring"; %typemap(ffitype) void * ":pointer-void"; %typemap(ffitype) void ":void"; // FIXME: This is guesswork typedef long size_t; %wrapper %{ (eval-when (compile eval) ;;; You can define your own identifier converter if you want. ;;; Use the -identifier-converter command line argument to ;;; specify its name. (defun identifier-convert-null (id &key type) (declare (ignore type)) (read-from-string id)) (defun identifier-convert-lispify (cname &key type) (assert (stringp cname)) (if (eq type :constant) (setf cname (format nil "*~A*" cname))) (setf cname (replace-regexp cname "_" "-")) (let ((lastcase :other) newcase char res) (dotimes (n (length cname)) (setf char (schar cname n)) (if* (alpha-char-p char) then (setf newcase (if (upper-case-p char) :upper :lower)) (when (or (and (eq lastcase :upper) (eq newcase :lower)) (and (eq lastcase :lower) (eq newcase :upper))) ;; case change... add a dash (push #\- res) (setf newcase :other)) (push (char-downcase char) res) (setf lastcase newcase) else (push char res) (setf lastcase :other))) (read-from-string (coerce (nreverse res) 'string)))) (defun identifier-convert-low-level (cname &key type) (assert (stringp cname)) (if (eq type :constant) (setf cname (format nil "+~A+" cname))) (setf cname (substitute #\- #\_ cname)) (if (eq type :operator) (setf cname (format nil "%~A" cname))) (if (eq type :constant-function) nil) (read-from-string cname)) (defmacro swig-defconstant (string value &key (export T)) (let ((symbol (funcall *swig-identifier-converter* string :type :constant))) `(eval-when (compile load eval) (uffi:def-constant ,symbol ,value ,export)))) (defmacro swig-defun (name &rest rest) (let ((symbol (funcall *swig-identifier-converter* name :type :operator))) `(eval-when (compile load eval) (uffi:def-function (,name ,symbol) ,@rest) (export (quote ,symbol))))) (defmacro swig-def-struct (name &rest fields) "Declare a struct object" (let ((symbol (funcall *swig-identifier-converter* name :type :type))) `(eval-when (compile load eval) (uffi:def-struct ,symbol ,@fields) (export (quote ,symbol))))) ) ;; eval-when %} swig-3.0.8/Lib/swiginit.swg0000664000175000017500000001744512641054563015461 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back * to swig_type_info structures, we need some lookup code at initialization. * The idea is that swig generates all the structures that are needed. * The runtime then collects these partially filled structures. * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * * The generated swig_type_info structures are assigned statically to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a * two-dimensional array. Each row corresponds to a type (there are the same * number of rows as there are in the swig_type_initial array). Each entry in * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #if 0 } /* c-mode */ #endif #endif #if 0 #define SWIGRUNTIME_DEBUG #endif SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; int init; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { /* Initialize the swig_module */ swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; init = 1; } else { init = 0; } /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); if (!module_head) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ iter=module_head; do { if (iter==&swig_module) { /* Our module is already in the list, so there's nothing more to do. */ return; } iter=iter->next; } while (iter!= module_head); /* otherwise we must add our module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ if (init == 0) return; /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ if (swig_module.next != &swig_module) { type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); } if (type) { /* Overwrite clientdata field */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found type %s\n", type->name); #endif if (swig_module.type_initial[i]->clientdata) { type->clientdata = swig_module.type_initial[i]->clientdata; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); #endif } } else { type = swig_module.type_initial[i]; } /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); #endif if (swig_module.next != &swig_module) { ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); #ifdef SWIGRUNTIME_DEBUG if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); #endif } if (ret) { if (type == swig_module.type_initial[i]) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: skip old type %s\n", ret->name); #endif cast->type = ret; ret = 0; } else { /* Check for casting already in the list */ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); #ifdef SWIGRUNTIME_DEBUG if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); #endif if (!ocast) ret = 0; } } if (!ret) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); #endif if (type->cast) { type->cast->prev = cast; cast->next = type->cast; } type->cast = cast; } cast++; } /* Set entry in modules->types array equal to the type */ swig_module.types[i] = type; } swig_module.types[i] = 0; #ifdef SWIGRUNTIME_DEBUG printf("**** SWIG_InitializeModule: Cast List ******\n"); for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; ++j; } printf("---- Total casts: %d\n",j); } printf("**** SWIG_InitializeModule: Cast List ******\n"); #endif } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ SWIGRUNTIME void SWIG_PropagateClientData(void) { size_t i; swig_cast_info *equiv; static int init_run = 0; if (init_run) return; init_run = 1; for (i = 0; i < swig_module.size; i++) { if (swig_module.types[i]->clientdata) { equiv = swig_module.types[i]->cast; while (equiv) { if (!equiv->converter) { if (equiv->type && !equiv->type->clientdata) SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); } equiv = equiv->next; } } } } #ifdef __cplusplus #if 0 { /* c-mode */ #endif } #endif swig-3.0.8/Lib/mzscheme/0000775000175000017500000000000012641054563014702 5ustar williamwilliamswig-3.0.8/Lib/mzscheme/std_pair.i0000664000175000017500000012541312641054563016667 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // // See std_vector.i for the rationale of typemap application // ------------------------------------------------------------------------ %{ #include %} // exported class namespace std { template struct pair { %typemap(in) pair (std::pair* m) { if (SCHEME_PAIRP($input)) { T* x; U* y; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(*x,*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const pair& (std::pair temp, std::pair* m), const pair* (std::pair temp, std::pair* m) { if (SCHEME_PAIRP($input)) { T* x; U* y; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = std::make_pair(*x,*y); $1 = &temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) pair { T* x = new T($1.first); U* y = new U($1.second); Scheme_Object* first = SWIG_NewPointerObj(x,$descriptor(T *), 1); Scheme_Object* second = SWIG_NewPointerObj(y,$descriptor(U *), 1); $result = scheme_make_pair(first,second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (SCHEME_PAIRP($input)) { T* x; U* y; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) != -1 && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) != -1) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (SCHEME_PAIRP($input)) { T* x; U* y; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) != -1 && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) != -1) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // specializations for built-ins %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair (std::pair* m) { if (SCHEME_PAIRP($input)) { U* y; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(CONVERT_FROM(first),*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const pair& (std::pair temp, std::pair* m), const pair* (std::pair temp, std::pair* m) { if (SCHEME_PAIRP($input)) { U* y; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = std::make_pair(CONVERT_FROM(first),*y); $1 = &temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) pair { U* y = new U($1.second); Scheme_Object* second = SWIG_NewPointerObj(y,$descriptor(U *), 1); $result = scheme_make_pair(CONVERT_TO($1.first),second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (SCHEME_PAIRP($input)) { U* y; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) != -1) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (SCHEME_PAIRP($input)) { U* y; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) != -1) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair (std::pair* m) { if (SCHEME_PAIRP($input)) { T* x; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); $1 = std::make_pair(*x,CONVERT_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const pair& (std::pair temp, std::pair* m), const pair* (std::pair temp, std::pair* m) { if (SCHEME_PAIRP($input)) { T* x; Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); temp = std::make_pair(*x,CONVERT_FROM(second)); $1 = &temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) pair { T* x = new T($1.first); Scheme_Object* first = SWIG_NewPointerObj(x,$descriptor(T *), 1); $result = scheme_make_pair(first,CONVERT_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (SCHEME_PAIRP($input)) { T* x; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) != -1 && CHECK(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (SCHEME_PAIRP($input)) { T* x; Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) != -1 && CHECK(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) template<> struct pair { %typemap(in) pair (std::pair* m) { if (SCHEME_PAIRP($input)) { Scheme_Object *first, *second; first = scheme_car($input); second = scheme_cdr($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); $1 = make_pair(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const pair& (std::pair temp, std::pair* m), const pair* (std::pair temp, std::pair* m) { if (SCHEME_PAIRP($input)) { Scheme_Object *first, *second; T *x; first = scheme_car($input); second = scheme_cdr($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); temp = make_pair(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); $1 = &temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) pair { $result = scheme_make_pair(CONVERT_T_TO($1.first), CONVERT_U_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (SCHEME_PAIRP($input)) { Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (SCHEME_PAIRP($input)) { Scheme_Object* first = scheme_car($input); Scheme_Object* second = scheme_cdr($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair* p; if (SWIG_ConvertPtr($input,(void **) &p, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef specialize_std_pair_on_first(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_first(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_first(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_first(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_first(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_second(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_second(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_second(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_second(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_second(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_pair_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); } swig-3.0.8/Lib/mzscheme/std_deque.i0000664000175000017500000000003412641054563017026 0ustar williamwilliam%include swig-3.0.8/Lib/mzscheme/std_common.i0000664000175000017500000000077712641054563017231 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; %{ #include std::string swig_scm_to_string(Scheme_Object* x) { return std::string(SCHEME_STR_VAL(x)); } Scheme_Object* swig_make_string(const std::string& s) { return scheme_make_string(s.c_str()); } %} swig-3.0.8/Lib/mzscheme/mzrun.swg0000664000175000017500000003447712641054563016616 0ustar williamwilliam/* ----------------------------------------------------------------------------- * mzrun.swg * ----------------------------------------------------------------------------- */ #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* Common SWIG API */ #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_MzScheme_ConvertPtr(s, result, type, flags) #define SWIG_NewPointerObj(ptr, type, owner) \ SWIG_MzScheme_NewPointerObj((void *)ptr, type, owner) #define SWIG_MustGetPtr(s, type, argnum, flags) \ SWIG_MzScheme_MustGetPtr(s, type, argnum, flags, FUNC_NAME, argc, argv) #define SWIG_contract_assert(expr,msg) \ if (!(expr)) { \ char *m=(char *) scheme_malloc(strlen(msg)+1000); \ sprintf(m,"SWIG contract, assertion failed: function=%s, message=%s", \ (char *) FUNC_NAME,(char *) msg); \ scheme_signal_error(m); \ } /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_MzScheme_GetModule((Scheme_Env *)(clientdata)) #define SWIG_SetModule(clientdata, pointer) SWIG_MzScheme_SetModule((Scheme_Env *) (clientdata), pointer) #define SWIG_MODULE_CLIENTDATA_TYPE Scheme_Env * /* MzScheme-specific SWIG API */ #define SWIG_malloc(size) SWIG_MzScheme_Malloc(size, FUNC_NAME) #define SWIG_free(mem) free(mem) #define SWIG_NewStructFromPtr(ptr,type) \ _swig_convert_struct_##type##(ptr) #define MAXVALUES 6 #define swig_make_boolean(b) (b ? scheme_true : scheme_false) static long SWIG_convert_integer(Scheme_Object *o, long lower_bound, long upper_bound, const char *func_name, int argnum, int argc, Scheme_Object **argv) { long value; int status = scheme_get_int_val(o, &value); if (!status) scheme_wrong_type(func_name, "integer", argnum, argc, argv); if (value < lower_bound || value > upper_bound) scheme_wrong_type(func_name, "integer", argnum, argc, argv); return value; } static int SWIG_is_integer(Scheme_Object *o) { long value; return scheme_get_int_val(o, &value); } static unsigned long SWIG_convert_unsigned_integer(Scheme_Object *o, unsigned long lower_bound, unsigned long upper_bound, const char *func_name, int argnum, int argc, Scheme_Object **argv) { unsigned long value; int status = scheme_get_unsigned_int_val(o, &value); if (!status) scheme_wrong_type(func_name, "integer", argnum, argc, argv); if (value < lower_bound || value > upper_bound) scheme_wrong_type(func_name, "integer", argnum, argc, argv); return value; } static int SWIG_is_unsigned_integer(Scheme_Object *o) { unsigned long value; return scheme_get_unsigned_int_val(o, &value); } /* ----------------------------------------------------------------------- * mzscheme 30X support code * ----------------------------------------------------------------------- */ #ifndef SCHEME_STR_VAL #define MZSCHEME30X 1 #endif #ifdef MZSCHEME30X /* * This is MZSCHEME 299.100 or higher (30x). From version 299.100 of * mzscheme upwards, strings are in unicode. These functions convert * to and from utf8 encodings of these strings. NB! strlen(s) will be * the size in bytes of the string, not the actual length. */ #define SCHEME_STR_VAL(obj) SCHEME_BYTE_STR_VAL(scheme_char_string_to_byte_string(obj)) #define SCHEME_STRLEN_VAL(obj) SCHEME_BYTE_STRLEN_VAL(scheme_char_string_to_byte_string(obj)) #define SCHEME_STRINGP(obj) SCHEME_CHAR_STRINGP(obj) #define scheme_make_string(s) scheme_make_utf8_string(s) #define scheme_make_sized_string(s,l) scheme_make_sized_utf8_string(s,l) #define scheme_make_sized_offset_string(s,d,l) \ scheme_make_sized_offset_utf8_string(s,d,l) #define SCHEME_MAKE_STRING(s) scheme_make_utf8_string(s) #else #define SCHEME_MAKE_STRING(s) scheme_make_string_without_copying(s) #endif /* ----------------------------------------------------------------------- * End of mzscheme 30X support code * ----------------------------------------------------------------------- */ struct swig_mz_proxy { Scheme_Type mztype; swig_type_info *type; void *object; }; static Scheme_Type swig_type; static void mz_free_swig(void *p, void *data) { struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) p; if (SCHEME_NULLP((Scheme_Object*)p) || SCHEME_TYPE((Scheme_Object*)p) != swig_type) return; if (proxy->type) { if (proxy->type->clientdata) { ((Scheme_Prim *)proxy->type->clientdata)(1, (Scheme_Object **)&proxy); } } } static Scheme_Object * SWIG_MzScheme_NewPointerObj(void *ptr, swig_type_info *type, int owner) { struct swig_mz_proxy *new_proxy; new_proxy = (struct swig_mz_proxy *) scheme_malloc(sizeof(struct swig_mz_proxy)); new_proxy->mztype = swig_type; new_proxy->type = type; new_proxy->object = ptr; if (owner) { scheme_add_finalizer(new_proxy, mz_free_swig, NULL); } return (Scheme_Object *) new_proxy; } static int SWIG_MzScheme_ConvertPtr(Scheme_Object *s, void **result, swig_type_info *type, int flags) { swig_cast_info *cast; if (SCHEME_NULLP(s)) { *result = NULL; return 0; } else if (SCHEME_TYPE(s) == swig_type) { struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) s; if (type) { cast = SWIG_TypeCheckStruct(proxy->type, type); if (cast) { int newmemory = 0; *result = SWIG_TypeCast(cast, proxy->object, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return 0; } else { return 1; } } else { *result = proxy->object; return 0; } } return 1; } static SWIGINLINE void * SWIG_MzScheme_MustGetPtr(Scheme_Object *s, swig_type_info *type, int argnum, int flags, const char *func_name, int argc, Scheme_Object **argv) { void *result; if (SWIG_MzScheme_ConvertPtr(s, &result, type, flags)) { scheme_wrong_type(func_name, type->str ? type->str : "void *", argnum - 1, argc, argv); } return result; } static SWIGINLINE void * SWIG_MzScheme_Malloc(size_t size, const char *func_name) { void *p = malloc(size); if (p == NULL) { scheme_signal_error("swig-memory-error"); } else return p; } static Scheme_Object * SWIG_MzScheme_PackageValues(int num, Scheme_Object **values) { /* ignore first value if void */ if (num > 0 && SCHEME_VOIDP(values[0])) num--, values++; if (num == 0) return scheme_void; else if (num == 1) return values[0]; else return scheme_values(num, values); } #ifndef scheme_make_inspector #define scheme_make_inspector(x,y) \ _scheme_apply(scheme_builtin_value("make-inspector"), x, y) #endif /* Function to create a new struct. */ static Scheme_Object * SWIG_MzScheme_new_scheme_struct (Scheme_Env* env, const char* basename, int num_fields, char** field_names) { Scheme_Object *new_type; int count_out, i; Scheme_Object **struct_names; Scheme_Object **vals; Scheme_Object **a = (Scheme_Object**) \ scheme_malloc(num_fields*sizeof(Scheme_Object*)); for (i=0; i #else #include #endif static char **mz_dlopen_libraries=NULL; static void **mz_libraries=NULL; static char **mz_dynload_libpaths=NULL; static void mz_set_dlopen_libraries(const char *_libs) { int i,k,n; int mz_dynload_debug=(1==0); char *extra_paths[1000]; char *EP; { char *dbg=getenv("MZ_DYNLOAD_DEBUG"); if (dbg!=NULL) { mz_dynload_debug=atoi(dbg); } } { char *ep=getenv("MZ_DYNLOAD_LIBPATH"); int i,k,j; k=0; if (ep!=NULL) { EP=strdup(ep); for(i=0,j=0;EP[i]!='\0';i++) { if (EP[i]==':') { EP[i]='\0'; extra_paths[k++]=&EP[j]; j=i+1; } } if (j!=i) { extra_paths[k++]=&EP[j]; } } else { EP=strdup(""); } extra_paths[k]=NULL; k+=1; if (mz_dynload_debug) { fprintf(stderr,"SWIG:mzscheme:MZ_DYNLOAD_LIBPATH=%s\n",(ep==NULL) ? "(null)" : ep); fprintf(stderr,"SWIG:mzscheme:extra_paths[%d]\n",k-1); for(i=0;i %p\n",libp,mz_libraries[i]); } free(libp); } } } } { int i; void *func=NULL; for(i=0;mz_dlopen_libraries[i]!=NULL && func==NULL;i++) { if (mz_libraries[i]!=NULL) { #ifdef __OS_WIN32 func=GetProcAddress(mz_libraries[i],function); #else func=dlsym(mz_libraries[i],function); #endif } if (mz_dynload_debug) { fprintf(stderr, "SWIG:mzscheme:library:%s;dlopen=%p,function=%s,func=%p\n", mz_dlopen_libraries[i],mz_libraries[i],function,func ); } } return func; } } } /* The interpreter will store a pointer to this structure in a global variable called swig-runtime-data-type-pointer. The instance of this struct is only used if no other module has yet been loaded */ struct swig_mzscheme_runtime_data { swig_module_info *module_head; Scheme_Type type; }; static struct swig_mzscheme_runtime_data swig_mzscheme_runtime_data; static swig_module_info * SWIG_MzScheme_GetModule(Scheme_Env *env) { Scheme_Object *pointer, *symbol; struct swig_mzscheme_runtime_data *data; /* first check if pointer already created */ symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); pointer = scheme_lookup_global(symbol, env); if (pointer && SCHEME_CPTRP(pointer)) { data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer); swig_type = data->type; return data->module_head; } else { return NULL; } } static void SWIG_MzScheme_SetModule(Scheme_Env *env, swig_module_info *module) { Scheme_Object *pointer, *symbol; struct swig_mzscheme_runtime_data *data; /* first check if pointer already created */ symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); pointer = scheme_lookup_global(symbol, env); if (pointer && SCHEME_CPTRP(pointer)) { data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer); swig_type = data->type; data->module_head = module; } else { /* create a new type for wrapped pointer values */ swig_type = scheme_make_type((char *)"swig"); swig_mzscheme_runtime_data.module_head = module; swig_mzscheme_runtime_data.type = swig_type; /* create a new pointer */ #ifndef MZSCHEME30X pointer = scheme_make_cptr((void *) &swig_mzscheme_runtime_data, "swig_mzscheme_runtime_data"); #else pointer = scheme_make_cptr((void *) &swig_mzscheme_runtime_data, scheme_make_byte_string("swig_mzscheme_runtime_data")); #endif scheme_add_global_symbol(symbol, pointer, env); } } #ifdef __cplusplus } #endif swig-3.0.8/Lib/mzscheme/std_map.i0000664000175000017500000017617412641054563016523 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // // The aim of all that follows would be to integrate std::map with // MzScheme as much as possible, namely, to allow the user to pass and // be returned Scheme association lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::map), f(const std::map&), f(const std::map*): // the parameter being read-only, either a Scheme alist or a // previously wrapped std::map can be passed. // -- f(std::map&), f(std::map*): // the parameter must be modified; therefore, only a wrapped std::map // can be passed. // -- std::map f(): // the map is returned by copy; therefore, a Scheme alist // is returned which is most easily used in other Scheme functions // -- std::map& f(), std::map* f(), const std::map& f(), // const std::map* f(): // the map is returned by reference; therefore, a wrapped std::map // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { %typemap(in) map (std::map* m) { if (SCHEME_NULLP($input)) { $1 = std::map(); } else if (SCHEME_PAIRP($input)) { $1 = std::map(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; T* x; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[*k] = *x; alist = scheme_cdr(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (SCHEME_NULLP($input)) { temp = std::map(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::map(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; T* x; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[*k] = *x; alist = scheme_cdr(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { Scheme_Object* alist = scheme_null; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); Scheme_Object* x = SWIG_NewPointerObj(val,$descriptor(T *), 1); Scheme_Object* entry = scheme_make_pair(k,x); alist = scheme_make_pair(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { /* native sequence? */ if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ K* k; T* x; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) == -1) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { /* wrapped map? */ std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { /* native sequence? */ if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ K* k; T* x; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) == -1) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { /* wrapped map? */ std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(const K& key, const T& x) { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scheme_make_pair(k,result); } return result; } } }; // specializations for built-ins %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { if (SCHEME_NULLP($input)) { $1 = std::map(); } else if (SCHEME_PAIRP($input)) { $1 = std::map(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { T* x; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[CONVERT_FROM(key)] = *x; alist = scheme_cdr(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (SCHEME_NULLP($input)) { temp = std::map(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::map(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { T* x; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[CONVERT_FROM(key)] = *x; alist = scheme_cdr(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { Scheme_Object* alist = scheme_null; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { T* val = new T(i->second); Scheme_Object* k = CONVERT_TO(i->first); Scheme_Object* x = SWIG_NewPointerObj(val,$descriptor(T *), 1); Scheme_Object* entry = scheme_make_pair(k,x); alist = scheme_make_pair(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only T* x; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only T* x; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(K key, const T& x) { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { std::map::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { Scheme_Object* k = CONVERT_TO(i->first); result = scheme_make_pair(k,result); } return result; } } }; %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { if (SCHEME_NULLP($input)) { $1 = std::map(); } else if (SCHEME_PAIRP($input)) { $1 = std::map(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[*k] = CONVERT_FROM(val); alist = scheme_cdr(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (SCHEME_NULLP($input)) { temp = std::map(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::map(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[*k] = CONVERT_FROM(val); alist = scheme_cdr(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { Scheme_Object* alist = scheme_null; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); Scheme_Object* x = CONVERT_TO(i->second); Scheme_Object* entry = scheme_make_pair(k,x); alist = scheme_make_pair(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only K* k; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) == -1) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (CHECK(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only K* k; Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) == -1) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (CHECK(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(const K& key, T x) { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scheme_make_pair(k,result); } return result; } } }; %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) template<> class map { %typemap(in) map (std::map* m) { if (SCHEME_NULLP($input)) { $1 = std::map(); } else if (SCHEME_PAIRP($input)) { $1 = std::map(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = scheme_cdr(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (SCHEME_NULLP($input)) { temp = std::map(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::map(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { Scheme_Object *entry, *key, *val; entry = scheme_car(alist); if (!SCHEME_PAIRP(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = scheme_car(entry); val = scheme_cdr(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = scheme_cdr(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { Scheme_Object* alist = scheme_null; for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { Scheme_Object* k = CONVERT_K_TO(i->first); Scheme_Object* x = CONVERT_T_TO(i->second); Scheme_Object* entry = scheme_make_pair(k,x); alist = scheme_make_pair(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (CHECK_T(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { // check the first element only Scheme_Object* head = scheme_car($input); if (SCHEME_PAIRP(head)) { Scheme_Object* key = scheme_car(head); Scheme_Object* val = scheme_cdr(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; } else if (SCHEME_PAIRP(val)) { val = scheme_car(val); if (CHECK_T(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(K key, T x) { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { std::map::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; for (std::map::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { Scheme_Object* k = CONVERT_K_TO(i->first); result = scheme_make_pair(k,result); } return result; } } }; %enddef specialize_std_map_on_key(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_key(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_key(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_key(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_key(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_value(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_value(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_value(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_value(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_value(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(double,SCHEME_REALP, scheme_real_to_double,scheme_make_double, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(float,SCHEME_REALP, scheme_real_to_double,scheme_make_double, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, bool,SCHEME_BOOLP, SCHEME_TRUEP,swig_make_boolean); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned int,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned short,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, unsigned long,SCHEME_INTP, SCHEME_INT_VAL,scheme_make_integer_value); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, double,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, float,SCHEME_REALP, scheme_real_to_double,scheme_make_double); specialize_std_map_on_both(std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string, std::string,SCHEME_STRINGP, swig_scm_to_string,swig_make_string); } swig-3.0.8/Lib/mzscheme/std_string.i0000664000175000017500000000263312641054563017240 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string types * ----------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ // std::string is typemapped by value // This can prevent exporting methods which return a string // in order for the user to modify it. // However, I think I'll wait until someone asks for it... // ------------------------------------------------------------------------ %include %{ #include %} namespace std { %naturalvar string; class string; /* Overloading check */ %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; %typemap(in) string { if (SCHEME_STRINGP($input)) $1.assign(SCHEME_STR_VAL($input)); else SWIG_exception(SWIG_TypeError, "string expected"); } %typemap(in) const string & ($*1_ltype temp) { if (SCHEME_STRINGP($input)) { temp.assign(SCHEME_STR_VAL($input)); $1 = &temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(out) string { $result = scheme_make_string($1.c_str()); } %typemap(out) const string & { $result = scheme_make_string($1->c_str()); } } swig-3.0.8/Lib/mzscheme/mzscheme.swg0000664000175000017500000000346412641054563017246 0ustar williamwilliam/* ----------------------------------------------------------------------------- * mzscheme.swg * * SWIG Configuration File for MzScheme. * This file is parsed by SWIG before reading any other interface file. * ----------------------------------------------------------------------------- */ /* Include headers */ %runtime "swigrun.swg" // Common C API type-checking code %runtime "mzrun.swg" %define SWIG_APPEND_VALUE(value) values[lenv++] = value %enddef /* Definitions */ #define SWIG_malloc(size) swig_malloc(size, FUNC_NAME) #define SWIG_free(mem) free(mem) #define SWIG_convert_short(o) \ SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \ (1 << (8 * sizeof(short) - 1)) - 1, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_int(o) \ SWIG_convert_integer(o, INT_MIN, INT_MAX, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_long(o) \ SWIG_convert_integer(o, LONG_MIN, LONG_MAX, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_unsigned_short(o) \ SWIG_convert_unsigned_integer(o, 0, \ (1 << (8 * sizeof(short))) - 1, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_unsigned_int(o) \ SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \ FUNC_NAME, $argnum-1, argc, argv) #define SWIG_convert_unsigned_long(o) \ SWIG_convert_unsigned_integer(o, 0, ULONG_MAX, \ FUNC_NAME, $argnum-1, argc, argv) /* Guile compatibility kludges */ #define SCM_VALIDATE_VECTOR(argnum, value) (void)0 #define SCM_VALIDATE_LIST(argnum, value) (void)0 /* Read in standard typemaps. */ %include %insert(init) "swiginit.swg" %init %{ Scheme_Object *scheme_reload(Scheme_Env *env) { Scheme_Env *menv = SWIG_MZSCHEME_CREATE_MENV(env); SWIG_InitializeModule((void *) env); %} swig-3.0.8/Lib/mzscheme/stl.i0000664000175000017500000000054412641054563015661 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/mzscheme/Makefile0000664000175000017500000000003512641054563016340 0ustar williamwilliam co: co RCS/*.i* RCS/*.swg* swig-3.0.8/Lib/mzscheme/typemaps.i0000664000175000017500000002432512641054563016724 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * ----------------------------------------------------------------------------- */ /* The MzScheme module handles all types uniformly via typemaps. Here are the definitions. */ /* Pointers */ %typemap(in) SWIGTYPE * { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); } %typemap(in) void * { $1 = SWIG_MustGetPtr($input, NULL, $argnum, 0); } %typemap(varin) SWIGTYPE * { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, 1, 0); } %typemap(varin) SWIGTYPE & { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin) SWIGTYPE && { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin) SWIGTYPE [ANY] { void *temp; int ii; $1_basetype *b = 0; temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); b = ($1_basetype *) $1; for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); } %typemap(varin) void * { $1 = SWIG_MustGetPtr($input, NULL, 1, 0); } %typemap(out) SWIGTYPE * { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } %typemap(out) SWIGTYPE *DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); $result = SWIG_NewPointerObj ($1, ty, $owner); } %typemap(varout) SWIGTYPE *, SWIGTYPE [] { $result = SWIG_NewPointerObj ($1, $descriptor, 0); } %typemap(varout) SWIGTYPE & { $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); } %typemap(varout) SWIGTYPE && { $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); } /* C++ References */ #ifdef __cplusplus %typemap(in) SWIGTYPE &, SWIGTYPE && { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); if ($1 == NULL) scheme_signal_error("swig-type-error (null reference)"); } %typemap(out) SWIGTYPE &, SWIGTYPE && { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } %typemap(out) SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); $result = SWIG_NewPointerObj ($1, ty, $owner); } #endif /* Arrays */ %typemap(in) SWIGTYPE[] { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); } %typemap(out) SWIGTYPE[] { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } /* Enums */ %typemap(in) enum SWIGTYPE { if (!SWIG_is_integer($input)) scheme_wrong_type(FUNC_NAME, "integer", $argnum - 1, argc, argv); $1 = ($1_type) SWIG_convert_int($input); } %typemap(varin) enum SWIGTYPE { if (!SWIG_is_integer($input)) scheme_wrong_type(FUNC_NAME, "integer", 0, argc, argv); $1 = ($1_type) SWIG_convert_int($input); } %typemap(out) enum SWIGTYPE "$result = scheme_make_integer_value($1);"; %typemap(varout) enum SWIGTYPE "$result = scheme_make_integer_value($1);"; /* Pass-by-value */ %typemap(in) SWIGTYPE($&1_ltype argp) { argp = ($&1_ltype) SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); $1 = *argp; } %typemap(varin) SWIGTYPE { $&1_ltype argp; argp = ($&1_ltype) SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); $1 = *argp; } %typemap(out) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; resultptr = new $1_ltype(($1_ltype &) $1); $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 1); } #else { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); } #endif %typemap(varout) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; resultptr = new $1_ltype(($1_ltype &) $1); $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 0); } #else { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); } #endif /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. */ %define SIMPLE_MAP(C_NAME, MZ_PREDICATE, MZ_TO_C, C_TO_MZ, MZ_NAME) %typemap(in) C_NAME { if (!MZ_PREDICATE($input)) scheme_wrong_type(FUNC_NAME, #MZ_NAME, $argnum - 1, argc, argv); $1 = MZ_TO_C($input); } %typemap(varin) C_NAME { if (!MZ_PREDICATE($input)) scheme_wrong_type(FUNC_NAME, #MZ_NAME, 0, argc, argv); $1 = MZ_TO_C($input); } %typemap(out) C_NAME { $result = C_TO_MZ($1); } %typemap(varout) C_NAME { $result = C_TO_MZ($1); } %typemap(in) C_NAME *INPUT (C_NAME temp) { temp = (C_NAME) MZ_TO_C($input); $1 = &temp; } %typemap(in,numinputs=0) C_NAME *OUTPUT (C_NAME temp) { $1 = &temp; } %typemap(argout) C_NAME *OUTPUT { Scheme_Object *s; s = C_TO_MZ(*$1); SWIG_APPEND_VALUE(s); } %typemap(in) C_NAME *BOTH = C_NAME *INPUT; %typemap(argout) C_NAME *BOTH = C_NAME *OUTPUT; %typemap(in) C_NAME *INOUT = C_NAME *INPUT; %typemap(argout) C_NAME *INOUT = C_NAME *OUTPUT; %enddef SIMPLE_MAP(bool, SCHEME_BOOLP, SCHEME_TRUEP, swig_make_boolean, boolean); SIMPLE_MAP(char, SCHEME_CHARP, SCHEME_CHAR_VAL, scheme_make_character, character); SIMPLE_MAP(unsigned char, SCHEME_CHARP, SCHEME_CHAR_VAL, scheme_make_character, character); SIMPLE_MAP(int, SWIG_is_integer, SWIG_convert_int, scheme_make_integer_value, integer); SIMPLE_MAP(short, SWIG_is_integer, SWIG_convert_short, scheme_make_integer_value, integer); SIMPLE_MAP(long, SWIG_is_integer, SWIG_convert_long, scheme_make_integer_value, integer); SIMPLE_MAP(ptrdiff_t, SWIG_is_integer, SWIG_convert_long, scheme_make_integer_value, integer); SIMPLE_MAP(unsigned int, SWIG_is_unsigned_integer, SWIG_convert_unsigned_int, scheme_make_integer_value_from_unsigned, integer); SIMPLE_MAP(unsigned short, SWIG_is_unsigned_integer, SWIG_convert_unsigned_short, scheme_make_integer_value_from_unsigned, integer); SIMPLE_MAP(unsigned long, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, scheme_make_integer_value_from_unsigned, integer); SIMPLE_MAP(size_t, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, scheme_make_integer_value_from_unsigned, integer); SIMPLE_MAP(float, SCHEME_REALP, scheme_real_to_double, scheme_make_double, real); SIMPLE_MAP(double, SCHEME_REALP, scheme_real_to_double, scheme_make_double, real); SIMPLE_MAP(char *, SCHEME_STRINGP, SCHEME_STR_VAL, SCHEME_MAKE_STRING, string); SIMPLE_MAP(const char *, SCHEME_STRINGP, SCHEME_STR_VAL, SCHEME_MAKE_STRING, string); /* For MzScheme 30x: Use these typemaps if you are not going to use UTF8 encodings in your C code. SIMPLE_MAP(char *,SCHEME_BYTE_STRINGP, SCHEME_BYTE_STR_VAL, scheme_make_byte_string_without_copying,bytestring); SIMPLE_MAP(const char *,SCHEME_BYTE_STRINGP, SCHEME_BYTE_STR_VAL, scheme_make_byte_string_without_copying,bytestring); */ /* Const primitive references. Passed by value */ %define REF_MAP(C_NAME, MZ_PREDICATE, MZ_TO_C, C_TO_MZ, MZ_NAME) %typemap(in) const C_NAME & (C_NAME temp) { if (!MZ_PREDICATE($input)) scheme_wrong_type(FUNC_NAME, #MZ_NAME, $argnum - 1, argc, argv); temp = MZ_TO_C($input); $1 = &temp; } %typemap(out) const C_NAME & { $result = C_TO_MZ(*$1); } %enddef REF_MAP(bool, SCHEME_BOOLP, SCHEME_TRUEP, swig_make_boolean, boolean); REF_MAP(char, SCHEME_CHARP, SCHEME_CHAR_VAL, scheme_make_character, character); REF_MAP(unsigned char, SCHEME_CHARP, SCHEME_CHAR_VAL, scheme_make_character, character); REF_MAP(int, SWIG_is_integer, SWIG_convert_int, scheme_make_integer_value, integer); REF_MAP(short, SWIG_is_integer, SWIG_convert_short, scheme_make_integer_value, integer); REF_MAP(long, SWIG_is_integer, SWIG_convert_long, scheme_make_integer_value, integer); REF_MAP(unsigned int, SWIG_is_unsigned_integer, SWIG_convert_unsigned_int, scheme_make_integer_value_from_unsigned, integer); REF_MAP(unsigned short, SWIG_is_unsigned_integer, SWIG_convert_unsigned_short, scheme_make_integer_value_from_unsigned, integer); REF_MAP(unsigned long, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, scheme_make_integer_value_from_unsigned, integer); REF_MAP(float, SCHEME_REALP, scheme_real_to_double, scheme_make_double, real); REF_MAP(double, SCHEME_REALP, scheme_real_to_double, scheme_make_double, real); /* Void */ %typemap(out) void "$result = scheme_void;"; /* Pass through Scheme_Object * */ %typemap (in) Scheme_Object * "$1=$input;"; %typemap (out) Scheme_Object * "$result=$1;"; %typecheck(SWIG_TYPECHECK_POINTER) Scheme_Object * "$1=1;"; /* ------------------------------------------------------------ * String & length * ------------------------------------------------------------ */ //%typemap(in) (char *STRING, int LENGTH) { // int temp; // $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp); // $2 = ($2_ltype) temp; //} /* ------------------------------------------------------------ * Typechecking rules * ------------------------------------------------------------ */ %typecheck(SWIG_TYPECHECK_INTEGER) int, short, long, unsigned int, unsigned short, unsigned long, signed char, unsigned char, long long, unsigned long long, const int &, const short &, const long &, const unsigned int &, const unsigned short &, const unsigned long &, const long long &, const unsigned long long &, enum SWIGTYPE { $1 = (SWIG_is_integer($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_BOOL) bool, bool &, const bool & { $1 = (SCHEME_BOOLP($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) float, double, const float &, const double & { $1 = (SCHEME_REALP($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_STRING) char { $1 = (SCHEME_STRINGP($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = (SCHEME_STRINGP($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; if (SWIG_ConvertPtr($input, (void **) &ptr, 0, 0)) { $1 = 0; } else { $1 = 1; } } /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-3.0.8/Lib/mzscheme/std_vector.i0000664000175000017500000004262312641054563017237 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // MzScheme as much as possible, namely, to allow the user to pass and // be returned MzScheme vectors or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&), f(const std::vector*): // the parameter being read-only, either a MzScheme sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(): // the vector is returned by copy; therefore, a MzScheme vector of T:s // is returned which is most easily used in other MzScheme functions // -- std::vector& f(), std::vector* f(), const std::vector& f(), // const std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class vector { %typemap(in) vector { if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); $1 = std::vector(size); Scheme_Object** items = SCHEME_VEC_ELS($input); for (unsigned int i=0; i(); } else if (SCHEME_PAIRP($input)) { Scheme_Object *head, *tail; $1 = std::vector(); tail = $input; while (!SCHEME_NULLP(tail)) { head = scheme_car(tail); tail = scheme_cdr(tail); $1.push_back(*((T*)SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const vector& (std::vector temp), const vector* (std::vector temp) { if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); temp = std::vector(size); $1 = &temp; Scheme_Object** items = SCHEME_VEC_ELS($input); for (unsigned int i=0; i(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::vector(); $1 = &temp; Scheme_Object *head, *tail; tail = $input; while (!SCHEME_NULLP(tail)) { head = scheme_car(tail); tail = scheme_cdr(tail); temp.push_back(*((T*) SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) vector { $result = scheme_make_vector($1.size(),scheme_undefined); Scheme_Object** els = SCHEME_VEC_ELS($result); for (unsigned int i=0; i<$1.size(); i++) { T* x = new T((($1_type &)$1)[i]); els[i] = SWIG_NewPointerObj(x,$descriptor(T *), 1); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; Scheme_Object** items = SCHEME_VEC_ELS($input); if (SWIG_ConvertPtr(items[0],(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } } else if (SCHEME_NULLP($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ T* x; Scheme_Object *head = scheme_car($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; Scheme_Object** items = SCHEME_VEC_ELS($input); if (SWIG_ConvertPtr(items[0],(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } } else if (SCHEME_NULLP($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ T* x; Scheme_Object *head = scheme_car($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { /* wrapped vector? */ std::vector* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); %rename(length) size; unsigned int size() const; %rename("empty?") empty; bool empty() const; %rename("clear!") clear; void clear(); %rename("set!") set; %rename("pop!") pop; %rename("push!") push_back; void push_back(const T& x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T& ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { %typemap(in) vector { if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); $1 = std::vector(size); Scheme_Object** items = SCHEME_VEC_ELS($input); for (unsigned int i=0; i", $argnum - 1, argc, argv); } } else if (SCHEME_NULLP($input)) { $1 = std::vector(); } else if (SCHEME_PAIRP($input)) { Scheme_Object *head, *tail; $1 = std::vector(); tail = $input; while (!SCHEME_NULLP(tail)) { head = scheme_car(tail); tail = scheme_cdr(tail); if (CHECK(head)) $1.push_back((T)(CONVERT_FROM(head))); else scheme_wrong_type(FUNC_NAME, "vector<" #T ">", $argnum - 1, argc, argv); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const vector& (std::vector temp), const vector* (std::vector temp) { if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); temp = std::vector(size); $1 = &temp; Scheme_Object** items = SCHEME_VEC_ELS($input); for (unsigned int i=0; i", $argnum - 1, argc, argv); } } else if (SCHEME_NULLP($input)) { temp = std::vector(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { temp = std::vector(); $1 = &temp; Scheme_Object *head, *tail; tail = $input; while (!SCHEME_NULLP(tail)) { head = scheme_car(tail); tail = scheme_cdr(tail); if (CHECK(head)) temp.push_back((T)(CONVERT_FROM(head))); else scheme_wrong_type(FUNC_NAME, "vector<" #T ">", $argnum - 1, argc, argv); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum - 1, 0); } } %typemap(out) vector { $result = scheme_make_vector($1.size(),scheme_undefined); Scheme_Object** els = SCHEME_VEC_ELS($result); for (unsigned int i=0; i<$1.size(); i++) els[i] = CONVERT_TO((($1_type &)$1)[i]); } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; Scheme_Object** items = SCHEME_VEC_ELS($input); $1 = CHECK(items[0]) ? 1 : 0; } } else if (SCHEME_NULLP($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ T* x; Scheme_Object *head = scheme_car($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ std::vector* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) ? 1 : 0; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ if (SCHEME_VECTORP($input)) { unsigned int size = SCHEME_VEC_SIZE($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; Scheme_Object** items = SCHEME_VEC_ELS($input); $1 = CHECK(items[0]) ? 1 : 0; } } else if (SCHEME_NULLP($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (SCHEME_PAIRP($input)) { /* check the first element only */ T* x; Scheme_Object *head = scheme_car($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ std::vector* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) ? 1 : 0; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); %rename(length) size; unsigned int size() const; %rename("empty?") empty; bool empty() const; %rename("clear!") clear; void clear(); %rename("set!") set; %rename("pop!") pop; %rename("push!") push_back; void push_back(T x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i %} /* A really cut down version of the pair class. this is not useful on its own - it needs a %template definition with it eg. namespace std { %template(IntPair) pair; %template(make_IntPair) make_pair; } */ namespace std { template struct pair { typedef T first_type; typedef U second_type; pair(); pair(T first, U second); pair(const pair& p); T first; U second; }; template pair make_pair(const T&,const U&); } swig-3.0.8/Lib/lua/std_except.i0000664000175000017500000000352712641054563016173 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Typemaps used by the STL wrappers that throw exceptions. * These typemaps are used when methods are declared with an STL exception * specification, such as: * size_t at() const throw (std::out_of_range); * * std_except.i * ----------------------------------------------------------------------------- */ %{ #include %} %include namespace std { %ignore exception; // not sure if I should ignore this... class exception { public: exception() throw() { } virtual ~exception() throw(); virtual const char* what() const throw(); }; } // normally objects which are thrown are returned to the interpreter as errors // (which potentially may have problems if they are not copied) // therefore all classes based upon std::exception are converted to their strings & returned as errors %typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());" %typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());" %typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());" %typemap(throws) std::invalid_argument "SWIG_exception(SWIG_ValueError, $1.what());" %typemap(throws) std::length_error "SWIG_exception(SWIG_IndexError, $1.what());" %typemap(throws) std::logic_error "SWIG_exception(SWIG_RuntimeError, $1.what());" %typemap(throws) std::out_of_range "SWIG_exception(SWIG_IndexError, $1.what());" %typemap(throws) std::overflow_error "SWIG_exception(SWIG_OverflowError, $1.what());" %typemap(throws) std::range_error "SWIG_exception(SWIG_IndexError, $1.what());" %typemap(throws) std::runtime_error "SWIG_exception(SWIG_RuntimeError, $1.what());" %typemap(throws) std::underflow_error "SWIG_exception(SWIG_RuntimeError, $1.what());" swig-3.0.8/Lib/lua/luatypemaps.swg0000664000175000017500000003365112641054563016746 0ustar williamwilliam/* ----------------------------------------------------------------------------- * luatypemaps.swg * * basic typemaps for Lua. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * standard typemaps * ----------------------------------------------------------------------------- */ /* NEW LANGUAGE NOTE: the 'checkfn' param is something that I added for typemap(in) it is an optional fn call to check the type of the lua object the fn call must be of the form int checkfn(lua_State *L, int index); and return 1/0 depending upon if this is the correct type For the typemap(out), an additional SWIG_arg parameter must be incremented to reflect the number of values returned (normally SWIG_arg++; will do) */ // numbers %typemap(in,checkfn="lua_isnumber") int, short, long, signed char, float, double %{$1 = ($type)lua_tonumber(L, $input);%} // additional check for unsigned numbers, to not permit negative input %typemap(in,checkfn="lua_isnumber") unsigned int, unsigned short, unsigned long, unsigned char %{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative") $1 = ($type)lua_tonumber(L, $input);%} %typemap(out) int,short,long, unsigned int,unsigned short,unsigned long, signed char,unsigned char, float,double %{ lua_pushnumber(L, (lua_Number) $1); SWIG_arg++;%} // we must also provide typemaps for primitives by const reference: // given a function: // int intbyref(const int& i); // SWIG assumes that this code will need a pointer to int to be passed in // (this might be ok for objects by const ref, but not for numeric primitives) // therefore we add a set of typemaps to fix this (for both in & out) %typemap(in,checkfn="lua_isnumber") const int&($basetype temp) %{ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} %typemap(in,checkfn="lua_isnumber") const unsigned int&($basetype temp) %{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative") temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} %typemap(out) const int&, const unsigned int& %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} // for the other numbers we can just use an apply statement to cover them %apply const int & {const short&,const long&,const signed char&, const float&,const double&}; %apply const unsigned int & {const unsigned short&,const unsigned long&, const unsigned char&}; /* enums have to be handled slightly differently VC++ .net will not allow a cast from lua_Number(double) to enum directly. */ %typemap(in,checkfn="lua_isnumber") enum SWIGTYPE %{$1 = ($type)(int)lua_tonumber(L, $input);%} %typemap(out) enum SWIGTYPE %{ lua_pushnumber(L, (lua_Number)(int)($1)); SWIG_arg++;%} // and const refs %typemap(in,checkfn="lua_isnumber") const enum SWIGTYPE &($basetype temp) %{ temp=($basetype)(int)lua_tonumber(L,$input); $1=&temp;%} %typemap(in,checkfn="lua_isnumber") const enum SWIGTYPE &&($basetype temp) %{ temp=($basetype)(int)lua_tonumber(L,$input); $1=&temp;%} %typemap(out) const enum SWIGTYPE & %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} %typemap(out) const enum SWIGTYPE && %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} // boolean (which is a special type in lua) // note: lua_toboolean() returns 1 or 0 // note: 1 & 0 are not booleans in lua, only true & false %typemap(in,checkfn="lua_isboolean") bool %{$1 = (lua_toboolean(L, $input)!=0);%} %typemap(out) bool %{ lua_pushboolean(L,(int)($1!=0)); SWIG_arg++;%} // for const bool&, SWIG treats this as a const bool* so we must dereference it %typemap(in,checkfn="lua_isboolean") const bool& (bool temp) %{temp=(lua_toboolean(L, $input)!=0); $1=&temp;%} %typemap(out) const bool& %{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%} // strings (char * and char[]) %fragment("SWIG_lua_isnilstring", "header") { SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) { int ret = lua_isstring(L, idx); if (!ret) ret = lua_isnil(L, idx); return ret; } } %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char *, char * %{$1 = ($ltype)lua_tostring(L, $input);%} %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char[ANY], char[ANY] %{$1 = ($ltype)lua_tostring(L, $input);%} %typemap(out) const char *, char * %{ lua_pushstring(L,(const char *)$1); SWIG_arg++;%} %typemap(out) const char[ANY], char[ANY] %{ lua_pushstring(L,(const char *)$1); SWIG_arg++;%} // char's // currently treating chars as small strings, not as numbers // (however signed & unsigned char's are numbers...) %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") char %{$1 = (lua_tostring(L, $input))[0];%} %typemap(out) char %{ lua_pushlstring(L, &$1, 1); SWIG_arg++;%} // by const ref %typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char& (char temp) %{temp = (lua_tostring(L, $input))[0]; $1=&temp;%} %typemap(out) const char& %{ lua_pushlstring(L, $1, 1); SWIG_arg++;%} // pointers and references // under SWIG rules, it is ok, to have a pass in a lua nil, // it should be converted to a SWIG NULL. // This will only be allowed for pointers & arrays, not refs or by value // the checkfn lua_isuserdata will only work for userdata // the checkfn SWIG_isptrtype will work for both userdata and nil %typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE*,SWIGTYPE[] %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){ SWIG_fail_ptr("$symname",$argnum,$descriptor); } %} %typemap(in,checkfn="lua_isuserdata") SWIGTYPE& %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){ SWIG_fail_ptr("$symname",$argnum,$descriptor); } %} %typemap(in,checkfn="lua_isuserdata") SWIGTYPE&& %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){ SWIG_fail_ptr("$symname",$argnum,$descriptor); } %} // out is simple %typemap(out) SWIGTYPE*,SWIGTYPE& %{SWIG_NewPointerObj(L,$1,$descriptor,$owner); SWIG_arg++; %} %typemap(out) SWIGTYPE*,SWIGTYPE&& %{SWIG_NewPointerObj(L,$1,$descriptor,$owner); SWIG_arg++; %} // dynamic casts // this uses the SWIG_TypeDynamicCast() which relies on RTTI to find out what the pointer really is // the we return it as the correct type %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); SWIG_NewPointerObj(L,(void*)$1,ty,$owner); SWIG_arg++; } // passing objects by value // SWIG_ConvertPtr wants an object pointer (the $<ype argp) // then dereferences it to get the object %typemap(in,checkfn="lua_isuserdata") SWIGTYPE ($<ype argp) %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&argp,$&descriptor,0))){ SWIG_fail_ptr("$symname",$argnum,$&descriptor); } $1 = *argp; %} // Also needed for object ptrs by const ref // eg A* const& ref_pointer(A* const& a); // found in mixed_types.i %typemap(in,checkfn="lua_isuserdata") SWIGTYPE *const&($*ltype temp) %{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname"); $1=($1_ltype)&temp;%} %typemap(out) SWIGTYPE *const& %{SWIG_NewPointerObj(L,*$1,$*descriptor,$owner); SWIG_arg++; %} // DISOWN-ing typemaps // if you have an object pointer which must be disowned, use this typemap // eg. for void destroy_foo(Foo* toDie); // use %apply SWIGTYPE* DISOWN {Foo* toDie}; // you could just use %delobject, but this is more flexible %typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE* DISOWN,SWIGTYPE DISOWN[] %{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,SWIG_POINTER_DISOWN))){ SWIG_fail_ptr("$symname",$argnum,$descriptor); } %} // Primitive types--return by value // must make a new object, copy the data & return the new object // Note: the brackets are {...} and not %{..%}, because we want them to be included in the wrapper // this is because typemap(out) does not support local variables, like in typemap(in) does // and we need the $&1_ltype resultptr; to be declared #ifdef __cplusplus %typemap(out) SWIGTYPE { $&1_ltype resultptr = new $1_ltype((const $1_ltype &) $1); SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++; } #else %typemap(out) SWIGTYPE { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++; } #endif // member function pointer // a member fn ptr is not 4 bytes like a normal pointer, but 8 bytes (at least on mingw) // so the standard wrapping cannot be done // nor can you cast a member function pointer to a void* (obviously) // therefore a special wrapping functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written #ifdef __cplusplus %typemap(in,checkfn="lua_isuserdata") SWIGTYPE (CLASS::*) %{ if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($type),$descriptor))) SWIG_fail_ptr("$symname",$argnum,$descriptor); %} %typemap(out) SWIGTYPE (CLASS::*) %{ SWIG_NewMemberObj(L,(void*)(&$1),sizeof($type),$descriptor); SWIG_arg++; %} #endif // void (must be empty without the SWIG_arg++) %typemap(out) void ""; /* void* is a special case A function void fn(void*) should take any kind of pointer as a parameter (just like C/C++ does) but if its an output, then it should be wrapped like any other SWIG object (using default typemap) */ %typemap(in,checkfn="SWIG_isptrtype") void* %{$1=($1_ltype)SWIG_MustGetPtr(L,$input,0,0,$argnum,"$symname");%} /* long long is another special case: as lua only supports one numeric type (lua_Number), we will just cast it to that & accept the loss of precision. An alternative solution would be a long long struct or class with the relevant operators. */ %apply long {long long, signed long long, unsigned long long}; %apply const long& {const long long&, const signed long long&, const unsigned long long&}; /* It is possible to also pass a lua_State* into a function, so void fn(int a, float b, lua_State* s) is wrappable as > fn(1,4.3) -- note: the state is implicitly passed in */ %typemap(in, numinputs=0) lua_State* %{$1 = L;%} /* ----------------------------------------------------------------------------- * typecheck rules * ----------------------------------------------------------------------------- */ /* These are needed for the overloaded functions These define the detection routines which will spot what parameters match which function */ // unfortunately lua only considers one type of number // so all numbers (int,float,double) match // you could add an advanced fn to get type & check if its integral %typecheck(SWIG_TYPECHECK_INTEGER) int, short, long, unsigned int, unsigned short, unsigned long, signed char, unsigned char, long long, unsigned long long, signed long long, const int &, const short &, const long &, const unsigned int &, const unsigned short &, const unsigned long &, const signed char&, const unsigned char&, const long long &, const unsigned long long &, enum SWIGTYPE, const enum SWIGTYPE&, const enum SWIGTYPE &&, float, double, const float &, const double& { $1 = lua_isnumber(L,$input); } %typecheck(SWIG_TYPECHECK_BOOL) bool, const bool & { $1 = lua_isboolean(L,$input); } // special check for a char (string of length 1) %typecheck(SWIG_TYPECHECK_CHAR,fragment="SWIG_lua_isnilstring") char, const char& { $1 = SWIG_lua_isnilstring(L,$input) && (lua_rawlen(L,$input)==1); } %typecheck(SWIG_TYPECHECK_STRING,fragment="SWIG_lua_isnilstring") char *, char[] { $1 = SWIG_lua_isnilstring(L,$input); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] { void *ptr; if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, 0)) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, 0, 0)) { $1 = 0; } else { $1 = 1; } } // Also needed for object pointers by const ref // eg const A* ref_pointer(A* const& a); // found in mixed_types.i %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& { void *ptr; if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) { $1 = 0; } else { $1 = 1; } } /* ----------------------------------------------------------------------------- * Others * ----------------------------------------------------------------------------- */ // Array reference typemaps %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } // size_t (which is just a unsigned long) %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; /* ----------------------------------------------------------------------------- * Specials * ----------------------------------------------------------------------------- */ // swig::LANGUAGE_OBJ was added to allow containers of native objects // however its rather difficult to do this in lua, as you cannot hold pointers // to native objects (they are held in the interpreter) // therefore for now: just ignoring this feature #ifdef __cplusplus %ignore swig::LANGUAGE_OBJ; //%inline %{ %{ namespace swig { typedef struct{} LANGUAGE_OBJ; } %} #endif // __cplusplus swig-3.0.8/Lib/lua/carrays.i0000664000175000017500000000040012641054563015460 0ustar williamwilliam/* Small change to the standard carrays.i renaming the field to __getitem & __setitem for operator[] access */ %rename(__getitem) *::getitem; // the v=X[i] (get operator) %rename(__setitem) *::setitem; // the X[i]=v (set operator) %include <../carrays.i> swig-3.0.8/Lib/lua/std_deque.i0000664000175000017500000000003412641054563015774 0ustar williamwilliam%include swig-3.0.8/Lib/lua/std_common.i0000664000175000017500000000014612641054563016165 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.8/Lib/lua/_std_common.i0000664000175000017500000000477212641054563016335 0ustar williamwilliam/* ----------------------------------------------------------------------------- * _std_common.i * * std::helpers for LUA * ----------------------------------------------------------------------------- */ %include // the general exceptions /* The basic idea here, is instead of trying to feed SWIG all the horribly templated STL code, to give it a neatened version. These %defines cover some of the more common methods so the class declarations become just a set of %defines */ /* #define for basic container features note: I allow front(), back() & pop_back() to throw exceptions upon empty containers, rather than coredump (as we haven't defined the methods, we can use %extend to add with new features) */ %define %STD_CONTAINER_METHODS(CLASS,T) public: CLASS(); CLASS(const CLASS&); unsigned int size() const; unsigned int max_size() const; bool empty() const; void clear(); %extend { // the extra stuff which must be checked T front()const throw (std::out_of_range){ // only read front & back if (self->empty()) throw std::out_of_range("in "#CLASS"::front()"); return self->front(); } T back()const throw (std::out_of_range){ // not write to them if (self->empty()) throw std::out_of_range("in "#CLASS"::back()"); return self->back(); } } %enddef /* push/pop for front/back also note: front & back are read only methods, not used for writing */ %define %STD_FRONT_ACCESS_METHODS(CLASS,T) public: void push_front(const T& val); %extend { // must check this void pop_front() throw (std::out_of_range){ if (self->empty()) throw std::out_of_range("in "#CLASS"::pop_front()"); self->pop_back(); } } %enddef %define %STD_BACK_ACCESS_METHODS(CLASS,T) public: void push_back(const T& val); %extend { // must check this void pop_back() throw (std::out_of_range){ if (self->empty()) throw std::out_of_range("in "#CLASS"::pop_back()"); self->pop_back(); } } %enddef /* Random access methods */ %define %STD_RANDOM_ACCESS_METHODS(CLASS,T) %extend // this is a extra bit of SWIG code { // [] is replaced by __getitem__ & __setitem__ // simply throws a string, which causes a lua error T __getitem__(unsigned int idx) throw (std::out_of_range){ if (idx>=self->size()) throw std::out_of_range("in "#CLASS"::__getitem__()"); return (*self)[idx]; } void __setitem__(unsigned int idx,const T& val) throw (std::out_of_range){ if (idx>=self->size()) throw std::out_of_range("in "#CLASS"::__setitem__()"); (*self)[idx]=val; } }; %enddef swig-3.0.8/Lib/lua/factory.i0000664000175000017500000000100712641054563015467 0ustar williamwilliam/* A modification of factory.swg from the generic UTL library. */ %include %define %_factory_dispatch(Type) if (!dcast) { Type *dobj = dynamic_cast($1); if (dobj) { dcast = 1; SWIG_NewPointerObj(L, dobj, $descriptor(Type *), $owner); SWIG_arg++; } }%enddef %define %factory(Method,Types...) %typemap(out) Method { int dcast = 0; %formacro(%_factory_dispatch, Types) if (!dcast) { SWIG_NewPointerObj(L, $1, $descriptor, $owner); SWIG_arg++; } }%enddef swig-3.0.8/Lib/lua/lua_fnptr.i0000664000175000017500000001020412641054563016011 0ustar williamwilliam/* ----------------------------------------------------------------------------- * lua_fnptr.i * * SWIG Library file containing the main typemap code to support Lua modules. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * Basic function pointer support * ----------------------------------------------------------------------------- */ /* The structure: SWIGLUA_FN provides a simple (local only) wrapping for a function. For example if you wanted to have a C/C++ function take a lua function as a parameter. You could declare it as: int my_func(int a, int b, SWIGLUA_FN fn); note: it should be passed by value, not byref or as a pointer. The SWIGLUA_FN holds a pointer to the lua_State, and the stack index where the function is held. The macro SWIGLUA_FN_GET() will put a copy of the lua function at the top of the stack. After that its fairly simple to write the rest of the code (assuming know how to use lua), just push the parameters, call the function and return the result. int my_func(int a, int b, SWIGLUA_FN fn) { SWIGLUA_FN_GET(fn); lua_pushnumber(fn.L,a); lua_pushnumber(fn.L,b); lua_call(fn.L,2,1); // 2 in, 1 out return luaL_checknumber(fn.L,-1); } SWIG will automatically performs the wrapping of the arguments in and out. However: if you wish to store the function between calls, look to the SWIGLUA_REF below. */ // this is for the C code only, we don't want SWIG to wrapper it for us. %{ typedef struct{ lua_State* L; /* the state */ int idx; /* the index on the stack */ }SWIGLUA_FN; #define SWIGLUA_FN_GET(fn) {lua_pushvalue(fn.L,fn.idx);} %} // the actual typemap %typemap(in,checkfn="lua_isfunction") SWIGLUA_FN %{ $1.L=L; $1.idx=$input; %} /* ----------------------------------------------------------------------------- * Storing lua object support * ----------------------------------------------------------------------------- */ /* The structure: SWIGLUA_REF provides a mechanism to store object (usually functions) between calls to the interpreter. For example if you wanted to have a C/C++ function take a lua function as a parameter. Then call it later, You could declare it as: SWIGLUA_REF myref; void set_func(SWIGLUA_REF ref); SWIGLUA_REF get_func(); void call_func(int val); note: it should be passed by value, not byref or as a pointer. The SWIGLUA_REF holds a pointer to the lua_State, and an integer reference to the object. Because it holds a permanent ref to an object, the SWIGLUA_REF must be handled with a bit more care. It should be initialised to {0,0}. The function swiglua_ref_set() should be used to set it. swiglua_ref_clear() should be used to clear it when not in use, and swiglua_ref_get() to get the data back. Note: the typemap does not check that the object is in fact a function, if you need that you must add it yourself. int my_func(int a, int b, SWIGLUA_FN fn) { SWIGLUA_FN_GET(fn); lua_pushnumber(fn.L,a); lua_pushnumber(fn.L,b); lua_call(fn.L,2,1); // 2 in, 1 out return luaL_checknumber(fn.L,-1); } SWIG will automatically performs the wrapping of the arguments in and out. However: if you wish to store the function between calls, look to the SWIGLUA_REF below. */ %{ typedef struct{ lua_State* L; /* the state */ int ref; /* a ref in the lua global index */ }SWIGLUA_REF; void swiglua_ref_clear(SWIGLUA_REF* pref){ if (pref->L!=0 && pref->ref!=LUA_NOREF && pref->ref!=LUA_REFNIL){ luaL_unref(pref->L,LUA_REGISTRYINDEX,pref->ref); } pref->L=0; pref->ref=0; } void swiglua_ref_set(SWIGLUA_REF* pref,lua_State* L,int idx){ pref->L=L; lua_pushvalue(L,idx); /* copy obj to top */ pref->ref=luaL_ref(L,LUA_REGISTRYINDEX); /* remove obj from top & put into registry */ } void swiglua_ref_get(SWIGLUA_REF* pref){ if (pref->L!=0) lua_rawgeti(pref->L,LUA_REGISTRYINDEX,pref->ref); } %} %typemap(in) SWIGLUA_REF %{ swiglua_ref_set(&$1,L,$input); %} %typemap(out) SWIGLUA_REF %{ if ($1.L!=0) {swiglua_ref_get(&$1);} else {lua_pushnil(L);} SWIG_arg++; %} swig-3.0.8/Lib/lua/wchar.i0000664000175000017500000000210612641054563015125 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wchar.i * * Typemaps for the wchar_t type * These are mapped to a Lua string and are passed around by value. * ----------------------------------------------------------------------------- */ // note: only support for pointer right now, not fixed length strings // TODO: determine how long a const wchar_t* is so we can write wstr2str() // & do the output typemap %{ #include wchar_t* str2wstr(const char *str, int len) { wchar_t* p; if (str==0 || len<1) return 0; p=(wchar_t *)malloc((len+1)*sizeof(wchar_t)); if (p==0) return 0; if (mbstowcs(p, str, len)==(size_t)-1) { free(p); return 0; } p[len]=0; return p; } %} %typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t * %{ $1 = str2wstr(lua_tostring( L, $input ),lua_rawlen( L, $input )); if ($1==0) {SWIG_Lua_pushferrstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} %} %typemap(freearg) wchar_t * %{ free($1); %} %typemap(typecheck) wchar_t * = char *; swig-3.0.8/Lib/lua/lua.swg0000664000175000017500000002133212641054563015154 0ustar williamwilliam/* ----------------------------------------------------------------------------- * lua.swg * * SWIG Configuration File for Lua. * This file is parsed by SWIG before reading any other interface file. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * includes * ----------------------------------------------------------------------------- */ %include /* The typemaps */ %include /* The runtime stuff */ %include /* Warnings for Lua keywords */ //%include /* ----------------------------------------------------------------------------- * constants typemaps * ----------------------------------------------------------------------------- */ // this basically adds to a table of constants %typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE {SWIG_LUA_CONSTTAB_INT("$symname", $value)} %typemap(consttab) float, double {SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)} %typemap(consttab) long long, unsigned long long, signed long long {SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)} %typemap(consttab) const long long&, const unsigned long long&, const signed long long& {SWIG_LUA_CONSTTAB_FLOAT("$symname", *$value)} %typemap(consttab) char *, const char *, char [], const char [] {SWIG_LUA_CONSTTAB_STRING("$symname", $value)} // note: char is treated as a seperate special type // signed char & unsigned char are numbers %typemap(consttab) char {SWIG_LUA_CONSTTAB_CHAR("$symname", $value)} %typemap(consttab) long long, unsigned long long {SWIG_LUA_CONSTTAB_STRING("$symname", "$value")} %typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { SWIG_LUA_CONSTTAB_POINTER("$symname",$value, $1_descriptor) } %typemap(consttab) SWIGTYPE { SWIG_LUA_CONSTTAB_POINTER("$symname",&$value, $&1_descriptor) } // member function pointers %typemap(consttab) SWIGTYPE (CLASS::*) { SWIG_LUA_CONSTTAB_BINARY("$symname", sizeof($type),&$value, $1_descriptor) } /* ----------------------------------------------------------------------------- * Overloaded operator support * ----------------------------------------------------------------------------- */ // lua calls the + operator '__add' // python likes to call it '__add__' // Assuming most SWIGers will probably use the __add__ if they extend their classes // we have two sets of renames // one to rename the operator+() to __add() // (this lets SWIG rename the operator overloads) // another is to rename __add__() to __add() // (this means that people who wrote SWIG code to do that add will also work) #ifdef __cplusplus // this is extra renaming for lua // not all operators are supported, so only those that are, are listed %rename(__add) *::operator+; %rename(__sub) *::operator-; %rename(__mul) *::operator*; %rename(__div) *::operator/; %rename(__unm) *::operator-(); %rename(__unm) *::operator-() const; %rename(__eq) *::operator==; %ignore *::operator!=; // note: Lua does not have a notequal operator // it just uses 'not (a==b)' %rename(__lt) *::operator<; %ignore *::operator>; // ditto less than vs greater than %rename(__le) *::operator<=; %ignore *::operator>=; // ditto less than vs greater than %ignore *::operator!; // does not support not %rename(__call) *::operator(); // the fn call operator // lua does not support overloading of: // logical/bitwise operators // assign operator // +=,-=,*=, etc // therefore ignoring them for now // it also doesn't support non class operators // eg friends or XX operator+(XX,XX) // also ignoring // note: some of these might be better to rename, but not doing that for now %ignore *::operator&&; %ignore operator&&; %ignore *::operator||; %ignore operator||; %ignore *::operator+=; %ignore *::operator-=; %ignore *::operator*=; %ignore *::operator/=; %ignore *::operator%=; %ignore *::operator++; %ignore *::operator--; %ignore *::operator=; // note: this might be better to rename to assign() or similar %ignore operator+; %ignore operator-; %ignore operator*; %ignore operator/; %ignore operator%; %ignore operator[]; %ignore operator>; %ignore operator>=; %ignore operator<; %ignore operator<=; %ignore operator==; %ignore operator!=; // renaming the python operators to be compatible with lua // this means that if a developer has written a fn __add__() // it will be used for the lua + %rename(__add) *::__add__; %rename(__sub) *::__sub__; %rename(__mul) *::__mul__; %rename(__div) *::__div__; %rename(__unm) *::__neg__; // lua calls unary minus,'unm' not 'neg' %rename(__tostring) *::__str__; // both map to __tostring %rename(__tostring) *::__repr__; // both map to __tostring %rename(__pow) *::__pow__; // lua power '^' operator %rename(__concat) *::__concat__; // lua concat '..' operator %rename(__eq) *::__eq__; %rename(__lt) *::__lt__; %rename(__le) *::__le__; %rename(__call) *::__call__; // the fn call operator() // the [] operator has two parts, the get & the set %rename(__getitem) *::__getitem__; // the v=X[i] (get operator) %rename(__setitem) *::__setitem__; // the X[i]=v (set operator) #endif /* ------------------------------------------------------------ * Exceptions * ------------------------------------------------------------ */ /* Confession: I don't really like C++ exceptions The python/lua ones are great, but C++ ones I don't like (mainly because I cannot get the stack trace out of it) Therefore I have not bothered to try doing much in this Therefore currently its just enough to get a few test cases running ok note: if you wish to throw anything related to std::exception use %include instead */ // number as number+error %typemap(throws) int,unsigned int,signed int, long,unsigned long,signed long, short,unsigned short,signed short, float,double, long long,unsigned long long, unsigned char, signed char, int&,unsigned int&,signed int&, long&,unsigned long&,signed long&, short&,unsigned short&,signed short&, float&,double&, long long&,unsigned long long&, unsigned char&, signed char& %{lua_pushnumber(L,(lua_Number)$1);SWIG_fail; %} %typemap(throws) bool,bool& %{lua_pushboolean(L,(int)($1==true));SWIG_fail; %} // enum as number+error %typemap(throws) enum SWIGTYPE %{lua_pushnumber(L,(lua_Number)(int)$1);SWIG_fail; %} // strings are just sent as errors %typemap(throws) char *, const char * %{lua_pushstring(L,$1);SWIG_fail;%} // char is changed to a string %typemap(throws) char %{lua_pushlstring(L,&$1,1);SWIG_fail;%} /* Throwing object is a serious problem: Assuming some code throws a 'FooBar' There are a few options: - return a pointer to it: but its unclear how long this will last for. - return a copy of it: but not all objects are copyable (see exception_partial_info in the test suite for a case where you cannot do this) - convert to a string & throw that it's not so useful, but it works (this is more lua like). The third option (though not nice) is used For a more useful solution: see std_except for more details */ // basic typemap for structs, classes, pointers & references // convert to string and error %typemap(throws) SWIGTYPE %{(void)$1; /* ignore it */ lua_pushfstring(L,"object exception:%s",SWIG_TypePrettyName($1_descriptor)); SWIG_fail;%} // code to make a copy of the object and return this // if you have a function which throws a FooBar & you want SWIG to return a copy of the object as its error // then use one of the below // %apply SWIGTYPE EXCEPTION_BY_VAL {FooBar}; // %apply SWIGTYPE& EXCEPTION_BY_VAL {FooBar&}; // note: need & twice %typemap(throws) SWIGTYPE EXCEPTION_BY_VAL %{SWIG_NewPointerObj(L,(void *)new $1_ltype(($1_ltype &) $1),$&1_descriptor,1); SWIG_fail;%} // similar for object reference // note: swig typemaps seem a little confused around here, therefore we use $basetype %typemap(throws) SWIGTYPE& EXCEPTION_BY_VAL %{SWIG_NewPointerObj(L,(void *)new $basetype($1),$1_descriptor,1); SWIG_fail;%} // note: no support for object pointers // its not clear how long the pointer is valid for, therefore not supporting it /* ----------------------------------------------------------------------------- * extras * ----------------------------------------------------------------------------- */ // this %define is to allow insertion of lua source code into the wrapper file #define %luacode %insert("luacode") /* ------------------------------ end lua.swg ------------------------------ */ swig-3.0.8/Lib/lua/luarun.swg0000664000175000017500000020020412641054563015676 0ustar williamwilliam/* ----------------------------------------------------------------------------- * luarun.swg * * This file contains the runtime support for Lua modules * and includes code for managing global variables and pointer * type checking. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif #include "lua.h" #include "lauxlib.h" #include /* for malloc */ #include /* for a few sanity tests */ /* ----------------------------------------------------------------------------- * Lua flavors * ----------------------------------------------------------------------------- */ #define SWIG_LUA_FLAVOR_LUA 1 #define SWIG_LUA_FLAVOR_ELUA 2 #define SWIG_LUA_FLAVOR_ELUAC 3 #if !defined(SWIG_LUA_TARGET) # error SWIG_LUA_TARGET not defined #endif #if defined(SWIG_LUA_ELUA_EMULATE) struct swig_elua_entry; typedef struct swig_elua_key { int type; union { const char* strkey; lua_Number numkey; } key; } swig_elua_key; typedef struct swig_elua_val { int type; union { lua_Number number; const struct swig_elua_entry *table; const char *string; lua_CFunction function; struct { char member; long lvalue; void *pvalue; swig_type_info **ptype; } userdata; } value; } swig_elua_val; typedef struct swig_elua_entry { swig_elua_key key; swig_elua_val value; } swig_elua_entry; #define LSTRKEY(x) {LUA_TSTRING, {.strkey = x} } #define LNUMKEY(x) {LUA_TNUMBER, {.numkey = x} } #define LNILKEY {LUA_TNIL, {.strkey = 0} } #define LNUMVAL(x) {LUA_TNUMBER, {.number = x} } #define LFUNCVAL(x) {LUA_TFUNCTION, {.function = x} } #define LROVAL(x) {LUA_TTABLE, {.table = x} } #define LNILVAL {LUA_TNIL, {.string = 0} } #define LSTRVAL(x) {LUA_TSTRING, {.string = x} } #define LUA_REG_TYPE swig_elua_entry #define SWIG_LUA_ELUA_EMUL_METATABLE_KEY "__metatable" #define lua_pushrotable(L,p)\ lua_newtable(L);\ assert(p);\ SWIG_Lua_elua_emulate_register(L,(swig_elua_entry*)(p)); #define SWIG_LUA_CONSTTAB_POINTER(B,C,D)\ LSTRKEY(B), {LUA_TUSERDATA, { .userdata={0,0,(void*)(C),&D} } } #define SWIG_LUA_CONSTTAB_BINARY(B,S,C,D)\ LSTRKEY(B), {LUA_TUSERDATA, { .userdata={1,S,(void*)(C),&D} } } #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) # define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C) # define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C) # define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C) # define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C) /* Those two types of constants are not supported in elua */ #ifndef SWIG_LUA_CONSTTAB_POINTER #warning eLua does not support pointers as constants. By default, nil will be used as value #define SWIG_LUA_CONSTTAB_POINTER(B,C,D) LSTRKEY(B), LNILVAL #endif #ifndef SWIG_LUA_CONSTTAB_BINARY #warning eLua does not support pointers to member as constants. By default, nil will be used as value #define SWIG_LUA_CONSTTAB_BINARY(B, S, C, D) LSTRKEY(B), LNILVAL #endif #else /* SWIG_LUA_FLAVOR_LUA */ # define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0 # define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0 # define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0 # define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0 # define SWIG_LUA_CONSTTAB_POINTER(B,C,D)\ SWIG_LUA_POINTER, (char *)B, 0, 0, (void *)C, &D # define SWIG_LUA_CONSTTAB_BINARY(B, S, C, D)\ SWIG_LUA_BINARY, (char *)B, S, 0, (void *)C, &D #endif #ifndef SWIG_LUA_ELUA_EMULATE #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) # define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING} # define LSTRVAL LRO_STRVAL #endif #endif /* SWIG_LUA_ELUA_EMULATE*/ #ifndef SWIG_LUA_ELUA_EMULATE #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) #ifndef MIN_OPT_LEVEL #define MIN_OPT_LEVEL 2 #endif #include "lrodefs.h" #include "lrotable.h" #endif #endif /* SWIG_LUA_ELUA_EMULATE*/ /* ----------------------------------------------------------------------------- * compatibility defines * ----------------------------------------------------------------------------- */ /* History of Lua C API length functions: In Lua 5.0 (and before?) there was "lua_strlen". In Lua 5.1, this was renamed "lua_objlen", but a compatibility define of "lua_strlen" was added. In Lua 5.2, this function was again renamed, to "lua_rawlen" (to emphasize that it doesn't call the "__len" metamethod), and the compatibility define of lua_strlen was removed. All SWIG uses have been updated to "lua_rawlen", and we add our own defines of that here for older versions of Lua. */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 # define lua_rawlen lua_strlen #elif LUA_VERSION_NUM == 501 # define lua_rawlen lua_objlen #endif /* lua_pushglobaltable is the recommended "future-proof" way to get the global table for Lua 5.2 and later. Here we define lua_pushglobaltable ourselves for Lua versions before 5.2. */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 # define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) #endif /* lua_absindex was introduced in Lua 5.2 */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 # define lua_absindex(L,i) ((i)>0 || (i) <= LUA_REGISTRYINDEX ? (i) : lua_gettop(L) + (i) + 1) #endif /* lua_rawsetp was introduced in Lua 5.2 */ #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 #define lua_rawsetp(L,index,ptr)\ lua_pushlightuserdata(L,(void*)(ptr));\ lua_insert(L,-2);\ lua_rawset(L,index); #define lua_rawgetp(L,index,ptr)\ lua_pushlightuserdata(L,(void*)(ptr));\ lua_rawget(L,index); #endif /* -------------------------------------------------------------------------- * Helper functions for error handling * -------------------------------------------------------------------------- */ /* Push the string STR on the Lua stack, like lua_pushstring, but prefixed with the the location of the innermost Lua call-point (as formated by luaL_where). */ SWIGRUNTIME void SWIG_Lua_pusherrstring (lua_State *L, const char *str) { luaL_where (L, 1); lua_pushstring (L, str); lua_concat (L, 2); } /* Push a formatted string generated from FMT and following args on the Lua stack, like lua_pushfstring, but prefixed with the the location of the innermost Lua call-point (as formated by luaL_where). */ SWIGRUNTIME void SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...) { va_list argp; va_start(argp, fmt); luaL_where(L, 1); lua_pushvfstring(L, fmt, argp); va_end(argp); lua_concat(L, 2); } /* ----------------------------------------------------------------------------- * global swig types * ----------------------------------------------------------------------------- */ /* Constant table */ #define SWIG_LUA_INT 1 #define SWIG_LUA_FLOAT 2 #define SWIG_LUA_STRING 3 #define SWIG_LUA_POINTER 4 #define SWIG_LUA_BINARY 5 #define SWIG_LUA_CHAR 6 /* Structure for variable linking table */ typedef struct { const char *name; lua_CFunction get; lua_CFunction set; } swig_lua_var_info; #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) typedef const LUA_REG_TYPE swig_lua_method; typedef const LUA_REG_TYPE swig_lua_const_info; #else /* Normal lua */ typedef luaL_Reg swig_lua_method; /* Constant information structure */ typedef struct { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_lua_const_info; #endif typedef struct { const char *name; lua_CFunction getmethod; lua_CFunction setmethod; } swig_lua_attribute; struct swig_lua_class; /* Can be used to create namespaces. Currently used to wrap class static methods/variables/constants */ typedef struct swig_lua_namespace { const char *name; swig_lua_method *ns_methods; swig_lua_attribute *ns_attributes; swig_lua_const_info *ns_constants; struct swig_lua_class **ns_classes; struct swig_lua_namespace **ns_namespaces; } swig_lua_namespace; typedef struct swig_lua_class { const char *name; /* Name that this class has in Lua */ const char *fqname; /* Fully qualified name - Scope + class name */ swig_type_info **type; lua_CFunction constructor; void (*destructor)(void *); swig_lua_method *methods; swig_lua_attribute *attributes; swig_lua_namespace *cls_static; swig_lua_method *metatable; /* 0 for -eluac */ struct swig_lua_class **bases; const char **base_names; } swig_lua_class; /* this is the struct for wrapping all pointers in SwigLua */ typedef struct { swig_type_info *type; int own; /* 1 if owned & must be destroyed */ void *ptr; } swig_lua_userdata; /* this is the struct for wrapping arbitrary packed binary data (currently it is only used for member function pointers) the data ordering is similar to swig_lua_userdata, but it is currently not possible to tell the two structures apart within SWIG, other than by looking at the type */ typedef struct { swig_type_info *type; int own; /* 1 if owned & must be destroyed */ char data[1]; /* arbitary amount of data */ } swig_lua_rawdata; /* Common SWIG API */ #define SWIG_NewPointerObj(L, ptr, type, owner) SWIG_Lua_NewPointerObj(L, (void *)ptr, type, owner) #define SWIG_ConvertPtr(L,idx, ptr, type, flags) SWIG_Lua_ConvertPtr(L,idx,ptr,type,flags) #define SWIG_MustGetPtr(L,idx, type,flags, argnum,fnname) SWIG_Lua_MustGetPtr(L,idx, type,flags, argnum,fnname) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(L, idx, ptr, sz, ty) SWIG_Lua_ConvertPacked(L, idx, ptr, sz, ty) #define SWIG_NewMemberObj(L, ptr, sz, type) SWIG_Lua_NewPackedObj(L, ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Lua_GetModule((lua_State*)(clientdata)) #define SWIG_SetModule(clientdata, pointer) SWIG_Lua_SetModule((lua_State*) (clientdata), pointer) #define SWIG_MODULE_CLIENTDATA_TYPE lua_State* /* Contract support */ #define SWIG_contract_assert(expr, msg) \ if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else /* helper #defines */ #define SWIG_fail {goto fail;} #define SWIG_fail_arg(func_name,argnum,type) \ {SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ func_name,argnum,type,SWIG_Lua_typename(L,argnum));\ goto fail;} #define SWIG_fail_ptr(func_name,argnum,type) \ SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*") #define SWIG_check_num_args(func_name,a,b) \ if (lua_gettop(L)b) \ {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ goto fail;} #define SWIG_Lua_get_table(L,n) \ (lua_pushstring(L, n), lua_rawget(L,-2)) #define SWIG_Lua_add_function(L,n,f) \ (lua_pushstring(L, n), \ lua_pushcfunction(L, f), \ lua_rawset(L,-3)) #define SWIG_Lua_add_boolean(L,n,b) \ (lua_pushstring(L, n), \ lua_pushboolean(L, b), \ lua_rawset(L,-3)) /* special helper for allowing 'nil' for usertypes */ #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I)) #ifdef __cplusplus /* Special helper for member function pointers it gets the address, casts it, then dereferences it */ /*#define SWIG_mem_fn_as_voidptr(a) (*((char**)&(a))) */ #endif /* storing/access of swig_module_info */ SWIGRUNTIME swig_module_info * SWIG_Lua_GetModule(lua_State *L) { swig_module_info *ret = 0; lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); lua_rawget(L,LUA_REGISTRYINDEX); if (lua_islightuserdata(L,-1)) ret=(swig_module_info*)lua_touserdata(L,-1); lua_pop(L,1); /* tidy */ return ret; } SWIGRUNTIME void SWIG_Lua_SetModule(lua_State *L, swig_module_info *module) { /* add this all into the Lua registry: */ lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); lua_pushlightuserdata(L,(void*)module); lua_rawset(L,LUA_REGISTRYINDEX); } /* ----------------------------------------------------------------------------- * global variable support code: modules * ----------------------------------------------------------------------------- */ /* this function is called when trying to set an immutable. default action is to print an error. This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */ SWIGINTERN int SWIG_Lua_set_immutable(lua_State *L) { /* there should be 1 param passed in: the new value */ #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE lua_pop(L,1); /* remove it */ luaL_error(L,"This variable is immutable"); #endif return 0; /* should not return anything */ } #ifdef SWIG_LUA_ELUA_EMULATE SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L,void *ptr,swig_type_info *type, int own); SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_type_info *type); static int swig_lua_elua_emulate_unique_key; /* This function emulates eLua rotables behaviour. It loads a rotable definition into the usual lua table. */ SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_entry *table) { int i, table_parsed, parsed_tables_array, target_table; assert(lua_istable(L,-1)); target_table = lua_gettop(L); /* Get the registry where we put all parsed tables to avoid loops */ lua_rawgetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key); if(lua_isnil(L,-1)) { lua_pop(L,1); lua_newtable(L); lua_pushvalue(L,-1); lua_rawsetp(L,LUA_REGISTRYINDEX,(void*)(&swig_lua_elua_emulate_unique_key)); } parsed_tables_array = lua_gettop(L); lua_pushvalue(L,target_table); lua_rawsetp(L, parsed_tables_array, table); table_parsed = 0; const int SWIGUNUSED pairs_start = lua_gettop(L); for(i = 0;table[i].key.type != LUA_TNIL || table[i].value.type != LUA_TNIL;i++) { const swig_elua_entry *entry = table + i; int is_metatable = 0; switch(entry->key.type) { case LUA_TSTRING: lua_pushstring(L,entry->key.key.strkey); if(strcmp(entry->key.key.strkey, SWIG_LUA_ELUA_EMUL_METATABLE_KEY) == 0) is_metatable = 1; break; case LUA_TNUMBER: lua_pushnumber(L,entry->key.key.numkey); break; case LUA_TNIL: lua_pushnil(L); break; default: assert(0); } switch(entry->value.type) { case LUA_TSTRING: lua_pushstring(L,entry->value.value.string); break; case LUA_TNUMBER: lua_pushnumber(L,entry->value.value.number); break; case LUA_TFUNCTION: lua_pushcfunction(L,entry->value.value.function); break; case LUA_TTABLE: lua_rawgetp(L,parsed_tables_array, entry->value.value.table); table_parsed = !lua_isnil(L,-1); if(!table_parsed) { lua_pop(L,1); /*remove nil */ lua_newtable(L); SWIG_Lua_elua_emulate_register(L,entry->value.value.table); } if(is_metatable) { assert(lua_istable(L,-1)); lua_pushvalue(L,-1); lua_setmetatable(L,target_table); } break; case LUA_TUSERDATA: if(entry->value.value.userdata.member) SWIG_NewMemberObj(L,entry->value.value.userdata.pvalue, entry->value.value.userdata.lvalue, *(entry->value.value.userdata.ptype)); else SWIG_NewPointerObj(L,entry->value.value.userdata.pvalue, *(entry->value.value.userdata.ptype),0); break; case LUA_TNIL: lua_pushnil(L); break; default: assert(0); } assert(lua_gettop(L) == pairs_start + 2); lua_rawset(L,target_table); } lua_pop(L,1); /* Removing parsed tables storage */ assert(lua_gettop(L) == target_table); } SWIGINTERN void SWIG_Lua_elua_emulate_register_clear(lua_State *L) { lua_pushnil(L); lua_rawsetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key); } SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L); SWIGINTERN int SWIG_Lua_emulate_elua_getmetatable(lua_State *L) { SWIG_check_num_args("getmetatable(SWIG eLua emulation)", 1, 1); SWIG_Lua_get_class_registry(L); lua_getfield(L,-1,"lua_getmetatable"); lua_remove(L,-2); /* remove the registry*/ assert(!lua_isnil(L,-1)); lua_pushvalue(L,1); assert(lua_gettop(L) == 3); /* object | function | object again */ lua_call(L,1,1); if(!lua_isnil(L,-1)) /*There is an ordinary metatable */ return 1; /*if it is a table, then emulate elua behaviour - check for __metatable attribute of a table*/ assert(lua_gettop(L) == 2); if(lua_istable(L,-2)) { lua_pop(L,1); /*remove the nil*/ lua_getfield(L,-1, SWIG_LUA_ELUA_EMUL_METATABLE_KEY); } assert(lua_gettop(L) == 2); return 1; fail: lua_error(L); return 0; } SWIGINTERN void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State *L) { SWIG_Lua_get_class_registry(L); lua_pushglobaltable(L); lua_pushstring(L,"lua_getmetatable"); lua_getfield(L,-2,"getmetatable"); assert(!lua_isnil(L,-1)); lua_rawset(L,-4); lua_pushstring(L, "getmetatable"); lua_pushcfunction(L, SWIG_Lua_emulate_elua_getmetatable); lua_rawset(L,-3); lua_pop(L,2); } /* END OF REMOVE */ #endif /* ----------------------------------------------------------------------------- * global variable support code: namespaces and modules (which are the same thing) * ----------------------------------------------------------------------------- */ SWIGINTERN int SWIG_Lua_namespace_get(lua_State *L) { /* there should be 2 params passed in (1) table (not the meta table) (2) string name of the attribute */ assert(lua_istable(L,-2)); /* just in case */ lua_getmetatable(L,-2); assert(lua_istable(L,-1)); SWIG_Lua_get_table(L,".get"); /* find the .get table */ assert(lua_istable(L,-1)); /* look for the key in the .get table */ lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); lua_remove(L,-2); /* stack tidy, remove .get table */ if (lua_iscfunction(L,-1)) { /* found it so call the fn & return its value */ lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */ lua_remove(L,-2); /* stack tidy, remove metatable */ return 1; } lua_pop(L,1); /* remove whatever was there */ /* ok, so try the .fn table */ SWIG_Lua_get_table(L,".fn"); /* find the .get table */ assert(lua_istable(L,-1)); /* just in case */ lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); /* look for the fn */ lua_remove(L,-2); /* stack tidy, remove .fn table */ if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */ { /* found it so return the fn & let lua call it */ lua_remove(L,-2); /* stack tidy, remove metatable */ return 1; } lua_pop(L,1); /* remove whatever was there */ return 0; } SWIGINTERN int SWIG_Lua_namespace_set(lua_State *L) { /* there should be 3 params passed in (1) table (not the meta table) (2) string name of the attribute (3) any for the new value */ assert(lua_istable(L,1)); lua_getmetatable(L,1); /* get the meta table */ assert(lua_istable(L,-1)); SWIG_Lua_get_table(L,".set"); /* find the .set table */ if (lua_istable(L,-1)) { /* look for the key in the .set table */ lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); if (lua_iscfunction(L,-1)) { /* found it so call the fn & return its value */ lua_pushvalue(L,3); /* value */ lua_call(L,1,0); return 0; } lua_pop(L,1); /* remove the value */ } lua_pop(L,1); /* remove the value .set table */ lua_pop(L,1); /* remote metatable */ lua_rawset(L,-3); return 0; } #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */ SWIGINTERN void SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]); /* forward declaration */ SWIGINTERN void SWIG_Lua_add_variable(lua_State *L,const char *name,lua_CFunction getFn,lua_CFunction setFn); /* forward declaration */ SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss); /* helper function - register namespace methods and attributes into namespace */ SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State *L, swig_lua_namespace *ns) { int i; /* There must be namespace table (not metatable) at the top of the stack */ assert(lua_istable(L,-1)); SWIG_Lua_InstallConstants(L, ns->ns_constants); /* add methods to the namespace/module table */ for(i=0;ns->ns_methods[i].name;i++){ SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].func); } lua_getmetatable(L,-1); /* add fns */ for(i=0;ns->ns_attributes[i].name;i++){ SWIG_Lua_add_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod); } /* clear stack - remove metatble */ lua_pop(L,1); return 0; } /* Register all classes in the namespace */ SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns) { swig_lua_class **classes; /* There must be a module/namespace table at the top of the stack */ assert(lua_istable(L,-1)); classes = ns->ns_classes; if( classes != 0 ) { while(*classes != 0) { SWIG_Lua_class_register(L, *classes); classes++; } } } /* Helper function. Creates namespace table and adds it to module table if 'reg' is true, then will register namespace table to parent one (must be on top of the stack when function is called). Function always returns newly registered table on top of the stack. */ SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg) { swig_lua_namespace **sub_namespace; /* 1 argument - table on the top of the stack */ const int SWIGUNUSED begin = lua_gettop(L); assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */ lua_checkstack(L,5); lua_newtable(L); /* namespace itself */ lua_newtable(L); /* metatable for namespace */ /* add a table called ".get" */ lua_pushstring(L,".get"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".set" */ lua_pushstring(L,".set"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".fn" */ lua_pushstring(L,".fn"); lua_newtable(L); lua_rawset(L,-3); /* add accessor fns for using the .get,.set&.fn */ SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get); SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set); lua_setmetatable(L,-2); /* set metatable */ /* Register all functions, variables etc */ SWIG_Lua_add_namespace_details(L,ns); /* Register classes */ SWIG_Lua_add_namespace_classes(L,ns); sub_namespace = ns->ns_namespaces; if( sub_namespace != 0) { while(*sub_namespace != 0) { SWIG_Lua_namespace_register(L, *sub_namespace, 1); lua_pop(L,1); /* removing sub-namespace table */ sub_namespace++; } } if (reg) { lua_pushstring(L,ns->name); lua_pushvalue(L,-2); lua_rawset(L,-4); /* add namespace to module table */ } assert(lua_gettop(L) == begin+1); } #endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */ /* ----------------------------------------------------------------------------- * global variable support code: classes * ----------------------------------------------------------------------------- */ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname); typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret); SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED swig_type, int first_arg, swig_lua_base_iterator_func func, int *const ret) { /* first_arg - position of the object in stack. Everything that is above are arguments * and is passed to every evocation of the func */ int last_arg = lua_gettop(L);/* position of last argument */ int original_metatable = last_arg + 1; size_t bases_count; int result = SWIG_ERROR; int bases_table; (void)swig_type; lua_getmetatable(L,first_arg); /* initialise base search */ #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) SWIG_Lua_get_table(L,".bases"); assert(lua_istable(L,-1)); bases_count = lua_rawlen(L,-1); bases_table = lua_gettop(L); #else /* In elua .bases table doesn't exist. Use table from swig_lua_class */ (void)bases_table; assert(swig_type!=0); swig_module_info *module=SWIG_GetModule(L); swig_lua_class **bases= ((swig_lua_class*)(swig_type->clientdata))->bases; const char **base_names= ((swig_lua_class*)(swig_type->clientdata))->base_names; bases_count = 0; for(;base_names[bases_count]; bases_count++);/* get length of bases */ #endif if(ret) *ret = 0; if(bases_count>0) { int to_remove; size_t i; int j; int subcall_last_arg; int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */ int valid = 1; swig_type_info *base_swig_type = 0; for(j=first_arg;j<=last_arg;j++) lua_pushvalue(L,j); subcall_last_arg = lua_gettop(L); /* Trick: temporarily replacing original metatable with metatable for base class and call getter */ for(i=0;ifqname); base_swig_type = SWIG_TypeQueryModule(module,module,base_names[i]); assert(base_swig_type != 0); } #endif if(!valid) continue; assert(lua_isuserdata(L, subcall_first_arg)); assert(lua_istable(L,-1)); lua_setmetatable(L,subcall_first_arg); /* Set new metatable */ assert(lua_gettop(L) == subcall_last_arg); result = func(L, base_swig_type,subcall_first_arg, ret); /* Forward call */ if(result != SWIG_ERROR) { break; } } /* Restore original metatable */ lua_pushvalue(L,original_metatable); lua_setmetatable(L,first_arg); /* Clear - remove everything between last_arg and subcall_last_arg including */ to_remove = subcall_last_arg - last_arg; for(j=0;jtype; result = SWIG_Lua_class_do_get(L,type,1,&ret); if(result == SWIG_OK) return ret; return 0; } /* helper for the class.set method, performs the lookup of class attributes * It returns error code. Number of function return values is passed inside 'ret' */ SWIGINTERN int SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int first_arg, int *ret) { /* there should be 3 params passed in (1) table (not the meta table) (2) string name of the attribute (3) any for the new value */ int bases_search_result; int substack_start = lua_gettop(L) - 3; lua_checkstack(L,5); assert(lua_isuserdata(L,substack_start+1)); /* just in case */ lua_getmetatable(L,substack_start+1); /* get the meta table */ assert(lua_istable(L,-1)); /* just in case */ if(ret) *ret = 0; /* it is setter - number of return values is always 0 */ SWIG_Lua_get_table(L,".set"); /* find the .set table */ if (lua_istable(L,-1)) { /* look for the key in the .set table */ lua_pushvalue(L,substack_start+2); /* key */ lua_rawget(L,-2); lua_remove(L,-2); /* tidy stack, remove .set table */ if (lua_iscfunction(L,-1)) { /* found it so call the fn & return its value */ lua_pushvalue(L,substack_start+1); /* userdata */ lua_pushvalue(L,substack_start+3); /* value */ lua_call(L,2,0); lua_remove(L,substack_start+4); /*remove metatable*/ return SWIG_OK; } lua_pop(L,1); /* remove the value */ } else { lua_pop(L,1); /* remove the answer for .set table request*/ } /* NEW: looks for the __setitem() fn this is a user provided set fn */ SWIG_Lua_get_table(L,"__setitem"); /* find the fn */ if (lua_iscfunction(L,-1)) /* if its there */ { /* found it so call the fn & return its value */ lua_pushvalue(L,substack_start+1); /* the userdata */ lua_pushvalue(L,substack_start+2); /* the parameter */ lua_pushvalue(L,substack_start+3); /* the value */ lua_call(L,3,0); /* 3 values in ,0 out */ lua_remove(L,-2); /* stack tidy, remove metatable */ return SWIG_OK; } lua_pop(L,1); /* remove value */ lua_pop(L,1); /* remove metatable */ /* Search among bases */ bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret); if(ret) assert(*ret == 0); assert(lua_gettop(L) == substack_start + 3); return bases_search_result; } /* This is the actual method exported to Lua. It calls SWIG_Lua_class_do_set and correctly * handles return values. */ SWIGINTERN int SWIG_Lua_class_set(lua_State *L) { /* There should be 3 params passed in (1) table (not the meta table) (2) string name of the attribute (3) any for the new value */ int ret = 0; int result; swig_lua_userdata *usr; swig_type_info *type; assert(lua_isuserdata(L,1)); usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ type = usr->type; result = SWIG_Lua_class_do_set(L,type,1,&ret); if(result != SWIG_OK) { SWIG_Lua_pushferrstring(L,"Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method."); lua_error(L); } else { assert(ret==0); } return 0; } /* the class.destruct method called by the interpreter */ SWIGINTERN int SWIG_Lua_class_destruct(lua_State *L) { /* there should be 1 params passed in (1) userdata (not the meta table) */ swig_lua_userdata *usr; swig_lua_class *clss; assert(lua_isuserdata(L,-1)); /* just in case */ usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ /* if must be destroyed & has a destructor */ if (usr->own) /* if must be destroyed */ { clss=(swig_lua_class*)usr->type->clientdata; /* get the class */ if (clss && clss->destructor) /* there is a destroy fn */ { clss->destructor(usr->ptr); /* bye bye */ } } return 0; } /* the class.__tostring method called by the interpreter and print */ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) { /* there should be 1 param passed in (1) userdata (not the metatable) */ const char *className; void* userData; assert(lua_isuserdata(L,1)); /* just in case */ userData = lua_touserdata(L,1); /* get the userdata address for later */ lua_getmetatable(L,1); /* get the meta table */ assert(lua_istable(L,-1)); /* just in case */ lua_getfield(L, -1, ".type"); className = lua_tostring(L, -1); lua_pushfstring(L, "<%s userdata: %p>", className, userData); return 1; } /* to manually disown some userdata */ SWIGINTERN int SWIG_Lua_class_disown(lua_State *L) { /* there should be 1 params passed in (1) userdata (not the meta table) */ swig_lua_userdata *usr; assert(lua_isuserdata(L,-1)); /* just in case */ usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ usr->own = 0; /* clear our ownership */ return 0; } /* lua callable function to compare userdata's value the issue is that two userdata may point to the same thing but to lua, they are different objects */ SWIGRUNTIME int SWIG_Lua_class_equal(lua_State *L) { int result; swig_lua_userdata *usr1,*usr2; if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2)) /* just in case */ return 0; /* nil reply */ usr1=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ usr2=(swig_lua_userdata*)lua_touserdata(L,2); /* get data */ /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/ result=(usr1->ptr==usr2->ptr); lua_pushboolean(L,result); return 1; } /* populate table at the top of the stack with metamethods that ought to be inherited */ SWIGINTERN void SWIG_Lua_populate_inheritable_metamethods(lua_State *L) { SWIG_Lua_add_boolean(L, "__add", 1); SWIG_Lua_add_boolean(L, "__sub", 1); SWIG_Lua_add_boolean(L, "__mul", 1); SWIG_Lua_add_boolean(L, "__div", 1); SWIG_Lua_add_boolean(L, "__mod", 1); SWIG_Lua_add_boolean(L, "__pow", 1); SWIG_Lua_add_boolean(L, "__unm", 1); SWIG_Lua_add_boolean(L, "__len", 1 ); SWIG_Lua_add_boolean(L, "__concat", 1 ); SWIG_Lua_add_boolean(L, "__eq", 1); SWIG_Lua_add_boolean(L, "__lt", 1); SWIG_Lua_add_boolean(L, "__le", 1); SWIG_Lua_add_boolean(L, "__call", 1); SWIG_Lua_add_boolean(L, "__tostring", 1); SWIG_Lua_add_boolean(L, "__gc", 0); } /* creates the swig registry */ SWIGINTERN void SWIG_Lua_create_class_registry(lua_State *L) { /* create main SWIG registry table */ lua_pushstring(L,"SWIG"); lua_newtable(L); /* populate it with some predefined data */ /* .library table. Placeholder */ lua_pushstring(L,".library"); lua_newtable(L); { /* list of metamethods that class inherits from its bases */ lua_pushstring(L,"inheritable_metamethods"); lua_newtable(L); /* populate with list of metamethods */ SWIG_Lua_populate_inheritable_metamethods(L); lua_rawset(L,-3); } lua_rawset(L,-3); lua_rawset(L,LUA_REGISTRYINDEX); } /* gets the swig registry (or creates it) */ SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L) { /* add this all into the swig registry: */ lua_pushstring(L,"SWIG"); lua_rawget(L,LUA_REGISTRYINDEX); /* get the registry */ if (!lua_istable(L,-1)) /* not there */ { /* must be first time, so add it */ lua_pop(L,1); /* remove the result */ SWIG_Lua_create_class_registry(L); /* then get it */ lua_pushstring(L,"SWIG"); lua_rawget(L,LUA_REGISTRYINDEX); } } SWIGINTERN void SWIG_Lua_get_inheritable_metamethods(lua_State *L) { SWIG_Lua_get_class_registry(L); lua_pushstring(L, ".library"); lua_rawget(L,-2); assert( !lua_isnil(L,-1) ); lua_pushstring(L, "inheritable_metamethods"); lua_rawget(L,-2); /* Remove class registry and library table */ lua_remove(L,-2); lua_remove(L,-2); } /* Helper function to get the classes metatable from the register */ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname) { SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,cname); /* get the name */ lua_rawget(L,-2); /* get it */ lua_remove(L,-2); /* tidy up (remove registry) */ } /* Set up the base classes pointers. Each class structure has a list of pointers to the base class structures. This function fills them. It cannot be done at compile time, as this will not work with hireachies spread over more than one swig file. Therefore it must be done at runtime, querying the SWIG type system. */ SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L,swig_lua_class *clss) { int i=0; swig_module_info *module=SWIG_GetModule(L); for(i=0;clss->base_names[i];i++) { if (clss->bases[i]==0) /* not found yet */ { /* lookup and cache the base class */ swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]); if (info) clss->bases[i] = (swig_lua_class *) info->clientdata; } } } #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* Merges two tables */ SWIGINTERN void SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source) { /* iterating */ lua_pushnil(L); while (lua_next(L,source) != 0) { /* -1 - value, -2 - index */ /* have to copy to assign */ lua_pushvalue(L,-2); /* copy of index */ lua_pushvalue(L,-2); /* copy of value */ lua_rawset(L, target); lua_pop(L,1); /* only key is left */ } } /* Merges two tables with given name. original - index of target metatable, base - index of source metatable */ SWIGINTERN void SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base) { /* push original[name], then base[name] */ lua_pushstring(L,name); lua_rawget(L,original); int original_table = lua_gettop(L); lua_pushstring(L,name); lua_rawget(L,base); int base_table = lua_gettop(L); SWIG_Lua_merge_tables_by_index(L, original_table, base_table); /* clearing stack */ lua_pop(L,2); } /* Function takes all symbols from base and adds it to derived class. It's just a helper. */ SWIGINTERN void SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls) { /* There is one parameter - original, i.e. 'derived' class metatable */ assert(lua_istable(L,-1)); int original = lua_gettop(L); SWIG_Lua_get_class_metatable(L,base_cls->fqname); int base = lua_gettop(L); SWIG_Lua_merge_tables(L, ".fn", original, base ); SWIG_Lua_merge_tables(L, ".set", original, base ); SWIG_Lua_merge_tables(L, ".get", original, base ); lua_pop(L,1); } /* Function squashes all symbols from 'clss' bases into itself */ SWIGINTERN void SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss) { int i; SWIG_Lua_get_class_metatable(L,clss->fqname); for(i=0;clss->base_names[i];i++) { if (clss->bases[i]==0) /* Somehow it's not found. Skip it */ continue; /* Thing is: all bases are already registered. Thus they have already executed * this function. So we just need to squash them into us, because their bases * are already squashed into them. No need for recursion here! */ SWIG_Lua_class_squash_base(L, clss->bases[i]); } lua_pop(L,1); /*tidy stack*/ } #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */ /* helper add a variable to a registered class */ SWIGINTERN void SWIG_Lua_add_variable(lua_State *L,const char *name,lua_CFunction getFn,lua_CFunction setFn) { assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_get_table(L,".get"); /* find the .get table */ assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_function(L,name,getFn); lua_pop(L,1); /* tidy stack (remove table) */ if (setFn) { SWIG_Lua_get_table(L,".set"); /* find the .set table */ assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_function(L,name,setFn); lua_pop(L,1); /* tidy stack (remove table) */ } } /* helper to recursively add class static details (static attributes, operations and constants) */ SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State *L, swig_lua_class *clss) { int i = 0; /* The class namespace table must be on the top of the stack */ assert(lua_istable(L,-1)); /* call all the base classes first: we can then override these later: */ for(i=0;clss->bases[i];i++) { SWIG_Lua_add_class_static_details(L,clss->bases[i]); } SWIG_Lua_add_namespace_details(L, clss->cls_static); } SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss); /* forward declaration */ /* helper to recursively add class details (attributes & operations) */ SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss) { int i; size_t bases_count = 0; /* Add bases to .bases table */ SWIG_Lua_get_table(L,".bases"); assert(lua_istable(L,-1)); /* just in case */ for(i=0;clss->bases[i];i++) { SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); /* Base class must be already registered */ assert(lua_istable(L,-1)); lua_rawseti(L,-2,i+1); /* In lua indexing starts from 1 */ bases_count++; } assert(lua_rawlen(L,-1) == bases_count); lua_pop(L,1); /* remove .bases table */ /* add attributes */ for(i=0;clss->attributes[i].name;i++){ SWIG_Lua_add_variable(L,clss->attributes[i].name,clss->attributes[i].getmethod,clss->attributes[i].setmethod); } /* add methods to the metatable */ SWIG_Lua_get_table(L,".fn"); /* find the .fn table */ assert(lua_istable(L,-1)); /* just in case */ for(i=0;clss->methods[i].name;i++){ SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].func); } lua_pop(L,1); /* tidy stack (remove table) */ /* add operator overloads This adds methods from metatable array to metatable. Can mess up garbage collectind if someone defines __gc method */ if(clss->metatable) { for(i=0;clss->metatable[i].name;i++) { SWIG_Lua_add_function(L,clss->metatable[i].name,clss->metatable[i].func); } } #if !defined(SWIG_LUA_SQUASH_BASES) /* Adding metamethods that are defined in base classes. If bases were squashed * then it is obviously unnecessary */ SWIG_Lua_add_class_user_metamethods(L, clss); #endif } /* Helpers to add user defined class metamedhods - __add, __sub etc. The helpers are needed for the following issue: Lua runtime checks for metamethod existence with rawget function ignoring our SWIG-provided __index and __newindex functions. Thus our inheritance-aware method search algorithm doesn't work in such case. (Not to say that Lua runtime queries metamethod directly in metatable and not in object). Current solution is this: if somewhere in hierarchy metamethod __x is defined, then all descendants are automatically given a special proxy __x that calls the real __x method. Obvious idea - to copy __x instead of creating __x-proxy is wrong because if someone changes __x in runtime, those changes must be reflected in all descendants. */ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L); /*forward declaration*/ /* The real function that resolves a metamethod. * Function searches given class and all it's bases(recursively) for first instance of something that is * not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actual metamethod implementation * and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the * answer. * Returns 1 if found, 0 otherwise. * clss is class which metatable we will search for method * metamethod_name_idx is index in L where metamethod name (as string) lies * skip_check allows to skip searching metamethod in givel clss and immideatelly go to searching in bases. skip_check * is not caried to subsequent recursive calls - false is always passed. It is set to true only at first call from * SWIG_Lua_resolve_metamethod * */ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class *clss, int metamethod_name_idx, int skip_check) { /* This function is called recursively */ int result = 0; int i = 0; if (!skip_check) { SWIG_Lua_get_class_metatable(L, clss->fqname); lua_pushvalue(L, metamethod_name_idx); lua_rawget(L,-2); /* If this is cfunction and it is equal to SWIG_Lua_resolve_metamethod then * this isn't the function we are looking for :) * lua_tocfunction will return NULL if not cfunction */ if (!lua_isnil(L,-1) && lua_tocfunction(L,-1) != SWIG_Lua_resolve_metamethod ) { lua_remove(L,-2); /* removing class metatable */ return 1; } lua_pop(L,2); /* remove class metatable and query result */ } /* Forwarding calls to bases */ for(i=0;clss->bases[i];i++) { result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0); if (result) break; } return result; } /* The proxy function for metamethod. All parameters are passed as cclosure. Searches for actual method * and calls it */ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) { int numargs; int metamethod_name_idx; const swig_lua_class* clss; int result; lua_checkstack(L,5); numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */ /* Get upvalues from closure */ lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/ metamethod_name_idx = lua_gettop(L); lua_pushvalue(L, lua_upvalueindex(2)); clss = (const swig_lua_class*)(lua_touserdata(L,-1)); lua_pop(L,1); /* remove lightuserdata with clss from stack */ /* Actual work */ result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1); if (!result) { SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation."); lua_error(L); return 0; } lua_remove(L,-2); /* remove metamethod key */ lua_insert(L,1); /* move function to correct position */ lua_call(L, numargs, LUA_MULTRET); return lua_gettop(L); /* return all results */ } /* If given metamethod must be present in given class, then creates appropriate proxy * Returns 1 if successfully added, 0 if not added because no base class has it, -1 * if method is defined in the class metatable itself */ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index) { int key_index; int success = 0; int i = 0; /* metamethod name - on the top of the stack */ assert(lua_isstring(L,-1)); key_index = lua_gettop(L); /* Check whether method is already defined in metatable */ lua_pushvalue(L,key_index); /* copy of the key */ lua_gettable(L,metatable_index); if( !lua_isnil(L,-1) ) { lua_pop(L,1); return -1; } lua_pop(L,1); /* Iterating over immediate bases */ for(i=0;clss->bases[i];i++) { const swig_lua_class *base = clss->bases[i]; SWIG_Lua_get_class_metatable(L, base->fqname); lua_pushvalue(L, key_index); lua_rawget(L, -2); if( !lua_isnil(L,-1) ) { lua_pushvalue(L, key_index); /* Add proxy function */ lua_pushvalue(L, key_index); /* first closure value is function name */ lua_pushlightuserdata(L, clss); /* second closure value is swig_lua_class structure */ lua_pushcclosure(L, SWIG_Lua_resolve_metamethod, 2); lua_rawset(L, metatable_index); success = 1; } lua_pop(L,1); /* remove function or nil */ lua_pop(L,1); /* remove base class metatable */ if( success ) break; } return success; } SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss) { int metatable_index; int metamethods_info_index; int tostring_undefined; int eq_undefined = 0; SWIG_Lua_get_class_metatable(L, clss->fqname); metatable_index = lua_gettop(L); SWIG_Lua_get_inheritable_metamethods(L); assert(lua_istable(L,-1)); metamethods_info_index = lua_gettop(L); lua_pushnil(L); /* first key */ while(lua_next(L, metamethods_info_index) != 0 ) { /* key at index -2, value at index -1 */ const int is_inheritable = lua_toboolean(L,-2); lua_pop(L,1); /* remove value - we don't need it anymore */ if(is_inheritable) { /* if metamethod is inheritable */ SWIG_Lua_add_class_user_metamethod(L,clss,metatable_index); } } lua_pop(L,1); /* remove inheritable metatmethods table */ /* Special handling for __tostring method */ lua_pushstring(L, "__tostring"); lua_pushvalue(L,-1); lua_rawget(L,metatable_index); tostring_undefined = lua_isnil(L,-1); lua_pop(L,1); if( tostring_undefined ) { lua_pushcfunction(L, SWIG_Lua_class_tostring); lua_rawset(L, metatable_index); } else { lua_pop(L,1); /* remove copy of the key */ } /* Special handling for __eq method */ lua_pushstring(L, "__eq"); lua_pushvalue(L,-1); lua_rawget(L,metatable_index); eq_undefined = lua_isnil(L,-1); lua_pop(L,1); if( eq_undefined ) { lua_pushcfunction(L, SWIG_Lua_class_equal); lua_rawset(L, metatable_index); } else { lua_pop(L,1); /* remove copy of the key */ } /* Warning: __index and __newindex are SWIG-defined. For user-defined operator[] * a __getitem/__setitem method should be defined */ lua_pop(L,1); /* pop class metatable */ } /* Register class static methods,attributes etc as well as constructor proxy */ SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *clss) { const int SWIGUNUSED begin = lua_gettop(L); lua_checkstack(L,5); /* just in case */ assert(lua_istable(L,-1)); /* just in case */ assert(strcmp(clss->name, clss->cls_static->name) == 0); /* in class those 2 must be equal */ SWIG_Lua_namespace_register(L,clss->cls_static, 1); assert(lua_istable(L,-1)); /* just in case */ /* add its constructor to module with the name of the class so you can do MyClass(...) as well as new_MyClass(...) BUT only if a constructor is defined (this overcomes the problem of pure virtual classes without constructors)*/ if (clss->constructor) { lua_getmetatable(L,-1); assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_function(L,"__call", clss->constructor); lua_pop(L,1); } assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_class_static_details(L, clss); /* clear stack */ lua_pop(L,1); assert( lua_gettop(L) == begin ); } /* Performs the instance (non-static) class registration process. Metatable for class is created * and added to the class registry. */ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss) { const int SWIGUNUSED begin = lua_gettop(L); int i; /* if name already there (class is already registered) then do nothing */ SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->fqname); /* get the name */ lua_rawget(L,-2); if(!lua_isnil(L,-1)) { lua_pop(L,2); assert(lua_gettop(L)==begin); return; } lua_pop(L,2); /* tidy stack */ /* Recursively initialize all bases */ for(i=0;clss->bases[i];i++) { SWIG_Lua_class_register_instance(L,clss->bases[i]); } /* Again, get registry and push name */ SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->fqname); /* get the name */ lua_newtable(L); /* create the metatable */ #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* If squashing is requested, then merges all bases metatable into this one. * It would get us all special methods: __getitem, __add etc. * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away */ { int new_metatable_index = lua_absindex(L,-1); for(i=0;clss->bases[i];i++) { int base_metatable; SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); base_metatable = lua_absindex(L,-1); SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable); lua_pop(L,1); } } /* And now we will overwrite all incorrectly set data */ #endif /* add string of class name called ".type" */ lua_pushstring(L,".type"); lua_pushstring(L,clss->fqname); lua_rawset(L,-3); /* add a table called bases */ lua_pushstring(L,".bases"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".get" */ lua_pushstring(L,".get"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".set" */ lua_pushstring(L,".set"); lua_newtable(L); lua_rawset(L,-3); /* add a table called ".fn" */ lua_pushstring(L,".fn"); lua_newtable(L); /* add manual disown method */ SWIG_Lua_add_function(L,"__disown",SWIG_Lua_class_disown); lua_rawset(L,-3); /* add accessor fns for using the .get,.set&.fn */ SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get); SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set); SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct); /* add it */ lua_rawset(L,-3); /* metatable into registry */ lua_pop(L,1); /* tidy stack (remove registry) */ assert(lua_gettop(L) == begin); #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* Now merge all symbols from .fn, .set, .get etc from bases to our tables */ SWIG_Lua_class_squash_bases(L,clss); #endif SWIG_Lua_get_class_metatable(L,clss->fqname); SWIG_Lua_add_class_instance_details(L,clss); /* recursive adding of details (atts & ops) */ lua_pop(L,1); /* tidy stack (remove class metatable) */ assert( lua_gettop(L) == begin ); } SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss) { int SWIGUNUSED begin; assert(lua_istable(L,-1)); /* This is a table (module or namespace) where classes will be added */ SWIG_Lua_class_register_instance(L,clss); SWIG_Lua_class_register_static(L,clss); /* Add links from static part to instance part and vice versa */ /* [SWIG registry] [Module] * "MyClass" ----> [MyClass metatable] <===== "MyClass" -+> [static part] * ".get" ----> ... | | getmetatable()----| * ".set" ----> ... | | | * ".static" --------------)----------------/ [static part metatable] * | ".get" --> ... * | ".set" --> .... * |=============================== ".instance" */ begin = lua_gettop(L); lua_pushstring(L,clss->cls_static->name); lua_rawget(L,-2); /* get class static table */ assert(lua_istable(L,-1)); lua_getmetatable(L,-1); assert(lua_istable(L,-1)); /* get class static metatable */ lua_pushstring(L,".instance"); /* prepare key */ SWIG_Lua_get_class_metatable(L,clss->fqname); /* get class metatable */ assert(lua_istable(L,-1)); lua_pushstring(L,".static"); /* prepare key */ lua_pushvalue(L, -4); /* push static class TABLE */ assert(lua_istable(L,-1)); lua_rawset(L,-3); /* assign static class table(!NOT metatable) as ".static" member of class metatable */ lua_rawset(L,-3); /* assign class metatable as ".instance" member of class static METATABLE */ lua_pop(L,2); assert(lua_gettop(L) == begin); } #endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */ #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_class *clss) { const int SWIGUNUSED begin = lua_gettop(L); int i; /* if name already there (class is already registered) then do nothing */ SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->fqname); /* get the name */ lua_rawget(L,-2); if(!lua_isnil(L,-1)) { lua_pop(L,2); assert(lua_gettop(L)==begin); return; } lua_pop(L,2); /* tidy stack */ /* Recursively initialize all bases */ for(i=0;clss->bases[i];i++) { SWIG_Lua_elua_class_register_instance(L,clss->bases[i]); } /* Again, get registry and push name */ SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->fqname); /* get the name */ assert(clss->metatable); lua_pushrotable(L, (void*)(clss->metatable)); /* create the metatable */ lua_rawset(L,-3); lua_pop(L,1); assert(lua_gettop(L) == begin); } #endif /* elua && eluac */ /* ----------------------------------------------------------------------------- * Class/structure conversion fns * ----------------------------------------------------------------------------- */ /* helper to add metatable to new lua object */ SWIGINTERN void SWIG_Lua_AddMetatable(lua_State *L,swig_type_info *type) { if (type->clientdata) /* there is clientdata: so add the metatable */ { SWIG_Lua_get_class_metatable(L,((swig_lua_class*)(type->clientdata))->fqname); if (lua_istable(L,-1)) { lua_setmetatable(L,-2); } else { lua_pop(L,1); } } } /* pushes a new object into the lua stack */ SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L,void *ptr,swig_type_info *type, int own) { swig_lua_userdata *usr; if (!ptr){ lua_pushnil(L); return; } usr=(swig_lua_userdata*)lua_newuserdata(L,sizeof(swig_lua_userdata)); /* get data */ usr->ptr=ptr; /* set the ptr */ usr->type=type; usr->own=own; #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) SWIG_Lua_AddMetatable(L,type); /* add metatable */ #endif } /* takes a object from the lua stack & converts it into an object of the correct type (if possible) */ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type_info *type,int flags) { swig_lua_userdata *usr; swig_cast_info *cast; if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */ usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */ if (usr) { if (flags & SWIG_POINTER_DISOWN) /* must disown the object */ { usr->own=0; } if (!type) /* special cast void*, no casting fn */ { *ptr=usr->ptr; return SWIG_OK; /* ok */ } cast=SWIG_TypeCheckStruct(usr->type,type); /* performs normal type checking */ if (cast) { int newmemory = 0; *ptr=SWIG_TypeCast(cast,usr->ptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return SWIG_OK; /* ok */ } } return SWIG_ERROR; /* error */ } SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State *L,int index,swig_type_info *type,int flags, int argnum,const char *func_name){ void *result; if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){ luaL_error (L,"Error in %s, expected a %s at argument number %d\n", func_name,(type && type->str)?type->str:"void*",argnum); } return result; } /* pushes a packed userdata. user for member fn pointers only */ SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_type_info *type) { swig_lua_rawdata *raw; assert(ptr); /* not acceptable to pass in a NULL value */ raw=(swig_lua_rawdata*)lua_newuserdata(L,sizeof(swig_lua_rawdata)-1+size); /* alloc data */ raw->type=type; raw->own=0; memcpy(raw->data,ptr,size); /* copy the data */ SWIG_Lua_AddMetatable(L,type); /* add metatable */ } /* converts a packed userdata. user for member fn pointers only */ SWIGRUNTIME int SWIG_Lua_ConvertPacked(lua_State *L,int index,void *ptr,size_t size,swig_type_info *type) { swig_lua_rawdata *raw; raw=(swig_lua_rawdata*)lua_touserdata(L,index); /* get data */ if (!raw) return SWIG_ERROR; /* error */ if (type==0 || type==raw->type) /* void* or identical type */ { memcpy(ptr,raw->data,size); /* copy it */ return SWIG_OK; /* ok */ } return SWIG_ERROR; /* error */ } /* a function to get the typestring of a piece of data */ SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp) { swig_lua_userdata *usr; if (lua_isuserdata(L,tp)) { usr=(swig_lua_userdata*)lua_touserdata(L,tp); /* get data */ if (usr && usr->type && usr->type->str) return usr->type->str; return "userdata (unknown type)"; } return lua_typename(L,lua_type(L,tp)); } /* lua callable function to get the userdata's type */ SWIGRUNTIME int SWIG_Lua_type(lua_State *L) { lua_pushstring(L,SWIG_Lua_typename(L,1)); return 1; } /* ----------------------------------------------------------------------------- * global variable support code: class/struct typemap functions * ----------------------------------------------------------------------------- */ #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* Install Constants */ SWIGINTERN void SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) { int i; for (i = 0; constants[i].type; i++) { switch(constants[i].type) { case SWIG_LUA_INT: lua_pushstring(L,constants[i].name); lua_pushinteger(L,(lua_Number)constants[i].lvalue); lua_rawset(L,-3); break; case SWIG_LUA_FLOAT: lua_pushstring(L,constants[i].name); lua_pushnumber(L,(lua_Number)constants[i].dvalue); lua_rawset(L,-3); break; case SWIG_LUA_CHAR: lua_pushstring(L,constants[i].name); { char c = constants[i].lvalue; lua_pushlstring(L,&c,1); } lua_rawset(L,-3); break; case SWIG_LUA_STRING: lua_pushstring(L,constants[i].name); lua_pushstring(L,(char *) constants[i].pvalue); lua_rawset(L,-3); break; case SWIG_LUA_POINTER: lua_pushstring(L,constants[i].name); SWIG_NewPointerObj(L,constants[i].pvalue, *(constants[i]).ptype,0); lua_rawset(L,-3); break; case SWIG_LUA_BINARY: lua_pushstring(L,constants[i].name); SWIG_NewMemberObj(L,constants[i].pvalue,constants[i].lvalue,*(constants[i]).ptype); lua_rawset(L,-3); break; default: break; } } } #endif /* ----------------------------------------------------------------------------- * executing lua code from within the wrapper * ----------------------------------------------------------------------------- */ #ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */ #define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S) #endif /* Executes a C string in Lua which is a really simple way of calling lua from C Unfortunately lua keeps changing its APIs, so we need a conditional compile In lua 5.0.X it's lua_dostring() In lua 5.1.X it's luaL_dostring() */ SWIGINTERN int SWIG_Lua_dostring(lua_State *L, const char *str) { int ok,top; if (str==0 || str[0]==0) return 0; /* nothing to do */ top=lua_gettop(L); /* save stack */ #if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501)) ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */ #else ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */ #endif if (ok!=0) { SWIG_DOSTRING_FAIL(lua_tostring(L,-1)); } lua_settop(L,top); /* restore the stack */ return ok; } #ifdef __cplusplus } #endif /* ------------------------------ end luarun.swg ------------------------------ */ swig-3.0.8/Lib/lua/std_map.i0000664000175000017500000000333212641054563015452 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; } swig-3.0.8/Lib/lua/luakw.swg0000664000175000017500000000230412641054563015514 0ustar williamwilliam/* Warnings for Lua keywords, built-in names and bad names. */ #define LUAKW(x) %keywordwarn("'" `x` "' is a Lua keyword, renaming to 'c_" `x` "'", rename="c_%s") `x` #define LUABN(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "'" `x` "' conflicts with a basic function in Lua"), %$not %$ismember) `x` /* Warnings for Lua keywords http://www.lua.org/manual/5.2/manual.html#3.1 */ LUAKW(and); LUAKW(break); LUAKW(do); LUAKW(else); LUAKW(elseif); LUAKW(end); LUAKW(false); LUAKW(for); LUAKW(function); LUAKW(goto); LUAKW(if); LUAKW(in); LUAKW(local); LUAKW(nil); LUAKW(not); LUAKW(or); LUAKW(repeat); LUAKW(return); LUAKW(then); LUAKW(true); LUAKW(until); LUAKW(while); /* Basic functions http://www.lua.org/manual/5.2/manual.html#6.1 */ LUABN(assert); LUABN(collectgarbage); LUABN(dofile); LUABN(error); LUABN(_G); // Not actually a function LUABN(getmetatable); LUABN(ipairs); LUABN(load); LUABN(loadfile); LUABN(next); LUABN(pairs); LUABN(pcall); LUABN(print); LUABN(rawequal); LUABN(rawget); LUABN(rawlen); LUABN(rawset); LUABN(select); LUABN(setmetatable); LUABN(tonumber); LUABN(tostring); LUABN(type); LUABN(_VERSION); // Not actually a function LUABN(xpcall); #undef LUABN #undef LUAKW swig-3.0.8/Lib/lua/std_string.i0000664000175000017500000000632712641054563016212 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * std::string typemaps for LUA * ----------------------------------------------------------------------------- */ %{ #include %} /* Only std::string and const std::string& are typemapped they are converted to the Lua strings automatically std::string& and std::string* are not they must be explicitly managed (see below) eg. std::string test_value(std::string x) { return x; } can be used as s="hello world" s2=test_value(s) assert(s==s2) */ namespace std { %naturalvar string; /* Bug report #1526022: Lua strings and std::string can contain embedded zero bytes Therefore a standard out typemap should not be: lua_pushstring(L,$1.c_str()); but lua_pushlstring(L,$1.data(),$1.size()); Similarly for getting the string $1 = (char*)lua_tostring(L, $input); becomes $1.assign(lua_tostring(L,$input),lua_rawlen(L,$input)); Not using: lua_tolstring() as this is only found in Lua 5.1 & not 5.0.2 */ %typemap(in,checkfn="lua_isstring") string %{$1.assign(lua_tostring(L,$input),lua_rawlen(L,$input));%} %typemap(out) string %{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_arg++;%} %typemap(in,checkfn="lua_isstring") const string& ($*1_ltype temp) %{temp.assign(lua_tostring(L,$input),lua_rawlen(L,$input)); $1=&temp;%} %typemap(out) const string& %{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%} // for throwing of any kind of string, string ref's and string pointers // we convert all to lua strings %typemap(throws) string, string&, const string& %{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_fail;%} %typemap(throws) string*, const string* %{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_fail;%} %typecheck(SWIG_TYPECHECK_STRING) string, const string& { $1 = lua_isstring(L,$input); } /* std::string& can be wrapped, but you must inform SWIG if it is in or out eg: void fn(std::string& str); Is this an in/out/inout value? Therefore you need the usual %apply (std::string& INOUT) {std::string& str}; or %apply std::string& INOUT {std::string& str}; typemaps to tell SWIG what to do. */ %typemap(in) string &INPUT=const string &; %typemap(in, numinputs=0) string &OUTPUT ($*1_ltype temp) %{ $1 = &temp; %} %typemap(argout) string &OUTPUT %{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%} %typemap(in) string &INOUT =const string &; %typemap(argout) string &INOUT = string &OUTPUT; /* A really cut down version of the string class This provides basic mapping of lua strings <-> std::string and little else (the std::string has a lot of unneeded functions anyway) note: no fn's taking the const string& as this is overloaded by the const char* version */ class string { public: string(); string(const char*); //string(const string&); unsigned int size() const; unsigned int length() const; bool empty() const; // no support for operator[] const char* c_str()const; const char* data()const; // assign does not return a copy of this object // (no point in a scripting language) void assign(const char*); //void assign(const string&); // no support for all the other features // it's probably better to do it in lua }; } swig-3.0.8/Lib/lua/stl.i0000664000175000017500000000044312641054563014625 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/lua/luaruntime.swg0000664000175000017500000000572212641054563016565 0ustar williamwilliam/* ----------------------------------------------------------------------------- * luaruntime.swg * * all the runtime code for . * ----------------------------------------------------------------------------- */ %runtime "swigrun.swg"; /* Common C API type-checking code */ %runtime "luarun.swg"; /* Lua runtime stuff */ %insert(initbeforefunc) "swiginit.swg" %insert(initbeforefunc) %{ /* Forward declaration of where the user's %init{} gets inserted */ void SWIG_init_user(lua_State* L ); #ifdef __cplusplus extern "C" { #endif /* this is the initialization function added at the very end of the code the function is always called SWIG_init, but an earlier #define will rename it */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) LUALIB_API int SWIG_init(lua_State* L) #else SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */ #endif { #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */ int i; int globalRegister = 0; /* start with global table */ lua_pushglobaltable (L); /* SWIG's internal initialisation */ SWIG_InitializeModule((void*)L); SWIG_PropagateClientData(); #endif #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) || defined(SWIG_LUA_ELUA_EMULATE) /* add a global fn */ SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type); SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_class_equal); #endif #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* set up base class pointers (the hierarchy) */ for (i = 0; swig_types[i]; i++){ if (swig_types[i]->clientdata){ SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata)); } } #ifdef SWIG_LUA_MODULE_GLOBAL globalRegister = 1; #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) SWIG_Lua_namespace_register(L,&swig_SwigModule, globalRegister); #endif #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) for (i = 0; swig_types[i]; i++){ if (swig_types[i]->clientdata){ SWIG_Lua_elua_class_register_instance(L,(swig_lua_class*)(swig_types[i]->clientdata)); } } #endif #if defined(SWIG_LUA_ELUA_EMULATE) lua_newtable(L); SWIG_Lua_elua_emulate_register(L,swig_SwigModule.ns_methods); SWIG_Lua_elua_emulate_register_clear(L); if(globalRegister) { lua_pushstring(L,swig_SwigModule.name); lua_pushvalue(L,-2); lua_rawset(L,-4); } #endif #endif #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* invoke user-specific initialization */ SWIG_init_user(L); /* end module */ /* Note: We do not clean up the stack here (Lua will do this for us). At this point, we have the globals table and out module table on the stack. Returning one value makes the module table the result of the require command. */ return 1; #else return 0; #endif } #ifdef __cplusplus } #endif %} /* Note: the initialization function is closed after all code is generated */ swig-3.0.8/Lib/lua/typemaps.i0000664000175000017500000004575312641054563015702 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.swg * * SWIG Library file containing the main typemap code to support Lua modules. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * Basic inout typemaps * ----------------------------------------------------------------------------- */ /* These provide the basic ability for passing in & out of standard numeric data types (int,long,float,double, etc) The basic code looks like this: %typemap(in,checkfn="lua_isnumber") int *INPUT(int temp), int &INPUT(int temp) %{ temp = (int)lua_tonumber(L,$input); $1 = &temp; %} %typemap(in, numinputs=0) int *OUTPUT (int temp) %{ $1 = &temp; %} %typemap(argout) int *OUTPUT %{ lua_pushnumber(L, (double) *$1); SWIG_arg++;%} %typemap(in) int *INOUT = int *INPUT; %typemap(argout) int *INOUT = int *OUTPUT; However the code below is a mixture of #defines & such, so nowhere as easy to read To make you code work correctly its not just a matter of %including this file You also have to give SWIG the hints on which to use where eg extern int add_pointer(int* a1,int* a2); // a1 & a2 are pointer values to be added extern void swap(int* s1, int* s2); // does the swap You will need to either change the argument names extern int add_pointer(int* INPUT,int* INPUT); or provide a %apply statement %apply int* INOUT{ int *s1, int *s2 }; // if SWIG sees int* s1, int* s2, assume they are inout params */ %define SWIG_NUMBER_TYPEMAP(TYPE) %typemap(in,checkfn="lua_isnumber") TYPE *INPUT($*ltype temp), TYPE &INPUT($*ltype temp) %{ temp = ($*ltype)lua_tonumber(L,$input); $1 = &temp; %} %typemap(in, numinputs=0) TYPE *OUTPUT ($*ltype temp) %{ $1 = &temp; %} %typemap(argout) TYPE *OUTPUT %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} %typemap(in) TYPE *INOUT = TYPE *INPUT; %typemap(argout) TYPE *INOUT = TYPE *OUTPUT; %typemap(in) TYPE &OUTPUT = TYPE *OUTPUT; %typemap(argout) TYPE &OUTPUT = TYPE *OUTPUT; %typemap(in) TYPE &INOUT = TYPE *INPUT; %typemap(argout) TYPE &INOUT = TYPE *OUTPUT; // const version (the $*ltype is the basic number without ptr or const's) %typemap(in,checkfn="lua_isnumber") const TYPE *INPUT($*ltype temp) %{ temp = ($*ltype)lua_tonumber(L,$input); $1 = &temp; %} %enddef // now the code SWIG_NUMBER_TYPEMAP(unsigned char); SWIG_NUMBER_TYPEMAP(signed char); SWIG_NUMBER_TYPEMAP(short); SWIG_NUMBER_TYPEMAP(unsigned short); SWIG_NUMBER_TYPEMAP(signed short); SWIG_NUMBER_TYPEMAP(int); SWIG_NUMBER_TYPEMAP(unsigned int); SWIG_NUMBER_TYPEMAP(signed int); SWIG_NUMBER_TYPEMAP(long); SWIG_NUMBER_TYPEMAP(unsigned long); SWIG_NUMBER_TYPEMAP(signed long); SWIG_NUMBER_TYPEMAP(float); SWIG_NUMBER_TYPEMAP(double); SWIG_NUMBER_TYPEMAP(enum SWIGTYPE); // also for long longs's SWIG_NUMBER_TYPEMAP(long long); SWIG_NUMBER_TYPEMAP(unsigned long long); SWIG_NUMBER_TYPEMAP(signed long long); // note we dont do char, as a char* is probably a string not a ptr to a single char // similar for booleans %typemap(in,checkfn="lua_isboolean") bool *INPUT(bool temp), bool &INPUT(bool temp) %{ temp = (lua_toboolean(L,$input)!=0); $1 = &temp; %} %typemap(in, numinputs=0) bool *OUTPUT (bool temp),bool &OUTPUT (bool temp) %{ $1 = &temp; %} %typemap(argout) bool *OUTPUT,bool &OUTPUT %{ lua_pushboolean(L, (int)((*$1)!=0)); SWIG_arg++;%} %typemap(in) bool *INOUT = bool *INPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; /* ----------------------------------------------------------------------------- * Basic Array typemaps * ----------------------------------------------------------------------------- */ /* I have no idea why this kind of code does not exist in SWIG as standard, but here is it. This code will convert to/from 1D numeric arrays. In order to reduce code bloat, there are a few macros and quite a few functions defined (unfortunately this makes it a lot less clear) assuming we have functions void process_array(int arr[3]); // nice fixed size array void process_var_array(float arr[],int len); // variable sized array void process_var_array_inout(double* arr,int len); // variable sized array // data passed in & out void process_enum_inout_array_var(enum Days *arrinout, int len); // using enums void return_array_5(int arrout[5]); // out array only in order to wrap them correctly requires a typemap // inform SWIG of the correct typemap // For fixed length, you must specify it as INPUT[ANY] %apply (int INPUT[ANY]) {(int arr[3])}; // variable length arrays are just the same %apply (float INPUT[],int) {(float arr[],int len)}; // it is also ok, to map the TYPE* instead of a TYPE[] %apply (double *INOUT,int) {(double arr*,int len)}; // for the enum's you must use enum SWIGTYPE %apply (enum SWIGTYPE *INOUT,int) {(enum Days *arrinout, int len)}; // fixed length out if also fine %apply (int OUTPUT[ANY]) {(int arrout[5])}; Generally, you could use %typemap(...)=... but the %apply is neater & easier a few things of note: * all Lua tables are indexed from 1, all C/C++ arrays are indexed from 0 therefore t={6,5,3} -- t[1]==6, t[2]==5, t[3]==3 when passed to process_array(int arr[3]) becomes arr[0]==6, arr[1]==5, arr[2]==3 * for OUTPUT arrays, no array need be passed in, the fn will return a Lua table so for the above mentioned return_array_5() would look like arr=return_array_5() -- no parameters passed in * for INOUT arrays, a table must be passed in, and a new table will be returned (this is consistent with the way that numbers are processed) if you want just use arr={...} arr=process_var_array_inout(arr) -- arr is replaced by the new version The following are not yet supported: * variable length output only array (inout works ok) * multidimensional arrays * arrays of objects/structs * arrays of pointers */ /* The internals of the array management stuff helper fns/macros SWIG_ALLOC_ARRAY(TYPE,LEN) // returns a typed array TYPE[LEN] SWIG_FREE_ARRAY(PTR) // delete the ptr (if not zero) // counts the specified table & gets the size // integer version int SWIG_itable_size(lua_State* L, int index); // other version int SWIG_table_size(lua_State* L, int index); SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE) // this fn declares up 4 functions for helping to read/write tables // these can then be called by the macros ... // all assume the table is an integer indexes from 1 // but the C array is a indexed from 0 // created a fixed size array, reads the specified table // and then fills the array with numbers // returns ptr to the array if ok, or 0 for error // (also pushes a error message to the stack) TYPE* SWIG_get_NAME_num_array_fixed(lua_State* L, int index, int size); // as per SWIG_get_NAME_num_array_fixed() // but reads the entire table & creates an array of the correct size // (if the table is empty, it returns an error rather than a zero length array) TYPE* SWIG_get_NAME_num_array_var(lua_State* L, int index, int* size); // writes a table to Lua with all the specified numbers void SWIG_write_NAME_num_array(lua_State* L,TYPE *array,int size); // read the specified table, and fills the array with numbers // returns 1 of ok (only fails if it doesnt find numbers) // helper fn (called by SWIG_get_NAME_num_array_*() fns) int SWIG_read_NAME_num_array(lua_State* L,int index,TYPE *array,int size); */ /* Reported that you don't need to check for NULL for delete & free There probably is some compiler that its not true for, so the code is left here just in case. #ifdef __cplusplus #define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN] #define SWIG_FREE_ARRAY(PTR) if(PTR){delete[] PTR;} #else #define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE)) #define SWIG_FREE_ARRAY(PTR) if(PTR){free(PTR);} #endif */ %{ #ifdef __cplusplus /* generic alloc/dealloc fns*/ #define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN] #define SWIG_FREE_ARRAY(PTR) delete[] PTR #else #define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE)) #define SWIG_FREE_ARRAY(PTR) free(PTR) #endif /* counting the size of arrays:*/ SWIGINTERN int SWIG_itable_size(lua_State* L, int index) { int n=0; while(1){ lua_rawgeti(L,index,n+1); if (lua_isnil(L,-1))break; ++n; lua_pop(L,1); } lua_pop(L,1); return n; } SWIGINTERN int SWIG_table_size(lua_State* L, int index) { int n=0; lua_pushnil(L); /* first key*/ while (lua_next(L, index) != 0) { ++n; lua_pop(L, 1); /* removes `value'; keeps `key' for next iteration*/ } return n; } /* super macro to declare array typemap helper fns */ #define SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)\ SWIGINTERN int SWIG_read_##NAME##_num_array(lua_State* L,int index,TYPE *array,int size){\ int i;\ for (i = 0; i < size; i++) {\ lua_rawgeti(L,index,i+1);\ if (lua_isnumber(L,-1)){\ array[i] = (TYPE)lua_tonumber(L,-1);\ } else {\ lua_pop(L,1);\ return 0;\ }\ lua_pop(L,1);\ }\ return 1;\ }\ SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\ TYPE *array;\ if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\ SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\ SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ return array;\ }\ SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_var(lua_State* L, int index, int* size)\ {\ TYPE *array;\ if (!lua_istable(L,index)) {\ SWIG_Lua_pusherrstring(L,"expected a table");\ return 0;\ }\ *size=SWIG_itable_size(L,index);\ if (*size<1){\ SWIG_Lua_pusherrstring(L,"table appears to be empty");\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,*size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\ SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ return array;\ }\ SWIGINTERN void SWIG_write_##NAME##_num_array(lua_State* L,TYPE *array,int size){\ int i;\ lua_newtable(L);\ for (i = 0; i < size; i++){\ lua_pushnumber(L,(lua_Number)array[i]);\ lua_rawseti(L,-2,i+1);/* -1 is the number, -2 is the table*/ \ }\ } %} /* This is one giant macro to define the typemaps & the helpers for array handling */ %define SWIG_TYPEMAP_NUM_ARR(NAME,TYPE) %{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)%} // fixed size array's %typemap(in) TYPE INPUT[ANY] %{ $1 = SWIG_get_##NAME##_num_array_fixed(L,$input,$1_dim0); if (!$1) SWIG_fail;%} %typemap(freearg) TYPE INPUT[ANY] %{ SWIG_FREE_ARRAY($1);%} // variable size array's %typemap(in) (TYPE *INPUT,int) %{ $1 = SWIG_get_##NAME##_num_array_var(L,$input,&$2); if (!$1) SWIG_fail;%} %typemap(freearg) (TYPE *INPUT,int) %{ SWIG_FREE_ARRAY($1);%} // out fixed arrays %typemap(in,numinputs=0) TYPE OUTPUT[ANY] %{ $1 = SWIG_ALLOC_ARRAY(TYPE,$1_dim0); %} %typemap(argout) TYPE OUTPUT[ANY] %{ SWIG_write_##NAME##_num_array(L,$1,$1_dim0); SWIG_arg++; %} %typemap(freearg) TYPE OUTPUT[ANY] %{ SWIG_FREE_ARRAY($1); %} // inout fixed arrays %typemap(in) TYPE INOUT[ANY]=TYPE INPUT[ANY]; %typemap(argout) TYPE INOUT[ANY]=TYPE OUTPUT[ANY]; %typemap(freearg) TYPE INOUT[ANY]=TYPE INPUT[ANY]; // inout variable arrays %typemap(in) (TYPE *INOUT,int)=(TYPE *INPUT,int); %typemap(argout) (TYPE *INOUT,int) %{ SWIG_write_##NAME##_num_array(L,$1,$2); SWIG_arg++; %} %typemap(freearg) (TYPE *INOUT,int)=(TYPE *INPUT,int); // TODO out variable arrays (is there a standard form for such things?) // referencing so that (int *INPUT,int) and (int INPUT[],int) are the same %typemap(in) (TYPE INPUT[],int)=(TYPE *INPUT,int); %typemap(freearg) (TYPE INPUT[],int)=(TYPE *INPUT,int); %enddef // the following line of code // declares the C helper fns for the array typemaps // as well as defining typemaps for // fixed len arrays in & out, & variable length arrays in SWIG_TYPEMAP_NUM_ARR(schar,signed char); SWIG_TYPEMAP_NUM_ARR(uchar,unsigned char); SWIG_TYPEMAP_NUM_ARR(int,int); SWIG_TYPEMAP_NUM_ARR(uint,unsigned int); SWIG_TYPEMAP_NUM_ARR(short,short); SWIG_TYPEMAP_NUM_ARR(ushort,unsigned short); SWIG_TYPEMAP_NUM_ARR(long,long); SWIG_TYPEMAP_NUM_ARR(ulong,unsigned long); SWIG_TYPEMAP_NUM_ARR(float,float); SWIG_TYPEMAP_NUM_ARR(double,double); // again enums are a problem so they need their own type // we use the int conversion routine & recast it %typemap(in) enum SWIGTYPE INPUT[ANY] %{ $1 = ($ltype)SWIG_get_int_num_array_fixed(L,$input,$1_dim0); if (!$1) SWIG_fail;%} %typemap(freearg) enum SWIGTYPE INPUT[ANY] %{ SWIG_FREE_ARRAY($1);%} // variable size arrays %typemap(in) (enum SWIGTYPE *INPUT,int) %{ $1 = ($ltype)SWIG_get_int_num_array_var(L,$input,&$2); if (!$1) SWIG_fail;%} %typemap(freearg) (enum SWIGTYPE *INPUT,int) %{ SWIG_FREE_ARRAY($1);%} // out fixed arrays %typemap(in,numinputs=0) enum SWIGTYPE OUTPUT[ANY] %{ $1 = SWIG_ALLOC_ARRAY(enum SWIGTYPE,$1_dim0); %} %typemap(argout) enum SWIGTYPE OUTPUT[ANY] %{ SWIG_write_int_num_array(L,(int*)$1,$1_dim0); SWIG_arg++; %} %typemap(freearg) enum SWIGTYPE OUTPUT[ANY] %{ SWIG_FREE_ARRAY($1); %} // inout fixed arrays %typemap(in) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE INPUT[ANY]; %typemap(argout) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE OUTPUT[ANY]; %typemap(freearg) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE INPUT[ANY]; // inout variable arrays %typemap(in) (enum SWIGTYPE *INOUT,int)=(enum SWIGTYPE *INPUT,int); %typemap(argout) (enum SWIGTYPE *INOUT,int) %{ SWIG_write_int_num_array(L,(int*)$1,$2); SWIG_arg++; %} %typemap(freearg) (enum SWIGTYPE *INOUT,int)=(enum SWIGTYPE *INPUT,int); /* Surprisingly pointer arrays are easier: this is because all ptr arrays become void** so only a few fns are needed & a few casts The function defined are // created a fixed size array, reads the specified table // and then fills the array with pointers (checking the type) // returns ptr to the array if ok, or 0 for error // (also pushes a error message to the stack) void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type); // as per SWIG_get_ptr_array_fixed() // but reads the entire table & creates an array of the correct size // (if the table is empty, it returns an error rather than a zero length array) void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type); // writes a table to Lua with all the specified pointers // all pointers have the ownership value 'own' (normally 0) void SWIG_write_ptr_array(lua_State* L,void **array,int size,int own); // read the specified table, and fills the array with ptrs // returns 1 of ok (only fails if it doesn't find correct type of ptrs) // helper fn (called by SWIG_get_ptr_array_*() fns) int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,swig_type_info *type); The key thing to remember is that it is assumed that there is no modification of pointers ownership in the arrays eg A fn: void pointers_in(TYPE* arr[],int len); will make copies of the pointer into a temp array and then pass it into the fn Lua does not remember that this fn held the pointers, so it is not safe to keep these pointers until later eg A fn: void pointers_out(TYPE* arr[3]); will return a table containing three pointers however these pointers are NOT owned by Lua, merely borrowed so if the C/C++ frees then Lua is not aware */ %{ SWIGINTERN int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,swig_type_info *type){ int i; for (i = 0; i < size; i++) { lua_rawgeti(L,index,i+1); if (!lua_isuserdata(L,-1) || SWIG_ConvertPtr(L,-1,&array[i],type,0)==-1){ lua_pop(L,1); return 0; } lua_pop(L,1); } return 1; } SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){ void **array; if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) { SWIG_Lua_pushferrstring(L,"expected a table of size %d",size); return 0; } array=SWIG_ALLOC_ARRAY(void*,size); if (!SWIG_read_ptr_array(L,index,array,size,type)){ SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } return array; } SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){ void **array; if (!lua_istable(L,index)) { SWIG_Lua_pusherrstring(L,"expected a table"); return 0; } *size=SWIG_itable_size(L,index); if (*size<1){ SWIG_Lua_pusherrstring(L,"table appears to be empty"); return 0; } array=SWIG_ALLOC_ARRAY(void*,*size); if (!SWIG_read_ptr_array(L,index,array,*size,type)){ SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } return array; } SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_type_info *type,int own){ int i; lua_newtable(L); for (i = 0; i < size; i++){ SWIG_NewPointerObj(L,array[i],type,own); lua_rawseti(L,-2,i+1);/* -1 is the number, -2 is the table*/ } } %} // fixed size array's %typemap(in) SWIGTYPE* INPUT[ANY] %{ $1 = ($ltype)SWIG_get_ptr_array_fixed(L,$input,$1_dim0,$*1_descriptor); if (!$1) SWIG_fail;%} %typemap(freearg) SWIGTYPE* INPUT[ANY] %{ SWIG_FREE_ARRAY($1);%} // variable size array's %typemap(in) (SWIGTYPE **INPUT,int) %{ $1 = ($ltype)SWIG_get_ptr_array_var(L,$input,&$2,$*1_descriptor); if (!$1) SWIG_fail;%} %typemap(freearg) (SWIGTYPE **INPUT,int) %{ SWIG_FREE_ARRAY($1);%} // out fixed arrays %typemap(in,numinputs=0) SWIGTYPE* OUTPUT[ANY] %{ $1 = SWIG_ALLOC_ARRAY($*1_type,$1_dim0); %} %typemap(argout) SWIGTYPE* OUTPUT[ANY] %{ SWIG_write_ptr_array(L,(void**)$1,$1_dim0,$*1_descriptor,0); SWIG_arg++; %} %typemap(freearg) SWIGTYPE* OUTPUT[ANY] %{ SWIG_FREE_ARRAY($1); %} // inout fixed arrays %typemap(in) SWIGTYPE* INOUT[ANY]=SWIGTYPE* INPUT[ANY]; %typemap(argout) SWIGTYPE* INOUT[ANY]=SWIGTYPE* OUTPUT[ANY]; %typemap(freearg) SWIGTYPE* INOUT[ANY]=SWIGTYPE* INPUT[ANY]; // inout variable arrays %typemap(in) (SWIGTYPE** INOUT,int)=(SWIGTYPE** INPUT,int); %typemap(argout) (SWIGTYPE** INOUT,int) %{ SWIG_write_ptr_array(L,(void**)$1,$2,$*1_descriptor,0); SWIG_arg++; %} %typemap(freearg) (SWIGTYPE**INOUT,int)=(SWIGTYPE**INPUT,int); /* ----------------------------------------------------------------------------- * Pointer-Pointer typemaps * ----------------------------------------------------------------------------- */ /* This code is to deal with the issue for pointer-pointer's In particular for factory methods. for example take the following code segment: struct iMath; // some structure int Create_Math(iMath** pptr); // its factory (assume it mallocs) to use it you might have the following C code: iMath* ptr; int ok; ok=Create_Math(&ptr); // do things with ptr //... free(ptr); With the following SWIG code %apply SWIGTYPE** OUTPUT{iMath **pptr }; You can get natural wrapping in Lua as follows: ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int ptr=nil -- the iMath* will be GC'ed as normal */ %typemap(in,numinputs=0) SWIGTYPE** OUTPUT ($*ltype temp) %{ temp = ($*ltype)0; $1 = &temp; %} %typemap(argout) SWIGTYPE** OUTPUT %{SWIG_NewPointerObj(L,*$1,$*descriptor,1); SWIG_arg++; %} swig-3.0.8/Lib/lua/std_vector.i0000664000175000017500000000601212641054563016175 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * std::vector typemaps for LUA * ----------------------------------------------------------------------------- */ %{ #include %} %include // the general exceptions /* A really cut down version of the vector class. Note: this does not match the true std::vector class but instead is an approximate, so that SWIG knows how to wrapper it. (Eg, all access is by value, not ref, as SWIG turns refs to pointers) And no support for iterators & insert/erase It would be useful to have a vector<->Lua table conversion routine */ namespace std { template class vector { public: vector(); vector(unsigned int); vector(const vector&); vector(unsigned int,T); unsigned int size() const; unsigned int max_size() const; bool empty() const; void clear(); void push_back(T val); void pop_back(); T front()const; // only read front & back T back()const; // not write to them // operator [] given later: %extend // this is a extra bit of SWIG code { // [] is replaced by __getitem__ & __setitem__ // simply throws a string, which causes a lua error T __getitem__(unsigned int idx) throw (std::out_of_range) { if (idx>=self->size()) throw std::out_of_range("in vector::__getitem__()"); return (*self)[idx]; } void __setitem__(unsigned int idx,T val) throw (std::out_of_range) { if (idx>=self->size()) throw std::out_of_range("in vector::__setitem__()"); (*self)[idx]=val; } }; }; } /* Vector<->LuaTable fns These look a bit like the array<->LuaTable fns but are templated, not %defined (you must have template support for STL) */ /* %{ // reads a table into a vector of numbers // lua numbers will be cast into the type required (rounding may occur) // return 0 if non numbers found in the table // returns new'ed ptr if ok template std::vector* SWIG_read_number_vector(lua_State* L,int index) { int i=0; std::vector* vec=new std::vector(); while(1) { lua_rawgeti(L,index,i+1); if (!lua_isnil(L,-1)) { lua_pop(L,1); break; // finished } if (!lua_isnumber(L,-1)) { lua_pop(L,1); delete vec; return 0; // error } vec->push_back((T)lua_tonumber(L,-1)); lua_pop(L,1); ++i; } return vec; // ok } // writes a vector of numbers out as a lua table template int SWIG_write_number_vector(lua_State* L,std::vector *vec) { lua_newtable(L); for(int i=0;isize();++i) { lua_pushnumber(L,(double)((*vec)[i])); lua_rawseti(L,-2,i+1);// -1 is the number, -2 is the table } } %} // then the typemaps %define SWIG_TYPEMAP_NUM_VECTOR(T) // in %typemap(in) std::vector *INPUT %{ $1 = SWIG_read_number_vector(L,$input); if (!$1) SWIG_fail;%} %typemap(freearg) std::vector *INPUT %{ delete $1;%} // out %typemap(argout) std::vector *OUTPUT %{ SWIG_write_number_vector(L,$1); SWIG_arg++; %} %enddef */ swig-3.0.8/Lib/wchar.i0000664000175000017500000000046512641054563014352 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wchar.i * ----------------------------------------------------------------------------- */ /* wchar_t not supported, unless otherwise specified in the target language. */ #if defined(SWIG_WCHAR) #undef SWIG_WCHAR #endif swig-3.0.8/Lib/chicken/0000775000175000017500000000000012641054563014473 5ustar williamwilliamswig-3.0.8/Lib/chicken/swigclosprefix.scm0000664000175000017500000000221612641054563020250 0ustar williamwilliam(declare (hide swig-initialize)) (define (swig-initialize obj initargs create) (slot-set! obj 'swig-this (if (memq 'swig-this initargs) (cadr initargs) (let ((ret (apply create initargs))) (if (instance? ret) (slot-ref ret 'swig-this) ret))))) (define-class () (void)) (define-method (compute-getter-and-setter (class ) slot allocator) (if (not (memq ':swig-virtual slot)) (call-next-method) (let ((getter (let search-get ((lst slot)) (if (null? lst) #f (if (eq? (car lst) ':swig-get) (cadr lst) (search-get (cdr lst)))))) (setter (let search-set ((lst slot)) (if (null? lst) #f (if (eq? (car lst) ':swig-set) (cadr lst) (search-set (cdr lst))))))) (values (lambda (o) (getter (slot-ref o 'swig-this))) (lambda (o new) (setter (slot-ref o 'swig-this) new) new))))) swig-3.0.8/Lib/chicken/tinyclos-multi-generic.patch0000664000175000017500000001311312641054563022121 0ustar williamwilliam# This patch is against chicken 1.92, but it should work just fine # with older versions of chicken. It adds support for mulit-argument # generics, that is, generics now correctly handle adding methods # with different lengths of specializer lists # This patch has been committed into the CHICKEN darcs repository, # so chicken versions above 1.92 work fine. # Comments, bugs, suggestions send to chicken-users@nongnu.org # Patch written by John Lenz --- tinyclos.scm.old 2005-04-05 01:13:56.000000000 -0500 +++ tinyclos.scm 2005-04-11 16:37:23.746181489 -0500 @@ -37,8 +37,10 @@ (include "parameters") +(cond-expand [(not chicken-compile-shared) (declare (unit tinyclos))] + [else] ) + (declare - (unit tinyclos) (uses extras) (usual-integrations) (fixnum) @@ -234,7 +236,10 @@ y = C_block_item(y, 1); } } - return(C_block_item(v, i + 1)); + if (x == C_SCHEME_END_OF_LIST && y == C_SCHEME_END_OF_LIST) + return(C_block_item(v, i + 1)); + else + goto mismatch; } else if(free_index == -1) free_index = i; mismatch: @@ -438,7 +443,7 @@ (define hash-arg-list (foreign-lambda* unsigned-int ((scheme-object args) (scheme-object svector)) " C_word tag, h, x; - int n, i, j; + int n, i, j, len = 0; for(i = 0; args != C_SCHEME_END_OF_LIST; args = C_block_item(args, 1)) { x = C_block_item(args, 0); if(C_immediatep(x)) { @@ -481,8 +486,9 @@ default: i += 255; } } + ++len; } - return(i & (C_METHOD_CACHE_SIZE - 1));") ) + return((i + len) & (C_METHOD_CACHE_SIZE - 1));") ) ; @@ -868,13 +874,27 @@ (##tinyclos#slot-set! generic 'methods - (cons method - (filter-in - (lambda (m) - (let ([ms1 (method-specializers m)] - [ms2 (method-specializers method)] ) - (not (every2 (lambda (x y) (eq? x y)) ms1 ms2) ) ) ) - (##tinyclos#slot-ref generic 'methods)))) + (let* ([ms1 (method-specializers method)] + [l1 (length ms1)] ) + (let filter-in-method ([methods (##tinyclos#slot-ref generic 'methods)]) + (if (null? methods) + (list method) + (let* ([mm (##sys#slot methods 0)] + [ms2 (method-specializers mm)] + [l2 (length ms2)]) + (cond ((> l1 l2) + (cons mm (filter-in-method (##sys#slot methods 1)))) + ((< l1 l2) + (cons method methods)) + (else + (let check-method ([ms1 ms1] + [ms2 ms2]) + (cond ((and (null? ms1) (null? ms2)) + (cons method (##sys#slot methods 1))) ;; skip the method already in the generic + ((eq? (##sys#slot ms1 0) (##sys#slot ms2 0)) + (check-method (##sys#slot ms1 1) (##sys#slot ms2 1))) + (else + (cons mm (filter-in-method (##sys#slot methods 1))))))))))))) (if (memq generic generic-invocation-generics) (set! method-cache-tag (vector)) (%entity-cache-set! generic #f) ) @@ -925,11 +945,13 @@ (memq (car args) generic-invocation-generics)) (let ([proc (method-procedure + ; select the first method of one argument (let lp ([lis (generic-methods generic)]) - (let ([tail (##sys#slot lis 1)]) - (if (null? tail) - (##sys#slot lis 0) - (lp tail)) ) ) ) ] ) + (if (null? lis) + (##sys#error "Unable to find original compute-apply-generic") + (if (= (length (method-specializers (##sys#slot lis 0))) 1) + (##sys#slot lis 0) + (lp (##sys#slot lis 1)))))) ] ) (lambda (args) (apply proc #f args)) ) (let ([x (compute-apply-methods generic)] [y ((compute-methods generic) args)] ) @@ -946,9 +968,13 @@ (lambda (args) (let ([applicable (filter-in (lambda (method) - (every2 applicable? - (method-specializers method) - args)) + (let check-applicable ([list1 (method-specializers method)] + [list2 args]) + (cond ((null? list1) #t) + ((null? list2) #f) + (else + (and (applicable? (##sys#slot list1 0) (##sys#slot list2 0)) + (check-applicable (##sys#slot list1 1) (##sys#slot list2 1))))))) (generic-methods generic) ) ] ) (if (or (null? applicable) (null? (##sys#slot applicable 1))) applicable @@ -975,8 +1001,10 @@ [else (cond ((and (null? specls1) (null? specls2)) (##sys#error "two methods are equally specific" generic)) - ((or (null? specls1) (null? specls2)) - (##sys#error "two methods have different number of specializers" generic)) + ;((or (null? specls1) (null? specls2)) + ; (##sys#error "two methods have different number of specializers" generic)) + ((null? specls1) #f) + ((null? specls2) #t) ((null? args) (##sys#error "fewer arguments than specializers" generic)) (else @@ -1210,7 +1238,7 @@ (define (make-primitive-class "structure")) (define (make-primitive-class "procedure" )) (define (make-primitive-class "end-of-file")) -(define (make-primitive-class "environment" )) ; (Benedikt insisted on this) +(define (make-primitive-class "environment" )) (define (make-primitive-class "hash-table" )) (define (make-primitive-class "promise" )) (define (make-primitive-class "queue" )) swig-3.0.8/Lib/chicken/extra-install.list0000664000175000017500000000010212641054563020150 0ustar williamwilliamswigclosprefix.scm multi-generic.scm tinyclos-multi-generic.patch swig-3.0.8/Lib/chicken/chicken.swg0000664000175000017500000005476512641054563016642 0ustar williamwilliam/* ----------------------------------------------------------------------------- * chicken.swg * * CHICKEN configuration module. * ----------------------------------------------------------------------------- */ /* chicken.h has to appear first. */ %insert(runtime) %{ #include #include %} %insert(runtime) "swigrun.swg"; // Common C API type-checking code %insert(runtime) "chickenrun.swg"; // CHICKEN run-time code /* ----------------------------------------------------------------------------- * standard typemaps * ----------------------------------------------------------------------------- */ /* CHICKEN: C ---------- fixnum: int, short, unsigned int, unsigned short, unsigned char, signed char char: char bool: bool flonum: float, double, long, long long, unsigned long, unsigned long long */ /* --- Primitive types --- */ %define SIMPLE_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_) %typemap(in) type_ %{ if (!checker ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); } $1 = ($1_ltype) from_scheme ($input); %} /* Const primitive references. Passed by value */ %typemap(in) const type_ & ($*1_ltype temp) %{ if (!checker ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); } temp = ($*1_ltype) from_scheme ($input); $1 = &temp; %} /* --- Variable input --- */ %typemap(varin) type_ %{ if (!checker ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use '$1_ltype' for variable '$name' of type 'type_'"); } $1 = ($1_ltype) from_scheme ($input); %} #if "storage_" == "0" %typemap(out) type_ %{ $result = to_scheme (convtype ($1)); %} /* References to primitive types. Return by value */ %typemap(out) const type_ & %{ $result = to_scheme (convtype (*$1)); %} /* --- Variable output --- */ %typemap(varout) type_ %{ $result = to_scheme (convtype ($varname)); %} %typemap(throws) type_ %{ SWIG_Chicken_ThrowException(to_scheme ( convtype ($1))); %} #else %typemap(out) type_ %{ { C_word *space = C_alloc(storage_); $result = to_scheme (&space, convtype ($1)); } %} /* References to primitive types. Return by value */ %typemap(out) const type_ & %{ { C_word *space = C_alloc(storage_); $result = to_scheme (&space, convtype (*$1)); } %} /* --- Variable output --- */ %typemap(varout) type_ %{ { C_word *space = C_alloc(storage_); $result = to_scheme (&space, convtype ($varname)); } %} %typemap(throws) type_ %{ { C_word *space = C_alloc(storage_); SWIG_Chicken_ThrowException(to_scheme (&space, convtype ($1))); } %} #endif /* --- Constants --- */ %typemap(constcode) type_ "static const $1_type $result = $value;" %enddef SIMPLE_TYPEMAP(int, C_num_to_int, C_fix, C_swig_is_number, (int), 0); //SIMPLE_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0); SIMPLE_TYPEMAP(short, C_num_to_int, C_fix, C_swig_is_number, (int), 0); SIMPLE_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(unsigned int, C_num_to_unsigned_int, C_unsigned_int_to_num, C_swig_is_number, (unsigned int), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(unsigned short, C_num_to_unsigned_int, C_fix, C_swig_is_number, (unsigned int), 0); SIMPLE_TYPEMAP(unsigned long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(unsigned long long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(unsigned char, C_character_code, C_make_character, C_swig_is_char, (unsigned int), 0); SIMPLE_TYPEMAP(signed char, C_character_code, C_make_character, C_swig_is_char, (int), 0); SIMPLE_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0); SIMPLE_TYPEMAP(bool, C_truep, C_mk_bool, C_swig_is_bool, (bool), 0); SIMPLE_TYPEMAP(float, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); /* enum SWIGTYPE */ %apply int { enum SWIGTYPE }; %apply const int& { const enum SWIGTYPE& }; %apply const int& { const enum SWIGTYPE&& }; %typemap(varin) enum SWIGTYPE { if (!C_swig_is_fixnum($input) && sizeof(int) != sizeof($1)) { swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "enum variable '$name' can not be set"); } *((int *)(void *)&$1) = C_unfix($input); } /* --- Input arguments --- */ /* Strings */ %typemap(in) char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else { if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'char *'"); } $1 = ($ltype) SWIG_MakeString ($input); } } %typemap(freearg) char * "if ($1 != NULL) { free ($1); }" /* Pointers, references, and arrays */ %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, $disown); } %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *DISOWN { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, SWIG_POINTER_DISOWN); } /* Void pointer. Accepts any kind of pointer */ %typemap(in) void * { $1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0); } %typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE * { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, SWIG_POINTER_DISOWN); } %typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE & { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE && { $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); } %typemap(varin) SWIGTYPE [] { SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "Type error"); } %typemap(varin) SWIGTYPE [ANY] { void *temp; int ii; $1_basetype *b = 0; temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); b = ($1_basetype *) $1; for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); } %typemap(varin) void * { $1 = SWIG_MustGetPtr($input, NULL, 1, 0); } %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); $result = SWIG_NewPointerObj($1, $descriptor, $owner); } %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); $result = SWIG_NewPointerObj($1, ty, $owner); } %typemap(varout) SWIGTYPE *, SWIGTYPE [] { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); $result = SWIG_NewPointerObj($varname, $descriptor, 0); } %typemap(varout) SWIGTYPE & { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); $result = SWIG_NewPointerObj((void *) &$varname, $1_descriptor, 0); } %typemap(varout) SWIGTYPE && { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); $result = SWIG_NewPointerObj((void *) &$varname, $1_descriptor, 0); } /* special typemaps for class pointers */ %typemap(in) SWIGTYPE (CLASS::*) { char err_msg[256]; if (C_swig_is_pair($input)) { /* try and convert pointer object */ void *result; if (!SWIG_ConvertPtr(C_block_item($input,1), &result, $descriptor, 0)) { C_word ptr = C_block_item($input,0); if (C_swig_is_string(ptr)) { SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($type)); } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } %typemap(out) SWIGTYPE (CLASS::*) { size_t ptr_size = sizeof($type); C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(2*ptr_size) + C_SIZEOF_SWIG_POINTER); char *temp = (char *)malloc(2*ptr_size); C_word ptr = SWIG_NewPointerObj((void *) known_space, $descriptor, 0); SWIG_PackData(temp, (void *) &$1, ptr_size); $result = C_pair(&known_space, C_string(&known_space, 2*ptr_size, temp), ptr); free(temp); } %typemap(varin) SWIGTYPE (CLASS::*) { char err_msg[256]; if (C_swig_is_pair($input)) { /* try and convert pointer object */ void *result; if (!SWIG_ConvertPtr(C_block_item($input,1), &result, $descriptor, 0)) { C_word ptr = C_block_item($input,0); if (C_swig_is_string(ptr)) { SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($type)); } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } else { snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } } %typemap(varout) SWIGTYPE (CLASS::*) { size_t ptr_size = sizeof($type); C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(2*ptr_size) + C_SIZEOF_SWIG_POINTER); char *temp = (char *)malloc(2*ptr_size); C_word ptr = SWIG_NewPointerObj((void *) known_space, $descriptor, 0); SWIG_PackData(temp, (void *) &$varname, ptr_size); $result = C_pair(&known_space, C_string(&known_space, 2*ptr_size, temp), ptr); free(temp); } /* Pass-by-value */ %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE($&1_ltype argp) { argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); $1 = *argp; } %typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE { $&1_ltype argp; argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); $1 = *argp; } %typemap(out) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); resultptr = new $1_ltype((const $1_ltype &) $1); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); } #else { $&1_ltype resultptr; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); } #endif %typemap(varout) SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); resultptr = new $1_ltype((const $1_ltype&) $1); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); } #else { $&1_ltype resultptr; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); } #endif /* --- Output values --- */ /* Strings */ %typemap(out) char * { char *s = (char*) $1; if ($1 == NULL) { $result = C_SCHEME_FALSE; } else { int string_len = strlen ((char *) ($1)); C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); $result = C_string (&string_space, string_len, s); } } %typemap(varout) char * { char *s = (char*) $varname; if ($varname == NULL) { $result = C_SCHEME_FALSE; } else { int string_len = strlen ($varname); C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); $result = C_string (&string_space, string_len, s); } } %typemap(throws) char * { if ($1 == NULL) { SWIG_Chicken_ThrowException(C_SCHEME_FALSE); } else { int string_len = strlen($1); C_word *string_space = C_alloc(C_SIZEOF_STRING(string_len)); SWIG_Chicken_ThrowException(C_string(&string_space, string_len, (char *) $1)); } } /* Void */ %typemap(out) void %{ $result = C_SCHEME_UNDEFINED; %} /* Special typemap for character array return values */ %typemap(out) char [ANY], const char [ANY] %{ if ($1 == NULL) { $result = C_SCHEME_FALSE; } else { const int string_len = strlen ($1); C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); $result = C_string (&string_space, string_len, $1); } %} /* Primitive types--return by value */ /* --- Variable input --- */ /* A string */ #ifdef __cplusplus %typemap(varin) char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); int len = C_header_size ($input); if ($1) delete [] $1; $1 = ($type) new char[len+1]; strncpy((char*)$1, temp, len); ((char*)$1) [len] = 0; } } %typemap(varin,warning="451:Setting const char * variable may leak memory") const char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); int len = C_header_size ($input); $1 = ($type) new char[len+1]; strncpy((char*)$1,temp,len); ((char*)$1) [len] = 0; } } #else %typemap(varin) char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); int len = C_header_size ($input); if ($1) free((char*) $1); $1 = ($type) malloc(len+1); strncpy((char*)$1,temp,len); ((char*)$1) [len] = 0; } } %typemap(varin,warning="451:Setting const char * variable may leak memory") const char * { if ($input == C_SCHEME_FALSE) { $1 = NULL; } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); int len = C_header_size ($input); $1 = ($type) malloc(len+1); strncpy((char*)$1,temp,len); ((char*)$1) [len] = 0; } } #endif %typemap(varin) char [] { swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "C/C++ variable '$name' is read-only"); } /* Special case for string array variables */ %typemap(varin) char [ANY] { if ($input == C_SCHEME_FALSE) { memset($1,0,$1_dim0*sizeof(char)); } else if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); } else { char *temp = C_c_string ($input); strncpy($1,temp,$1_dim0*sizeof(char)); } } /* --- Variable output --- */ /* Void */ %typemap(varout) void "$result = C_SCHEME_UNDEFINED;"; /* Special typemap for character array return values */ %typemap(varout) char [ANY], const char [ANY] %{ if ($varname == NULL) { $result = C_SCHEME_FALSE; } else { const int string_len = strlen ($varname); C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); $result = C_string (&string_space, string_len, (char *) $varname); } %} /* --- Constants --- */ %typemap(constcode) char * "static const char *$result = $value;" %typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "static const void *$result = (void*) $value;" /* ------------------------------------------------------------ * String & length * ------------------------------------------------------------ */ %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { if ($input == C_SCHEME_FALSE) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use a null/#f string for a char*, int arguments"); } else if (C_swig_is_string ($input)) { $1 = ($1_ltype) C_c_string ($input); $2 = ($2_ltype) C_header_size ($input); } else { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'string'"); } } /* ------------------------------------------------------------ * CHICKEN types * ------------------------------------------------------------ */ %typemap(in) C_word "$1 = $input;"; %typemap(out) C_word "$result = $1;"; /* ------------------------------------------------------------ * Typechecking rules * ------------------------------------------------------------ */ %typecheck(SWIG_TYPECHECK_INTEGER) bool, const bool & { $1 = C_swig_is_bool ($input); } %typecheck(SWIG_TYPECHECK_INTEGER) int, short, unsigned int, unsigned short, signed char, unsigned char, const int &, const short &, const unsigned int &, const unsigned short &, enum SWIGTYPE { $1 = C_swig_is_fixnum ($input); } %typecheck(SWIG_TYPECHECK_INTEGER) long, unsigned long, long long, unsigned long long, const long &, const unsigned long &, const long long &, const unsigned long long & { $1 = (C_swig_is_bool ($input) || C_swig_is_fixnum ($input) || C_swig_is_flonum ($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) float, double, const float &, const double & { $1 = C_swig_is_flonum ($input); } %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = C_swig_is_string ($input); } %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = C_swig_is_string ($input); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; $1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; $1 = !SWIG_ConvertPtr($input, &ptr, 0, 0); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & { void *ptr = 0; if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) { /* error */ $1 = 0; } else { $1 = (ptr != 0); } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && { void *ptr = 0; if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) { /* error */ $1 = 0; } else { $1 = (ptr != 0); } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr = 0; if (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0)) { /* error */ $1 = 0; } else { $1 = (ptr != 0); } } /* ------------------------------------------------------------ * Exception handling * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * --- Exception handling --- * ------------------------------------------------------------ */ %typemap(throws) SWIGTYPE { $<ype temp = new $ltype($1); C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj(temp, $&descriptor,1); SWIG_Chicken_ThrowException(ptr); } %typemap(throws) SWIGTYPE * { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0); SWIG_Chicken_ThrowException(ptr); } %typemap(throws) SWIGTYPE [ANY] { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0); SWIG_Chicken_ThrowException(ptr); } %typemap(throws) SWIGTYPE & { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj((void *)&($1),$descriptor,0); SWIG_Chicken_ThrowException(ptr); } %typemap(throws) SWIGTYPE && { C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); C_word ptr = SWIG_NewPointerObj((void *)&($1),$descriptor,0); SWIG_Chicken_ThrowException(ptr); } /* ------------------------------------------------------------ * ANSI C typemaps * ------------------------------------------------------------ */ %apply unsigned long { size_t }; /* ------------------------------------------------------------ * Various * ------------------------------------------------------------ */ /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus %rename(__add__) *::operator+; %rename(__pos__) *::operator+(); %rename(__pos__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-(); %rename(__neg__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__and__) *::operator&; %rename(__or__) *::operator|; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__iadd__) *::operator+=; %rename(__isub__) *::operator-=; %rename(__imul__) *::operator*=; %rename(__idiv__) *::operator/=; %rename(__imod__) *::operator%=; %rename(__ilshift__) *::operator<<=; %rename(__irshift__) *::operator>>=; %rename(__iand__) *::operator&=; %rename(__ior__) *::operator|=; %rename(__ixor__) *::operator^=; %rename(__lt__) *::operator<; %rename(__le__) *::operator<=; %rename(__gt__) *::operator>; %rename(__ge__) *::operator>=; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; /* Special cases */ %rename(__call__) *::operator(); #endif /* Warnings for certain CHICKEN keywords */ %include /* TinyCLOS <--> Low-level CHICKEN */ %typemap("clos_in") SIMPLE_CLOS_OBJECT * "(slot-ref $input (quote this))" %typemap("clos_out") SIMPLE_CLOS_OBJECT * "(make $class (quote this) $1)" %insert(header) %{ #ifdef __cplusplus extern "C" { #endif /* Chicken initialization function */ SWIGEXPORT void SWIG_init(C_word, C_word, C_word) C_noret; #ifdef __cplusplus } #endif %} %insert(closprefix) "swigclosprefix.scm" %insert(init) "swiginit.swg" %insert(init) %{ /* CHICKEN initialization function */ #ifdef __cplusplus extern "C" { #endif SWIGEXPORT void SWIG_init(C_word argc, C_word closure, C_word continuation) { int i; C_word sym; C_word tmp; C_word *a; C_word ret; C_word *return_vec; SWIG_InitializeModule(0); SWIG_PropagateClientData(); ret = C_SCHEME_TRUE; #if $veclength return_vec = C_alloc(C_SIZEOF_VECTOR($veclength)); ret = (C_word) return_vec; *(return_vec++) = C_VECTOR_TYPE | $veclength; #endif a = C_alloc(2*$nummethods$symsize); %} swig-3.0.8/Lib/chicken/chickenkw.swg0000664000175000017500000000124612641054563017166 0ustar williamwilliam#ifndef CHICKEN_CHICKENKW_SWG_ #define CHICKEN_CHICKENKW_SWG_ /* Warnings for certain CHICKEN keywords. From Section 7.1.1 of Revised^5 Report on the Algorithmic Language Scheme */ #define CHICKENKW(x) %namewarn("314: '" #x "' is a R^5RS syntatic keyword") #x CHICKENKW(else); CHICKENKW(=>); CHICKENKW(define); CHICKENKW(unquote); CHICKENKW(unquote-splicing); CHICKENKW(quote); CHICKENKW(lambda); CHICKENKW(if); CHICKENKW(set!); CHICKENKW(begin); CHICKENKW(cond); CHICKENKW(and); CHICKENKW(or); CHICKENKW(case); CHICKENKW(let); CHICKENKW(let*); CHICKENKW(letrec); CHICKENKW(do); CHICKENKW(delay); CHICKENKW(quasiquote); #undef CHICKENKW #endif //CHICKEN_CHICKENKW_SWG_ swig-3.0.8/Lib/chicken/std_string.i0000664000175000017500000000452712641054563017035 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; %insert(closprefix) %{ (declare (hide )) %} %nodefault string; %rename("std-string") string; class string { public: ~string() {} }; %extend string { char *str; } %{ #define std_string_str_get(s) ((char *)((s)->c_str())) #define std_string_str_set(s,v) (s->assign((char *)(v))) %} %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; %typemap(in) string (char * tempptr) { if ($input == C_SCHEME_FALSE) { $1.resize(0); } else { if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not a string"); } tempptr = SWIG_MakeString($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } } %typemap(in) const string& ($*1_ltype temp, char *tempptr) { if ($input == C_SCHEME_FALSE) { temp.resize(0); $1 = &temp; } else { if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not a string"); } tempptr = SWIG_MakeString($input); temp.assign(tempptr); if (tempptr) SWIG_free(tempptr); $1 = &temp; } } %typemap(out) string { int size = $1.size(); C_word *space = C_alloc (C_SIZEOF_STRING (size)); $result = C_string (&space, size, (char *) $1.c_str()); } %typemap(out) const string& { int size = $1->size(); C_word *space = C_alloc (C_SIZEOF_STRING (size)); $result = C_string (&space, size, (char *) $1->c_str()); } %typemap(varin) string { if ($input == C_SCHEME_FALSE) { $1.resize(0); } else { char *tempptr; if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not a string"); } tempptr = SWIG_MakeString($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } } %typemap(varout) string { int size = $1.size(); C_word *space = C_alloc (C_SIZEOF_STRING (size)); $result = C_string (&space, size, (char *) $1.c_str()); } } swig-3.0.8/Lib/chicken/multi-generic.scm0000664000175000017500000001361412641054563017750 0ustar williamwilliam;; This file is no longer necessary with Chicken versions above 1.92 ;; ;; This file overrides two functions inside TinyCLOS to provide support ;; for multi-argument generics. There are many ways of linking this file ;; into your code... all that needs to happen is this file must be ;; executed after loading TinyCLOS but before any SWIG modules are loaded ;; ;; something like the following ;; (require 'tinyclos) ;; (load "multi-generic") ;; (declare (uses swigmod)) ;; ;; An alternative to loading this scheme code directly is to add a ;; (declare (unit multi-generic)) to the top of this file, and then ;; compile this into the final executable or something. Or compile ;; this into an extension. ;; Lastly, to override TinyCLOS method creation, two functions are ;; overridden: see the end of this file for which two are overridden. ;; You might want to remove those two lines and then exert more control over ;; which functions are used when. ;; Comments, bugs, suggestions: send either to chicken-users@nongnu.org or to ;; Most code copied from TinyCLOS (define (make 'name "multi-generic" 'direct-supers (list ) 'direct-slots '())) (letrec ([applicable? (lambda (c arg) (memq c (class-cpl (class-of arg))))] [more-specific? (lambda (c1 c2 arg) (memq c2 (memq c1 (class-cpl (class-of arg)))))] [filter-in (lambda (f l) (if (null? l) '() (let ([h (##sys#slot l 0)] [r (##sys#slot l 1)] ) (if (f h) (cons h (filter-in f r)) (filter-in f r) ) ) ) )]) (add-method compute-apply-generic (make-method (list ) (lambda (call-next-method generic) (lambda args (let ([cam (let ([x (compute-apply-methods generic)] [y ((compute-methods generic) args)] ) (lambda (args) (x y args)) ) ] ) (cam args) ) ) ) ) ) (add-method compute-methods (make-method (list ) (lambda (call-next-method generic) (lambda (args) (let ([applicable (filter-in (lambda (method) (let check-applicable ([list1 (method-specializers method)] [list2 args]) (cond ((null? list1) #t) ((null? list2) #f) (else (and (applicable? (##sys#slot list1 0) (##sys#slot list2 0)) (check-applicable (##sys#slot list1 1) (##sys#slot list2 1))))))) (generic-methods generic) ) ] ) (if (or (null? applicable) (null? (##sys#slot applicable 1))) applicable (let ([cmms (compute-method-more-specific? generic)]) (sort applicable (lambda (m1 m2) (cmms m1 m2 args))) ) ) ) ) ) ) ) (add-method compute-method-more-specific? (make-method (list ) (lambda (call-next-method generic) (lambda (m1 m2 args) (let loop ((specls1 (method-specializers m1)) (specls2 (method-specializers m2)) (args args)) (cond-expand [unsafe (let ((c1 (##sys#slot specls1 0)) (c2 (##sys#slot specls2 0)) (arg (##sys#slot args 0))) (if (eq? c1 c2) (loop (##sys#slot specls1 1) (##sys#slot specls2 1) (##sys#slot args 1)) (more-specific? c1 c2 arg))) ] [else (cond ((and (null? specls1) (null? specls2)) (##sys#error "two methods are equally specific" generic)) ;((or (null? specls1) (null? specls2)) ; (##sys#error "two methods have different number of specializers" generic)) ((null? specls1) #f) ((null? specls2) #t) ((null? args) (##sys#error "fewer arguments than specializers" generic)) (else (let ((c1 (##sys#slot specls1 0)) (c2 (##sys#slot specls2 0)) (arg (##sys#slot args 0))) (if (eq? c1 c2) (loop (##sys#slot specls1 1) (##sys#slot specls2 1) (##sys#slot args 1)) (more-specific? c1 c2 arg)))) ) ] ) ) ) ) ) ) ) ;; end of letrec (define multi-add-method (lambda (generic method) (slot-set! generic 'methods (let filter-in-method ([methods (slot-ref generic 'methods)]) (if (null? methods) (list method) (let ([l1 (length (method-specializers method))] [l2 (length (method-specializers (##sys#slot methods 0)))]) (cond ((> l1 l2) (cons (##sys#slot methods 0) (filter-in-method (##sys#slot methods 1)))) ((< l1 l2) (cons method methods)) (else (let check-method ([ms1 (method-specializers method)] [ms2 (method-specializers (##sys#slot methods 0))]) (cond ((and (null? ms1) (null? ms2)) (cons method (##sys#slot methods 1))) ;; skip the method already in the generic ((eq? (##sys#slot ms1 0) (##sys#slot ms2 0)) (check-method (##sys#slot ms1 1) (##sys#slot ms2 1))) (else (cons (##sys#slot methods 0) (filter-in-method (##sys#slot methods 1)))))))))))) (##sys#setslot (##sys#slot generic (- (##sys#size generic) 2)) 1 (compute-apply-generic generic)) )) (define (multi-add-global-method val sym specializers proc) (let ((generic (if (procedure? val) val (make 'name (##sys#symbol->string sym))))) (multi-add-method generic (make-method specializers proc)) generic)) ;; Might want to remove these, or perhaps do something like ;; (define old-add-method ##tinyclos#add-method) ;; and then you can switch between creating multi-generics and TinyCLOS generics. (set! ##tinyclos#add-method multi-add-method) (set! ##tinyclos#add-global-method multi-add-global-method) swig-3.0.8/Lib/chicken/chickenrun.swg0000664000175000017500000002547012641054563017356 0ustar williamwilliam/* ----------------------------------------------------------------------------- * chickenrun.swg * ----------------------------------------------------------------------------- */ #include #include #include #include #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf # define snprintf _snprintf # endif #endif #ifdef __cplusplus extern "C" { #endif #define SWIG_malloc(size) \ malloc(size) #define SWIG_free(mem) \ free(mem) #define SWIG_MakeString(c) \ SWIG_Chicken_MakeString(c) #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Chicken_ConvertPtr(s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ SWIG_Chicken_MustGetPtr(s, type, argnum, flags) #define SWIG_NewPointerObj(ptr, type, owner) \ SWIG_Chicken_NewPointerObj((void*)ptr, type, owner, &known_space) #define swig_barf SWIG_Chicken_Barf #define SWIG_ThrowException(val) SWIG_Chicken_ThrowException(val) #define SWIG_contract_assert(expr, message) if (!(expr)) { \ SWIG_Chicken_Barf(SWIG_BARF1_CONTRACT_ASSERT, C_text(message)); } else /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer) #define C_swig_is_bool(x) C_truep (C_booleanp (x)) #define C_swig_is_char(x) C_truep (C_charp (x)) #define C_swig_is_fixnum(x) C_truep (C_fixnump (x)) #define C_swig_is_flonum(x) (C_truep (C_blockp (x)) && C_truep (C_flonump (x))) #define C_swig_is_string(x) (C_truep (C_blockp (x)) && C_truep (C_stringp (x))) #define C_swig_is_vector(x) (C_truep (C_blockp (x)) && C_truep (C_vectorp (x))) #define C_swig_is_list(x) (C_truep (C_i_listp (x))) #define C_swig_is_pair(x) (C_truep (C_blockp(x)) && C_truep (C_pairp(x))) #define C_swig_is_ptr(x) (C_truep (C_blockp (x)) && C_truep (C_pointerp (x))) #define C_swig_is_swigpointer(x) (C_truep (C_blockp(x)) && C_truep (C_swigpointerp(x))) #define C_swig_is_closurep(x) (C_truep (C_blockp(x)) && C_truep(C_closurep(x))) #define C_swig_is_number(x) (C_swig_is_fixnum(x) || C_swig_is_flonum(x)) #define C_swig_is_long(x) C_swig_is_number(x) #define C_swig_sizeof_closure(num) (num+1) #define SWIG_Chicken_SetupArgout { \ C_word *a = C_alloc(C_swig_sizeof_closure(2)); \ C_word *closure = a; \ *(a++)=C_CLOSURE_TYPE|2; \ *(a++)=(C_word)SWIG_Chicken_ApplyResults; \ *(a++)=continuation; \ continuation=(C_word)closure; \ } #define SWIG_APPEND_VALUE(obj) { \ C_word val = (C_word)(obj); \ if (val != C_SCHEME_UNDEFINED) { \ C_word *a = C_alloc(C_swig_sizeof_closure(3)); \ C_word *closure = a; \ *(a++)=C_CLOSURE_TYPE|3; \ *(a++)=(C_word)SWIG_Chicken_MultiResultBuild; \ *(a++)=(C_word)continuation; \ *(a++)=val; \ continuation=(C_word)closure; \ } } #define SWIG_Chicken_FindCreateProxy(func,obj) \ if (C_swig_is_swigpointer(obj)) { \ swig_type_info *t = (swig_type_info *) C_block_item(obj, 1); \ if (t && t->clientdata && ((swig_chicken_clientdata *)t->clientdata)->gc_proxy_create) { \ func = CHICKEN_gc_root_ref( ((swig_chicken_clientdata *)t->clientdata)->gc_proxy_create); \ } else { \ func = C_SCHEME_FALSE; \ } \ } else { \ func = C_SCHEME_FALSE; \ } enum { SWIG_BARF1_BAD_ARGUMENT_TYPE /* 1 arg */, SWIG_BARF1_ARGUMENT_NULL /* 1 arg */, SWIG_BARF1_CONTRACT_ASSERT /* 1 arg */, }; typedef C_word (*swig_chicken_destructor)(C_word,C_word,C_word,C_word); typedef struct swig_chicken_clientdata { void *gc_proxy_create; swig_chicken_destructor destroy; } swig_chicken_clientdata; static char * SWIG_Chicken_MakeString(C_word str) { char *ret; size_t l; l = C_header_size(str); ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); if (!ret) return NULL; memcpy(ret, C_c_string(str), l); ret[l] = '\0'; return ret; } static C_word SWIG_Chicken_LookupSymbol(char *name, C_SYMBOL_TABLE *stable) { C_word *a = C_alloc(C_SIZEOF_STRING (strlen (name))); C_word n = C_string2(&a, name); C_word sym = C_find_symbol(n, stable); if (C_truep(sym)) { return C_symbol_value(sym); } else { return C_SCHEME_FALSE; } } /* Just a helper function. Do not export it */ static void SWIG_Chicken_Panic (C_char *) C_noret; static void SWIG_Chicken_Panic (C_char *msg) { C_word *a = C_alloc (C_SIZEOF_STRING (strlen (msg))); C_word scmmsg = C_string2 (&a, msg); C_halt (scmmsg); exit (5); /* should never get here */ } static void SWIG_Chicken_Barf(int code, C_char *msg, ...) C_noret; static void SWIG_Chicken_Barf(int code, C_char *msg, ...) { char *errorhook = C_text("\003syserror-hook"); C_word *a = C_alloc (C_SIZEOF_STRING (strlen (errorhook))); C_word err = C_intern2 (&a, errorhook); int c = -1; int i, barfval; va_list v; C_temporary_stack = C_temporary_stack_bottom; err = C_block_item(err, 0); if(C_immediatep (err)) SWIG_Chicken_Panic (C_text ("`##sys#error-hook' is not defined")); switch (code) { case SWIG_BARF1_BAD_ARGUMENT_TYPE: barfval = C_BAD_ARGUMENT_TYPE_ERROR; c = 1; break; case SWIG_BARF1_ARGUMENT_NULL: barfval = C_BAD_ARGUMENT_TYPE_ERROR; c = 1; break; case SWIG_BARF1_CONTRACT_ASSERT: barfval = C_BAD_ARGUMENT_TYPE_ERROR; c = 1; break; default: SWIG_Chicken_Panic (C_text (msg)); }; if(c > 0 && !C_immediatep (err)) { C_save (C_fix (barfval)); i = c; if (i) { C_word *b = C_alloc (C_SIZEOF_STRING (strlen (msg))); C_word scmmsg = C_string2 (&b, msg); C_save (scmmsg); i--; } va_start (v, msg); while(i--) C_save (va_arg (v, C_word)); va_end (v); C_do_apply (c + 1, err, C_SCHEME_UNDEFINED); /* <- no continuation is passed: '##sys#error-hook' may not return! */ } else if (msg) { SWIG_Chicken_Panic (msg); } else { SWIG_Chicken_Panic (C_text ("unspecified panic")); } } static void SWIG_Chicken_ThrowException(C_word value) C_noret; static void SWIG_Chicken_ThrowException(C_word value) { char *aborthook = C_text("\003sysabort"); C_word *a = C_alloc(C_SIZEOF_STRING(strlen(aborthook))); C_word abort = C_intern2(&a, aborthook); abort = C_block_item(abort, 0); if (C_immediatep(abort)) SWIG_Chicken_Panic(C_text("`##sys#abort' is not defined")); C_save(value); C_do_apply(1, abort, C_SCHEME_UNDEFINED); } static void SWIG_Chicken_Finalizer(C_word argc, C_word closure, C_word continuation, C_word s) { swig_type_info *type; swig_chicken_clientdata *cdata; if (argc == 3 && s != C_SCHEME_FALSE && C_swig_is_swigpointer(s)) { type = (swig_type_info *) C_block_item(s, 1); if (type) { cdata = (swig_chicken_clientdata *) type->clientdata; if (cdata && cdata->destroy) { /* this will not return, but will continue correctly */ cdata->destroy(3,closure,continuation,s); } } } C_kontinue(continuation, C_SCHEME_UNDEFINED); } static C_word finalizer_obj[2] = {(C_word) (C_CLOSURE_TYPE|1), (C_word) SWIG_Chicken_Finalizer}; static C_word SWIG_Chicken_NewPointerObj(void *ptr, swig_type_info *type, int owner, C_word **data) { swig_chicken_clientdata *cdata = (swig_chicken_clientdata *) type->clientdata; if (ptr == NULL) return C_SCHEME_FALSE; else { C_word cptr = C_swigmpointer(data, ptr, type); /* add finalizer to object */ #ifndef SWIG_CHICKEN_NO_COLLECTION if (owner) C_do_register_finalizer(cptr, (C_word) finalizer_obj); #endif return cptr; } } /* Return 0 if successful. */ static int SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags) { swig_cast_info *cast; swig_type_info *from; if (s == C_SCHEME_FALSE) { *result = NULL; } else if (C_swig_is_swigpointer(s)) { /* try and convert type */ from = (swig_type_info *) C_block_item(s, 1); if (!from) return 1; if (type) { cast = SWIG_TypeCheckStruct(from, type); if (cast) { int newmemory = 0; *result = SWIG_TypeCast(cast, (void *) C_block_item(s, 0), &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } else { return 1; } } else { *result = (void *) C_block_item(s, 0); } /* check if we are disowning this object */ if (flags & SWIG_POINTER_DISOWN) { C_do_unregister_finalizer(s); } } else { return 1; } return 0; } static SWIGINLINE void * SWIG_Chicken_MustGetPtr (C_word s, swig_type_info *type, int argnum, int flags) { void *result; char err_msg[256]; if (SWIG_Chicken_ConvertPtr(s, &result, type, flags)) { /* type mismatch */ snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", argnum, (type->str ? type->str : type->name)); SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); } return result; } static char *chicken_runtimevar_name = "type_pointer" SWIG_TYPE_TABLE_NAME; static swig_module_info * SWIG_Chicken_GetModule(void *SWIGUNUSEDPARM(clientdata)) { swig_module_info *ret = 0; C_word sym; /* lookup the type pointer... it is stored in its own symbol table */ C_SYMBOL_TABLE *stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION); if (stable != NULL) { sym = SWIG_Chicken_LookupSymbol(chicken_runtimevar_name, stable); if (C_truep(sym) && C_swig_is_ptr(sym)) { ret = (swig_module_info *) C_block_item(sym, 0); } } return ret; } static void SWIG_Chicken_SetModule(swig_module_info *module) { C_word *a; C_SYMBOL_TABLE *stable; C_word sym; C_word pointer; static C_word *space = 0; /* type pointer is stored in its own symbol table */ stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION); if (stable == NULL) { stable = C_new_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION, 16); } if (!space) { space = (C_word *) C_malloc((C_SIZEOF_POINTER + C_SIZEOF_INTERNED_SYMBOL(C_strlen(chicken_runtimevar_name))) * sizeof(C_word)); } a = space; pointer = C_mpointer(&a, (void *) module); sym = C_intern_in(&a, C_strlen(chicken_runtimevar_name), chicken_runtimevar_name, stable); C_set_block_item(sym, 0, pointer); } static C_word SWIG_Chicken_MultiResultBuild(C_word num, C_word closure, C_word lst) { C_word cont = C_block_item(closure,1); C_word obj = C_block_item(closure,2); C_word func; SWIG_Chicken_FindCreateProxy(func,obj); if (C_swig_is_closurep(func)) { ((C_proc4)(void *)C_block_item(func, 0))(4,func,cont,obj,lst); } else { C_word *a = C_alloc(C_SIZEOF_PAIR); C_kontinue(cont,C_pair(&a,obj,lst)); } return C_SCHEME_UNDEFINED; /* never reached */ } static C_word SWIG_Chicken_ApplyResults(C_word num, C_word closure, C_word result) { C_apply_values(3,C_SCHEME_UNDEFINED,C_block_item(closure,1),result); return C_SCHEME_UNDEFINED; /* never reached */ } #ifdef __cplusplus } #endif swig-3.0.8/Lib/chicken/typemaps.i0000664000175000017500000002700312641054563016511 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * * These mappings provide support for input/output arguments and * common uses for C/C++ pointers. INOUT mappings allow for C/C++ * pointer variables in addition to input/output arguments. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Scheme list. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); */ //---------------------------------------------------------------------- // // T_OUTPUT typemap (and helper function) to return multiple argouts as // a tuple instead of a list. // //---------------------------------------------------------------------- // Simple types %define INOUT_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_) %typemap(in) type_ *INPUT($*1_ltype temp), type_ &INPUT($*1_ltype temp) %{ if (!checker ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); } temp = ($*1_ltype) from_scheme ($input); $1 = &temp; %} %typemap(typecheck) type_ *INPUT = type_; %typemap(typecheck) type_ &INPUT = type_; %typemap(in, numinputs=0) type_ *OUTPUT($*1_ltype temp), type_ &OUTPUT($*1_ltype temp) " $1 = &temp;" #if "storage_" == "0" %typemap(argout) type_ *OUTPUT, type_ &OUTPUT %{ if ($1 == NULL) { swig_barf (SWIG_BARF1_ARGUMENT_NULL, "Argument #$argnum must be non-null"); } SWIG_APPEND_VALUE(to_scheme (convtype (*$1))); %} #else %typemap(argout) type_ *OUTPUT, type_ &OUTPUT %{ { C_word *known_space = C_alloc(storage_); if ($1 == NULL) { swig_barf (SWIG_BARF1_ARGUMENT_NULL, "Variable '$1' must be non-null"); } SWIG_APPEND_VALUE(to_scheme (&known_space, convtype (*$1))); } %} #endif %enddef INOUT_TYPEMAP(int, C_num_to_int, C_fix, C_swig_is_number, (int), 0); INOUT_TYPEMAP(enum SWIGTYPE, C_num_to_int, C_fix, C_swig_is_number, (int), 0); INOUT_TYPEMAP(short, C_num_to_int, C_fix, C_swig_is_number, (int), 0); INOUT_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); INOUT_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); INOUT_TYPEMAP(unsigned int, C_num_to_unsigned_int, C_unsigned_int_to_num, C_swig_is_number, (int), C_SIZEOF_FLONUM); INOUT_TYPEMAP(unsigned short, C_num_to_unsigned_int, C_fix, C_swig_is_number, (unsigned int), 0); INOUT_TYPEMAP(unsigned long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); INOUT_TYPEMAP(unsigned long long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); INOUT_TYPEMAP(unsigned char, C_character_code, C_make_character, C_swig_is_char, (unsigned int), 0); INOUT_TYPEMAP(signed char, C_character_code, C_make_character, C_swig_is_char, (int), 0); INOUT_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0); INOUT_TYPEMAP(bool, C_truep, C_mk_bool, C_swig_is_bool, (bool), 0); INOUT_TYPEMAP(float, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); INOUT_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a CHICKEN tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); As well, you can wrap variables with : %include %apply double *INOUT { double *y }; extern double *y; Unlike C, this mapping does not directly modify the input value (since this makes no sense in CHICKEN). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a CHICKEN variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %typemap(in) int *INOUT = int *INPUT; %typemap(in) enum SWIGTYPE *INOUT = enum SWIGTYPE *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) char *INOUT = char *INPUT; %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) int &INOUT = int &INPUT; %typemap(in) enum SWIGTYPE &INOUT = enum SWIGTYPE &INPUT; %typemap(in) short &INOUT = short &INPUT; %typemap(in) long &INOUT = long &INPUT; %typemap(in) long long &INOUT = long long &INPUT; %typemap(in) unsigned &INOUT = unsigned &INPUT; %typemap(in) unsigned short &INOUT = unsigned short &INPUT; %typemap(in) unsigned long &INOUT = unsigned long &INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; %typemap(in) unsigned char &INOUT = unsigned char &INPUT; %typemap(in) char &INOUT = char &INPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(in) float &INOUT = float &INPUT; %typemap(in) double &INOUT = double &INPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) enum SWIGTYPE *INOUT = enum SWIGTYPE *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT = long *OUTPUT; %typemap(argout) long long *INOUT = long long *OUTPUT; %typemap(argout) unsigned *INOUT = unsigned *OUTPUT; %typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT = double *OUTPUT; %typemap(argout) int &INOUT = int &OUTPUT; %typemap(argout) enum SWIGTYPE &INOUT = enum SWIGTYPE &OUTPUT; %typemap(argout) short &INOUT = short &OUTPUT; %typemap(argout) long &INOUT = long &OUTPUT; %typemap(argout) long long &INOUT = long long &OUTPUT; %typemap(argout) unsigned &INOUT = unsigned &OUTPUT; %typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; %typemap(argout) char &INOUT = char &OUTPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; %typemap(argout) float &INOUT = float &OUTPUT; %typemap(argout) double &INOUT = double &OUTPUT; /* Overloading information */ %typemap(typecheck) double *INOUT = double; %typemap(typecheck) bool *INOUT = bool; %typemap(typecheck) char *INOUT = char; %typemap(typecheck) signed char *INOUT = signed char; %typemap(typecheck) unsigned char *INOUT = unsigned char; %typemap(typecheck) unsigned long *INOUT = unsigned long; %typemap(typecheck) unsigned long long *INOUT = unsigned long long; %typemap(typecheck) unsigned short *INOUT = unsigned short; %typemap(typecheck) unsigned int *INOUT = unsigned int; %typemap(typecheck) long *INOUT = long; %typemap(typecheck) long long *INOUT = long long; %typemap(typecheck) short *INOUT = short; %typemap(typecheck) int *INOUT = int; %typemap(typecheck) enum SWIGTYPE *INOUT = enum SWIGTYPE; %typemap(typecheck) float *INOUT = float; %typemap(typecheck) double &INOUT = double; %typemap(typecheck) bool &INOUT = bool; %typemap(typecheck) char &INOUT = char; %typemap(typecheck) signed char &INOUT = signed char; %typemap(typecheck) unsigned char &INOUT = unsigned char; %typemap(typecheck) unsigned long &INOUT = unsigned long; %typemap(typecheck) unsigned long long &INOUT = unsigned long long; %typemap(typecheck) unsigned short &INOUT = unsigned short; %typemap(typecheck) unsigned int &INOUT = unsigned int; %typemap(typecheck) long &INOUT = long; %typemap(typecheck) long long &INOUT = long long; %typemap(typecheck) short &INOUT = short; %typemap(typecheck) int &INOUT = int; %typemap(typecheck) enum SWIGTYPE &INOUT = enum SWIGTYPE; %typemap(typecheck) float &INOUT = float; swig-3.0.8/Lib/director_common.swg0000664000175000017500000000100012641054563016763 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director_common.swg * * This file contains support for director classes which is common between * languages. * ----------------------------------------------------------------------------- */ /* Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the 'Swig' namespace. This could be useful for multi-modules projects. */ #ifdef SWIG_DIRECTOR_STATIC /* Force anonymous (static) namespace */ #define Swig #endif swig-3.0.8/Lib/csharp/0000775000175000017500000000000012641054563014347 5ustar williamwilliamswig-3.0.8/Lib/csharp/boost_intrusive_ptr.i0000664000175000017500000005766012641054563020662 0ustar williamwilliam// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the // visibility of the constructor and getCPtr method if desired to public if using multiple modules. #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS #define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE) #endif #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP #define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE) #endif %include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE "(void)arg1; delete smartarg1;" // Typemap customisations... %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain value argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); return $null; } $1 = *argp; %} %typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{ //plain value(out) $1_ltype* resultp = new $1_ltype(($1_ltype &)$1); intrusive_ptr_add_ref(resultp); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); %} %typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{ //plain pointer(out) #if ($owner) if ($1) { intrusive_ptr_add_ref($1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} %typemap(in, canthrow=1) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain reference $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if(!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); return $null; } %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{ //plain reference(out) #if ($owner) if ($1) { intrusive_ptr_add_ref($1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} %typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer by reference temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{ // plain pointer by reference(out) #if ($owner) if (*$1) { intrusive_ptr_add_ref(*$1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); #endif %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by value smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if (smartarg) { $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ if ($1) { intrusive_ptr_add_ref($1.get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1.get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by reference if ( $input ) { smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ delete &($1); if ($self) { SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); $1 = *temp; } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ if (*$1) { intrusive_ptr_add_ref($1->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer if ( $input ) { smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ delete $1; if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ if ($1 && *$1) { intrusive_ptr_add_ref($1->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } if ($owner) delete $1; %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer reference smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if ($input) { temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } tempp = &temp; $1 = &tempp; %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if ($self) $1 = *$input; %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if (*$1 && **$1) { intrusive_ptr_add_ref((*$1)->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (ctype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *" %typemap (imtype, out="global::System.IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef" %typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)" %typemap(csin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ get { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{ get { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{ get { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %} %typemap(csout, excode=SWIGEXCODE) CONST TYPE { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE & { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE * { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } // Base proxy classes %typemap(csbody) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); base.Dispose(); } } // CONST version needed ???? also for C# %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef" %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; %enddef ///////////////////////////////////////////////////////////////////// %include %define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE "(void)arg1; delete smartarg1;" // plain value %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in, canthrow=1) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *" %typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *" %typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)" %typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { global::System.IntPtr cPtr = $imcall; return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); } %typemap(csout, excode=SWIGEXCODE) CONST TYPE { return new $typemap(cstype, TYPE)($imcall, true); } %typemap(csout, excode=SWIGEXCODE) CONST TYPE & { return new $typemap(cstype, TYPE)($imcall, true); } %typemap(csout, excode=SWIGEXCODE) CONST TYPE * { global::System.IntPtr cPtr = $imcall; return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { global::System.IntPtr cPtr = $imcall; return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(csbody) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); base.Dispose(); } } // CONST version needed ???? also for C# %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef" %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/csharp/std_pair.i0000664000175000017500000000127712641054563016335 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T t, U u); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/csharp/enumtypesafe.swg0000664000175000017500000001127612641054563017605 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumtypesafe.swg * * Include this file in order for C/C++ enums to be wrapped by the so called * typesafe enum pattern. Each enum has an equivalent C# class named after the * enum and each enum item is a static instance of this class. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(ctype) const enum SWIGTYPE & "int" %typemap(imtype) const enum SWIGTYPE & "int" %typemap(cstype) const enum SWIGTYPE & "$*csclassname" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;" %typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)" %typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue" %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) const enum SWIGTYPE & "$csinput.swigValue" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { $*csclassname ret = $*csclassname.swigToEnum($imcall);$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ get { $*csclassname ret = $*csclassname.swigToEnum($imcall);$excode return ret; } %} // enum SWIGTYPE typemaps %typemap(ctype) enum SWIGTYPE "int" %typemap(imtype) enum SWIGTYPE "int" %typemap(cstype) enum SWIGTYPE "$csclassname" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE "$input = (int)$1;" %typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)" %typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue" %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) enum SWIGTYPE "$csinput.swigValue" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { $csclassname ret = $csclassname.swigToEnum($imcall);$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ get { $csclassname ret = $csclassname.swigToEnum($imcall);$excode return ret; } %} %typemap(csbase) enum SWIGTYPE "" %typemap(csclassmodifiers) enum SWIGTYPE "public sealed class" %typemap(cscode) enum SWIGTYPE "" %typemap(csimports) enum SWIGTYPE "" %typemap(csinterfaces) enum SWIGTYPE "" /* * The swigToEnum method is used to find the C# enum from a C++ enum integer value. The default one here takes * advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial * values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be * written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum. * The special variable, $enumvalues, is replaced with a comma separated list of all the enum values. */ %typemap(csbody) enum SWIGTYPE %{ public readonly int swigValue; public static $csclassname swigToEnum(int swigValue) { if (swigValue < swigValues.Length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) return swigValues[swigValue]; for (int i = 0; i < swigValues.Length; i++) if (swigValues[i].swigValue == swigValue) return swigValues[i]; throw new global::System.ArgumentOutOfRangeException("No enum $csclassname with value " + swigValue); } public override string ToString() { return swigName; } private $csclassname(string swigName) { this.swigName = swigName; this.swigValue = swigNext++; } private $csclassname(string swigName, int swigValue) { this.swigName = swigName; this.swigValue = swigValue; swigNext = swigValue+1; } private $csclassname(string swigName, $csclassname swigEnum) { this.swigName = swigName; this.swigValue = swigEnum.swigValue; swigNext = this.swigValue+1; } private static $csclassname[] swigValues = { $enumvalues }; private static int swigNext = 0; private readonly string swigName; %} %csenum(typesafe); swig-3.0.8/Lib/csharp/std_except.i0000664000175000017500000000411312641054563016662 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. These typemaps are * used when methods are declared with an STL exception specification, such as * size_t at() const throw (std::out_of_range); * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %ignore exception; struct exception {}; } %typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::invalid_argument "SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentException, $1.what(), \"\");\n return $null;" %typemap(throws, canthrow=1) std::length_error "SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::logic_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::out_of_range "SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, 0, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::overflow_error "SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::range_error "SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::runtime_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::underflow_error "SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, $1.what());\n return $null;" swig-3.0.8/Lib/csharp/std_auto_ptr.i0000664000175000017500000000164012641054563017231 0ustar williamwilliam/* The typemaps here allow to handle functions returning std::auto_ptr<>, which is the most common use of this type. If you have functions taking it as parameter, these typemaps can't be used for them and you need to do something else (e.g. use shared_ptr<> which SWIG supports fully). */ %define %auto_ptr(TYPE) %typemap (ctype) std::auto_ptr "void *" %typemap (imtype, out="System.IntPtr") std::auto_ptr "HandleRef" %typemap (cstype) std::auto_ptr "$typemap(cstype, TYPE)" %typemap (out) std::auto_ptr %{ $result = (void *)$1.release(); %} %typemap(csout, excode=SWIGEXCODE) std::auto_ptr { System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %template() std::auto_ptr; %enddef namespace std { template class auto_ptr {}; } swig-3.0.8/Lib/csharp/enumsimple.swg0000664000175000017500000000550512641054563017254 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumsimple.swg * * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 * and earlier wrapped global enums with constant integers in the module * class. Enums declared within a C++ class were wrapped by constant integers * in the C# proxy class. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(ctype) const enum SWIGTYPE & "int" %typemap(imtype) const enum SWIGTYPE & "int" %typemap(cstype) const enum SWIGTYPE & "int" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;" %typemap(csdirectorin) const enum SWIGTYPE & "$iminput" %typemap(csdirectorout) const enum SWIGTYPE & "$cscall" %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) const enum SWIGTYPE & "$csinput" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { int ret = $imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ get { int ret = $imcall;$excode return ret; } %} // enum SWIGTYPE typemaps %typemap(ctype) enum SWIGTYPE "int" %typemap(imtype) enum SWIGTYPE "int" %typemap(cstype) enum SWIGTYPE "int" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE "$input = (int)$1;" %typemap(csdirectorin) enum SWIGTYPE "$iminput" %typemap(csdirectorout) enum SWIGTYPE "$cscall" %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) enum SWIGTYPE "$csinput" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { int ret = $imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ get { int ret = $imcall;$excode return ret; } %} %typemap(csbase) enum SWIGTYPE "" %typemap(csclassmodifiers) enum SWIGTYPE "" %typemap(cscode) enum SWIGTYPE "" %typemap(csimports) enum SWIGTYPE "" %typemap(csinterfaces) enum SWIGTYPE "" %typemap(csbody) enum SWIGTYPE "" %csenum(simple); swig-3.0.8/Lib/csharp/std_deque.i0000664000175000017500000000003412641054563016473 0ustar williamwilliam%include swig-3.0.8/Lib/csharp/std_common.i0000664000175000017500000000014612641054563016664 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.8/Lib/csharp/swigtype_inout.i0000664000175000017500000000267612641054563017625 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigtype_inout.i * * Pointer pointer and pointer reference handling typemap library for non-primitive types * * These mappings provide support for input/output arguments and common * uses for C/C++ pointer references and pointer to pointers. * * These are named typemaps (OUTPUT) and can be used like any named typemap. * Alternatively they can be made the default by using %apply: * %apply SWIGTYPE *& OUTPUT { SWIGTYPE *& } * ----------------------------------------------------------------------------- */ /* * OUTPUT typemaps. Example usage wrapping: * * void f(XXX *& x) { x = new XXX(111); } * * would be: * * XXX x = null; * f(out x); * // use x * x.Dispose(); // manually clear memory or otherwise leave out and leave it to the garbage collector */ %typemap(ctype) SWIGTYPE *& OUTPUT "void **" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE *& OUTPUT "out global::System.IntPtr" %typemap(cstype) SWIGTYPE *& OUTPUT "out $*csclassname" %typemap(csin, pre=" global::System.IntPtr cPtr_$csinput = global::System.IntPtr.Zero;", post=" $csinput = (cPtr_$csinput == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr_$csinput, true);", cshin="out $csinput") SWIGTYPE *& OUTPUT "out cPtr_$csinput" %typemap(in) SWIGTYPE *& OUTPUT %{ $1 = ($1_ltype)$input; %} %typemap(freearg) SWIGTYPE *& OUTPUT "" swig-3.0.8/Lib/csharp/csharp.swg0000664000175000017500000011536712641054563016366 0ustar williamwilliam/* ----------------------------------------------------------------------------- * csharp.swg * * C# typemaps * ----------------------------------------------------------------------------- */ %include /* The ctype, imtype and cstype typemaps work together and so there should be one of each. * The ctype typemap contains the PInvoke type used in the PInvoke (C/C++) code. * The imtype typemap contains the C# type used in the intermediary class. * The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */ /* SWIG 3 no longer inserts using directives into generated C# code. For backwards compatibility, the SWIG2_CSHARP macro can be defined to have SWIG 3 generate using directives similar to those generated by SWIG 2. */ #ifdef SWIG2_CSHARP %typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing global::System;\nusing global::System.Runtime.InteropServices;\n" %pragma(csharp) moduleimports=%{ using global::System; using global::System.Runtime.InteropServices; %} %pragma(csharp) imclassimports=%{ using global::System; using global::System.Runtime.InteropServices; %} #endif /* Fragments */ %fragment("SWIG_PackData", "header") { /* Pack binary data into a string */ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } } %fragment("SWIG_UnPackData", "header") { /* Unpack binary data from a string */ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } } /* Primitive types */ %typemap(ctype) bool, const bool & "unsigned int" %typemap(ctype) char, const char & "char" %typemap(ctype) signed char, const signed char & "signed char" %typemap(ctype) unsigned char, const unsigned char & "unsigned char" %typemap(ctype) short, const short & "short" %typemap(ctype) unsigned short, const unsigned short & "unsigned short" %typemap(ctype) int, const int & "int" %typemap(ctype) unsigned int, const unsigned int & "unsigned int" %typemap(ctype) long, const long & "long" %typemap(ctype) unsigned long, const unsigned long & "unsigned long" %typemap(ctype) long long, const long long & "long long" %typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long" %typemap(ctype) float, const float & "float" %typemap(ctype) double, const double & "double" %typemap(ctype) void "void" %typemap(imtype) bool, const bool & "bool" %typemap(imtype) char, const char & "char" %typemap(imtype) signed char, const signed char & "sbyte" %typemap(imtype) unsigned char, const unsigned char & "byte" %typemap(imtype) short, const short & "short" %typemap(imtype) unsigned short, const unsigned short & "ushort" %typemap(imtype) int, const int & "int" %typemap(imtype) unsigned int, const unsigned int & "uint" %typemap(imtype) long, const long & "int" %typemap(imtype) unsigned long, const unsigned long & "uint" %typemap(imtype) long long, const long long & "long" %typemap(imtype) unsigned long long, const unsigned long long & "ulong" %typemap(imtype) float, const float & "float" %typemap(imtype) double, const double & "double" %typemap(imtype) void "void" %typemap(cstype) bool, const bool & "bool" %typemap(cstype) char, const char & "char" %typemap(cstype) signed char, const signed char & "sbyte" %typemap(cstype) unsigned char, const unsigned char & "byte" %typemap(cstype) short, const short & "short" %typemap(cstype) unsigned short, const unsigned short & "ushort" %typemap(cstype) int, const int & "int" %typemap(cstype) unsigned int, const unsigned int & "uint" %typemap(cstype) long, const long & "int" %typemap(cstype) unsigned long, const unsigned long & "uint" %typemap(cstype) long long, const long long & "long" %typemap(cstype) unsigned long long, const unsigned long long & "ulong" %typemap(cstype) float, const float & "float" %typemap(cstype) double, const double & "double" %typemap(cstype) void "void" %typemap(ctype) char *, char *&, char[ANY], char[] "char *" %typemap(imtype) char *, char *&, char[ANY], char[] "string" %typemap(cstype) char *, char *&, char[ANY], char[] "string" /* Non primitive types */ %typemap(ctype) SWIGTYPE "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE "$&csclassname" %typemap(ctype) SWIGTYPE [] "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE [] "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE [] "$csclassname" %typemap(ctype) SWIGTYPE * "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE * "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE * "$csclassname" %typemap(ctype) SWIGTYPE & "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE & "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE & "$csclassname" %typemap(ctype) SWIGTYPE && "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE && "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE && "$csclassname" /* pointer to a class member */ %typemap(ctype) SWIGTYPE (CLASS::*) "char *" %typemap(imtype) SWIGTYPE (CLASS::*) "string" %typemap(cstype) SWIGTYPE (CLASS::*) "$csclassname" /* The following are the in and out typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */ /* primitive types */ %typemap(in) bool %{ $1 = $input ? true : false; %} %typemap(directorout) bool %{ $result = $input ? true : false; %} %typemap(csdirectorin) bool "$iminput" %typemap(csdirectorout) bool "$cscall" %typemap(in) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $1 = ($1_ltype)$input; %} %typemap(directorout) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $result = ($1_ltype)$input; %} %typemap(directorin) bool "$input = $1;" %typemap(directorin) char "$input = $1;" %typemap(directorin) signed char "$input = $1;" %typemap(directorin) unsigned char "$input = $1;" %typemap(directorin) short "$input = $1;" %typemap(directorin) unsigned short "$input = $1;" %typemap(directorin) int "$input = $1;" %typemap(directorin) unsigned int "$input = $1;" %typemap(directorin) long "$input = $1;" %typemap(directorin) unsigned long "$input = (unsigned long)$1;" %typemap(directorin) long long "$input = $1;" %typemap(directorin) unsigned long long "$input = $1;" %typemap(directorin) float "$input = $1;" %typemap(directorin) double "$input = $1;" %typemap(csdirectorin) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double "$iminput" %typemap(csdirectorout) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double "$cscall" %typemap(out) bool %{ $result = $1; %} %typemap(out) char %{ $result = $1; %} %typemap(out) signed char %{ $result = $1; %} %typemap(out) unsigned char %{ $result = $1; %} %typemap(out) short %{ $result = $1; %} %typemap(out) unsigned short %{ $result = $1; %} %typemap(out) int %{ $result = $1; %} %typemap(out) unsigned int %{ $result = $1; %} %typemap(out) long %{ $result = $1; %} %typemap(out) unsigned long %{ $result = (unsigned long)$1; %} %typemap(out) long long %{ $result = $1; %} %typemap(out) unsigned long long %{ $result = $1; %} %typemap(out) float %{ $result = $1; %} %typemap(out) double %{ $result = $1; %} /* char * - treat as String */ %typemap(in) char * %{ $1 = ($1_ltype)$input; %} %typemap(out) char * %{ $result = SWIG_csharp_string_callback((const char *)$1); %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %} %typemap(directorin) char * %{ $input = SWIG_csharp_string_callback((const char *)$1); %} %typemap(csdirectorin) char * "$iminput" %typemap(csdirectorout) char * "$cscall" /* char *& - treat as String */ %typemap(in) char *& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) char *& %{ if ($1) $result = SWIG_csharp_string_callback((const char *)*$1); %} %typemap(out, null="") void "" %typemap(csdirectorin) void "$iminput" %typemap(csdirectorout) void "$cscall" %typemap(directorin) void "" /* primitive types by const reference */ %typemap(in) const bool & ($*1_ltype temp) %{ temp = $input ? true : false; $1 = &temp; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & %{ static $*1_ltype temp; temp = $input ? true : false; $result = &temp; %} %typemap(csdirectorin) const bool & "$iminput" %typemap(csdirectorout) const bool & "$cscall" %typemap(in) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ static $*1_ltype temp; temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin) const bool & "$input = $1;" %typemap(directorin) const char & "$input = $1;" %typemap(directorin) const signed char & "$input = $1;" %typemap(directorin) const unsigned char & "$input = $1;" %typemap(directorin) const short & "$input = $1;" %typemap(directorin) const unsigned short & "$input = $1;" %typemap(directorin) const int & "$input = $1;" %typemap(directorin) const unsigned int & "$input = $1;" %typemap(directorin) const long & "$input = $1;" %typemap(directorin) const unsigned long & "$input = $1;" %typemap(directorin) const long long & "$input = $1;" %typemap(directorin) const unsigned long long & "$input = $1;" %typemap(directorin) const float & "$input = $1;" %typemap(directorin) const double & "$input = $1;" %typemap(csdirectorin) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) "$iminput" %typemap(csdirectorout) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) "$cscall" %typemap(out) const bool & %{ $result = *$1; %} %typemap(out) const char & %{ $result = *$1; %} %typemap(out) const signed char & %{ $result = *$1; %} %typemap(out) const unsigned char & %{ $result = *$1; %} %typemap(out) const short & %{ $result = *$1; %} %typemap(out) const unsigned short & %{ $result = *$1; %} %typemap(out) const int & %{ $result = *$1; %} %typemap(out) const unsigned int & %{ $result = *$1; %} %typemap(out) const long & %{ $result = *$1; %} %typemap(out) const unsigned long & %{ $result = (unsigned long)*$1; %} %typemap(out) const long long & %{ $result = *$1; %} %typemap(out) const unsigned long long & %{ $result = *$1; %} %typemap(out) const float & %{ $result = *$1; %} %typemap(out) const double & %{ $result = *$1; %} /* Default handling. Object passed by value. Convert to a pointer */ %typemap(in, canthrow=1) SWIGTYPE ($&1_type argp) %{ argp = ($&1_ltype)$input; if (!argp) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); return $null; } $1 = *argp; %} %typemap(directorout) SWIGTYPE %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); return $null; } $result = *($&1_ltype)$input; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{ $result = new $1_ltype((const $1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); $result = $1ptr; } #endif %typemap(directorin) SWIGTYPE %{ $input = (void *)&$1; %} %typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE "$&csclassname.getCPtr($cscall).Handle" /* Generic pointers and references */ %typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %} %typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{ SWIG_UnpackData($input, (void *)&$1, sizeof($1)); %} %typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input; if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0); return $null; } %} %typemap(in, canthrow=1) SWIGTYPE && %{ $1 = ($1_ltype)$input; if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0); return $null; } %} %typemap(out) SWIGTYPE * %{ $result = (void *)$1; %} %typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{ char buf[128]; char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1)); *data = '\0'; $result = SWIG_csharp_string_callback(buf); %} %typemap(out) SWIGTYPE & %{ $result = (void *)$1; %} %typemap(out) SWIGTYPE && %{ $result = (void *)$1; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE * %{ $result = ($1_ltype)$input; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*) %{ $result = ($1_ltype)$input; %} %typemap(directorin) SWIGTYPE * %{ $input = (void *) $1; %} %typemap(directorin) SWIGTYPE (CLASS::*) %{ $input = (void *) $1; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); return $null; } $result = ($1_ltype)$input; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE && %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); return $null; } $result = ($1_ltype)$input; %} %typemap(directorin) SWIGTYPE & %{ $input = ($1_ltype) &$1; %} %typemap(directorin) SWIGTYPE && %{ $input = ($1_ltype) &$1; %} %typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == global::System.IntPtr.Zero) ? null : new $csclassname($iminput, false)" %typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)" %typemap(csdirectorin) SWIGTYPE && "new $csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$csclassname.getCPtr($cscall).Handle" /* Default array handling */ %typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %} %typemap(out) SWIGTYPE [] %{ $result = $1; %} /* char arrays - treat as String */ %typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %} %typemap(out) char[ANY], char[] %{ $result = SWIG_csharp_string_callback((const char *)$1); %} %typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %} %typemap(directorin) char[ANY], char[] %{ $input = SWIG_csharp_string_callback((const char *)$1); %} %typemap(csdirectorin) char[ANY], char[] "$iminput" %typemap(csdirectorout) char[ANY], char[] "$cscall" /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */ %typecheck(SWIG_TYPECHECK_BOOL) bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) char, const char & "" %typecheck(SWIG_TYPECHECK_INT8) signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_UINT8) unsigned char, const unsigned char & "" %typecheck(SWIG_TYPECHECK_INT16) short, const short & "" %typecheck(SWIG_TYPECHECK_UINT16) unsigned short, const unsigned short & "" %typecheck(SWIG_TYPECHECK_INT32) int, long, const int &, const long & "" %typecheck(SWIG_TYPECHECK_UINT32) unsigned int, unsigned long, const unsigned int &, const unsigned long & "" %typecheck(SWIG_TYPECHECK_INT64) long long, const long long & "" %typecheck(SWIG_TYPECHECK_UINT64) unsigned long long, const unsigned long long & "" %typecheck(SWIG_TYPECHECK_FLOAT) float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & "" %typecheck(SWIG_TYPECHECK_STRING) char *, char *&, char[ANY], char[] "" %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Exception handling */ %typemap(throws, canthrow=1) int, long, short, unsigned int, unsigned long, unsigned short %{ char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg); return $null; %} %typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [ANY] %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(throws, canthrow=1) char * %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1); return $null; %} /* Typemaps for code generation in proxy classes and C# type wrapper classes */ /* The csin typemap is used for converting function parameter types from the type * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */ %typemap(csin) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double & "$csinput" %typemap(csin) char *, char *&, char[ANY], char[] "$csinput" %typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)" %typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$csclassname.getCPtr($csinput)" %typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)" /* The csout typemap is used for converting function return types from the return type * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. * The $excode special variable is replaced by the excode typemap attribute code if the * method can throw any exceptions from unmanaged code, otherwise replaced by nothing. */ // Macro used by the $excode special variable %define SWIGEXCODE "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef %define SWIGEXCODE2 "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef %typemap(csout, excode=SWIGEXCODE) bool, const bool & { bool ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) char, const char & { char ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) signed char, const signed char & { sbyte ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned char, const unsigned char & { byte ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) short, const short & { short ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned short, const unsigned short & { ushort ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) int, const int & { int ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned int, const unsigned int & { uint ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) long, const long & { int ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned long, const unsigned long & { uint ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) long long, const long long & { long ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) unsigned long long, const unsigned long long & { ulong ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) float, const float & { float ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) double, const double & { double ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] { string ret = $imcall;$excode return ret; } %typemap(csout, excode=SWIGEXCODE) void { $imcall;$excode } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE { $&csclassname ret = new $&csclassname($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE & { $csclassname ret = new $csclassname($imcall, $owner);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE && { $csclassname ret = new $csclassname($imcall, $owner);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *, SWIGTYPE [] { global::System.IntPtr cPtr = $imcall; $csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) { string cMemberPtr = $imcall; $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode return ret; } /* Properties */ %typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ set { $imcall;$excode } %} %typemap(csvarin, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) bool, const bool & %{ get { bool ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) char, const char & %{ get { char ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) signed char, const signed char & %{ get { sbyte ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned char, const unsigned char & %{ get { byte ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) short, const short & %{ get { short ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned short, const unsigned short & %{ get { ushort ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) int, const int & %{ get { int ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned int, const unsigned int & %{ get { uint ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) long, const long & %{ get { int ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned long, const unsigned long & %{ get { uint ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) long long, const long long & %{ get { long ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) unsigned long long, const unsigned long long & %{ get { ulong ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) float, const float & %{ get { float ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) double, const double & %{ get { double ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{ get { string ret = $imcall;$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) void %{ get { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE %{ get { $&csclassname ret = new $&csclassname($imcall, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE & %{ get { $csclassname ret = new $csclassname($imcall, $owner);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE && %{ get { $csclassname ret = new $csclassname($imcall, $owner);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [] %{ get { global::System.IntPtr cPtr = $imcall; $csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE (CLASS::*) %{ get { string cMemberPtr = $imcall; $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode return ret; } %} /* Pointer reference typemaps */ %typemap(ctype) SWIGTYPE *const& "void *" %typemap(imtype, out="global::System.IntPtr") SWIGTYPE *const& "global::System.Runtime.InteropServices.HandleRef" %typemap(cstype) SWIGTYPE *const& "$*csclassname" %typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& { global::System.IntPtr cPtr = $imcall; $*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode return ret; } %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; $1 = ($1_ltype)&temp; %} %typemap(out) SWIGTYPE *const& %{ $result = (void *)*$1; %} /* Marshal C/C++ pointer to global::System.IntPtr */ %typemap(ctype) void *VOID_INT_PTR "void *" %typemap(imtype) void *VOID_INT_PTR "global::System.IntPtr" %typemap(cstype) void *VOID_INT_PTR "global::System.IntPtr" %typemap(in) void *VOID_INT_PTR %{ $1 = ($1_ltype)$input; %} %typemap(out) void *VOID_INT_PTR %{ $result = (void *)$1; %} %typemap(csin) void *VOID_INT_PTR "$csinput" %typemap(csout, excode=SWIGEXCODE) void *VOID_INT_PTR { global::System.IntPtr ret = $imcall;$excode return ret; } /* Typemaps used for the generation of proxy and type wrapper class code */ %typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" %typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csinterfaces) SWIGTYPE "global::System.IDisposable" %typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" // csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users. %define SWIG_CSBODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Proxy classes (base classes, ie, not derived classes) %typemap(csbody) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; protected bool swigCMemOwn; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %enddef %define SWIG_CSBODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Typewrapper classes %typemap(csbody) TYPE *, TYPE &, TYPE &&, TYPE [] %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool futureUse) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } DEFAULTCTOR_VISIBILITY $csclassname() { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csbody) TYPE (CLASS::*) %{ private string swigCMemberPtr; PTRCTOR_VISIBILITY $csclassname(string cMemberPtr, bool futureUse) { swigCMemberPtr = cMemberPtr; } DEFAULTCTOR_VISIBILITY $csclassname() { swigCMemberPtr = null; } CPTR_VISIBILITY static string getCMemberPtr($csclassname obj) { return obj.swigCMemberPtr; } %} %enddef /* Set the default csbody typemaps to use internal visibility. Use the macros to change to public if using multiple modules. */ SWIG_CSBODY_PROXY(internal, internal, SWIGTYPE) SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE) %typemap(csfinalize) SWIGTYPE %{ ~$csclassname() { Dispose(); } %} %typemap(csconstruct, excode=SWIGEXCODE,directorconnect="\n SwigDirectorConnect();") SWIGTYPE %{: this($imcall, true) {$excode$directorconnect } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); base.Dispose(); } } %typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{ protected void $methodname() { swigCMemOwn = false; $imcall; } %} /* C# specific directives */ #define %csconst(flag) %feature("cs:const","flag") #define %csconstvalue(value) %feature("cs:constvalue",value) #define %csenum(wrapapproach) %feature("cs:enum","wrapapproach") #define %csmethodmodifiers %feature("cs:methodmodifiers") #define %csnothrowexception %feature("except") #define %csattributes %feature("cs:attributes") %pragma(csharp) imclassclassmodifiers="class" %pragma(csharp) moduleclassmodifiers="public class" /* Some ANSI C typemaps */ %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* csharp keywords */ %include // Default enum handling %include // For vararg handling in macros, from swigmacros.swg #define %arg(X...) X /* // Alternative char * typemaps. %pragma(csharp) imclasscode=%{ public class SWIGStringMarshal : global::System.IDisposable { public readonly global::System.Runtime.InteropServices.HandleRef swigCPtr; public SWIGStringMarshal(string str) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, global::System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str)); } public virtual void Dispose() { global::System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle); global::System.GC.SuppressFinalize(this); } } %} %typemap(imtype, out="global::System.IntPtr") char *, char[ANY], char[] "global::System.Runtime.InteropServices.HandleRef" %typemap(out) char *, char[ANY], char[] %{ $result = $1; %} %typemap(csin) char *, char[ANY], char[] "new $imclassname.SWIGStringMarshal($csinput).swigCPtr" %typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] { string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode return ret; } %typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ get { string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode return ret; } %} */ swig-3.0.8/Lib/csharp/wchar.i0000664000175000017500000000651112641054563015630 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wchar.i * * Typemaps for the wchar_t type * These are mapped to a C# String and are passed around by value. * * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER * * ----------------------------------------------------------------------------- */ #if !defined(SWIG_CSHARP_NO_WSTRING_HELPER) #if !defined(SWIG_CSHARP_WSTRING_HELPER_) #define SWIG_CSHARP_WSTRING_HELPER_ %insert(runtime) %{ /* Callback for returning strings to C# without leaking memory */ typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *); static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; %} %pragma(csharp) imclasscode=%{ protected class SWIGWStringHelper { public delegate string SWIGWStringDelegate(global::System.IntPtr message); static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); static string CreateWString([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString) { return global::System.Runtime.InteropServices.Marshal.PtrToStringUni(cString); } static SWIGWStringHelper() { SWIGRegisterWStringCallback_$module(wstringDelegate); } } static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper(); %} %insert(runtime) %{ #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) { SWIG_csharp_wstring_callback = callback; } %} #endif // SWIG_CSHARP_WSTRING_HELPER_ #endif // SWIG_CSHARP_NO_WSTRING_HELPER // wchar_t %typemap(ctype) wchar_t "wchar_t" %typemap(imtype) wchar_t "char" %typemap(cstype) wchar_t "char" %typemap(csin) wchar_t "$csinput" %typemap(csout, excode=SWIGEXCODE) wchar_t { char ret = $imcall;$excode return ret; } %typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{ get { char ret = $imcall;$excode return ret; } %} %typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %} %typemap(out) wchar_t %{ $result = (wchar_t)$1; %} %typemap(typecheck) wchar_t = char; // wchar_t * %typemap(ctype) wchar_t * "wchar_t *" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]", out="global::System.IntPtr" ) wchar_t * "string" %typemap(cstype) wchar_t * "string" %typemap(csin) wchar_t * "$csinput" %typemap(csout, excode=SWIGEXCODE) wchar_t * { string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode return ret; } %typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{ get { string ret = $imcall;$excode return ret; } %} %typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %} %typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %} %typemap(typecheck) wchar_t * = char *; swig-3.0.8/Lib/csharp/std_wstring.i0000664000175000017500000000707612641054563017102 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_wstring.i * * Typemaps for std::wstring and const std::wstring& * These are mapped to a C# String and are passed around by value. * * To use non-const std::wstring references use the following %apply. Note * that they are passed by value. * %apply const std::wstring & {std::wstring &}; * ----------------------------------------------------------------------------- */ %include %{ #include %} namespace std { %naturalvar wstring; class wstring; // wstring %typemap(ctype, out="void *") wstring "wchar_t *" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") wstring "string" %typemap(cstype) wstring "string" %typemap(csdirectorin) wstring "$iminput" %typemap(csdirectorout) wstring "$cscall" %typemap(in, canthrow=1) wstring %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } $1.assign($input); %} %typemap(out) wstring %{ $result = SWIG_csharp_wstring_callback($1.c_str()); %} %typemap(directorout, canthrow=1) wstring %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } $result.assign($input); %} %typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %} %typemap(csin) wstring "$csinput" %typemap(csout, excode=SWIGEXCODE) wstring { string ret = $imcall;$excode return ret; } %typemap(typecheck) wstring = wchar_t *; %typemap(throws, canthrow=1) wstring %{ std::string message($1.begin(), $1.end()); SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str()); return $null; %} // const wstring & %typemap(ctype, out="void *") const wstring & "wchar_t *" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") const wstring & "string" %typemap(cstype) const wstring & "string" %typemap(csdirectorin) const wstring & "$iminput" %typemap(csdirectorout) const wstring & "$cscall" %typemap(in, canthrow=1) const wstring & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } std::wstring $1_str($input); $1 = &$1_str; %} %typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_callback($1->c_str()); %} %typemap(csin) const wstring & "$csinput" %typemap(csout, excode=SWIGEXCODE) const wstring & { string ret = $imcall;$excode return ret; } %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const wstring & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } /* possible thread/reentrant code problem */ static std::wstring $1_str; $1_str = $input; $result = &$1_str; %} %typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %} %typemap(csvarin, excode=SWIGEXCODE2) const wstring & %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) const wstring & %{ get { string ret = $imcall;$excode return ret; } %} %typemap(typecheck) const wstring & = wchar_t *; %typemap(throws, canthrow=1) const wstring & %{ std::string message($1.begin(), $1.end()); SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str()); return $null; %} } swig-3.0.8/Lib/csharp/csharphead.swg0000664000175000017500000003754112641054563017205 0ustar williamwilliam/* ----------------------------------------------------------------------------- * csharphead.swg * * Support code for exceptions if the SWIG_CSHARP_NO_EXCEPTION_HELPER is not defined * Support code for strings if the SWIG_CSHARP_NO_STRING_HELPER is not defined * ----------------------------------------------------------------------------- */ %insert(runtime) %{ #include #include #include %} #if !defined(SWIG_CSHARP_NO_EXCEPTION_HELPER) %insert(runtime) %{ /* Support for throwing C# exceptions from C/C++. There are two types: * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */ typedef enum { SWIG_CSharpApplicationException, SWIG_CSharpArithmeticException, SWIG_CSharpDivideByZeroException, SWIG_CSharpIndexOutOfRangeException, SWIG_CSharpInvalidCastException, SWIG_CSharpInvalidOperationException, SWIG_CSharpIOException, SWIG_CSharpNullReferenceException, SWIG_CSharpOutOfMemoryException, SWIG_CSharpOverflowException, SWIG_CSharpSystemException } SWIG_CSharpExceptionCodes; typedef enum { SWIG_CSharpArgumentException, SWIG_CSharpArgumentNullException, SWIG_CSharpArgumentOutOfRangeException } SWIG_CSharpExceptionArgumentCodes; typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *); typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *); typedef struct { SWIG_CSharpExceptionCodes code; SWIG_CSharpExceptionCallback_t callback; } SWIG_CSharpException_t; typedef struct { SWIG_CSharpExceptionArgumentCodes code; SWIG_CSharpExceptionArgumentCallback_t callback; } SWIG_CSharpExceptionArgument_t; static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { { SWIG_CSharpApplicationException, NULL }, { SWIG_CSharpArithmeticException, NULL }, { SWIG_CSharpDivideByZeroException, NULL }, { SWIG_CSharpIndexOutOfRangeException, NULL }, { SWIG_CSharpInvalidCastException, NULL }, { SWIG_CSharpInvalidOperationException, NULL }, { SWIG_CSharpIOException, NULL }, { SWIG_CSharpNullReferenceException, NULL }, { SWIG_CSharpOutOfMemoryException, NULL }, { SWIG_CSharpOverflowException, NULL }, { SWIG_CSharpSystemException, NULL } }; static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { { SWIG_CSharpArgumentException, NULL }, { SWIG_CSharpArgumentNullException, NULL }, { SWIG_CSharpArgumentOutOfRangeException, NULL } }; static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { callback = SWIG_csharp_exceptions[code].callback; } callback(msg); } static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { callback = SWIG_csharp_exceptions_argument[code].callback; } callback(msg, param_name); } %} %insert(runtime) %{ #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_$module( SWIG_CSharpExceptionCallback_t applicationCallback, SWIG_CSharpExceptionCallback_t arithmeticCallback, SWIG_CSharpExceptionCallback_t divideByZeroCallback, SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback, SWIG_CSharpExceptionCallback_t invalidCastCallback, SWIG_CSharpExceptionCallback_t invalidOperationCallback, SWIG_CSharpExceptionCallback_t ioCallback, SWIG_CSharpExceptionCallback_t nullReferenceCallback, SWIG_CSharpExceptionCallback_t outOfMemoryCallback, SWIG_CSharpExceptionCallback_t overflowCallback, SWIG_CSharpExceptionCallback_t systemCallback) { SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback; SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback; SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback; SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback; SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback; SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback; SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback; SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback; SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback; SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback; SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback; } #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module( SWIG_CSharpExceptionArgumentCallback_t argumentCallback, SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback, SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) { SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback; SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback; SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback; } %} %pragma(csharp) imclasscode=%{ protected class SWIGExceptionHelper { public delegate void ExceptionDelegate(string message); public delegate void ExceptionArgumentDelegate(string message, string paramName); static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException); static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException); static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException); static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException); static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException); static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException); static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException); static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException); static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException); static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException); static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException); static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException); static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException); static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException); [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")] public static extern void SWIGRegisterExceptionCallbacks_$module( ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate); [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_$module")] public static extern void SWIGRegisterExceptionCallbacksArgument_$module( ExceptionArgumentDelegate argumentDelegate, ExceptionArgumentDelegate argumentNullDelegate, ExceptionArgumentDelegate argumentOutOfRangeDelegate); static void SetPendingApplicationException(string message) { SWIGPendingException.Set(new global::System.ApplicationException(message, SWIGPendingException.Retrieve())); } static void SetPendingArithmeticException(string message) { SWIGPendingException.Set(new global::System.ArithmeticException(message, SWIGPendingException.Retrieve())); } static void SetPendingDivideByZeroException(string message) { SWIGPendingException.Set(new global::System.DivideByZeroException(message, SWIGPendingException.Retrieve())); } static void SetPendingIndexOutOfRangeException(string message) { SWIGPendingException.Set(new global::System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve())); } static void SetPendingInvalidCastException(string message) { SWIGPendingException.Set(new global::System.InvalidCastException(message, SWIGPendingException.Retrieve())); } static void SetPendingInvalidOperationException(string message) { SWIGPendingException.Set(new global::System.InvalidOperationException(message, SWIGPendingException.Retrieve())); } static void SetPendingIOException(string message) { SWIGPendingException.Set(new global::System.IO.IOException(message, SWIGPendingException.Retrieve())); } static void SetPendingNullReferenceException(string message) { SWIGPendingException.Set(new global::System.NullReferenceException(message, SWIGPendingException.Retrieve())); } static void SetPendingOutOfMemoryException(string message) { SWIGPendingException.Set(new global::System.OutOfMemoryException(message, SWIGPendingException.Retrieve())); } static void SetPendingOverflowException(string message) { SWIGPendingException.Set(new global::System.OverflowException(message, SWIGPendingException.Retrieve())); } static void SetPendingSystemException(string message) { SWIGPendingException.Set(new global::System.SystemException(message, SWIGPendingException.Retrieve())); } static void SetPendingArgumentException(string message, string paramName) { SWIGPendingException.Set(new global::System.ArgumentException(message, paramName, SWIGPendingException.Retrieve())); } static void SetPendingArgumentNullException(string message, string paramName) { global::System.Exception e = SWIGPendingException.Retrieve(); if (e != null) message = message + " Inner Exception: " + e.Message; SWIGPendingException.Set(new global::System.ArgumentNullException(paramName, message)); } static void SetPendingArgumentOutOfRangeException(string message, string paramName) { global::System.Exception e = SWIGPendingException.Retrieve(); if (e != null) message = message + " Inner Exception: " + e.Message; SWIGPendingException.Set(new global::System.ArgumentOutOfRangeException(paramName, message)); } static SWIGExceptionHelper() { SWIGRegisterExceptionCallbacks_$module( applicationDelegate, arithmeticDelegate, divideByZeroDelegate, indexOutOfRangeDelegate, invalidCastDelegate, invalidOperationDelegate, ioDelegate, nullReferenceDelegate, outOfMemoryDelegate, overflowDelegate, systemDelegate); SWIGRegisterExceptionCallbacksArgument_$module( argumentDelegate, argumentNullDelegate, argumentOutOfRangeDelegate); } } protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper(); public class SWIGPendingException { [global::System.ThreadStatic] private static global::System.Exception pendingException = null; private static int numExceptionsPending = 0; public static bool Pending { get { bool pending = false; if (numExceptionsPending > 0) if (pendingException != null) pending = true; return pending; } } public static void Set(global::System.Exception e) { if (pendingException != null) throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); pendingException = e; lock(typeof($imclassname)) { numExceptionsPending++; } } public static global::System.Exception Retrieve() { global::System.Exception e = null; if (numExceptionsPending > 0) { if (pendingException != null) { e = pendingException; pendingException = null; lock(typeof($imclassname)) { numExceptionsPending--; } } } return e; } } %} #endif // SWIG_CSHARP_NO_EXCEPTION_HELPER #if !defined(SWIG_CSHARP_NO_STRING_HELPER) %insert(runtime) %{ /* Callback for returning strings to C# without leaking memory */ typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *); static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL; %} %pragma(csharp) imclasscode=%{ protected class SWIGStringHelper { public delegate string SWIGStringDelegate(string message); static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString); [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterStringCallback_$module")] public static extern void SWIGRegisterStringCallback_$module(SWIGStringDelegate stringDelegate); static string CreateString(string cString) { return cString; } static SWIGStringHelper() { SWIGRegisterStringCallback_$module(stringDelegate); } } static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper(); %} %insert(runtime) %{ #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpStringHelperCallback callback) { SWIG_csharp_string_callback = callback; } %} #endif // SWIG_CSHARP_NO_STRING_HELPER #if !defined(SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR) // Ensure the class is not marked beforefieldinit %pragma(csharp) imclasscode=%{ static $imclassname() { } %} #endif %insert(runtime) %{ /* Contract support */ #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else %} swig-3.0.8/Lib/csharp/std_map.i0000664000175000017500000002526712641054563016164 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map< K, T, C > * * The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>. * * Using this wrapper is fairly simple. For example, to create a map from integers to doubles use: * * %include * %template(MapIntDouble) std::map * * Notes: * 1) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with * C++ std::map wrappers. * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ %{ #include #include #include %} /* K is the C++ key type, T is the C++ value type */ %define SWIG_STD_MAP_INTERNAL(K, T, C) %typemap(csinterfaces) std::map< K, T, C > "global::System.IDisposable \n , global::System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n"; %typemap(cscode) std::map %{ public $typemap(cstype, T) this[$typemap(cstype, K) key] { get { return getitem(key); } set { setitem(key, value); } } public bool TryGetValue($typemap(cstype, K) key, out $typemap(cstype, T) value) { if (this.ContainsKey(key)) { value = this[key]; return true; } value = default($typemap(cstype, T)); return false; } public int Count { get { return (int)size(); } } public bool IsReadOnly { get { return false; } } public global::System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys { get { global::System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new global::System.Collections.Generic.List<$typemap(cstype, K)>(); int size = this.Count; if (size > 0) { global::System.IntPtr iter = create_iterator_begin(); for (int i = 0; i < size; i++) { keys.Add(get_next_key(iter)); } destroy_iterator(iter); } return keys; } } public global::System.Collections.Generic.ICollection<$typemap(cstype, T)> Values { get { global::System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new global::System.Collections.Generic.List<$typemap(cstype, T)>(); foreach (global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) { vals.Add(pair.Value); } return vals; } } public void Add(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { Add(item.Key, item.Value); } public bool Remove(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { if (Contains(item)) { return Remove(item.Key); } else { return false; } } public bool Contains(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { if (this[item.Key] == item.Value) { return true; } else { return false; } } public void CopyTo(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) { CopyTo(array, 0); } public void CopyTo(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) { if (array == null) throw new global::System.ArgumentNullException("array"); if (arrayIndex < 0) throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); if (array.Rank > 1) throw new global::System.ArgumentException("Multi dimensional array.", "array"); if (arrayIndex+this.Count > array.Length) throw new global::System.ArgumentException("Number of elements to copy is too large."); global::System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new global::System.Collections.Generic.List<$typemap(cstype, K)>(this.Keys); for (int i = 0; i < keyList.Count; i++) { $typemap(cstype, K) currentKey = keyList[i]; array.SetValue(new global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i); } } global::System.Collections.Generic.IEnumerator> global::System.Collections.Generic.IEnumerable>.GetEnumerator() { return new $csclassnameEnumerator(this); } global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return new $csclassnameEnumerator(this); } public $csclassnameEnumerator GetEnumerator() { return new $csclassnameEnumerator(this); } // Type-safe enumerator /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown /// whenever the collection is modified. This has been done for changes in the size of the /// collection but not when one of the elements of the collection is modified as it is a bit /// tricky to detect unmanaged code that modifies the collection under our feet. public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator, global::System.Collections.Generic.IEnumerator> { private $csclassname collectionRef; private global::System.Collections.Generic.IList<$typemap(cstype, K)> keyCollection; private int currentIndex; private object currentObject; private int currentSize; public $csclassnameEnumerator($csclassname collection) { collectionRef = collection; keyCollection = new global::System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys); currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; } // Type-safe iterator Current public global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current { get { if (currentIndex == -1) throw new global::System.InvalidOperationException("Enumeration not started."); if (currentIndex > currentSize - 1) throw new global::System.InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new global::System.InvalidOperationException("Collection modified."); return (global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject; } } // Type-unsafe IEnumerator.Current object global::System.Collections.IEnumerator.Current { get { return Current; } } public bool MoveNext() { int size = collectionRef.Count; bool moveOkay = (currentIndex+1 < size) && (size == currentSize); if (moveOkay) { currentIndex++; $typemap(cstype, K) currentKey = keyCollection[currentIndex]; currentObject = new global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, collectionRef[currentKey]); } else { currentObject = null; } return moveOkay; } public void Reset() { currentIndex = -1; currentObject = null; if (collectionRef.Count != currentSize) { throw new global::System.InvalidOperationException("Collection modified."); } } public void Dispose() { currentIndex = -1; currentObject = null; } } %} public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map< K, T, C > &other); size_type size() const; bool empty() const; %rename(Clear) clear; void clear(); %extend { const mapped_type& getitem(const key_type& key) throw (std::out_of_range) { std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) return iter->second; else throw std::out_of_range("key not found"); } void setitem(const key_type& key, const mapped_type& x) { (*$self)[key] = x; } bool ContainsKey(const key_type& key) { std::map< K, T, C >::iterator iter = $self->find(key); return iter != $self->end(); } void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) { std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) throw std::out_of_range("key already exists"); $self->insert(std::pair< K, T >(key, val)); } bool Remove(const key_type& key) { std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) { $self->erase(iter); return true; } return false; } // create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C# %apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *create_iterator_begin } %apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *swigiterator } std::map< K, T, C >::iterator *create_iterator_begin() { return new std::map< K, T, C >::iterator($self->begin()); } const key_type& get_next_key(std::map< K, T, C >::iterator *swigiterator) { std::map< K, T, C >::iterator iter = *swigiterator; (*swigiterator)++; return (*iter).first; } void destroy_iterator(std::map< K, T, C >::iterator *swigiterator) { delete swigiterator; } } %enddef %csmethodmodifiers std::map::size "private" %csmethodmodifiers std::map::getitem "private" %csmethodmodifiers std::map::setitem "private" %csmethodmodifiers std::map::create_iterator_begin "private" %csmethodmodifiers std::map::get_next_key "private" %csmethodmodifiers std::map::destroy_iterator "private" // Default implementation namespace std { template > class map { SWIG_STD_MAP_INTERNAL(K, T, C) }; } // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef swig-3.0.8/Lib/csharp/csharpkw.swg0000664000175000017500000000350212641054563016713 0ustar williamwilliam#ifndef CSHARP_CSHARPKW_SWG_ #define CSHARP_CSHARPKW_SWG_ /* Warnings for C# keywords */ #define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x` #define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '_" `x` "'",%$isclass,rename="_%s") `x` /* from http://www.jaggersoft.com/csharp_grammar.html#1.7%20Keywords */ CSHARPKW(abstract); CSHARPKW(as); CSHARPKW(base); CSHARPKW(bool); CSHARPKW(break); CSHARPKW(byte); CSHARPKW(case); CSHARPKW(catch); CSHARPKW(char); CSHARPKW(checked); CSHARPKW(class); CSHARPKW(const); CSHARPKW(continue); CSHARPKW(decimal); CSHARPKW(default); CSHARPKW(delegate); CSHARPKW(do); CSHARPKW(double); CSHARPKW(else); CSHARPKW(enum); CSHARPKW(event); CSHARPKW(explicit); CSHARPKW(extern); CSHARPKW(false); CSHARPKW(finally); CSHARPKW(fixed); CSHARPKW(float); CSHARPKW(for); CSHARPKW(foreach); CSHARPKW(goto); CSHARPKW(if); CSHARPKW(implicit); CSHARPKW(in); CSHARPKW(int); CSHARPKW(interface); CSHARPKW(internal); CSHARPKW(is); CSHARPKW(lock); CSHARPKW(long); CSHARPKW(namespace); CSHARPKW(new); CSHARPKW(null); CSHARPKW(object); CSHARPKW(operator); CSHARPKW(out); CSHARPKW(override); CSHARPKW(params); CSHARPKW(private); CSHARPKW(protected); CSHARPKW(public); CSHARPKW(readonly); CSHARPKW(ref); CSHARPKW(return); CSHARPKW(sbyte); CSHARPKW(sealed); CSHARPKW(short); CSHARPKW(sizeof); CSHARPKW(stackalloc); CSHARPKW(static); CSHARPKW(struct); CSHARPKW(string); CSHARPKW(switch); CSHARPKW(this); CSHARPKW(throw); CSHARPKW(true); CSHARPKW(try); CSHARPKW(typeof); CSHARPKW(uint); CSHARPKW(ulong); CSHARPKW(unchecked); CSHARPKW(unsafe); CSHARPKW(ushort); CSHARPKW(using); CSHARPKW(virtual); CSHARPKW(void); CSHARPKW(volatile); CSHARPKW(while); CSHARPCLASSKW(delete); #undef CSHARPKW #endif //CSHARP_CSHARPKW_SWG_ swig-3.0.8/Lib/csharp/std_string.i0000664000175000017500000000614712641054563016711 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * Typemaps for std::string and const std::string& * These are mapped to a C# String and are passed around by value. * * To use non-const std::string references use the following %apply. Note * that they are passed by value. * %apply const std::string & {std::string &}; * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; class string; // string %typemap(ctype) string "char *" %typemap(imtype) string "string" %typemap(cstype) string "string" %typemap(csdirectorin) string "$iminput" %typemap(csdirectorout) string "$cscall" %typemap(in, canthrow=1) string %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; } $1.assign($input); %} %typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %} %typemap(directorout, canthrow=1) string %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; } $result.assign($input); %} %typemap(directorin) string %{ $input = SWIG_csharp_string_callback($1.c_str()); %} %typemap(csin) string "$csinput" %typemap(csout, excode=SWIGEXCODE) string { string ret = $imcall;$excode return ret; } %typemap(typecheck) string = char *; %typemap(throws, canthrow=1) string %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); return $null; %} // const string & %typemap(ctype) const string & "char *" %typemap(imtype) const string & "string" %typemap(cstype) const string & "string" %typemap(csdirectorin) const string & "$iminput" %typemap(csdirectorout) const string & "$cscall" %typemap(in, canthrow=1) const string & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; } $*1_ltype $1_str($input); $1 = &$1_str; %} %typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %} %typemap(csin) const string & "$csinput" %typemap(csout, excode=SWIGEXCODE) const string & { string ret = $imcall;$excode return ret; } %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; } /* possible thread/reentrant code problem */ static $*1_ltype $1_str; $1_str = $input; $result = &$1_str; %} %typemap(directorin) const string & %{ $input = SWIG_csharp_string_callback($1.c_str()); %} %typemap(csvarin, excode=SWIGEXCODE2) const string & %{ set { $imcall;$excode } %} %typemap(csvarout, excode=SWIGEXCODE2) const string & %{ get { string ret = $imcall;$excode return ret; } %} %typemap(typecheck) const string & = char *; %typemap(throws, canthrow=1) const string & %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); return $null; %} } swig-3.0.8/Lib/csharp/stl.i0000664000175000017500000000054512641054563015327 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/csharp/boost_shared_ptr.i0000664000175000017500000002604312641054563020067 0ustar williamwilliam// Users can provide their own SWIG_SHARED_PTR_TYPEMAPS macro before including this file to change the // visibility of the constructor and getCPtr method if desired to public if using multiple modules. #ifndef SWIG_SHARED_PTR_TYPEMAPS #define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE) #endif %include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0; if (!argp) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ $result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in, canthrow=1) CONST TYPE & %{ $1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); if (!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = (TYPE *)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ if ($input) $1 = *($&1_ltype)$input; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ $result = $1 ? new $1_ltype($1) : 0; %} // shared_ptr by reference %typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ $result = *$1 ? new $*1_ltype(*$1) : 0; %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out, fragment="SWIG_null_deleter") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ $result = ($1 && *$1) ? new $*1_ltype(*($1_ltype)$1) : 0; if ($owner) delete $1; %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0) %{ temp = $input ? *($1_ltype)&$input : &tempnull; $1 = &temp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void *" %typemap (imtype, out="global::System.IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef" %typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)" %typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE & { $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) CONST TYPE * { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE & %{ get { $csclassname ret = new $csclassname($imcall, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE * %{ get { global::System.IntPtr cPtr = $imcall; $csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ get { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ get { global::System.IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %} // Proxy classes (base classes, ie, not derived classes) %typemap(csbody) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private global::System.Runtime.InteropServices.HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } global::System.GC.SuppressFinalize(this); base.Dispose(); } } %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/csharp/director.swg0000664000175000017500000000222112641054563016701 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that C# proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #if defined(DEBUG_DIRECTOR_OWNED) #include #endif #include #include namespace Swig { /* Director base class - not currently used in C# directors */ class Director { }; /* Base class for director exceptions */ class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(const char *msg) : swig_msg(msg) { } DirectorException(const std::string &msg) : swig_msg(msg) { } virtual ~DirectorException() throw() { } const char *what() const throw() { return swig_msg.c_str(); } }; /* Pure virtual method exception */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) { } }; } swig-3.0.8/Lib/csharp/std_shared_ptr.i0000664000175000017500000000010412641054563017521 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.8/Lib/csharp/typemaps.i0000664000175000017500000002472312641054563016373 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* INPUT typemaps -------------- These typemaps are used for pointer/reference parameters that are input only and are mapped to a C# input parameter. The following typemaps can be applied to turn a pointer or reference into a simple input value. That is, instead of passing a pointer or reference to an object, you would use a real value instead. bool *INPUT, bool &INPUT signed char *INPUT, signed char &INPUT unsigned char *INPUT, unsigned char &INPUT short *INPUT, short &INPUT unsigned short *INPUT, unsigned short &INPUT int *INPUT, int &INPUT unsigned int *INPUT, unsigned int &INPUT long *INPUT, long &INPUT unsigned long *INPUT, unsigned long &INPUT long long *INPUT, long long &INPUT unsigned long long *INPUT, unsigned long long &INPUT float *INPUT, float &INPUT double *INPUT, double &INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); In C# you could then use it like this: double answer = modulename.fadd(10.0, 20.0); */ %define INPUT_TYPEMAP(TYPE, CTYPE, CSTYPE) %typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE" %typemap(imtype, out="global::System.IntPtr") TYPE *INPUT, TYPE &INPUT "CSTYPE" %typemap(cstype, out="$csclassname") TYPE *INPUT, TYPE &INPUT "CSTYPE" %typemap(csin) TYPE *INPUT, TYPE &INPUT "$csinput" %typemap(in) TYPE *INPUT, TYPE &INPUT %{ $1 = ($1_ltype)&$input; %} %typemap(typecheck) TYPE *INPUT = TYPE; %typemap(typecheck) TYPE &INPUT = TYPE; %enddef INPUT_TYPEMAP(bool, unsigned int, bool) //INPUT_TYPEMAP(char, char, char) INPUT_TYPEMAP(signed char, signed char, sbyte) INPUT_TYPEMAP(unsigned char, unsigned char, byte) INPUT_TYPEMAP(short, short, short) INPUT_TYPEMAP(unsigned short, unsigned short, ushort) INPUT_TYPEMAP(int, int, int) INPUT_TYPEMAP(unsigned int, unsigned int, uint) INPUT_TYPEMAP(long, long, int) INPUT_TYPEMAP(unsigned long, unsigned long, uint) INPUT_TYPEMAP(long long, long long, long) INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong) INPUT_TYPEMAP(float, float, float) INPUT_TYPEMAP(double, double, double) #undef INPUT_TYPEMAP /* OUTPUT typemaps --------------- These typemaps are used for pointer/reference parameters that are output only and are mapped to a C# output parameter. The following typemaps can be applied to turn a pointer or reference into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In C#, the 'out' keyword is used when passing the parameter to a function that takes an output parameter. bool *OUTPUT, bool &OUTPUT signed char *OUTPUT, signed char &OUTPUT unsigned char *OUTPUT, unsigned char &OUTPUT short *OUTPUT, short &OUTPUT unsigned short *OUTPUT, unsigned short &OUTPUT int *OUTPUT, int &OUTPUT unsigned int *OUTPUT, unsigned int &OUTPUT long *OUTPUT, long &OUTPUT unsigned long *OUTPUT, unsigned long &OUTPUT long long *OUTPUT, long long &OUTPUT unsigned long long *OUTPUT, unsigned long long &OUTPUT float *OUTPUT, float &OUTPUT double *OUTPUT, double &OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters): double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The C# output of the function would be the function return value and the value returned in the second output parameter. In C# you would use it like this: double dptr; double fraction = modulename.modf(5, out dptr); */ %define OUTPUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE) %typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *" %typemap(imtype, out="global::System.IntPtr") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE" %typemap(cstype, out="$csclassname") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE" %typemap(csin) TYPE *OUTPUT, TYPE &OUTPUT "out $csinput" %typemap(in) TYPE *OUTPUT, TYPE &OUTPUT %{ $1 = ($1_ltype)$input; %} %typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT "" %enddef OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) //OUTPUT_TYPEMAP(char, char, char, CHAR_PTR) OUTPUT_TYPEMAP(signed char, signed char, sbyte, INT8_PTR) OUTPUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR) OUTPUT_TYPEMAP(short, short, short, INT16_PTR) OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) OUTPUT_TYPEMAP(int, int, int, INT32_PTR) OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) OUTPUT_TYPEMAP(long, long, int, INT32_PTR) OUTPUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR) OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR) OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR) OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR) #undef OUTPUT_TYPEMAP %typemap(in) bool *OUTPUT, bool &OUTPUT %{ *$input = 0; $1 = ($1_ltype)$input; %} /* INOUT typemaps -------------- These typemaps are for pointer/reference parameters that are both input and output and are mapped to a C# reference parameter. The following typemaps can be applied to turn a pointer or reference into a reference parameters, that is the parameter is both an input and an output. In C#, the 'ref' keyword is used for reference parameters. bool *INOUT, bool &INOUT signed char *INOUT, signed char &INOUT unsigned char *INOUT, unsigned char &INOUT short *INOUT, short &INOUT unsigned short *INOUT, unsigned short &INOUT int *INOUT, int &INOUT unsigned int *INOUT, unsigned int &INOUT long *INOUT, long &INOUT unsigned long *INOUT, unsigned long &INOUT long long *INOUT, long long &INOUT unsigned long long *INOUT, unsigned long long &INOUT float *INOUT, float &INOUT double *INOUT, double &INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); The C# output of the function would be the new value returned by the reference parameter. In C# you would use it like this: double x = 5.0; neg(ref x); The implementation of the OUTPUT and INOUT typemaps is different to the scripting languages in that the scripting languages will return the output value as part of the function return value. */ %define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE) %typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *" %typemap(imtype, out="global::System.IntPtr") TYPE *INOUT, TYPE &INOUT "ref CSTYPE" %typemap(cstype, out="$csclassname") TYPE *INOUT, TYPE &INOUT "ref CSTYPE" %typemap(csin) TYPE *INOUT, TYPE &INOUT "ref $csinput" %typemap(in) TYPE *INOUT, TYPE &INOUT %{ $1 = ($1_ltype)$input; %} %typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT "" %enddef INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) //INOUT_TYPEMAP(char, char, char, CHAR_PTR) INOUT_TYPEMAP(signed char, signed char, sbyte, INT8_PTR) INOUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR) INOUT_TYPEMAP(short, short, short, INT16_PTR) INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) INOUT_TYPEMAP(int, int, int, INT32_PTR) INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) INOUT_TYPEMAP(long, long, int, INT32_PTR) INOUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR) INOUT_TYPEMAP(long long, long long, long, INT64_PTR) INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) INOUT_TYPEMAP(float, float, float, FLOAT_PTR) INOUT_TYPEMAP(double, double, double, DOUBLE_PTR) #undef INOUT_TYPEMAP swig-3.0.8/Lib/csharp/std_vector.i0000664000175000017500000003410212641054563016675 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector * C# implementation * The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection. * * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with * C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality * whenever we are confident that the required C++ operator== is available. This is the case for when * T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED * macro to obtain this enhanced functionality, for example: * * SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass) * %template(VectKlass) std::vector; * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ // Warning: Use the typemaps here in the expectation that the macros they are in will change name. %include // MACRO for use within the std::vector class body %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...) %typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"; %typemap(cscode) std::vector< CTYPE > %{ public $csclassname(global::System.Collections.ICollection c) : this() { if (c == null) throw new global::System.ArgumentNullException("c"); foreach ($typemap(cstype, CTYPE) element in c) { this.Add(element); } } public bool IsFixedSize { get { return false; } } public bool IsReadOnly { get { return false; } } public $typemap(cstype, CTYPE) this[int index] { get { return getitem(index); } set { setitem(index, value); } } public int Capacity { get { return (int)capacity(); } set { if (value < size()) throw new global::System.ArgumentOutOfRangeException("Capacity"); reserve((uint)value); } } public int Count { get { return (int)size(); } } public bool IsSynchronized { get { return false; } } public void CopyTo($typemap(cstype, CTYPE)[] array) { CopyTo(0, array, 0, this.Count); } public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex) { CopyTo(0, array, arrayIndex, this.Count); } public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count) { if (array == null) throw new global::System.ArgumentNullException("array"); if (index < 0) throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero"); if (arrayIndex < 0) throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); if (count < 0) throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero"); if (array.Rank > 1) throw new global::System.ArgumentException("Multi dimensional array.", "array"); if (index+count > this.Count || arrayIndex+count > array.Length) throw new global::System.ArgumentException("Number of elements to copy is too large."); for (int i=0; i global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() { return new $csclassnameEnumerator(this); } global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return new $csclassnameEnumerator(this); } public $csclassnameEnumerator GetEnumerator() { return new $csclassnameEnumerator(this); } // Type-safe enumerator /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown /// whenever the collection is modified. This has been done for changes in the size of the /// collection but not when one of the elements of the collection is modified as it is a bit /// tricky to detect unmanaged code that modifies the collection under our feet. public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator , global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> { private $csclassname collectionRef; private int currentIndex; private object currentObject; private int currentSize; public $csclassnameEnumerator($csclassname collection) { collectionRef = collection; currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; } // Type-safe iterator Current public $typemap(cstype, CTYPE) Current { get { if (currentIndex == -1) throw new global::System.InvalidOperationException("Enumeration not started."); if (currentIndex > currentSize - 1) throw new global::System.InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new global::System.InvalidOperationException("Collection modified."); return ($typemap(cstype, CTYPE))currentObject; } } // Type-unsafe IEnumerator.Current object global::System.Collections.IEnumerator.Current { get { return Current; } } public bool MoveNext() { int size = collectionRef.Count; bool moveOkay = (currentIndex+1 < size) && (size == currentSize); if (moveOkay) { currentIndex++; currentObject = collectionRef[currentIndex]; } else { currentObject = null; } return moveOkay; } public void Reset() { currentIndex = -1; currentObject = null; if (collectionRef.Count != currentSize) { throw new global::System.InvalidOperationException("Collection modified."); } } public void Dispose() { currentIndex = -1; currentObject = null; } } %} public: typedef size_t size_type; typedef CTYPE value_type; typedef CONST_REFERENCE const_reference; %rename(Clear) clear; void clear(); %rename(Add) push_back; void push_back(CTYPE const& x); size_type size() const; size_type capacity() const; void reserve(size_type n); %newobject GetRange(int index, int count); %newobject Repeat(CTYPE const& value, int count); vector(); vector(const vector &other); %extend { vector(int capacity) throw (std::out_of_range) { std::vector< CTYPE >* pv = 0; if (capacity >= 0) { pv = new std::vector< CTYPE >(); pv->reserve(capacity); } else { throw std::out_of_range("capacity"); } return pv; } CTYPE getitemcopy(int index) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) return (*$self)[index]; else throw std::out_of_range("index"); } CONST_REFERENCE getitem(int index) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) return (*$self)[index]; else throw std::out_of_range("index"); } void setitem(int index, CTYPE const& val) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) (*$self)[index] = val; else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.AddRange void AddRange(const std::vector< CTYPE >& values) { $self->insert($self->end(), values.begin(), values.end()); } // Takes a deep copy of the elements unlike ArrayList.GetRange std::vector< CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { if (index < 0) throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); return new std::vector< CTYPE >($self->begin()+index, $self->begin()+index+count); } void Insert(int index, CTYPE const& x) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()+1) $self->insert($self->begin()+index, x); else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange void InsertRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()+1) $self->insert($self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index"); } void RemoveAt(int index) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) $self->erase($self->begin() + index); else throw std::out_of_range("index"); } void RemoveRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { if (index < 0) throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); $self->erase($self->begin()+index, $self->begin()+index+count); } static std::vector< CTYPE > *Repeat(CTYPE const& value, int count) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("count"); return new std::vector< CTYPE >(count, value); } void Reverse() { std::reverse($self->begin(), $self->end()); } void Reverse(int index, int count) throw (std::out_of_range, std::invalid_argument) { if (index < 0) throw std::out_of_range("index"); if (count < 0) throw std::out_of_range("count"); if (index >= (int)$self->size()+1 || index+count > (int)$self->size()) throw std::invalid_argument("invalid range"); std::reverse($self->begin()+index, $self->begin()+index+count); } // Takes a deep copy of the elements unlike ArrayList.SetRange void SetRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) { if (index < 0) throw std::out_of_range("index"); if (index+values.size() > $self->size()) throw std::out_of_range("index"); std::copy(values.begin(), values.end(), $self->begin()+index); } } %enddef // Extra methods added to the collection class if operator== is defined for the class being wrapped // The class will then implement IList<>, which adds extra functionality %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...) %extend { bool Contains(CTYPE const& value) { return std::find($self->begin(), $self->end(), value) != $self->end(); } int IndexOf(CTYPE const& value) { int index = -1; std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) index = (int)(it - $self->begin()); return index; } int LastIndexOf(CTYPE const& value) { int index = -1; std::vector< CTYPE >::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value); if (rit != $self->rend()) index = (int)($self->rend() - 1 - rit); return index; } bool Remove(CTYPE const& value) { std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) { $self->erase(it); return true; } return false; } } %enddef // Macros for std::vector class specializations/enhancements %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector< CTYPE > { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE)) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } %enddef // Legacy macros %define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) #warning SWIG_STD_VECTOR_SPECIALIZE macro deprecated, please see csharp/std_vector.i and switch to SWIG_STD_VECTOR_ENHANCED SWIG_STD_VECTOR_ENHANCED(CTYPE) %enddef %define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...) #warning SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro deprecated, it is no longer required %enddef %{ #include #include #include %} %csmethodmodifiers std::vector::getitemcopy "private" %csmethodmodifiers std::vector::getitem "private" %csmethodmodifiers std::vector::setitem "private" %csmethodmodifiers std::vector::size "private" %csmethodmodifiers std::vector::capacity "private" %csmethodmodifiers std::vector::reserve "private" namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, T const&, T) }; // specialization for pointers template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *) }; // bool is specialized in the C++ standard - const_reference in particular template<> class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool) }; } // template specializations for std::vector // these provide extra collections methods as operator== is defined SWIG_STD_VECTOR_ENHANCED(char) SWIG_STD_VECTOR_ENHANCED(signed char) SWIG_STD_VECTOR_ENHANCED(unsigned char) SWIG_STD_VECTOR_ENHANCED(short) SWIG_STD_VECTOR_ENHANCED(unsigned short) SWIG_STD_VECTOR_ENHANCED(int) SWIG_STD_VECTOR_ENHANCED(unsigned int) SWIG_STD_VECTOR_ENHANCED(long) SWIG_STD_VECTOR_ENHANCED(unsigned long) SWIG_STD_VECTOR_ENHANCED(long long) SWIG_STD_VECTOR_ENHANCED(unsigned long long) SWIG_STD_VECTOR_ENHANCED(float) SWIG_STD_VECTOR_ENHANCED(double) SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include swig-3.0.8/Lib/csharp/enums.swg0000664000175000017500000000557612641054563016235 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enums.swg * * Include this file in order for C/C++ enums to be wrapped by proper C# enums. * Note that the PINVOKE layer handles the enum as an int. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(ctype) const enum SWIGTYPE & "int" %typemap(imtype) const enum SWIGTYPE & "int" %typemap(cstype) const enum SWIGTYPE & "$*csclassname" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;" %typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput" %typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall" %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) const enum SWIGTYPE & "(int)$csinput" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { $*csclassname ret = ($*csclassname)$imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ get { $*csclassname ret = ($*csclassname)$imcall;$excode return ret; } %} // enum SWIGTYPE typemaps %typemap(ctype) enum SWIGTYPE "int" %typemap(imtype) enum SWIGTYPE "int" %typemap(cstype) enum SWIGTYPE "$csclassname" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE "$input = (int)$1;" %typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput" %typemap(csdirectorout) enum SWIGTYPE "(int)$cscall" %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(csin) enum SWIGTYPE "(int)$csinput" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { $csclassname ret = ($csclassname)$imcall;$excode return ret; } %typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ get { $csclassname ret = ($csclassname)$imcall;$excode return ret; } %} %typemap(csbase) enum SWIGTYPE "" %typemap(csclassmodifiers) enum SWIGTYPE "public enum" %typemap(cscode) enum SWIGTYPE "" %typemap(csimports) enum SWIGTYPE "" %typemap(csinterfaces) enum SWIGTYPE "" %typemap(csbody) enum SWIGTYPE "" %csenum(proper); swig-3.0.8/Lib/csharp/arrays_csharp.i0000664000175000017500000001252012641054563017362 0ustar williamwilliam/* ----------------------------------------------------------------------------- * arrays_csharp.i * * This file contains a two approaches to marshaling arrays. The first uses * default p/invoke marshaling and the second uses pinning of the arrays. * * Default marshaling approach * ---------------------------- * Array typemaps using default p/invoke marshaling. The data is copied to a separately * allocated buffer when passing over the managed-native boundary. * * There are separate typemaps for in, out and inout arrays to enable avoiding * unnecessary copying. * * Example usage: * * %include "arrays_csharp.i" * %apply int INPUT[] { int* sourceArray } * %apply int OUTPUT[] { int* targetArray } * void myArrayCopy( int* sourceArray, int* targetArray, int nitems ); * * %apply int INOUT[] { int* array1, int *array2 } * void myArraySwap( int* array1, int* array2, int nitems ); * * If handling large arrays you should consider using the pinning array typemaps * described next. * * Pinning approach * ---------------- * Array typemaps using pinning. These typemaps pin the managed array given * as parameter and pass a pointer to it to the c/c++ side. This is very * efficient as no copying is done (unlike in the default array marshaling), * but it makes garbage collection more difficult. When considering using * these typemaps, think carefully whether you have callbacks that may cause * the control to re-enter the managed side from within the call (and produce * garbage for the gc) or whether other threads may produce enough garbage to * trigger gc while the call is being executed. In those cases it may be * wiser to use the default marshaling typemaps. * * Please note that when using fixed arrays, you have to mark your corresponding * module class method unsafe using * %csmethodmodifiers "public unsafe" * (the visibility of the method is up to you). * * Example usage: * * %include "arrays_csharp.i" * %apply int FIXED[] { int* sourceArray, int *targetArray } * %csmethodmodifiers myArrayCopy "public unsafe"; * void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); * * ----------------------------------------------------------------------------- */ %define CSHARP_ARRAYS( CTYPE, CSTYPE ) // input only arrays %typemap(ctype) CTYPE INPUT[] "CTYPE*" %typemap(cstype) CTYPE INPUT[] "CSTYPE[]" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE INPUT[] "CSTYPE[]" %typemap(csin) CTYPE INPUT[] "$csinput" %typemap(in) CTYPE INPUT[] "$1 = $input;" %typemap(freearg) CTYPE INPUT[] "" %typemap(argout) CTYPE INPUT[] "" // output only arrays %typemap(ctype) CTYPE OUTPUT[] "CTYPE*" %typemap(cstype) CTYPE OUTPUT[] "CSTYPE[]" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE OUTPUT[] "CSTYPE[]" %typemap(csin) CTYPE OUTPUT[] "$csinput" %typemap(in) CTYPE OUTPUT[] "$1 = $input;" %typemap(freearg) CTYPE OUTPUT[] "" %typemap(argout) CTYPE OUTPUT[] "" // inout arrays %typemap(ctype) CTYPE INOUT[] "CTYPE*" %typemap(cstype) CTYPE INOUT[] "CSTYPE[]" %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE INOUT[] "CSTYPE[]" %typemap(csin) CTYPE INOUT[] "$csinput" %typemap(in) CTYPE INOUT[] "$1 = $input;" %typemap(freearg) CTYPE INOUT[] "" %typemap(argout) CTYPE INOUT[] "" %enddef // CSHARP_ARRAYS CSHARP_ARRAYS(signed char, sbyte) CSHARP_ARRAYS(unsigned char, byte) CSHARP_ARRAYS(short, short) CSHARP_ARRAYS(unsigned short, ushort) CSHARP_ARRAYS(int, int) CSHARP_ARRAYS(unsigned int, uint) // FIXME - on Unix 64 bit, long is 8 bytes but is 4 bytes on Windows 64 bit. // How can this be handled sensibly? // See e.g. http://www.xml.com/ldd/chapter/book/ch10.html CSHARP_ARRAYS(long, int) CSHARP_ARRAYS(unsigned long, uint) CSHARP_ARRAYS(long long, long) CSHARP_ARRAYS(unsigned long long, ulong) CSHARP_ARRAYS(float, float) CSHARP_ARRAYS(double, double) CSHARP_ARRAYS(bool, bool) %define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE ) %typemap(ctype) CTYPE FIXED[] "CTYPE*" %typemap(imtype) CTYPE FIXED[] "global::System.IntPtr" %typemap(cstype) CTYPE FIXED[] "CSTYPE[]" %typemap(csin, pre= " fixed ( CSTYPE* swig_ptrTo_$csinput = $csinput ) {", terminator=" }") CTYPE FIXED[] "(global::System.IntPtr)swig_ptrTo_$csinput" %typemap(in) CTYPE FIXED[] "$1 = $input;" %typemap(freearg) CTYPE FIXED[] "" %typemap(argout) CTYPE FIXED[] "" %enddef // CSHARP_ARRAYS_FIXED CSHARP_ARRAYS_FIXED(signed char, sbyte) CSHARP_ARRAYS_FIXED(unsigned char, byte) CSHARP_ARRAYS_FIXED(short, short) CSHARP_ARRAYS_FIXED(unsigned short, ushort) CSHARP_ARRAYS_FIXED(int, int) CSHARP_ARRAYS_FIXED(unsigned int, uint) CSHARP_ARRAYS_FIXED(long, int) CSHARP_ARRAYS_FIXED(unsigned long, uint) CSHARP_ARRAYS_FIXED(long long, long) CSHARP_ARRAYS_FIXED(unsigned long long, ulong) CSHARP_ARRAYS_FIXED(float, float) CSHARP_ARRAYS_FIXED(double, double) CSHARP_ARRAYS_FIXED(bool, bool) swig-3.0.8/Lib/allegrocl/0000775000175000017500000000000012641054563015033 5ustar williamwilliamswig-3.0.8/Lib/allegrocl/longlongs.i0000664000175000017500000000312512641054563017210 0ustar williamwilliam/* ----------------------------------------------------------------------------- * longlongs.i * * Typemap addition for support of 'long long' type and 'unsigned long long * Makes use of swig-def-foreign-class, so this header should be loaded * after allegrocl.swg and after any custom user identifier-conversion * functions have been defined. * ----------------------------------------------------------------------------- */ #ifdef Acl64Bit %typemap(ctype) long long, unsigned long long "$1_ltype"; %typemap(out) long long, unsigned long long "$result = $1;"; %typemap(ffitype) long long ":nat"; %typemap(ffitype) unsigned long long ":unsigned-nat"; %typemap(lout) long long, unsigned long long " #+64bit (cl::setq ACL_ffresult $body)"; #else %typemap(out) long long, unsigned long long "$result = &$1;"; %typemap(ffitype) long long "(:struct (l1 :long) (l2 :long))"; %typemap(ffitype) unsigned long long "(:struct (l1 :unsigned-long) (l2 :unsigned-long))"; %typemap(lout) long long " (cl::setq ACL_ffresult (make-instance '#.(swig-insert-id \"longlong\" () :type :class) :foreign-address $body))"; %typemap(lout) unsigned long long " (cl:setq ACL_ffresult (make-instance '#.(swig-insert-id \"ulonglong\" () :type :class) :foreign-address $body))"; #endif %typemap(in) long long, unsigned long long "$1 = $input;"; %insert("lisphead") %{ #-64bit (swig-def-foreign-class "longlong" (ff:foreign-pointer) (:struct (l1 :long) (l2 :long))) #-64bit (swig-def-foreign-class "ulonglong" (ff:foreign-pointer) (:struct (l1 :unsigned-long) (l2 :unsigned-long))) %} swig-3.0.8/Lib/allegrocl/inout_typemaps.i0000664000175000017500000001053312641054563020267 0ustar williamwilliam/* inout_typemaps.i Support for INPUT, OUTPUT, and INOUT typemaps. OUTPUT variables are returned as multiple values. */ /* Note that this macro automatically adds a pointer to the type passed in. As a result, INOUT typemaps for char are for 'char *'. The definition of typemaps for 'char' takes advantage of this, believing that it's more likely to see an INOUT argument for strings, than a single char. */ %define INOUT_TYPEMAP(type_, OUTresult_, INbind_) // OUTPUT map. %typemap(lin,numinputs=0) type_ *OUTPUT, type_ &OUTPUT %{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) $body OUTresult_ (ff:free-fobject $out)) %} // INPUT map. %typemap(in) type_ *INPUT, type_ &INPUT %{ $1 = &$input; %} %typemap(ctype) type_ *INPUT, type_ &INPUT "$*1_ltype"; // INOUT map. // careful here. the input string is converted to a C string // with length equal to the input string. This should be large // enough to contain whatever OUTPUT value will be stored in it. %typemap(lin,numinputs=1) type_ *INOUT, type_ &INOUT %{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) INbind_ $body OUTresult_ (ff:free-fobject $out)) %} %enddef // $in, $out, $lclass, // $in_fftype, $*in_fftype INOUT_TYPEMAP(int, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(short, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(long, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(unsigned int, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(unsigned short, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(unsigned long, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); // char * mapping for passing strings. didn't quite work // INOUT_TYPEMAP(char, // (cl::push (excl:native-to-string $out) ACL_result), // (cl::setf (ff:fslot-value-typed (cl::quote $in_fftype) :c $out) // (excl:string-to-native $in))) INOUT_TYPEMAP(float, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(double, (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); INOUT_TYPEMAP(bool, (cl::push (not (zerop (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out))) ACL_result), (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) (if $in 1 0))); %typemap(lisptype) bool *INPUT, bool &INPUT "boolean"; // long long support not yet complete // INOUT_TYPEMAP(long long); // INOUT_TYPEMAP(unsigned long long); // char *OUTPUT map. // for this to work, swig needs to know how large an array to allocate. // you can fake this by // %typemap(ffitype) char *myarg "(:array :char 30)"; // %apply char *OUTPUT { char *myarg }; %typemap(lin,numinputs=0) char *OUTPUT, char &OUTPUT %{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) $body (cl::push (excl:native-to-string $out) ACL_result) (ff:free-fobject $out)) %} // char *INPUT map. %typemap(in) char *INPUT, char &INPUT %{ $1 = &$input; %} %typemap(ctype) char *INPUT, char &INPUT "$*1_ltype"; // char *INOUT map. %typemap(lin,numinputs=1) char *INOUT, char &INOUT %{(cl::let (($out (excl:string-to-native $in))) $body (cl::push (excl:native-to-string $out) ACL_result) (ff:free-fobject $out)) %} // uncomment this if you want INOUT mappings for chars instead of strings. // INOUT_TYPEMAP(char, // (cl::push (code-char (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out)) // ACL_result), // (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); swig-3.0.8/Lib/allegrocl/allegrocl.swg0000664000175000017500000005750112641054563017531 0ustar williamwilliam/* Define a C preprocessor symbol that can be used in interface files to distinguish between the SWIG language modules. */ #define SWIG_ALLEGRO_CL #define %ffargs(...) %feature("ffargs", "1", ##__VA_ARGS__) %ffargs(strings_convert="t"); /* typemaps for argument and result type conversions. */ %typemap(lin,numinputs=1) SWIGTYPE "(cl::let (($out $in))\n $body)"; %typemap(lout) bool, char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, enum SWIGTYPE "(cl::setq ACL_ffresult $body)"; %typemap(lout) void "$body"; #ifdef __cplusplus %typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE && %{ (cl:let* ((address $body) (new-inst (cl:make-instance '$lclass :foreign-address address))) (cl:when (cl:and $owner (cl:not (cl:zerop address))) (excl:schedule-finalization new-inst #'$ldestructor)) (cl:setq ACL_ffresult new-inst)) %} %typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))"; #else %typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE %{ (cl:let* ((address $body) (new-inst (cl:make-instance '$lclass :foreign-address address))) (cl:setq ACL_ffresult new-inst)) %} #endif %typemap(lisptype) bool, const bool "cl:boolean"; %typemap(lisptype) char, const char "cl:character"; %typemap(lisptype) unsigned char, const unsigned char "cl:integer"; %typemap(lisptype) signed char, const signed char "cl:integer"; %typemap(ffitype) bool, const bool ":int"; %typemap(ffitype) char, const char, signed char, const signed char ":char"; %typemap(ffitype) unsigned char, const unsigned char ":unsigned-char"; %typemap(ffitype) short, const short, signed short, const signed short ":short"; %typemap(ffitype) unsigned short, const unsigned short ":unsigned-short"; %typemap(ffitype) int, const int, signed int, const signed int ":int"; %typemap(ffitype) unsigned int, const unsigned int ":unsigned-int"; %typemap(ffitype) long, const long, signed long, const signed long ":long"; %typemap(ffitype) unsigned long, const unsigned long ":unsigned-long"; %typemap(ffitype) float, const float ":float"; %typemap(ffitype) double, const double ":double"; %typemap(ffitype) char *, const char *, signed char *, const signed char *, signed char &, const signed char & "(* :char)"; %typemap(ffitype) unsigned char *, const unsigned char *, unsigned char &, const unsigned char & "(* :unsigned-char)"; %typemap(ffitype) short *, const short *, short &, const short & "(* :short)"; %typemap(ffitype) unsigned short *, const unsigned short *, unsigned short &, const unsigned short & "(* :unsigned-short)"; %typemap(ffitype) int *, const int *, int &, const int & "(* :int)"; %typemap(ffitype) unsigned int *, const unsigned int *, unsigned int &, const unsigned int & "(* :unsigned-int)"; %typemap(ffitype) void * "(* :void)"; %typemap(ffitype) void ":void"; %typemap(ffitype) enum SWIGTYPE ":int"; %typemap(ffitype) SWIGTYPE & "(* :void)"; %typemap(ffitype) SWIGTYPE && "(* :void)"; /* const typemaps idea: marshall all primitive c types to their respective lisp types to maintain const corretness. For pointers/references, all bets are off if you try to modify them. idea: add a constant-p slot to the base foreign-pointer class. For constant pointer/references check this value when setting (around method?) and error if a setf operation is performed on the address of this object. */ /* %exception %{ try { $action } catch (...) { return $null; } %} */ // %typemap(throws) SWIGTYPE { // (void)$1; // SWIG_fail; // } %typemap(ctype) bool, const bool "int"; %typemap(ctype) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE &&, const SWIGTYPE "$1_ltype"; %typemap(ctype) SWIGTYPE "$&1_type"; %typemap(in) bool "$1 = (bool)$input;"; %typemap(in) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1 = $input;"; %typemap(in) SWIGTYPE "$1 = *$input;"; /* We don't need to do any actual C-side typechecking, but need to use the precedence values to choose which overloaded function interfaces to generate when conflicts arise. */ /* predefined precedence values Symbolic Name Precedence Value ------------------------------ ------------------ SWIG_TYPECHECK_POINTER 0 SWIG_TYPECHECK_VOIDPTR 10 SWIG_TYPECHECK_BOOL 15 SWIG_TYPECHECK_UINT8 20 SWIG_TYPECHECK_INT8 25 SWIG_TYPECHECK_UINT16 30 SWIG_TYPECHECK_INT16 35 SWIG_TYPECHECK_UINT32 40 SWIG_TYPECHECK_INT32 45 SWIG_TYPECHECK_UINT64 50 SWIG_TYPECHECK_INT64 55 SWIG_TYPECHECK_UINT128 60 SWIG_TYPECHECK_INT128 65 SWIG_TYPECHECK_INTEGER 70 SWIG_TYPECHECK_FLOAT 80 SWIG_TYPECHECK_DOUBLE 90 SWIG_TYPECHECK_COMPLEX 100 SWIG_TYPECHECK_UNICHAR 110 SWIG_TYPECHECK_UNISTRING 120 SWIG_TYPECHECK_CHAR 130 SWIG_TYPECHECK_STRING 140 SWIG_TYPECHECK_BOOL_ARRAY 1015 SWIG_TYPECHECK_INT8_ARRAY 1025 SWIG_TYPECHECK_INT16_ARRAY 1035 SWIG_TYPECHECK_INT32_ARRAY 1045 SWIG_TYPECHECK_INT64_ARRAY 1055 SWIG_TYPECHECK_INT128_ARRAY 1065 SWIG_TYPECHECK_FLOAT_ARRAY 1080 SWIG_TYPECHECK_DOUBLE_ARRAY 1090 SWIG_TYPECHECK_CHAR_ARRAY 1130 SWIG_TYPECHECK_STRING_ARRAY 1140 */ %typecheck(SWIG_TYPECHECK_BOOL) bool { $1 = 1; }; %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = 1; }; %typecheck(SWIG_TYPECHECK_FLOAT) float { $1 = 1; }; %typecheck(SWIG_TYPECHECK_DOUBLE) double { $1 = 1; }; %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = 1; }; %typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE { $1 = 1; }; %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[], SWIGTYPE[ANY], SWIGTYPE { $1 = 1; }; /* This maps C/C++ types to Lisp classes for overload dispatch */ %typemap(lispclass) bool "t"; %typemap(lispclass) char "cl:character"; %typemap(lispclass) unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE "cl:integer"; %typemap(lispclass) float "cl:single-float"; %typemap(lispclass) double "cl:double-float"; %typemap(lispclass) char * "cl:string"; %typemap(out) void ""; %typemap(out) bool "$result = (int)$1;"; %typemap(out) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;"; #ifdef __cplusplus %typemap(out) SWIGTYPE "$result = new $1_ltype($1);"; #else %typemap(out) SWIGTYPE { $result = ($&1_ltype) malloc(sizeof($1_type)); memmove($result, &$1, sizeof($1_type)); } #endif ////////////////////////////////////////////////////////////// // UCS-2 string conversion // should this be SWIG_TYPECHECK_CHAR? %typecheck(SWIG_TYPECHECK_UNICHAR) wchar_t { $1 = 1; }; %typemap(in) wchar_t "$1 = $input;"; %typemap(lin,numinputs=1) wchar_t "(cl::let (($out (cl:char-code $in)))\n $body)"; %typemap(lin,numinputs=1) wchar_t * "(excl:with-native-string ($out $in :external-format #+little-endian :fat-le #-little-endian :fat)\n $body)" %typemap(out) wchar_t "$result = $1;"; %typemap(lout) wchar_t "(cl::setq ACL_ffresult (cl::code-char $body))"; %typemap(lout) wchar_t * "(cl::setq ACL_ffresult (excl:native-to-string $body :external-format #+little-endian :fat-le #-little-endian :fat))"; %typemap(ffitype) wchar_t ":unsigned-short"; %typemap(lisptype) wchar_t ""; %typemap(ctype) wchar_t "wchar_t"; %typemap(lispclass) wchar_t "cl:character"; %typemap(lispclass) wchar_t * "cl:string"; ////////////////////////////////////////////////////////////// /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* name conversion for overloaded operators. */ #ifdef __cplusplus %rename(__add__) *::operator+; %rename(__pos__) *::operator+(); %rename(__pos__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-() const; %rename(__neg__) *::operator-(); %rename(__mul__) *::operator*; %rename(__deref__) *::operator*(); %rename(__deref__) *::operator*() const; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__logxor__) *::operator^; %rename(__logand__) *::operator&; %rename(__logior__) *::operator|; %rename(__lognot__) *::operator~(); %rename(__lognot__) *::operator~() const; %rename(__not__) *::operator!(); %rename(__not__) *::operator!() const; %rename(__assign__) *::operator=; %rename(__add_assign__) *::operator+=; %rename(__sub_assign__) *::operator-=; %rename(__mul_assign__) *::operator*=; %rename(__div_assign__) *::operator/=; %rename(__mod_assign__) *::operator%=; %rename(__logxor_assign__) *::operator^=; %rename(__logand_assign__) *::operator&=; %rename(__logior_assign__) *::operator|=; %rename(__lshift__) *::operator<<; %rename(__lshift_assign__) *::operator<<=; %rename(__rshift__) *::operator>>; %rename(__rshift_assign__) *::operator>>=; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__lt__) *::operator<; %rename(__gt__) *::operator>; %rename(__lte__) *::operator<=; %rename(__gte__) *::operator>=; %rename(__and__) *::operator&&; %rename(__or__) *::operator||; %rename(__preincr__) *::operator++(); %rename(__postincr__) *::operator++(int); %rename(__predecr__) *::operator--(); %rename(__postdecr__) *::operator--(int); %rename(__comma__) *::operator,(); %rename(__comma__) *::operator,() const; %rename(__member_ref__) *::operator->; %rename(__member_func_ref__) *::operator->*; %rename(__funcall__) *::operator(); %rename(__aref__) *::operator[]; %rename(__bool__) *::operator bool(); %rename(__bool__) *::operator bool() const; #endif %insert("lisphead") %{ (eval-when (:compile-toplevel :load-toplevel :execute) ;; avoid compiling ef-templates at runtime (excl:find-external-format :fat) (excl:find-external-format :fat-le) ;;; You can define your own identifier converter if you want. ;;; Use the -identifier-converter command line argument to ;;; specify its name. (eval-when (:compile-toplevel :load-toplevel :execute) (cl::defparameter *swig-export-list* nil)) (cl::defconstant *void* :..void..) ;; parsers to aid in finding SWIG definitions in files. (cl::defun scm-p1 (form) (let* ((info (cl::second form)) (id (car info)) (id-args (if (eq (cl::car form) 'swig-dispatcher) (cl::cdr info) (cl::cddr info)))) (cl::apply *swig-identifier-converter* id (cl::progn (cl::when (cl::eq (cl::car form) 'swig-dispatcher) (cl::remf id-args :arities)) id-args)))) (cl::defmacro defswig1 (name (&rest args) &body body) `(cl::progn (cl::defmacro ,name ,args ,@body) (excl::define-simple-parser ,name scm-p1)) ) (cl::defmacro defswig2 (name (&rest args) &body body) `(cl::progn (cl::defmacro ,name ,args ,@body) (excl::define-simple-parser ,name second))) (defun read-symbol-from-string (string) (cl::multiple-value-bind (result position) (cl::read-from-string string nil "eof" :preserve-whitespace t) (cl::if (cl::and (cl::symbolp result) (cl::eql position (cl::length string))) result (cl::multiple-value-bind (sym) (cl::intern string) sym)))) (cl::defun full-name (id type arity class) ; We need some kind of a hack here to handle template classes ; and other synonym types right. We need the original name. (let*( (sym (read-symbol-from-string (if (eq *swig-identifier-converter* 'identifier-convert-lispify) (string-lispify id) id))) (sym-class (find-class sym nil)) (id (cond ( (not sym-class) id ) ( (and sym-class (not (eq (class-name sym-class) sym))) (class-name sym-class) ) ( t id ))) ) (cl::case type (:getter (cl::format nil "~@[~A_~]~A" class id)) (:constructor (cl::format nil "new_~A~@[~A~]" id arity)) (:destructor (cl::format nil "delete_~A" id)) (:type (cl::format nil "ff_~A" id)) (:slot id) (:ff-operator (cl::format nil "ffi_~A" id)) (otherwise (cl::format nil "~@[~A_~]~A~@[~A~]" class id arity))))) (cl::defun identifier-convert-null (id &key type class arity) (cl::if (cl::eq type :setter) `(cl::setf ,(identifier-convert-null id :type :getter :class class :arity arity)) (read-symbol-from-string (full-name id type arity class)))) (cl::defun string-lispify (str) (cl::let ( (cname (excl::replace-regexp str "_" "-")) (lastcase :other) newcase char res ) (cl::dotimes (n (cl::length cname)) (cl::setf char (cl::schar cname n)) (excl::if* (cl::alpha-char-p char) then (cl::setf newcase (cl::if (cl::upper-case-p char) :upper :lower)) (cl::when (cl::and (cl::eq lastcase :lower) (cl::eq newcase :upper)) ;; case change... add a dash (cl::push #\- res) (cl::setf newcase :other)) (cl::push (cl::char-downcase char) res) (cl::setf lastcase newcase) else (cl::push char res) (cl::setf lastcase :other))) (cl::coerce (cl::nreverse res) 'string))) (cl::defun identifier-convert-lispify (cname &key type class arity) (cl::assert (cl::stringp cname)) (cl::when (cl::eq type :setter) (cl::return-from identifier-convert-lispify `(cl::setf ,(identifier-convert-lispify cname :type :getter :class class :arity arity)))) (cl::setq cname (full-name cname type arity class)) (cl::if (cl::eq type :constant) (cl::setf cname (cl::format nil "*~A*" cname))) (read-symbol-from-string (string-lispify cname))) (cl::defun id-convert-and-export (name &rest kwargs) (cl::multiple-value-bind (symbol package) (cl::apply *swig-identifier-converter* name kwargs) (cl::let ((args (cl::list (cl::if (cl::consp symbol) (cl::cadr symbol) symbol) (cl::or package cl::*package*)))) (cl::apply #'cl::export args) (cl::pushnew args *swig-export-list*)) symbol)) (cl::defmacro swig-insert-id (name namespace &key (type :type) class) `(cl::let ((cl::*package* (cl::find-package ,(package-name-for-namespace namespace)))) (id-convert-and-export ,name :type ,type :class ,class))) (defswig2 swig-defconstant (string value) (cl::let ((symbol (id-convert-and-export string :type :constant))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defconstant ,symbol ,value)))) (cl::defun maybe-reorder-args (funcname arglist) ;; in the foreign setter function the new value will be the last argument ;; in Lisp it needs to be the first (cl::if (cl::consp funcname) (cl::append (cl::last arglist) (cl::butlast arglist)) arglist)) (cl::defun maybe-return-value (funcname arglist) ;; setf functions should return the new value (cl::when (cl::consp funcname) `(,(cl::if (cl::consp (cl::car arglist)) (cl::caar arglist) (cl::car arglist))))) (cl::defun swig-anyvarargs-p (arglist) (cl::member :SWIG__varargs_ arglist)) (defswig1 swig-defun ((name &optional (mangled-name name) &key (type :operator) class arity) arglist kwargs &body body) (cl::let* ((symbol (id-convert-and-export name :type type :arity arity :class class)) (mangle (excl::if* (cl::string-equal name mangled-name) then (id-convert-and-export (cl::cond ((cl::eq type :setter) (cl::format nil "~A-set" name)) ((cl::eq type :getter) (cl::format nil "~A-get" name)) (t name)) :type :ff-operator :arity arity :class class) else (cl::intern mangled-name))) (defun-args (maybe-reorder-args symbol (cl::mapcar #'cl::car (cl::and (cl::not (cl::equal arglist '(:void))) (cl::loop as i in arglist when (cl::eq (cl::car i) :p+) collect (cl::cdr i)))))) (ffargs (cl::if (cl::equal arglist '(:void)) arglist (cl::mapcar #'cl::cdr arglist))) ) (cl::when (swig-anyvarargs-p ffargs) (cl::setq ffargs '())) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (excl::compiler-let ((*record-xref-info* nil)) (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) (cl::macrolet ((swig-ff-call (&rest args) (cl::cons ',mangle args))) (cl::defun ,symbol ,defun-args ,@body ,@(maybe-return-value symbol defun-args)))))) (defswig1 swig-defmethod ((name &optional (mangled-name name) &key (type :operator) class arity) ffargs kwargs &body body) (cl::let* ((symbol (id-convert-and-export name :type type :arity arity :class class)) (mangle (cl::intern mangled-name)) (defmethod-args (maybe-reorder-args symbol (cl::unless (cl::equal ffargs '(:void)) (cl::loop for (lisparg name dispatch) in ffargs when (eq lisparg :p+) collect `(,name ,dispatch))))) (ffargs (cl::if (cl::equal ffargs '(:void)) ffargs (cl::loop for (nil name nil . ffi) in ffargs collect `(,name ,@ffi))))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (excl::compiler-let ((*record-xref-info* nil)) (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) (cl::macrolet ((swig-ff-call (&rest args) (cl::cons ',mangle args))) (cl::defmethod ,symbol ,defmethod-args ,@body ,@(maybe-return-value symbol defmethod-args)))))) (defswig1 swig-dispatcher ((name &key (type :operator) class arities)) (cl::let ((symbol (id-convert-and-export name :type type :class class))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defun ,symbol (&rest args) (cl::case (cl::length args) ,@(cl::loop for arity in arities for symbol-n = (id-convert-and-export name :type type :class class :arity arity) collect `(,arity (cl::apply #',symbol-n args))) (t (cl::error "No applicable wrapper-methods for foreign call ~a with args ~a of classes ~a" ',symbol args (cl::mapcar #'(cl::lambda (x) (cl::class-name (cl::class-of x))) args))) ))))) (defswig2 swig-def-foreign-stub (name) (cl::let ((lsymbol (id-convert-and-export name :type :class)) (symbol (id-convert-and-export name :type :type))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol (:class )) (cl::defclass ,lsymbol (ff:foreign-pointer) ())))) (defswig2 swig-def-foreign-class (name supers &rest rest) (cl::let ((lsymbol (id-convert-and-export name :type :class)) (symbol (id-convert-and-export name :type :type))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol ,@rest) (cl::defclass ,lsymbol ,supers ((foreign-type :initform ',symbol :initarg :foreign-type :accessor foreign-pointer-type)))))) (defswig2 swig-def-foreign-type (name &rest rest) (cl::let ((symbol (id-convert-and-export name :type :type))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-type ,symbol ,@rest)))) (defswig2 swig-def-synonym-type (synonym of ff-synonym) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::setf (cl::find-class ',synonym) (cl::find-class ',of)) (ff:def-foreign-type ,ff-synonym (:struct )))) (cl::defun package-name-for-namespace (namespace) (excl::list-to-delimited-string (cl::cons *swig-module-name* (cl::mapcar #'(cl::lambda (name) (cl::string (cl::funcall *swig-identifier-converter* name :type :namespace))) namespace)) ".")) (cl::defmacro swig-defpackage (namespace) (cl::let* ((parent-namespaces (cl::maplist #'cl::reverse (cl::cdr (cl::reverse namespace)))) (parent-strings (cl::mapcar #'package-name-for-namespace parent-namespaces)) (string (package-name-for-namespace namespace))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::defpackage ,string (:use :swig :ff #+ignore '(:common-lisp :ff :excl) ,@parent-strings ,*swig-module-name*) (:import-from :cl :* :nil :t))))) (cl::defmacro swig-in-package (namespace) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (cl::in-package ,(package-name-for-namespace namespace)))) (defswig2 swig-defvar (name mangled-name &key type (ftype :unsigned-natural)) (cl::let ((symbol (id-convert-and-export name :type type))) `(cl::eval-when (:compile-toplevel :load-toplevel :execute) (ff:def-foreign-variable (,symbol ,mangled-name) :type ,ftype)))) ) ;; eval-when (cl::eval-when (:compile-toplevel :execute) (cl::flet ((starts-with-p (str prefix) (cl::and (cl::>= (cl::length str) (cl::length prefix)) (cl::string= str prefix :end1 (cl::length prefix))))) (cl::export (cl::loop for sym being each present-symbol of cl::*package* when (cl::or (starts-with-p (cl::symbol-name sym) (cl::symbol-name :swig-)) (starts-with-p (cl::symbol-name sym) (cl::symbol-name :identifier-convert-))) collect sym)))) %} typedef void *__SWIGACL_FwdReference; %{ #ifdef __cplusplus # define EXTERN extern "C" #else # define EXTERN extern #endif #define EXPORT EXTERN SWIGEXPORT typedef void *__SWIGACL_FwdReference; #include #include %} swig-3.0.8/Lib/allegrocl/std_list.i0000664000175000017500000001136112641054563017034 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_list.i * * SWIG typemaps for std::list types * * To use, add: * * %include "std_list.i" * * to your interface file. You will also need to include a template directive * for each instance of the list container you want to use in your application. * e.g. * * %template (intlist) std::list; * %template (floatlist) std::list; * ----------------------------------------------------------------------------- */ %module std_list %warnfilter(468) std::list; %{ #include #include %} namespace std{ template class list { public: typedef T &reference; typedef const T& const_reference; typedef T &iterator; typedef const T& const_iterator; list(); list(unsigned int size, const T& value = T()); list(const list &); ~list(); void assign(unsigned int n, const T& value); void swap(list &x); const_reference front(); const_reference back(); const_iterator begin(); const_iterator end(); void resize(unsigned int n, T c = T()); bool empty() const; void push_front(const T& INPUT); void push_back(const T& INPUT); void pop_front(); void pop_back(); void clear(); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, const T& INPUT); void remove(const T& INPUT); void unique(); void reverse(); void sort(); %extend { %typemap(lout) T &__getitem__ "(cl::setq ACL_ffresult (ff:fslot-value-typed '$*out_fftype :c $body))"; %typemap(lout) T *__getitem__ "(cl::setq ACL_ffresult (make-instance '$lclass :foreign-address $body))"; const_reference __getitem__(int i) throw (std::out_of_range) { std::list::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && i::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && i::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && ierase(first); } else throw std::out_of_range("list index out of range"); } std::list __getslice__(int i,int j) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; if (i>=j) i=j; if (i>=0 && i=0) { for (int k=0;k tmp(j-i); if (j>i) std::copy(first,end,tmp.begin()); return tmp; } else throw std::out_of_range("list index out of range"); } void __delslice__(int i,int j) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; for (int k=0;kerase(first,end); } void __setslice__(int i,int j, const std::list& v) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; for (int k=0;kerase(first,end); if (i+1 <= int(self->size())) { first = self->begin(); for (int k=0;kinsert(first,v.begin(),v.end()); } else self->insert(self->end(),v.begin(),v.end()); } } unsigned int __len__() { return self->size(); } bool __nonzero__() { return !(self->empty()); } void append(const T& INPUT) { self->push_back(INPUT); } void pop() { self->pop_back(); } }; }; } swig-3.0.8/Lib/allegrocl/std_string.i0000664000175000017500000001502212641054563017365 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ // std::string is typemapped by value // This can prevent exporting methods which return a string // in order for the user to modify it. // However, I think I'll wait until someone asks for it... // ------------------------------------------------------------------------ // %include %warnfilter(404) std::string; %warnfilter(404) std::wstring; %{ #include %} // %include // %naturalvar std::string; // %naturalvar std::wstring; namespace std { typedef unsigned long size_t; typedef signed long ptrdiff_t; template class basic_string { public: typedef charT *pointer; typedef charT &reference; typedef const charT &const_reference; typedef size_t size_type; typedef ptrdiff_t difference_type; basic_string(); basic_string( charT *str ); size_type size(); charT operator []( int pos ) const; charT *c_str() const; basic_string &operator = ( const basic_string &ws ); basic_string &operator = ( const charT *str ); basic_string &append( const basic_string &other ); basic_string &append( const charT *str ); void push_back( charT c ); void clear(); void reserve( size_type t ); void resize( size_type n, charT c = charT() ); int compare( const basic_string &other ) const; int compare( const charT *str ) const; basic_string &insert( size_type pos, const basic_string &str ); size_type find( const basic_string &other, int pos = 0 ) const; size_type find( charT c, int pos = 0 ) const; %extend { bool operator == ( const basic_string &other ) const { return self->compare( other ) == 0; } bool operator != ( const basic_string &other ) const { return self->compare( other ) != 0; } bool operator < ( const basic_string &other ) const { return self->compare( other ) == -1; } bool operator > ( const basic_string &other ) const { return self->compare( other ) == 1; } bool operator <= ( const basic_string &other ) const { return self->compare( other ) != 1; } bool operator >= ( const basic_string &other ) const { return self->compare( other ) != -1; } } }; %template(string) basic_string; %template(wstring) basic_string; %apply char * { string }; %apply wchar_t * { wstring }; typedef basic_string string; typedef basic_string wstring; // automatically convert constant std::strings to cl:strings %typemap(ctype) string "char *"; %typemap(in) string "$1.assign($input);"; %typemap(out) string "$result = (char *)(&$1)->c_str();"; %typemap(lisptype) string "cl:string"; %typemap(lout) string "(cl::setq ACL_ffresult $body)"; %typemap(ctype) const string *"char *"; %typemap(in) const string * "$1.assign($input);"; %typemap(out) const string * "$result = (char *)($1)->c_str();"; %typemap(lisptype) const string * "cl:string"; %typemap(lout) const string * "(cl::setq ACL_ffresult $body)"; %typemap(ctype) wstring "wchar_t *"; %typemap(in) wstring "$1.assign($input);"; %typemap(out) wstring "$result = (wchar_t *)(&$1)->c_str();"; %typemap(lisptype) wstring "cl:string"; %typemap(lout) wstring "(cl::setq ACL_ffresult (excl:native-to-string $body :external-format #+little-endian :fat-le #-little-endian :fat))"; %typemap(ctype) const wstring *"char *"; %typemap(in) const wstring * "$1.assign($input);"; %typemap(out) const wstring * "$result = (char *)($1)->c_str();"; %typemap(lisptype) const wstring * "cl:string"; %typemap(lout) const wstring * "(cl::setq ACL_ffresult $body)"; /* Overloading check */ // %typemap(in) string { // if (caml_ptr_check($input)) // $1.assign((char *)caml_ptr_val($input,0), // caml_string_len($input)); // else // SWIG_exception(SWIG_TypeError, "string expected"); // } // %typemap(in) const string & ($*1_ltype temp) { // if (caml_ptr_check($input)) { // temp.assign((char *)caml_ptr_val($input,0), // caml_string_len($input)); // $1 = &temp; // } else { // SWIG_exception(SWIG_TypeError, "string expected"); // } // } // %typemap(in) string & ($*1_ltype temp) { // if (caml_ptr_check($input)) { // temp.assign((char *)caml_ptr_val($input,0), // caml_string_len($input)); // $1 = &temp; // } else { // SWIG_exception(SWIG_TypeError, "string expected"); // } // } // %typemap(in) string * ($*1_ltype *temp) { // if (caml_ptr_check($input)) { // temp = new $*1_ltype((char *)caml_ptr_val($input,0), // caml_string_len($input)); // $1 = temp; // } else { // SWIG_exception(SWIG_TypeError, "string expected"); // } // } // %typemap(free) string * ($*1_ltype *temp) { // delete temp; // } // %typemap(argout) string & { // caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), // (*$1).size())); // } // %typemap(directorout) string { // $result.assign((char *)caml_ptr_val($input,0), // caml_string_len($input)); // } // %typemap(out) string { // $result = caml_val_string_len($1.c_str(),$1.size()); // } // %typemap(out) string * { // $result = caml_val_string_len((*$1).c_str(),(*$1).size()); // } } // #ifdef ENABLE_CHARPTR_ARRAY // char **c_charptr_array( const std::vector &str_v ); // %{ // SWIGEXT char **c_charptr_array( const std::vector &str_v ) { // char **out = new char *[str_v.size() + 1]; // out[str_v.size()] = 0; // for( int i = 0; i < str_v.size(); i++ ) { // out[i] = (char *)str_v[i].c_str(); // } // return out; // } // %} // #endif // #ifdef ENABLE_STRING_VECTOR // %template (StringVector) std::vector; // %insert(ml) %{ // (* Some STL convenience items *) // let string_array_to_vector sa = // let nv = _new_StringVector C_void in // array_to_vector nv (fun x -> C_string x) sa ; nv // let c_string_array ar = // _c_charptr_array (string_array_to_vector ar) // %} // %insert(mli) %{ // val c_string_array: string array -> c_obj // %} // #endif swig-3.0.8/Lib/allegrocl/typemaps.i0000664000175000017500000000012712641054563017047 0ustar williamwilliam/* Unused for Allegro CL module */ %include "inout_typemaps.i" %include "longlongs.i" swig-3.0.8/Lib/d/0000775000175000017500000000000012641054563013312 5ustar williamwilliamswig-3.0.8/Lib/d/std_pair.i0000664000175000017500000000127712641054563015300 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T t, U u); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/d/dstrings.swg0000664000175000017500000000501112641054563015666 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dstrings.swg * * Typemaps for wrapping pointers to/arrays of C chars as D strings. * ----------------------------------------------------------------------------- */ %define SWIGD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ) %typemap(ctype) char *, char *&, char[ANY], char[] "char *" %typemap(imtype) char *, char *&, char[ANY], char[] #DW_STRING_TYPE %typemap(dtype) char *, char *&, char[ANY], char[] #DP_STRING_TYPE /* * char* typemaps. */ %typemap(in) char * %{ $1 = ($1_ltype)$input; %} %typemap(out) char * %{ $result = SWIG_d_string_callback((const char *)$1); %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %} %typemap(directorin) char * %{ $input = SWIG_d_string_callback((const char *)$1); %} %typemap(ddirectorin) char * "FROM_STRINGZ($winput)" %typemap(ddirectorout) char * "TO_STRINGZ($dcall)" /* * char*& typemaps. */ %typemap(in) char *& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) char *& %{ if ($1) $result = SWIG_d_string_callback((const char *)*$1); %} /* * char array typemaps. */ %typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %} %typemap(out) char[ANY], char[] %{ $result = SWIG_d_string_callback((const char *)$1); %} %typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %} %typemap(directorin) char[ANY], char[] %{ $input = SWIG_d_string_callback((const char *)$1); %} %typemap(ddirectorin) char[ANY], char[] "$winput" %typemap(ddirectorout) char[ANY], char[] "$dcall" %typemap(din) char *, char *&, char[ANY], char[] "($dinput ? TO_STRINGZ($dinput) : null)" %typemap(dout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] { DP_STRING_TYPE ret = FROM_STRINGZ ## ($imcall);$excode return ret; } %typecheck(SWIG_TYPECHECK_STRING) char *, char *&, char[ANY], char[] "" %enddef // We need to have the \0-terminated string conversion functions available in // the D proxy modules. #if (SWIG_D_VERSION == 1) // Could be easily extended to support Phobos as well. SWIGD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz) %pragma(d) globalproxyimports = "static import tango.stdc.stringz;"; #else SWIGD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz) %pragma(d) globalproxyimports = %{ static import std.conv; static import std.string; %} #endif #undef SWIGD_STRING_TYPEMAPS swig-3.0.8/Lib/d/std_except.i0000664000175000017500000000355512641054563015636 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. These typemaps are * used when methods are declared with an STL exception specification, such as * size_t at() const throw (std::out_of_range); * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %ignore exception; struct exception {}; } %typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::invalid_argument "SWIG_DSetPendingException(SWIG_DIllegalArgumentException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::length_error "SWIG_DSetPendingException(SWIG_DNoSuchElementException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::logic_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::out_of_range "SWIG_DSetPendingException(SWIG_DNoSuchElementException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::overflow_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::range_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::runtime_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" %typemap(throws, canthrow=1) std::underflow_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;" swig-3.0.8/Lib/d/carrays.i0000664000175000017500000000502312641054563015130 0ustar williamwilliam/* ----------------------------------------------------------------------------- * carrays.i * * D-specific version of ../carrays.i. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %array_functions(TYPE,NAME) * * Generates functions for creating and accessing elements of a C array * (as pointers). Creates the following functions: * * TYPE *new_NAME(int nelements) * void delete_NAME(TYPE *); * TYPE NAME_getitem(TYPE *, int index); * void NAME_setitem(TYPE *, int index, TYPE value); * * ----------------------------------------------------------------------------- */ %define %array_functions(TYPE,NAME) %{ static TYPE *new_##NAME(int nelements) { %} #ifdef __cplusplus %{ return new TYPE[nelements](); %} #else %{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %} #endif %{} static void delete_##NAME(TYPE *ary) { %} #ifdef __cplusplus %{ delete [] ary; %} #else %{ free(ary); %} #endif %{} static TYPE NAME##_getitem(TYPE *ary, int index) { return ary[index]; } static void NAME##_setitem(TYPE *ary, int index, TYPE value) { ary[index] = value; } %} TYPE *new_##NAME(int nelements); void delete_##NAME(TYPE *ary); TYPE NAME##_getitem(TYPE *ary, int index); void NAME##_setitem(TYPE *ary, int index, TYPE value); %enddef /* ----------------------------------------------------------------------------- * %array_class(TYPE,NAME) * * Generates a class wrapper around a C array. The class has the following * interface: * * struct NAME { * NAME(int nelements); * ~NAME(); * TYPE getitem(int index); * void setitem(int index, TYPE value); * TYPE * ptr(); * static NAME *frompointer(TYPE *t); * } * * ----------------------------------------------------------------------------- */ %define %array_class(TYPE,NAME) %{ typedef TYPE NAME; %} typedef struct {} NAME; %extend NAME { #ifdef __cplusplus NAME(int nelements) { return new TYPE[nelements](); } ~NAME() { delete [] self; } #else NAME(int nelements) { return (TYPE *) calloc(nelements,sizeof(TYPE)); } ~NAME() { free(self); } #endif TYPE getitem(int index) { return self[index]; } void setitem(int index, TYPE value) { self[index] = value; } TYPE * ptr() { return self; } static NAME *frompointer(TYPE *t) { return (NAME *) t; } }; %types(NAME = TYPE); %enddef swig-3.0.8/Lib/d/dswigtype.swg0000664000175000017500000001213412641054563016054 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dswigtype.swg * * Typemaps for non-primitive types (C/C++ classes and structs). * ----------------------------------------------------------------------------- */ %typemap(ctype) SWIGTYPE "void *" %typemap(imtype) SWIGTYPE "void*" %typemap(dtype) SWIGTYPE "$&dclassname" %typemap(ctype) SWIGTYPE [] "void *" %typemap(imtype) SWIGTYPE [] "void*" %typemap(dtype) SWIGTYPE [] "$dclassname" %typemap(ctype) SWIGTYPE * "void *" %typemap(imtype) SWIGTYPE * "void*" %typemap(dtype, nativepointer="$dtype") SWIGTYPE * "$dclassname" %typemap(ctype) SWIGTYPE & "void *" %typemap(imtype) SWIGTYPE & "void*" %typemap(dtype, nativepointer="$dtype") SWIGTYPE & "$dclassname" %typemap(ctype) SWIGTYPE *const& "void *" %typemap(imtype) SWIGTYPE *const& "void*" %typemap(dtype) SWIGTYPE *const& "$*dclassname" %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE *const& "" /* * By-value conversion typemaps (parameter is converted to a pointer). */ %typemap(in, canthrow=1) SWIGTYPE ($&1_type argp) %{ argp = ($&1_ltype)$input; if (!argp) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{ $result = new $1_ltype((const $1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); $result = $1ptr; } #endif %typemap(directorin) SWIGTYPE "$input = (void *)&$1;" %typemap(directorout) SWIGTYPE %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type"); return $null; } $result = *($&1_ltype)$input; %} %typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, false)" %typemap(ddirectorout) SWIGTYPE "$&dclassname.swigGetCPtr($dcall)" %typemap(din) SWIGTYPE "$&dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIGTYPE { $&dclassname ret = new $&dclassname($imcall, true);$excode return ret; } /* * Pointer conversion typemaps. */ %typemap(in) SWIGTYPE * "$1 = ($1_ltype)$input;" %typemap(out) SWIGTYPE * "$result = (void *)$1;" %typemap(directorin) SWIGTYPE * "$input = (void *) $1;" %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE * "$result = ($1_ltype)$input;" %typemap(ddirectorin, nativepointer="cast($dtype)$winput" ) SWIGTYPE * "($winput is null) ? null : new $dclassname($winput, false)" %typemap(ddirectorout, nativepointer="cast(void*)$dcall" ) SWIGTYPE * "$dclassname.swigGetCPtr($dcall)" %typemap(din, nativepointer="cast(void*)$dinput" ) SWIGTYPE * "$dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE, nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}" ) SWIGTYPE * { void* cPtr = $imcall; $dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode return ret; } // Use the same typemaps for const pointers. %apply SWIGTYPE * { SWIGTYPE *const } /* * Reference conversion typemaps. */ %typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input; if (!$1) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type type is null"); return $null; } %} %typemap(out) SWIGTYPE & "$result = (void *)$1;" %typemap(directorin) SWIGTYPE & "$input = ($1_ltype) &$1;" %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type"); return $null; } $result = ($1_ltype)$input; %} %typemap(ddirectorin, nativepointer="cast($dtype)$winput" ) SWIGTYPE & "new $dclassname($winput, false)" %typemap(ddirectorout, nativepointer="cast(void*)$dcall" ) SWIGTYPE & "$dclassname.swigGetCPtr($dcall)" %typemap(din, nativepointer="cast(void*)$dinput" ) SWIGTYPE & "$dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE, nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE & { $dclassname ret = new $dclassname($imcall, $owner);$excode return ret; } /* * Array conversion typemaps. */ %typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %} %typemap(out) SWIGTYPE [] %{ $result = $1; %} %typemap(din) SWIGTYPE [] "$dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIGTYPE [] { void* cPtr = $imcall; $dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode return ret; } // Treat references to arrays like like references to a single element. %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } /* * Pointer reference conversion typemaps. */ %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)$input; $1 = ($1_ltype)&temp; %} %typemap(out) SWIGTYPE *const& %{ $result = (void *)*$1; %} %typemap(din) SWIGTYPE *const& "$*dclassname.swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIGTYPE *const& { void* cPtr = $imcall; $*dclassname ret = (cPtr is null) ? null : new $*dclassname(cPtr, $owner);$excode return ret; } swig-3.0.8/Lib/d/dexception.swg0000664000175000017500000000222612641054563016200 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dexception.swg * * Typemaps used for propagating C++ exceptions to D. * ----------------------------------------------------------------------------- */ // Code which is inserted into the dout typemaps and class constructors via // excode if exceptions can be thrown. %define SWIGEXCODE "\n if ($imdmodule.SwigPendingException.isPending) throw $imdmodule.SwigPendingException.retrieve();" %enddef %typemap(throws, canthrow=1) int, long, short, unsigned int, unsigned long, unsigned short %{ char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); SWIG_DSetPendingException(SWIG_DException, error_msg); return $null; %} %typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY], enum SWIGTYPE, const enum SWIGTYPE & %{ (void)$1; SWIG_DSetPendingException(SWIG_DException, "C++ $1_type exception thrown"); return $null; %} %typemap(throws, canthrow=1) char * %{ SWIG_DSetPendingException(SWIG_DException, $1); return $null; %} swig-3.0.8/Lib/d/std_deque.i0000664000175000017500000000003412641054563015436 0ustar williamwilliam%include swig-3.0.8/Lib/d/std_common.i0000664000175000017500000000014612641054563015627 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.8/Lib/d/dkw.swg0000664000175000017500000000456512641054563014633 0ustar williamwilliam#ifndef D_DKW_SWG_ #define D_DKW_SWG_ /* Warnings for D keywords */ #define DKEYWORD(x) %keywordwarn("'" `x` "' is a D keyword, renaming to '_" `x` "'",rename="_%s") `x` // Source: http://www.digitalmars.com/d/{1.0,2.0}/lex.html and DKEYWORD(Error); DKEYWORD(Exception); DKEYWORD(Object); DKEYWORD(__FILE__); DKEYWORD(__LINE__); DKEYWORD(__gshared); DKEYWORD(__thread); DKEYWORD(__traits); DKEYWORD(abstract); DKEYWORD(alias); DKEYWORD(align); DKEYWORD(asm); DKEYWORD(assert); DKEYWORD(auto); DKEYWORD(body); DKEYWORD(bool); DKEYWORD(break); DKEYWORD(byte); DKEYWORD(case); DKEYWORD(cast); DKEYWORD(catch); DKEYWORD(cdouble); DKEYWORD(cent); DKEYWORD(cfloat); DKEYWORD(char); DKEYWORD(class); DKEYWORD(const); DKEYWORD(continue); DKEYWORD(creal); DKEYWORD(dchar); DKEYWORD(debug); DKEYWORD(default); DKEYWORD(delegate); DKEYWORD(delete); DKEYWORD(deprecated); DKEYWORD(do); DKEYWORD(double); DKEYWORD(dstring); DKEYWORD(else); DKEYWORD(enum); DKEYWORD(export); DKEYWORD(extern); DKEYWORD(false); DKEYWORD(final); DKEYWORD(finally); DKEYWORD(float); DKEYWORD(for); DKEYWORD(foreach); DKEYWORD(foreach_reverse); DKEYWORD(function); DKEYWORD(goto); DKEYWORD(idouble); DKEYWORD(if); DKEYWORD(ifloat); DKEYWORD(immutable); DKEYWORD(import); DKEYWORD(in); DKEYWORD(inout); DKEYWORD(int); DKEYWORD(interface); DKEYWORD(invariant); DKEYWORD(ireal); DKEYWORD(is); DKEYWORD(lazy); DKEYWORD(long); DKEYWORD(macro); DKEYWORD(mixin); DKEYWORD(module); DKEYWORD(new); DKEYWORD(nothrow); DKEYWORD(null); DKEYWORD(out); DKEYWORD(override); DKEYWORD(package); DKEYWORD(pragma); DKEYWORD(private); DKEYWORD(protected); DKEYWORD(public); DKEYWORD(pure); DKEYWORD(real); DKEYWORD(ref); DKEYWORD(return); DKEYWORD(scope); DKEYWORD(shared); DKEYWORD(short); DKEYWORD(static); DKEYWORD(string); DKEYWORD(struct); DKEYWORD(super); DKEYWORD(switch); DKEYWORD(synchronized); DKEYWORD(template); DKEYWORD(this); DKEYWORD(throw); DKEYWORD(true); DKEYWORD(try); DKEYWORD(typedef); DKEYWORD(typeid); DKEYWORD(typeof); DKEYWORD(ubyte); DKEYWORD(ucent); DKEYWORD(uint); DKEYWORD(ulong); DKEYWORD(union); DKEYWORD(unittest); DKEYWORD(ushort); DKEYWORD(version); DKEYWORD(void); DKEYWORD(volatile); DKEYWORD(wchar); DKEYWORD(while); DKEYWORD(with); DKEYWORD(wstring); // Not really a keyword, but dispose() methods are generated in proxy classes // and it's a special method name for D1/Tango. DKEYWORD(dispose); #undef DKEYWORD #endif //D_DKW_SWG_ swig-3.0.8/Lib/d/ddirectives.swg0000664000175000017500000000072212641054563016342 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ddirectives.swg * * D-specifiv directives. * ----------------------------------------------------------------------------- */ #define %dmanifestconst %feature("d:manifestconst") #define %dconstvalue(value) %feature("d:constvalue",value) #define %dmethodmodifiers %feature("d:methodmodifiers") #define %dnothrowexception %feature("except") swig-3.0.8/Lib/d/std_map.i0000664000175000017500000000332112641054563015112 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; } swig-3.0.8/Lib/d/denums.swg0000664000175000017500000000362112641054563015331 0ustar williamwilliam/* ----------------------------------------------------------------------------- * denums.swg * * Typemaps for enumerations. * ----------------------------------------------------------------------------- */ /* * Typemaps for enumeration types. */ %typemap(ctype) enum SWIGTYPE "int" %typemap(imtype) enum SWIGTYPE "int" %typemap(dtype, cprimitive="1") enum SWIGTYPE "$dclassname" %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE "$input = (int)$1;" %typemap(ddirectorin) enum SWIGTYPE "cast($dclassname)$winput" %typemap(ddirectorout) enum SWIGTYPE "cast(int)$dcall" %typemap(din) enum SWIGTYPE "cast(int)$dinput" %typemap(dout, excode=SWIGEXCODE) enum SWIGTYPE { $dclassname ret = cast($dclassname)$imcall;$excode return ret; } /* * Typemaps for (const) references to enumeration types. */ %typemap(ctype) const enum SWIGTYPE & "int" %typemap(imtype) const enum SWIGTYPE & "int" %typemap(dtype) const enum SWIGTYPE & "$*dclassname" %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(ddirectorin) const enum SWIGTYPE & "cast($*dclassname)$winput" %typemap(ddirectorout) const enum SWIGTYPE & "cast(int)$dcall" %typemap(din) const enum SWIGTYPE & "cast(int)$dinput" %typemap(dout, excode=SWIGEXCODE) const enum SWIGTYPE & { $*dclassname ret = cast($*dclassname)$imcall;$excode return ret; } swig-3.0.8/Lib/d/dclassgen.swg0000664000175000017500000000704312641054563016003 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dclassgen.swg * * Typemaps containing D code used when generating D proxy classes. * ----------------------------------------------------------------------------- */ %typemap(dbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(dclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "class" %typemap(dcode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(dimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(dinterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(dinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" // See . %typemap(dclassmodifiers) enum SWIGTYPE "enum" %typemap(dcode) enum SWIGTYPE "" /* * Proxy classes. */ %typemap(dconstructor, excode=SWIGEXCODE,directorconnect="\n swigDirectorConnect();") SWIGTYPE { this($imcall, true);$excode$directorconnect } %typemap(ddestructor) SWIGTYPE %{ ~this() { dispose(); } %} // We do not use »override« attribute for generated dispose() methods to stay // somewhat compatible to Phobos and older Tango versions where Object.dispose() // does not exist. %typemap(ddispose, methodname="dispose", methodmodifiers="public") SWIGTYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = null; } } } %typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") SWIGTYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = null; super.dispose(); } } } // Unfortunately, the »package« visibility attribute does not work in D when the // module in question is in the root package (happens if no -package is specified // at the SWIG command line), so we are stuck with public visibility for // swigGetCPtr(). %typemap(dbody) SWIGTYPE %{ private void* swigCPtr; protected bool swigCMemOwn; public this(void* cObject, bool ownCObject) { swigCPtr = cObject; swigCMemOwn = ownCObject; } public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } mixin $imdmodule.SwigOperatorDefinitions; %} %typemap(dbody_derived) SWIGTYPE %{ private void* swigCPtr; public this(void* cObject, bool ownCObject) { super($imdmodule.$dclazznameUpcast(cObject), ownCObject); swigCPtr = cObject; } public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } mixin $imdmodule.SwigOperatorDefinitions; %} /* * Type wrapper classes. */ %typemap(dbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ private void* swigCPtr; public this(void* cObject, bool futureUse) { swigCPtr = cObject; } protected this() { swigCPtr = null; } public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } mixin $imdmodule.SwigOperatorDefinitions; %} /* * Member function pointer wrapper classes (see ). */ %typemap(dbody) SWIGTYPE (CLASS::*) %{ private char* swigCPtr; public this(char* cMemberPtr, bool futureUse) { swigCPtr = cMemberPtr; } protected this() { swigCPtr = null; } package static char* swigGetCMemberPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } mixin $imdmodule.SwigOperatorDefinitions; %} swig-3.0.8/Lib/d/dhead.swg0000664000175000017500000002064012641054563015103 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dhead.swg * * Support code for exceptions if the SWIG_D_NO_EXCEPTION_HELPER is not defined * Support code for strings if the SWIG_D_NO_STRING_HELPER is not defined * * Support code for function pointers. ----------------------------------------------------------------------------- */ %insert(runtime) %{ #include #include #include /* Contract support. */ #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_DSetPendingException(SWIG_DException, msg); return nullreturn; } else %} /* * Exception support code. */ #if !defined(SWIG_D_NO_EXCEPTION_HELPER) %insert(runtime) %{ // Support for throwing D exceptions from C/C++. typedef enum { SWIG_DException = 0, SWIG_DIllegalArgumentException, SWIG_DIllegalElementException, SWIG_DIOException, SWIG_DNoSuchElementException } SWIG_DExceptionCodes; typedef void (* SWIG_DExceptionCallback_t)(const char *); typedef struct { SWIG_DExceptionCodes code; SWIG_DExceptionCallback_t callback; } SWIG_DException_t; static SWIG_DException_t SWIG_d_exceptions[] = { { SWIG_DException, NULL }, { SWIG_DIllegalArgumentException, NULL }, { SWIG_DIllegalElementException, NULL }, { SWIG_DIOException, NULL }, { SWIG_DNoSuchElementException, NULL } }; static void SWIGUNUSED SWIG_DSetPendingException(SWIG_DExceptionCodes code, const char *msg) { if ((size_t)code < sizeof(SWIG_d_exceptions)/sizeof(SWIG_DException_t)) { SWIG_d_exceptions[code].callback(msg); } else { SWIG_d_exceptions[SWIG_DException].callback(msg); } } #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGRegisterExceptionCallbacks_$module( SWIG_DExceptionCallback_t exceptionCallback, SWIG_DExceptionCallback_t illegalArgumentCallback, SWIG_DExceptionCallback_t illegalElementCallback, SWIG_DExceptionCallback_t ioCallback, SWIG_DExceptionCallback_t noSuchElementCallback) { SWIG_d_exceptions[SWIG_DException].callback = exceptionCallback; SWIG_d_exceptions[SWIG_DIllegalArgumentException].callback = illegalArgumentCallback; SWIG_d_exceptions[SWIG_DIllegalElementException].callback = illegalElementCallback; SWIG_d_exceptions[SWIG_DIOException].callback = ioCallback; SWIG_d_exceptions[SWIG_DNoSuchElementException].callback = noSuchElementCallback; } %} #if (SWIG_D_VERSION == 1) %pragma(d) imdmoduleimports=%{ // Exception throwing support currently requires Tango, but there is no reason // why it could not support Phobos. static import tango.core.Exception; static import tango.core.Thread; static import tango.stdc.stringz; %} %pragma(d) imdmodulecode=%{ private class SwigExceptionHelper { static this() { swigRegisterExceptionCallbacks$module( &setException, &setIllegalArgumentException, &setIllegalElementException, &setIOException, &setNoSuchElementException); } static void setException(char* message) { auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup); SwigPendingException.set(exception); } static void setIllegalArgumentException(char* message) { auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup); SwigPendingException.set(exception); } static void setIllegalElementException(char* message) { auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup); SwigPendingException.set(exception); } static void setIOException(char* message) { auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup); SwigPendingException.set(exception); } static void setNoSuchElementException(char* message) { auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup); SwigPendingException.set(exception); } } package class SwigPendingException { public: static this() { m_sPendingException = new ThreadLocalData(null); } static bool isPending() { return m_sPendingException.val !is null; } static void set(object.Exception e) { auto pending = m_sPendingException.val; if (pending !is null) { e.next = pending; throw new object.Exception("FATAL: An earlier pending exception from C/C++ " ~ "code was missed and thus not thrown (" ~ pending.classinfo.name ~ ": " ~ pending.msg ~ ")!", e); } m_sPendingException.val = e; } static object.Exception retrieve() { auto e = m_sPendingException.val; m_sPendingException.val = null; return e; } private: // The reference to the pending exception (if any) is stored thread-local. alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData; static ThreadLocalData m_sPendingException; } alias void function(char* message) SwigExceptionCallback; %} #else %pragma(d) imdmoduleimports=%{ static import std.conv; %} %pragma(d) imdmodulecode=%{ private class SwigExceptionHelper { static this() { // The D1/Tango version maps C++ exceptions to multiple exception types. swigRegisterExceptionCallbacks$module( &setException, &setException, &setException, &setException, &setException ); } static void setException(const char* message) { auto exception = new object.Exception(std.conv.to!string(message)); SwigPendingException.set(exception); } } package struct SwigPendingException { public: static this() { m_sPendingException = null; } static bool isPending() { return m_sPendingException !is null; } static void set(object.Exception e) { if (m_sPendingException !is null) { e.next = m_sPendingException; throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~ "was missed and thus not thrown (" ~ m_sPendingException.classinfo.name ~ ": " ~ m_sPendingException.msg ~ ")!", e); } m_sPendingException = e; } static object.Exception retrieve() { auto e = m_sPendingException; m_sPendingException = null; return e; } private: // The reference to the pending exception (if any) is stored thread-local. static object.Exception m_sPendingException; } alias void function(const char* message) SwigExceptionCallback; %} #endif // Callback registering function in wrapperloader.swg. #endif // SWIG_D_NO_EXCEPTION_HELPER /* * String support code. */ #if !defined(SWIG_D_NO_STRING_HELPER) %insert(runtime) %{ // Callback for returning strings to D without leaking memory. typedef char * (* SWIG_DStringHelperCallback)(const char *); static SWIG_DStringHelperCallback SWIG_d_string_callback = NULL; #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIGRegisterStringCallback_$module(SWIG_DStringHelperCallback callback) { SWIG_d_string_callback = callback; } %} #if (SWIG_D_VERSION == 1) %pragma(d) imdmoduleimports = "static import tango.stdc.stringz;"; %pragma(d) imdmodulecode = %{ private class SwigStringHelper { static this() { swigRegisterStringCallback$module(&createString); } static char* createString(char* cString) { // We are effectively dup'ing the string here. return tango.stdc.stringz.toStringz(tango.stdc.stringz.fromStringz(cString)); } } alias char* function(char* cString) SwigStringCallback; %} #else %pragma(d) imdmoduleimports = %{ static import std.conv; static import std.string; %} %pragma(d) imdmodulecode = %{ private class SwigStringHelper { static this() { swigRegisterStringCallback$module(&createString); } static const(char)* createString(const(char*) cString) { // We are effectively dup'ing the string here. // TODO: Is this also correct for D2/Phobos? return std.string.toStringz(std.conv.to!string(cString)); } } alias const(char)* function(const(char*) cString) SwigStringCallback; %} #endif // Callback registering function in wrapperloader.swg. #endif // SWIG_D_NO_STRING_HELPER /* * Function pointer support code. */ #if (SWIG_D_VERSION == 1) %pragma(d) imdmodulecode = %{ template SwigExternC(T) { static if (is(typeof(*(T.init)) R == return)) { static if (is(typeof(*(T.init)) P == function)) { alias extern(C) R function(P) SwigExternC; } } } %} #else %pragma(d) imdmodulecode = %{ template SwigExternC(T) if (is(typeof(*(T.init)) P == function)) { static if (is(typeof(*(T.init)) R == return)) { static if (is(typeof(*(T.init)) P == function)) { alias extern(C) R function(P) SwigExternC; } } } %} #endif swig-3.0.8/Lib/d/std_string.i0000664000175000017500000000604512641054563015651 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * Typemaps for std::string and const std::string& * These are mapped to a D char[] and are passed around by value. * * To use non-const std::string references, use the following %apply. Note * that they are passed by value. * %apply const std::string & {std::string &}; * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; class string; %define SWIGD_STD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ) // string %typemap(ctype) string, const string & "char *" %typemap(imtype) string, const string & #DW_STRING_TYPE %typemap(dtype) string, const string & #DP_STRING_TYPE %typemap(in, canthrow=1) string, const string & %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string"); return $null; } $1.assign($input); %} %typemap(in, canthrow=1) const string & %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string"); return $null; } $*1_ltype $1_str($input); $1 = &$1_str; %} %typemap(out) string %{ $result = SWIG_d_string_callback($1.c_str()); %} %typemap(out) const string & %{ $result = SWIG_d_string_callback($1->c_str()); %} %typemap(din) string, const string & "($dinput ? TO_STRINGZ($dinput) : null)" %typemap(dout, excode=SWIGEXCODE) string, const string & { DP_STRING_TYPE ret = FROM_STRINGZ($imcall);$excode return ret; } %typemap(directorin) string, const string & %{ $input = SWIG_d_string_callback($1.c_str()); %} %typemap(directorout, canthrow=1) string %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string"); return $null; } $result.assign($input); %} %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & %{ if (!$input) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string"); return $null; } /* possible thread/reentrant code problem */ static $*1_ltype $1_str; $1_str = $input; $result = &$1_str; %} %typemap(ddirectorin) string, const string & "FROM_STRINGZ($winput)" %typemap(ddirectorout) string, const string & "TO_STRINGZ($dcall)" %typemap(throws, canthrow=1) string, const string & %{ SWIG_DSetPendingException(SWIG_DException, $1.c_str()); return $null; %} %typemap(typecheck) string, const string & = char *; %enddef // We need to have the \0-terminated string conversion functions available in // the D proxy modules. #if (SWIG_D_VERSION == 1) // Could be easily extended to support Phobos as well. SWIGD_STD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz) %pragma(d) globalproxyimports = "static import tango.stdc.stringz;"; #else SWIGD_STD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz) %pragma(d) globalproxyimports = %{ static import std.conv; static import std.string; %} #endif #undef SWIGD_STD_STRING_TYPEMAPS } // namespace std swig-3.0.8/Lib/d/stl.i0000664000175000017500000000054512641054563014272 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/d/boost_shared_ptr.i0000664000175000017500000002004012641054563017021 0ustar williamwilliam%include %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ((*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\"))) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // plain value %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0; if (!argp) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ $result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in, canthrow=1) CONST TYPE & %{ $1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); if (!$1) { SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = (TYPE *)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ if ($input) $1 = *($&1_ltype)$input; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ $result = $1 ? new $1_ltype($1) : 0; %} // shared_ptr by reference %typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ $result = *$1 ? new $*1_ltype(*$1) : 0; %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out, fragment="SWIG_null_deleter") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ $result = ($1 && *$1) ? new $*1_ltype(*($1_ltype)$1) : 0; if ($owner) delete $1; %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0) %{ temp = $input ? *($1_ltype)&$input : &tempnull; $1 = &temp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void *" %typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void*" %typemap (dtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(dtype, TYPE)" %typemap(din) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(dtype, TYPE).swigGetCPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) CONST TYPE { auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) CONST TYPE & { auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) CONST TYPE * { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } %typemap(dout, excode=SWIGEXCODE) TYPE *CONST& { void* cPtr = $imcall; auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode return ret; } // For shared pointers, both the derived and the base class have to »own« their // pointer; otherwise the reference count is not decreased properly on destruction. %typemap(dbody) SWIGTYPE %{ private void* swigCPtr; private bool swigCMemOwn; public this(void* cObject, bool ownCObject) { swigCPtr = cObject; swigCMemOwn = ownCObject; } public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } %} %typemap(dbody_derived) SWIGTYPE %{ private void* swigCPtr; private bool swigCMemOwn; public this(void* cObject, bool ownCObject) { super($imdmodule.$dclazznameSmartPtrUpcast(cObject), ownCObject); swigCPtr = cObject; swigCMemOwn = ownCObject; } public static void* swigGetCPtr(typeof(this) obj) { return (obj is null) ? null : obj.swigCPtr; } %} %typemap(ddispose, methodname="dispose", methodmodifiers="public") TYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = null; } } } %typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") TYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = null; super.dispose(); } } } %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/d/d.swg0000664000175000017500000000250512641054563014261 0ustar williamwilliam/* ----------------------------------------------------------------------------- * d.swg * * Main library file for the D language module. See the D chapter in the SWIG * manual for explanation on the typemaps, pragmas, etc. used. * ----------------------------------------------------------------------------- */ // Typemaps for exception handling. %include // Typemaps for primitive types. %include // Typemaps for non-primitive types (C/C++ classes and structs). %include // Typemaps for enumeration types. %include // Typemaps for member function pointers. %include // Typemaps for wrapping pointers to/arrays of C chars as D strings. %include // Typemaps for handling void function return types and empty parameter lists. %include // Typemaps containing D code used when generating D proxy classes. %include // Mapping of C++ operator overloading methods to D. %include // Helper code string and exception handling. %include // Wrapper loader code for dynamically linking the C wrapper library from the D // wrapper module. %include // List of all reserved D keywords. %include // D-specific directives. %include swig-3.0.8/Lib/d/director.swg0000664000175000017500000000223212641054563015646 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that D proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #if defined(DEBUG_DIRECTOR_OWNED) #include #endif #include #include namespace Swig { // Director base class – not used in D directors. class Director { }; // Base class for director exceptions. class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(const std::string &msg) : swig_msg(msg) { } virtual ~DirectorException() throw() { } const char *what() const throw() { return swig_msg.c_str(); } }; // Exception which is thrown when attempting to call a pure virtual method // from D code through the director layer. class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) { } }; } swig-3.0.8/Lib/d/std_shared_ptr.i0000664000175000017500000000010412641054563016464 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.8/Lib/d/typemaps.i0000664000175000017500000002547712641054563015345 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* INPUT typemaps -------------- These typemaps are used for pointer/reference parameters that are input only and are mapped to a D input parameter. The following typemaps can be applied to turn a pointer or reference into a simple input value. That is, instead of passing a pointer or reference to an object, you would use a real value instead. bool *INPUT, bool &INPUT signed char *INPUT, signed char &INPUT unsigned char *INPUT, unsigned char &INPUT short *INPUT, short &INPUT unsigned short *INPUT, unsigned short &INPUT int *INPUT, int &INPUT unsigned int *INPUT, unsigned int &INPUT long *INPUT, long &INPUT unsigned long *INPUT, unsigned long &INPUT long long *INPUT, long long &INPUT unsigned long long *INPUT, unsigned long long &INPUT float *INPUT, float &INPUT double *INPUT, double &INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); In D you could then use it like this: double answer = fadd(10.0, 20.0); */ %define INPUT_TYPEMAP(TYPE, CTYPE, DTYPE) %typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE" %typemap(imtype, out="void*") TYPE *INPUT, TYPE &INPUT "DTYPE" %typemap(dtype, out="DTYPE*") TYPE *INPUT, TYPE &INPUT "DTYPE" %typemap(din) TYPE *INPUT, TYPE &INPUT "$dinput" %typemap(in) TYPE *INPUT, TYPE &INPUT %{ $1 = ($1_ltype)&$input; %} %typemap(typecheck) TYPE *INPUT = TYPE; %typemap(typecheck) TYPE &INPUT = TYPE; %enddef INPUT_TYPEMAP(bool, unsigned int, bool) //INPUT_TYPEMAP(char, char, char) // Why was this commented out? INPUT_TYPEMAP(signed char, signed char, byte) INPUT_TYPEMAP(unsigned char, unsigned char, ubyte) INPUT_TYPEMAP(short, short, short) INPUT_TYPEMAP(unsigned short, unsigned short, ushort) INPUT_TYPEMAP(int, int, int) INPUT_TYPEMAP(unsigned int, unsigned int, uint) INPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE) INPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE) INPUT_TYPEMAP(long long, long long, long) INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong) INPUT_TYPEMAP(float, float, float) INPUT_TYPEMAP(double, double, double) INPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int) %typemap(dtype) enum SWIGTYPE *INPUT, enum SWIGTYPE &INPUT "$*dclassname" #undef INPUT_TYPEMAP /* OUTPUT typemaps --------------- These typemaps are used for pointer/reference parameters that are output only and are mapped to a D output parameter. The following typemaps can be applied to turn a pointer or reference into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In D, the 'out' keyword is used when passing the parameter to a function that takes an output parameter. bool *OUTPUT, bool &OUTPUT signed char *OUTPUT, signed char &OUTPUT unsigned char *OUTPUT, unsigned char &OUTPUT short *OUTPUT, short &OUTPUT unsigned short *OUTPUT, unsigned short &OUTPUT int *OUTPUT, int &OUTPUT unsigned int *OUTPUT, unsigned int &OUTPUT long *OUTPUT, long &OUTPUT unsigned long *OUTPUT, unsigned long &OUTPUT long long *OUTPUT, long long &OUTPUT unsigned long long *OUTPUT, unsigned long long &OUTPUT float *OUTPUT, float &OUTPUT double *OUTPUT, double &OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters): double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The D output of the function would be the function return value and the value returned in the second output parameter. In D you would use it like this: double dptr; double fraction = modf(5, dptr); */ %define OUTPUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE) %typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *" %typemap(imtype, out="void*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE" %typemap(dtype, out="DTYPE*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE" %typemap(din) TYPE *OUTPUT, TYPE &OUTPUT "$dinput" %typemap(in) TYPE *OUTPUT, TYPE &OUTPUT %{ $1 = ($1_ltype)$input; %} %typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT "" %enddef OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) //OUTPUT_TYPEMAP(char, char, char, CHAR_PTR) // Why was this commented out? OUTPUT_TYPEMAP(signed char, signed char, byte, INT8_PTR) OUTPUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR) OUTPUT_TYPEMAP(short, short, short, INT16_PTR) OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) OUTPUT_TYPEMAP(int, int, int, INT32_PTR) OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) OUTPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR) OUTPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR) OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR) OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR) OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR) OUTPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR) %typemap(dtype) enum SWIGTYPE *OUTPUT, enum SWIGTYPE &OUTPUT "out $*dclassname" #undef OUTPUT_TYPEMAP %typemap(in) bool *OUTPUT, bool &OUTPUT %{ *$input = 0; $1 = ($1_ltype)$input; %} /* INOUT typemaps -------------- These typemaps are for pointer/reference parameters that are both input and output and are mapped to a D reference parameter. The following typemaps can be applied to turn a pointer or reference into a reference parameters, that is the parameter is both an input and an output. In D, the 'ref' keyword is used for reference parameters. bool *INOUT, bool &INOUT signed char *INOUT, signed char &INOUT unsigned char *INOUT, unsigned char &INOUT short *INOUT, short &INOUT unsigned short *INOUT, unsigned short &INOUT int *INOUT, int &INOUT unsigned int *INOUT, unsigned int &INOUT long *INOUT, long &INOUT unsigned long *INOUT, unsigned long &INOUT long long *INOUT, long long &INOUT unsigned long long *INOUT, unsigned long long &INOUT float *INOUT, float &INOUT double *INOUT, double &INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); The D output of the function would be the new value returned by the reference parameter. In D you would use it like this: double x = 5.0; neg(x); The implementation of the OUTPUT and INOUT typemaps is different to the scripting languages in that the scripting languages will return the output value as part of the function return value. */ %define INOUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE) %typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *" %typemap(imtype, out="void*") TYPE *INOUT, TYPE &INOUT "ref DTYPE" %typemap(dtype, out="DTYPE*") TYPE *INOUT, TYPE &INOUT "ref DTYPE" %typemap(din) TYPE *INOUT, TYPE &INOUT "$dinput" %typemap(in) TYPE *INOUT, TYPE &INOUT %{ $1 = ($1_ltype)$input; %} %typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT "" %enddef INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) //INOUT_TYPEMAP(char, char, char, CHAR_PTR) INOUT_TYPEMAP(signed char, signed char, byte, INT8_PTR) INOUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR) INOUT_TYPEMAP(short, short, short, INT16_PTR) INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) INOUT_TYPEMAP(int, int, int, INT32_PTR) INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) INOUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR) INOUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR) INOUT_TYPEMAP(long long, long long, long, INT64_PTR) INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) INOUT_TYPEMAP(float, float, float, FLOAT_PTR) INOUT_TYPEMAP(double, double, double, DOUBLE_PTR) INOUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR) %typemap(dtype) enum SWIGTYPE *INOUT, enum SWIGTYPE &INOUT "ref $*dclassname" #undef INOUT_TYPEMAP swig-3.0.8/Lib/d/std_vector.i0000664000175000017500000004010312641054563015636 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector, D implementation. * * The D wrapper is made to loosely resemble a tango.util.container.more.Vector * and to provide built-in array-like access. * * If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED * macro to obtain enhanced functionality (none yet), for example: * * SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass) * %template(VectKlass) std::vector; * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on * the real file contents! * ----------------------------------------------------------------------------- */ // Warning: Use the typemaps here in the expectation that the macros they are in will change name. %include // MACRO for use within the std::vector class body %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE, CTYPE...) #if (SWIG_D_VERSION == 1) %typemap(dimports) std::vector< CTYPE > "static import tango.core.Exception;" %typemap(dcode) std::vector< CTYPE > %{ public this($typemap(dtype, CTYPE)[] values) { this(); append(values); } alias push_back add; alias push_back push; alias push_back opCatAssign; alias size length; alias opSlice slice; public $typemap(dtype, CTYPE) opIndexAssign($typemap(dtype, CTYPE) value, size_t index) { if (index >= size()) { throw new tango.core.Exception.NoSuchElementException("Tried to assign to element out of vector bounds."); } setElement(index, value); return value; } public $typemap(dtype, CTYPE) opIndex(size_t index) { if (index >= size()) { throw new tango.core.Exception.NoSuchElementException("Tried to read from element out of vector bounds."); } return getElement(index); } public void append($typemap(dtype, CTYPE)[] value...) { foreach (v; value) { add(v); } } public $typemap(dtype, CTYPE)[] opSlice() { $typemap(dtype, CTYPE)[] array = new $typemap(dtype, CTYPE)[size()]; foreach (i, ref value; array) { value = getElement(i); } return array; } public int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) { int result; size_t currentSize = size(); for (size_t i = 0; i < currentSize; ++i) { auto value = getElement(i); result = dg(value); setElement(i, value); } return result; } public int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) { int result; size_t currentSize = size(); for (size_t i = 0; i < currentSize; ++i) { auto value = getElement(i); // Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443. auto index = i; result = dg(index, value); setElement(i, value); } return result; } public void capacity(size_t value) { if (value < size()) { throw new tango.core.Exception.IllegalArgumentException("Tried to make the capacity of a vector smaller than its size."); } reserve(value); } %} public: typedef size_t size_type; typedef CTYPE value_type; typedef CONST_REFERENCE const_reference; void clear(); void push_back(CTYPE const& x); size_type size() const; size_type capacity() const; void reserve(size_type n) throw (std::length_error); vector(); vector(const vector &other); %extend { vector(size_type capacity) throw (std::length_error) { std::vector< CTYPE >* pv = 0; pv = new std::vector< CTYPE >(); // Might throw std::length_error. pv->reserve(capacity); return pv; } size_type unused() const { return $self->capacity() - $self->size(); } CONST_REFERENCE remove() throw (std::out_of_range) { if ($self->empty()) { throw std::out_of_range("Tried to remove last element from empty vector."); } std::vector< CTYPE >::const_reference value = $self->back(); $self->pop_back(); return value; } CONST_REFERENCE remove(size_type index) throw (std::out_of_range) { if (index >= $self->size()) { throw std::out_of_range("Tried to remove element with invalid index."); } std::vector< CTYPE >::iterator it = $self->begin() + index; std::vector< CTYPE >::const_reference value = *it; $self->erase(it); return value; } } // Wrappers for setting/getting items with the possibly thrown exception // specified (important for SWIG wrapper generation). %extend { CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to get value of element with invalid index."); } return (*$self)[index]; } } // Use CTYPE const& instead of const_reference to work around SWIG code // generation issue when using const pointers as vector elements (like // std::vector< const int* >). %extend { void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to set value of element with invalid index."); } (*$self)[index] = val; } } %dmethodmodifiers std::vector::getElement "private" %dmethodmodifiers std::vector::setElement "private" %dmethodmodifiers std::vector::reserve "private" #else %typemap(dimports) std::vector< CTYPE > %{ static import std.algorithm; static import std.exception; static import std.range; static import std.traits; %} %typemap(dcode) std::vector< CTYPE > %{ alias size_t KeyType; alias $typemap(dtype, CTYPE) ValueType; this(ValueType[] values...) { this(); reserve(values.length); foreach (e; values) { this ~= e; } } struct Range { private $typemap(dtype, std::vector< CTYPE >) _outer; private size_t _a, _b; this($typemap(dtype, std::vector< CTYPE >) data, size_t a, size_t b) { _outer = data; _a = a; _b = b; } @property bool empty() const { assert((cast($typemap(dtype, std::vector< CTYPE >))_outer).length >= _b); return _a >= _b; } @property Range save() { return this; } @property ValueType front() { std.exception.enforce(!empty); return _outer[_a]; } @property void front(ValueType value) { std.exception.enforce(!empty); _outer[_a] = std.algorithm.move(value); } void popFront() { std.exception.enforce(!empty); ++_a; } void opIndexAssign(ValueType value, size_t i) { i += _a; std.exception.enforce(i < _b && _b <= _outer.length); _outer[i] = value; } void opIndexOpAssign(string op)(ValueType value, size_t i) { std.exception.enforce(_outer && _a + i < _b && _b <= _outer.length); auto element = _outer[i]; mixin("element "~op~"= value;"); _outer[i] = element; } } // TODO: dup? Range opSlice() { return Range(this, 0, length); } Range opSlice(size_t a, size_t b) { std.exception.enforce(a <= b && b <= length); return Range(this, a, b); } size_t opDollar() const { return length; } @property ValueType front() { std.exception.enforce(!empty); return getElement(0); } @property void front(ValueType value) { std.exception.enforce(!empty); setElement(0, value); } @property ValueType back() { std.exception.enforce(!empty); return getElement(length - 1); } @property void back(ValueType value) { std.exception.enforce(!empty); setElement(length - 1, value); } ValueType opIndex(size_t i) { return getElement(i); } void opIndexAssign(ValueType value, size_t i) { setElement(i, value); } void opIndexOpAssign(string op)(ValueType value, size_t i) { auto element = this[i]; mixin("element "~op~"= value;"); this[i] = element; } ValueType[] opBinary(string op, Stuff)(Stuff stuff) if (op == "~") { ValueType[] result; result ~= this[]; assert(result.length == length); result ~= stuff[]; return result; } void opOpAssign(string op, Stuff)(Stuff stuff) if (op == "~") { static if (is(typeof(insertBack(stuff)))) { insertBack(stuff); } else if (is(typeof(insertBack(stuff[])))) { insertBack(stuff[]); } else { static assert(false, "Cannot append " ~ Stuff.stringof ~ " to " ~ typeof(this).stringof); } } alias size length; alias remove removeAny; alias removeAny stableRemoveAny; size_t insertBack(Stuff)(Stuff stuff) if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)){ push_back(stuff); return 1; } size_t insertBack(Stuff)(Stuff stuff) if (std.range.isInputRange!Stuff && std.traits.isImplicitlyConvertible!(std.range.ElementType!Stuff, ValueType)) { size_t itemCount; foreach(item; stuff) { insertBack(item); ++itemCount; } return itemCount; } alias insertBack insert; alias pop_back removeBack; alias pop_back stableRemoveBack; size_t insertBefore(Stuff)(Range r, Stuff stuff) if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)) { std.exception.enforce(r._outer.swigCPtr == swigCPtr && r._a < length); insertAt(r._a, stuff); return 1; } size_t insertBefore(Stuff)(Range r, Stuff stuff) if (std.range.isInputRange!Stuff && std.traits.isImplicitlyConvertible!(ElementType!Stuff, ValueType)) { std.exception.enforce(r._outer.swigCPtr == swigCPtr && r._a <= length); size_t insertCount; foreach(i, item; stuff) { insertAt(r._a + i, item); ++insertCount; } return insertCount; } size_t insertAfter(Stuff)(Range r, Stuff stuff) { // TODO: optimize immutable offset = r._a + r.length; std.exception.enforce(offset <= length); auto result = insertBack(stuff); std.algorithm.bringToFront(this[offset .. length - result], this[length - result .. length]); return result; } size_t replace(Stuff)(Range r, Stuff stuff) if (std.range.isInputRange!Stuff && std.traits.isImplicitlyConvertible!(ElementType!Stuff, ValueType)) { immutable offset = r._a; std.exception.enforce(offset <= length); size_t result; for (; !stuff.empty; stuff.popFront()) { if (r.empty) { // append the rest return result + insertBack(stuff); } r.front = stuff.front; r.popFront(); ++result; } // Remove remaining stuff in r remove(r); return result; } size_t replace(Stuff)(Range r, Stuff stuff) if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)) { if (r.empty) { insertBefore(r, stuff); } else { r.front = stuff; r.popFront(); remove(r); } return 1; } Range linearRemove(Range r) { std.exception.enforce(r._a <= r._b && r._b <= length); immutable tailLength = length - r._b; linearRemove(r._a, r._b); return this[length - tailLength .. length]; } alias remove stableLinearRemove; int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) { int result; size_t currentSize = size(); for (size_t i = 0; i < currentSize; ++i) { auto value = getElement(i); result = dg(value); setElement(i, value); } return result; } int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) { int result; size_t currentSize = size(); for (size_t i = 0; i < currentSize; ++i) { auto value = getElement(i); // Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443. auto index = i; result = dg(index, value); setElement(i, value); } return result; } %} public: typedef size_t size_type; typedef CTYPE value_type; typedef CONST_REFERENCE const_reference; bool empty() const; void clear(); void push_back(CTYPE const& x); void pop_back(); size_type size() const; size_type capacity() const; void reserve(size_type n) throw (std::length_error); vector(); vector(const vector &other); %extend { vector(size_type capacity) throw (std::length_error) { std::vector< CTYPE >* pv = 0; pv = new std::vector< CTYPE >(); // Might throw std::length_error. pv->reserve(capacity); return pv; } CONST_REFERENCE remove() throw (std::out_of_range) { if ($self->empty()) { throw std::out_of_range("Tried to remove last element from empty vector."); } std::vector< CTYPE >::const_reference value = $self->back(); $self->pop_back(); return value; } CONST_REFERENCE remove(size_type index) throw (std::out_of_range) { if (index >= $self->size()) { throw std::out_of_range("Tried to remove element with invalid index."); } std::vector< CTYPE >::iterator it = $self->begin() + index; std::vector< CTYPE >::const_reference value = *it; $self->erase(it); return value; } void removeBack(size_type how_many) throw (std::out_of_range) { std::vector< CTYPE >::iterator end = $self->end(); std::vector< CTYPE >::iterator start = end - how_many; $self->erase(start, end); } void linearRemove(size_type start_index, size_type end_index) throw (std::out_of_range) { std::vector< CTYPE >::iterator start = $self->begin() + start_index; std::vector< CTYPE >::iterator end = $self->begin() + end_index; $self->erase(start, end); } void insertAt(size_type index, CTYPE const& x) throw (std::out_of_range) { std::vector< CTYPE >::iterator it = $self->begin() + index; $self->insert(it, x); } } // Wrappers for setting/getting items with the possibly thrown exception // specified (important for SWIG wrapper generation). %extend { CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to get value of element with invalid index."); } return (*$self)[index]; } } // Use CTYPE const& instead of const_reference to work around SWIG code // generation issue when using const pointers as vector elements (like // std::vector< const int* >). %extend { void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to set value of element with invalid index."); } (*$self)[index] = val; } } %dmethodmodifiers std::vector::getElement "private" %dmethodmodifiers std::vector::setElement "private" #endif %enddef // Extra methods added to the collection class if operator== is defined for the class being wrapped // The class will then implement IList<>, which adds extra functionality %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...) %extend { } %enddef // For vararg handling in macros, from swigmacros.swg #define %arg(X...) X // Macros for std::vector class specializations/enhancements %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE)) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } %enddef %{ #include #include %} namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(T const&, T) }; // specializations for pointers template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(T *const&, T *) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *) }; // bool is a bit different in the C++ standard - const_reference in particular template<> class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool) }; } // template specializations for std::vector // these provide extra collections methods as operator== is defined SWIG_STD_VECTOR_ENHANCED(char) SWIG_STD_VECTOR_ENHANCED(signed char) SWIG_STD_VECTOR_ENHANCED(unsigned char) SWIG_STD_VECTOR_ENHANCED(short) SWIG_STD_VECTOR_ENHANCED(unsigned short) SWIG_STD_VECTOR_ENHANCED(int) SWIG_STD_VECTOR_ENHANCED(unsigned int) SWIG_STD_VECTOR_ENHANCED(long) SWIG_STD_VECTOR_ENHANCED(unsigned long) SWIG_STD_VECTOR_ENHANCED(long long) SWIG_STD_VECTOR_ENHANCED(unsigned long long) SWIG_STD_VECTOR_ENHANCED(float) SWIG_STD_VECTOR_ENHANCED(double) SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include swig-3.0.8/Lib/d/wrapperloader.swg0000664000175000017500000001732712641054563016715 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wrapperloader.swg * * Support code for dynamically linking the C wrapper library from the D * wrapper module. * * The loading code was adapted from the Derelict project and is used with * permission from Michael Parker, the original author. * ----------------------------------------------------------------------------- */ %pragma(d) wrapperloadercode = %{ private { version(linux) { version = Nix; } else version(darwin) { version = Nix; } else version(OSX) { version = Nix; } else version(FreeBSD) { version = Nix; version = freebsd; } else version(freebsd) { version = Nix; } else version(Unix) { version = Nix; } else version(Posix) { version = Nix; } version(Tango) { static import tango.stdc.string; static import tango.stdc.stringz; version (PhobosCompatibility) { } else { alias char[] string; alias wchar[] wstring; alias dchar[] dstring; } } else { version(D_Version2) { static import std.conv; } static import std.string; static import std.c.string; } version(D_Version2) { mixin("alias const(char)* CCPTR;"); } else { alias char* CCPTR; } CCPTR swigToCString(string str) { version(Tango) { return tango.stdc.stringz.toStringz(str); } else { return std.string.toStringz(str); } } string swigToDString(CCPTR cstr) { version(Tango) { return tango.stdc.stringz.fromStringz(cstr); } else { version(D_Version2) { mixin("return std.conv.to!string(cstr);"); } else { return std.c.string.toString(cstr); } } } } class SwigSwigSharedLibLoadException : Exception { this(in string[] libNames, in string[] reasons) { string msg = "Failed to load one or more shared libraries:"; foreach(i, n; libNames) { msg ~= "\n\t" ~ n ~ " - "; if(i < reasons.length) msg ~= reasons[i]; else msg ~= "Unknown"; } super(msg); } } class SwigSymbolLoadException : Exception { this(string SwigSharedLibName, string symbolName) { super("Failed to load symbol " ~ symbolName ~ " from shared library " ~ SwigSharedLibName); _symbolName = symbolName; } string symbolName() { return _symbolName; } private: string _symbolName; } private { version(Nix) { version(freebsd) { // the dl* functions are in libc on FreeBSD } else { pragma(lib, "dl"); } version(Tango) { import tango.sys.Common; } else version(linux) { import std.c.linux.linux; } else { extern(C) { const RTLD_NOW = 2; void *dlopen(CCPTR file, int mode); int dlclose(void* handle); void *dlsym(void* handle, CCPTR name); CCPTR dlerror(); } } alias void* SwigSharedLibHandle; SwigSharedLibHandle swigLoadSharedLib(string libName) { return dlopen(swigToCString(libName), RTLD_NOW); } void swigUnloadSharedLib(SwigSharedLibHandle hlib) { dlclose(hlib); } void* swigGetSymbol(SwigSharedLibHandle hlib, string symbolName) { return dlsym(hlib, swigToCString(symbolName)); } string swigGetErrorStr() { CCPTR err = dlerror(); if (err is null) { return "Unknown Error"; } return swigToDString(err); } } else version(Windows) { alias ushort WORD; alias uint DWORD; alias CCPTR LPCSTR; alias void* HMODULE; alias void* HLOCAL; alias int function() FARPROC; struct VA_LIST {} extern (Windows) { HMODULE LoadLibraryA(LPCSTR); FARPROC GetProcAddress(HMODULE, LPCSTR); void FreeLibrary(HMODULE); DWORD GetLastError(); DWORD FormatMessageA(DWORD, in void*, DWORD, DWORD, LPCSTR, DWORD, VA_LIST*); HLOCAL LocalFree(HLOCAL); } DWORD MAKELANGID(WORD p, WORD s) { return (((cast(WORD)s) << 10) | cast(WORD)p); } enum { LANG_NEUTRAL = 0, SUBLANG_DEFAULT = 1, FORMAT_MESSAGE_ALLOCATE_BUFFER = 256, FORMAT_MESSAGE_IGNORE_INSERTS = 512, FORMAT_MESSAGE_FROM_SYSTEM = 4096 } alias HMODULE SwigSharedLibHandle; SwigSharedLibHandle swigLoadSharedLib(string libName) { return LoadLibraryA(swigToCString(libName)); } void swigUnloadSharedLib(SwigSharedLibHandle hlib) { FreeLibrary(hlib); } void* swigGetSymbol(SwigSharedLibHandle hlib, string symbolName) { return GetProcAddress(hlib, swigToCString(symbolName)); } string swigGetErrorStr() { DWORD errcode = GetLastError(); LPCSTR msgBuf; DWORD i = FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, null, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), cast(LPCSTR)&msgBuf, 0, null); string text = swigToDString(msgBuf); LocalFree(cast(HLOCAL)msgBuf); if (i >= 2) { i -= 2; } return text[0 .. i]; } } else { static assert(0, "Operating system not supported by the wrapper loading code."); } final class SwigSharedLib { void load(string[] names) { if (_hlib !is null) return; string[] failedLibs; string[] reasons; foreach(n; names) { _hlib = swigLoadSharedLib(n); if (_hlib is null) { failedLibs ~= n; reasons ~= swigGetErrorStr(); continue; } _name = n; break; } if (_hlib is null) { throw new SwigSwigSharedLibLoadException(failedLibs, reasons); } } void* loadSymbol(string symbolName, bool doThrow = true) { void* sym = swigGetSymbol(_hlib, symbolName); if(doThrow && (sym is null)) { throw new SwigSymbolLoadException(_name, symbolName); } return sym; } void unload() { if(_hlib !is null) { swigUnloadSharedLib(_hlib); _hlib = null; } } private: string _name; SwigSharedLibHandle _hlib; } } static this() { string[] possibleFileNames; version (Posix) { version (OSX) { possibleFileNames ~= ["lib$wraplibrary.dylib", "lib$wraplibrary.bundle"]; } possibleFileNames ~= ["lib$wraplibrary.so"]; } else version (Windows) { possibleFileNames ~= ["$wraplibrary.dll", "lib$wraplibrary.so"]; } else { static assert(false, "Operating system not supported by the wrapper loading code."); } auto library = new SwigSharedLib; library.load(possibleFileNames); string bindCode(string functionPointer, string symbol) { return functionPointer ~ " = cast(typeof(" ~ functionPointer ~ "))library.loadSymbol(`" ~ symbol ~ "`);"; } //#if !defined(SWIG_D_NO_EXCEPTION_HELPER) mixin(bindCode("swigRegisterExceptionCallbacks$module", "SWIGRegisterExceptionCallbacks_$module")); //#endif // SWIG_D_NO_EXCEPTION_HELPER //#if !defined(SWIG_D_NO_STRING_HELPER) mixin(bindCode("swigRegisterStringCallback$module", "SWIGRegisterStringCallback_$module")); //#endif // SWIG_D_NO_STRING_HELPER $wrapperloaderbindcode } //#if !defined(SWIG_D_NO_EXCEPTION_HELPER) extern(C) void function( SwigExceptionCallback exceptionCallback, SwigExceptionCallback illegalArgumentCallback, SwigExceptionCallback illegalElementCallback, SwigExceptionCallback ioCallback, SwigExceptionCallback noSuchElementCallback) swigRegisterExceptionCallbacks$module; //#endif // SWIG_D_NO_EXCEPTION_HELPER //#if !defined(SWIG_D_NO_STRING_HELPER) extern(C) void function(SwigStringCallback callback) swigRegisterStringCallback$module; //#endif // SWIG_D_NO_STRING_HELPER %} %pragma(d) wrapperloaderbindcommand = %{ mixin(bindCode("$function", "$symbol"));%} swig-3.0.8/Lib/d/doperators.swg0000664000175000017500000001767012641054563016231 0ustar williamwilliam/* ----------------------------------------------------------------------------- * doperators.swg * * Mapping of C++ operator overloading methods to D. * ----------------------------------------------------------------------------- */ #if (SWIG_D_VERSION == 1) %pragma(d) imdmodulecode=%{ template SwigOperatorDefinitions() { public override int opEquals(Object o) { if (auto rhs = cast(typeof(this))o) { if (swigCPtr == rhs.swigCPtr) return 1; static if (is(typeof(swigOpEquals(rhs)))) { return swigOpEquals(rhs) ? 1 : 0; } else { return 0; } } return super.opEquals(o); } %} // opEquals is emitted in pure C mode as well to define two proxy classes // pointing to the same struct as equal. #ifdef __cplusplus %rename(opPos) *::operator+(); %rename(opPos) *::operator+() const; %rename(opNeg) *::operator-(); %rename(opNeg) *::operator-() const; %rename(opCom) *::operator~(); %rename(opCom) *::operator~() const; %rename(opAdd) *::operator+; %rename(opAddAssign) *::operator+=; %rename(opSub) *::operator-; %rename(opSubAssign) *::operator-=; %rename(opMul) *::operator*; %rename(opMulAssign) *::operator*=; %rename(opDiv) *::operator/; %rename(opDivAssign) *::operator/=; %rename(opMod) *::operator%; %rename(opModAssign) *::operator%=; %rename(opAnd) *::operator&; %rename(opAndAssign) *::operator&=; %rename(opOr) *::operator|; %rename(opOrAssign) *::operator|=; %rename(opXor) *::operator^; %rename(opXorAssign) *::operator^=; %rename(opShl) *::operator<<; %rename(opShlAssign) *::operator<<=; %rename(opShr) *::operator>>; %rename(opShrAssign) *::operator>>=; %rename(opIndex) *::operator[](unsigned) const; // opIndexAssign is not currently generated, it needs more extensive support // mechanisms. %rename(opCall) *::operator(); // !a is not overrideable in D1. %ignoreoperator(LNOT) operator!; // opCmp is used in D. %rename(swigOpEquals) *::operator==; %rename(swigOpLt) *::operator<; %rename(swigOpLtEquals) *::operator<=; %rename(swigOpGt) *::operator>; %rename(swigOpGtEquals) *::operator>=; // a != b is rewritten as !a.opEquals(b) in D. %ignoreoperator(NOTEQUAL) operator!=; // The logic operators are not overrideable in D. %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; // ++/--a is rewritten as a +/-= 1 in D1,so ignore the prefix operators. %ignoreoperator(PLUSPLUS) *::operator++(); %ignoreoperator(MINUSMINUS) *::operator--(); %rename(swigOpInc) *::operator++(int); %rename(swigOpDec) *::operator--(int); // The C++ assignment operator does not translate well to D where the proxy // classes have reference semantics. %ignoreoperator(EQ) operator=; %pragma(d) imdmodulecode=%{ public override int opCmp(Object o) { static if (is(typeof(swigOpLt(typeof(this).init) && swigOpEquals(typeof(this).init)))) { if (auto rhs = cast(typeof(this))o) { if (swigOpLt(rhs)) { return -1; } else if (swigOpEquals(rhs)) { return 0; } else { return 1; } } } return super.opCmp(o); } public typeof(this) opPostInc(T = int)(T unused = 0) { static assert( is(typeof(swigOpInc(int.init))), "opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~ "increment operator exists in the corresponding C++ class." ); return swigOpInc(int.init); } public typeof(this) opPostDec(T = int)(T unused = 0) { static assert( is(typeof(swigOpDec(int.init))), "opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~ "decrement operator exists in the corresponding C++ class." ); return swigOpDec(int.init); } %} #endif %pragma(d) imdmodulecode=%{ } %} #else %pragma(d) imdmodulecode=%{ mixin template SwigOperatorDefinitions() { public override bool opEquals(Object o) { if (auto rhs = cast(typeof(this))o) { if (swigCPtr == rhs.swigCPtr) return true; static if (is(typeof(swigOpEquals(rhs)))) { return swigOpEquals(rhs); } else { return false; } } return super.opEquals(o); } %} // opEquals is emitted in pure C mode as well to define two proxy classes // pointing to the same struct as equal. #ifdef __cplusplus %rename(swigOpPos) *::operator+(); %rename(swigOpPos) *::operator+() const; %rename(swigOpNeg) *::operator-(); %rename(swigOpNeg) *::operator-() const; %rename(swigOpCom) *::operator~(); %rename(swigOpCom) *::operator~() const; %rename(swigOpInc) *::operator++(); %rename(swigOpDec) *::operator--(); %ignoreoperator(PLUSPLUS) *::operator++(int); %ignoreoperator(MINUSMINUS) *::operator--(int); // The postfix increment/decrement operators are ignored because they are // rewritten to (auto t = e, ++e, t) in D2. The unary * operator (used for // pointer dereferencing in C/C++) isn't mapped to opUnary("*") by default, // despite this would be possible in D2 – the difference in member access // semantics would only lead to confusion in most cases. %rename(swigOpAdd) *::operator+; %rename(swigOpSub) *::operator-; %rename(swigOpMul) *::operator*; %rename(swigOpDiv) *::operator/; %rename(swigOpMod) *::operator%; %rename(swigOpAnd) *::operator&; %rename(swigOpOr) *::operator|; %rename(swigOpXor) *::operator^; %rename(swigOpShl) *::operator<<; %rename(swigOpShr) *::operator>>; %rename(swigOpAddAssign) *::operator+=; %rename(swigOpSubAssign) *::operator-=; %rename(swigOpMulAssign) *::operator*=; %rename(swigOpDivAssign) *::operator/=; %rename(swigOpModAssign) *::operator%=; %rename(swigOpAndAssign) *::operator&=; %rename(swigOpOrAssign) *::operator|=; %rename(swigOpXorAssign) *::operator^=; %rename(swigOpShlAssign) *::operator<<=; %rename(swigOpShrAssign) *::operator>>=; %rename(opIndex) *::operator[]; // opIndexAssign is not currently generated, it needs more extensive support // mechanisms. %rename(opCall) *::operator(); %rename(swigOpEquals) *::operator==; %rename(swigOpLt) *::operator<; %rename(swigOpLtEquals) *::operator<=; %rename(swigOpGt) *::operator>; %rename(swigOpGtEquals) *::operator>=; // a != b is rewritten as !a.opEquals(b) in D. %ignoreoperator(NOTEQUAL) operator!=; // The logic operators are not overrideable in D. %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; // The C++ assignment operator does not translate well to D where the proxy // classes have reference semantics. %ignoreoperator(EQ) operator=; %pragma(d) imdmodulecode=%{ public override int opCmp(Object o) { static if (__traits(compiles, swigOpLt(typeof(this).init) && swigOpEquals(typeof(this).init))) { if (auto rhs = cast(typeof(this))o) { if (swigOpLt(rhs)) { return -1; } else if (swigOpEquals(rhs)) { return 0; } else { return 1; } } } return super.opCmp(o); } private template swigOpBinary(string operator, string name) { enum swigOpBinary = `public void opOpAssign(string op, T)(T rhs) if (op == "` ~ operator ~ `" && __traits(compiles, swigOp` ~ name ~ `Assign(rhs))) { swigOp` ~ name ~ `Assign(rhs);}` ~ `public auto opBinary(string op, T)(T rhs) if (op == "` ~ operator ~ `" && __traits(compiles, swigOp` ~ name ~ `(rhs))) { return swigOp` ~ name ~ `(rhs);}`; } mixin(swigOpBinary!("+", "Add")); mixin(swigOpBinary!("-", "Sub")); mixin(swigOpBinary!("*", "Mul")); mixin(swigOpBinary!("/", "Div")); mixin(swigOpBinary!("%", "Mod")); mixin(swigOpBinary!("&", "And")); mixin(swigOpBinary!("|", "Or")); mixin(swigOpBinary!("^", "Xor")); mixin(swigOpBinary!("<<", "Shl")); mixin(swigOpBinary!(">>", "Shr")); private template swigOpUnary(string operator, string name) { enum swigOpUnary = `public auto opUnary(string op)() if (op == "` ~ operator ~ `" && __traits(compiles, swigOp` ~ name ~ `())) { return swigOp` ~ name ~ `();}`; } mixin(swigOpUnary!("+", "Pos")); mixin(swigOpUnary!("-", "Neg")); mixin(swigOpUnary!("~", "Com")); mixin(swigOpUnary!("++", "Inc")); mixin(swigOpUnary!("--", "Dec")); %} #endif %pragma(d) imdmodulecode=%{ } %} #endif swig-3.0.8/Lib/d/dprimitives.swg0000664000175000017500000001077612641054563016406 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dprimitves.swg * * Typemaps for primitive types. * ----------------------------------------------------------------------------- */ // C long/ulong width depends on the target arch, use stdlib aliases for them. #if (SWIG_D_VERSION == 1) %pragma(d) imdmoduleimports = "static import tango.stdc.config;" %pragma(d) globalproxyimports = "static import tango.stdc.config;" #define SWIG_LONG_DTYPE tango.stdc.config.c_long #define SWIG_ULONG_DTYPE tango.stdc.config.c_ulong #else %pragma(d) imdmoduleimports = "static import core.stdc.config;" %pragma(d) globalproxyimports = "static import core.stdc.config;" #define SWIG_LONG_DTYPE core.stdc.config.c_long #define SWIG_ULONG_DTYPE core.stdc.config.c_ulong #endif /* * The SWIG_D_PRIMITIVE macro is used to define the typemaps for the primitive * types, because are more or less the same for all of them. The few special * cases are handeled below. */ %define SWIG_D_PRIMITIVE(TYPE, DTYPE) %typemap(ctype) TYPE, const TYPE & "TYPE" %typemap(imtype) TYPE, const TYPE & "DTYPE" %typemap(dtype, cprimitive="1") TYPE, const TYPE & "DTYPE" %typemap(in) TYPE "$1 = ($1_ltype)$input;" %typemap(out) TYPE "$result = $1;" %typemap(directorin) TYPE "$input = $1;" %typemap(directorout) TYPE "$result = ($1_ltype)$input;" %typemap(ddirectorin) TYPE "$winput" %typemap(ddirectorout) TYPE "$dcall" %typemap(in) const TYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const TYPE & "$result = *$1;" %typemap(directorin) const TYPE & "$input = $1;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const TYPE & %{ static $*1_ltype temp; temp = ($*1_ltype)$input; $result = &temp; %} %typemap(ddirectorin) const TYPE & "$winput" %typemap(ddirectorout) const TYPE & "$dcall" %typemap(din) TYPE, const TYPE & "$dinput" %typemap(dout, excode=SWIGEXCODE) TYPE, const TYPE & { auto ret = $imcall;$excode return ret; } %enddef SWIG_D_PRIMITIVE(bool, bool) SWIG_D_PRIMITIVE(char, char) SWIG_D_PRIMITIVE(signed char, byte) SWIG_D_PRIMITIVE(unsigned char, ubyte) SWIG_D_PRIMITIVE(short, short) SWIG_D_PRIMITIVE(unsigned short, ushort) SWIG_D_PRIMITIVE(int, int) SWIG_D_PRIMITIVE(unsigned int, uint) SWIG_D_PRIMITIVE(long, SWIG_LONG_DTYPE) SWIG_D_PRIMITIVE(unsigned long, SWIG_ULONG_DTYPE) SWIG_D_PRIMITIVE(size_t, size_t) SWIG_D_PRIMITIVE(long long, long) SWIG_D_PRIMITIVE(unsigned long long, ulong) SWIG_D_PRIMITIVE(float, float) SWIG_D_PRIMITIVE(double, double) // The C++ boolean type needs some special casing since it is not part of the // C standard and is thus represented as unsigned int in the C wrapper layer. %typemap(ctype) bool, const bool & "unsigned int" %typemap(imtype) bool, const bool & "uint" %typemap(in) bool "$1 = $input ? true : false;" %typemap(in) const bool & ($*1_ltype temp) %{ temp = $input ? true : false; $1 = &temp; %} %typemap(directorout) bool "$result = $input ? true : false;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & %{ static $*1_ltype temp; temp = $input ? true : false; $result = &temp; %} %typemap(ddirectorin) bool "($winput ? true : false)" %typemap(dout, excode=SWIGEXCODE) bool, const bool & { bool ret = $imcall ? true : false;$excode return ret; } // Judging from the history of the C# module, the explicit casts are needed for // certain versions of VC++. %typemap(out) unsigned long "$result = (unsigned long)$1;" %typemap(out) const unsigned long & "$result = (unsigned long)*$1;" /* * Typecheck typemaps. */ %typecheck(SWIG_TYPECHECK_BOOL) bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) char, const char & "" %typecheck(SWIG_TYPECHECK_INT8) signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_UINT8) unsigned char, const unsigned char & "" %typecheck(SWIG_TYPECHECK_INT16) short, const short & "" %typecheck(SWIG_TYPECHECK_UINT16) unsigned short, const unsigned short & "" %typecheck(SWIG_TYPECHECK_INT32) int, long, const int &, const long & "" %typecheck(SWIG_TYPECHECK_UINT32) unsigned int, unsigned long, const unsigned int &, const unsigned long & "" %typecheck(SWIG_TYPECHECK_INT64) long long, const long long & "" %typecheck(SWIG_TYPECHECK_UINT64) unsigned long long, const unsigned long long & "" %typecheck(SWIG_TYPECHECK_FLOAT) float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & "" swig-3.0.8/Lib/d/dmemberfunctionpointers.swg0000664000175000017500000000516312641054563021006 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dmemberfunctionpointers.swg * * Typemaps for member function pointers. * ----------------------------------------------------------------------------- */ %typemap(ctype) SWIGTYPE (CLASS::*) "char *" %typemap(imtype) SWIGTYPE (CLASS::*) "char*" %typemap(dtype) SWIGTYPE (CLASS::*) "$dclassname" %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE (CLASS::*) "" /* * Conversion generation typemaps. */ %typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{ SWIG_UnpackData($input, (void *)&$1, sizeof($1)); %} %typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{ char buf[128]; char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1)); *data = '\0'; $result = SWIG_d_string_callback(buf); %} %typemap(directorin) SWIGTYPE (CLASS::*) "$input = (void *) $1;" %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*) "$result = ($1_ltype)$input;" %typemap(ddirectorin) SWIGTYPE (CLASS::*) "($winput is null) ? null : new $dclassname($winput, false)" %typemap(ddirectorout) SWIGTYPE (CLASS::*) "$dclassname.swigGetCPtr($dcall)" %typemap(din) SWIGTYPE (CLASS::*) "$dclassname.swigGetCMemberPtr($dinput)" %typemap(dout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) { char* cMemberPtr = $imcall; $dclassname ret = (cMemberPtr is null) ? null : new $dclassname(cMemberPtr, $owner);$excode return ret; } /* * Helper functions to pack/unpack arbitrary binary data (member function * pointers in this case) into a string. */ %fragment("SWIG_PackData", "header") { /* Pack binary data into a string */ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } } %fragment("SWIG_UnPackData", "header") { /* Unpack binary data from a string */ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } } swig-3.0.8/Lib/d/cpointer.i0000664000175000017500000000663212641054563015316 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cpointer.i * * D-specific version of ../cpointer.i. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %pointer_class(type,name) * * Places a simple proxy around a simple type like 'int', 'float', or whatever. * The proxy provides this interface: * * class type { * public: * type(); * ~type(); * type value(); * void assign(type value); * }; * * Example: * * %pointer_class(int, intp); * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = intp() * >>> a.assign(10) * >>> a.value() * 10 * >>> b = intp() * >>> b.assign(20) * >>> print add(a,b) * 30 * * As a general rule, this macro should not be used on class/structures that * are already defined in the interface. * ----------------------------------------------------------------------------- */ %define %pointer_class(TYPE, NAME) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { #ifdef __cplusplus NAME() { return new TYPE(); } ~NAME() { if (self) delete self; } #else NAME() { return (TYPE *) calloc(1,sizeof(TYPE)); } ~NAME() { if (self) free(self); } #endif } %extend NAME { void assign(TYPE value) { *self = value; } TYPE value() { return *self; } TYPE * ptr() { return self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; } } %types(NAME = TYPE); %enddef /* ----------------------------------------------------------------------------- * %pointer_functions(type,name) * * Create functions for allocating/deallocating pointers. This can be used * if you don't want to create a proxy class or if the pointer is complex. * * %pointer_functions(int, intp) * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = copy_intp(10) * >>> intp_value(a) * 10 * >>> b = new_intp() * >>> intp_assign(b,20) * >>> print add(a,b) * 30 * >>> delete_intp(a) * >>> delete_intp(b) * * ----------------------------------------------------------------------------- */ %define %pointer_functions(TYPE,NAME) %{ static TYPE *new_##NAME() { %} #ifdef __cplusplus %{ return new TYPE(); %} #else %{ return (TYPE *) calloc(1,sizeof(TYPE)); %} #endif %{} static TYPE *copy_##NAME(TYPE value) { %} #ifdef __cplusplus %{ return new TYPE(value); %} #else %{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE)); *self = value; return self; %} #endif %{} static void delete_##NAME(TYPE *self) { %} #ifdef __cplusplus %{ if (self) delete self; %} #else %{ if (self) free(self); %} #endif %{} static void NAME ##_assign(TYPE *self, TYPE value) { *self = value; } static TYPE NAME ##_value(TYPE *self) { return *self; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); void delete_##NAME(TYPE *self); void NAME##_assign(TYPE *self, TYPE value); TYPE NAME##_value(TYPE *self); %enddef /* ----------------------------------------------------------------------------- * %pointer_cast(type1,type2,name) * * Generates a pointer casting function. * ----------------------------------------------------------------------------- */ %define %pointer_cast(TYPE1,TYPE2,NAME) %inline %{ TYPE2 NAME(TYPE1 x) { return (TYPE2) x; } %} %enddef swig-3.0.8/Lib/d/dvoid.swg0000664000175000017500000000105712641054563015144 0ustar williamwilliam/* ----------------------------------------------------------------------------- * dvoid.swg * * Typemaps for handling void function return types and empty parameter lists. * ----------------------------------------------------------------------------- */ %typemap(ctype) void "void" %typemap(imtype) void "void" %typemap(dtype, cprimitive="1") void "void" %typemap(out, null="") void "" %typemap(ddirectorin) void "$winput" %typemap(ddirectorout) void "$dcall" %typemap(directorin) void "" %typemap(dout, excode=SWIGEXCODE) void { $imcall;$excode } swig-3.0.8/Lib/javascript/0000775000175000017500000000000012641054563015235 5ustar williamwilliamswig-3.0.8/Lib/javascript/v8/0000775000175000017500000000000012641054563015572 5ustar williamwilliamswig-3.0.8/Lib/javascript/v8/std_pair.i0000664000175000017500000000126112641054563017551 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/javascript/v8/javascripttypemaps.swg0000664000175000017500000000244312641054563022250 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Javascript * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* Include fundamental fragemt definitions */ %include /* Look for user fragments file. */ %include /* Javascript fragments for fundamental types */ %include /* Javascript fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* Javascript types */ #define SWIG_Object v8::Handle #define VOID_Object SWIGV8_UNDEFINED() /* Overload of the output/constant/exception/dirout handling */ /* append output */ #define SWIG_AppendOutput(result, obj) SWIGV8_AppendOutput(result, obj) /* set constant */ #define SWIG_SetConstant(name, obj) /* raise */ #define SWIG_Raise(obj, type, desc) SWIG_V8_Raise(type) /* Include the unified typemap library */ %include swig-3.0.8/Lib/javascript/v8/javascriptrun.swg0000664000175000017500000005246712641054563021225 0ustar williamwilliam/* --------------------------------------------------------------------------- * These typedefs and defines are used to deal with v8 API changes * * ---------------------------------------------------------------------------*/ // First v8 version that uses "SetWeak" and not "MakeWeak" #define SWIGV8_SETWEAK_VERSION 0x032224 #if (SWIG_V8_VERSION < 0x031803) #define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len) #else #define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len) #endif #if (SWIG_V8_VERSION < 0x031903) typedef v8::Handle SwigV8ReturnValue; typedef v8::Arguments SwigV8Arguments; typedef v8::AccessorInfo SwigV8PropertyCallbackInfo; #define SWIGV8_RETURN(val) return scope.Close(val) #define SWIGV8_RETURN_INFO(val, info) return scope.Close(val) #else typedef void SwigV8ReturnValue; typedef v8::FunctionCallbackInfo SwigV8Arguments; typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return #define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return #endif #if (SWIG_V8_VERSION < 0x032117) #define SWIGV8_HANDLESCOPE() v8::HandleScope scope #define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope #define SWIGV8_ESCAPE(val) return scope.Close(val) #elif (SWIG_V8_VERSION < 0x032224) #define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent()); #define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent()); #define SWIGV8_ESCAPE(val) return scope.Close(val) #else #define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent()); #define SWIGV8_HANDLESCOPE_ESC() v8::EscapableHandleScope scope(v8::Isolate::GetCurrent()); #define SWIGV8_ESCAPE(val) return scope.Escape(val) #endif #if (SWIG_V8_VERSION < 0x032224) #define SWIGV8_ADJUST_MEMORY(size) v8::V8::AdjustAmountOfExternalAllocatedMemory(size) #define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent() #define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err) #define SWIGV8_STRING_NEW(str) v8::String::New(str) #define SWIGV8_SYMBOL_NEW(sym) v8::String::NewSymbol(sym) #else #define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size) #define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext() #define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err) #define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str) #define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym) #endif #if (SWIG_V8_VERSION < 0x032318) #define SWIGV8_ARRAY_NEW() v8::Array::New() #define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(bool) #define SWIGV8_EXTERNAL_NEW(val) v8::External::New(val) #define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(func) #define SWIGV8_FUNCTEMPLATE_NEW_VOID() v8::FunctionTemplate::New() #define SWIGV8_INT32_NEW(num) v8::Int32::New(num) #define SWIGV8_INTEGER_NEW(num) v8::Integer::New(num) #define SWIGV8_INTEGER_NEW_UNS(num) v8::Integer::NewFromUnsigned(num) #define SWIGV8_NUMBER_NEW(num) v8::Number::New(num) #define SWIGV8_OBJECT_NEW() v8::Object::New() #define SWIGV8_UNDEFINED() v8::Undefined() #define SWIGV8_NULL() v8::Null() #else #define SWIGV8_ARRAY_NEW() v8::Array::New(v8::Isolate::GetCurrent()) #define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(v8::Isolate::GetCurrent(), bool) #define SWIGV8_EXTERNAL_NEW(val) v8::External::New(v8::Isolate::GetCurrent(), val) #define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), func) #define SWIGV8_FUNCTEMPLATE_NEW_VOID() v8::FunctionTemplate::New(v8::Isolate::GetCurrent()) #define SWIGV8_INT32_NEW(num) v8::Int32::New(v8::Isolate::GetCurrent(), num) #define SWIGV8_INTEGER_NEW(num) v8::Integer::New(v8::Isolate::GetCurrent(), num) #define SWIGV8_INTEGER_NEW_UNS(num) v8::Integer::NewFromUnsigned(v8::Isolate::GetCurrent(), num) #define SWIGV8_NUMBER_NEW(num) v8::Number::New(v8::Isolate::GetCurrent(), num) #define SWIGV8_OBJECT_NEW() v8::Object::New(v8::Isolate::GetCurrent()) #define SWIGV8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent()) #define SWIGV8_NULL() v8::Null(v8::Isolate::GetCurrent()) #endif #if (SWIG_V8_VERSION < 0x031710) #define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent::New(class); #elif (SWIG_V8_VERSION < 0x031900) #define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent::New(v8::Isolate::GetCurrent(), class); #else #define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ.Reset(v8::Isolate::GetCurrent(), class); #endif /* --------------------------------------------------------------------------- * Error handling * * ---------------------------------------------------------------------------*/ #define SWIG_Error(code, msg) SWIGV8_ErrorHandler.error(code, msg) #define SWIG_exception(code, msg) SWIGV8_ErrorHandler.error(code, msg) #define SWIG_fail goto fail #define SWIGV8_OVERLOAD false SWIGINTERN void SWIG_V8_Raise(const char *msg) { SWIGV8_THROW_EXCEPTION(v8::Exception::Error(SWIGV8_STRING_NEW(msg))); } /* Note: There are two contexts for handling errors. A static V8ErrorHandler is used in not overloaded methods. For overloaded methods the throwing type checking mechanism is used during dispatching. As V8 exceptions can not be resetted properly the trick is to use a dynamic ErrorHandler with same local name as the global one. - See defintion of SWIG_Error above. - See code templates 'JS_function_dispatcher', 'JS_functionwrapper_overload', and 'JS_function_dispatch_case' in javascriptcode.swg */ class V8ErrorHandler { public: virtual ~V8ErrorHandler() {} virtual void error(int code, const char *msg) { SWIG_V8_Raise(msg); } }; // this is used in usually SWIGRUNTIME V8ErrorHandler SWIGV8_ErrorHandler; // instances of this are used in overloaded functions class OverloadErrorHandler: public V8ErrorHandler { public: virtual void error(int code, const char *msg) { err = v8::Exception::Error(SWIGV8_STRING_NEW(msg)); if(code != SWIG_TypeError) { SWIGV8_THROW_EXCEPTION(err); } } v8::Handle err; }; /* --------------------------------------------------------------------------- * Basic Proxy object * * ---------------------------------------------------------------------------*/ // Note: to trigger the v8 gc more often one can tell v8 about the memory consumption // TODO: we could add a v8 specific parameter to control this value #define SWIGV8_AVG_OBJ_SIZE 1000 class SWIGV8_Proxy { public: SWIGV8_Proxy(): swigCMemOwn(false), swigCObject(0), info(0) { SWIGV8_ADJUST_MEMORY(SWIGV8_AVG_OBJ_SIZE); }; ~SWIGV8_Proxy() { #if (SWIG_V8_VERSION < 0x031710) handle.ClearWeak(); handle.Dispose(); #elif (SWIG_V8_VERSION < 0x032100) handle.ClearWeak(v8::Isolate::GetCurrent()); handle.Dispose(v8::Isolate::GetCurrent()); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) handle.ClearWeak(); handle.Dispose(); #else handle.ClearWeak(); handle.Reset(); #endif #if (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) handle.Clear(); #endif SWIGV8_ADJUST_MEMORY(-SWIGV8_AVG_OBJ_SIZE); } bool swigCMemOwn; void *swigCObject; swig_type_info *info; v8::Persistent handle; }; class SWIGV8_ClientData { public: v8::Persistent class_templ; #if (SWIG_V8_VERSION < 0x031710) void (*dtor) (v8::Persistent< v8::Value> object, void *parameter); #elif (SWIG_V8_VERSION < 0x031900) void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Value> object, void *parameter); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy); #else void (*dtor) (const v8::WeakCallbackData &data); #endif }; SWIGRUNTIME v8::Persistent SWIGV8_SWIGTYPE_Proxy_class_templ; SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle objRef, void **ptr, swig_type_info *info, int flags) { SWIGV8_HANDLESCOPE(); if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; #if (SWIG_V8_VERSION < 0x031511) v8::Handle cdataRef = objRef->GetInternalField(0); SWIGV8_Proxy *cdata = static_cast(v8::External::Unwrap(cdataRef)); #else SWIGV8_Proxy *cdata = static_cast(objRef->GetAlignedPointerFromInternalField(0)); #endif if(cdata == NULL) { return SWIG_ERROR; } if(cdata->info != info) { swig_cast_info *tc = SWIG_TypeCheckStruct(cdata->info, info); if (!tc && cdata->info->name) { tc = SWIG_TypeCheck(cdata->info->name, info); } bool type_valid = tc != 0; if(!type_valid) { return SWIG_TypeError; } } *ptr = cdata->swigCObject; if(flags & SWIG_POINTER_DISOWN) { cdata->swigCMemOwn = false; } return SWIG_OK; } #if (SWIG_V8_VERSION < 0x031710) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); #elif (SWIG_V8_VERSION < 0x031900) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Value > object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) { #else SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData &data) { SWIGV8_Proxy *proxy = data.GetParameter(); #endif delete proxy; } SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle valRef, void **ptr) { if(!valRef->IsObject()) { return SWIG_TypeError; } v8::Handle objRef = valRef->ToObject(); if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; #if (SWIG_V8_VERSION < 0x031511) v8::Handle cdataRef = objRef->GetInternalField(0); SWIGV8_Proxy *cdata = static_cast(v8::External::Unwrap(cdataRef)); #else SWIGV8_Proxy *cdata = static_cast(objRef->GetAlignedPointerFromInternalField(0)); #endif if(cdata == NULL) { return SWIG_ERROR; } *ptr = cdata->swigCObject; return SWIG_OK; } SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle obj, void *ptr, swig_type_info *info, int flags) { SWIGV8_Proxy *cdata = new SWIGV8_Proxy(); cdata->swigCObject = ptr; cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0; cdata->info = info; #if (SWIG_V8_VERSION < 0x031511) obj->SetPointerInInternalField(0, cdata); #else obj->SetAlignedPointerInInternalField(0, cdata); #endif #if (SWIG_V8_VERSION < 0x031710) cdata->handle = v8::Persistent::New(obj); #elif (SWIG_V8_VERSION < 0x031900) cdata->handle = v8::Persistent::New(v8::Isolate::GetCurrent(), obj); #else cdata->handle.Reset(v8::Isolate::GetCurrent(), obj); #endif #if (SWIG_V8_VERSION < 0x031710) // clientdata must be set for owned data as we need to register the dtor if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor); } #elif (SWIG_V8_VERSION < 0x031918) if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor); } #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor); } #else if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.SetWeak(cdata, SWIGV8_Proxy_DefaultDtor); } #endif #if (SWIG_V8_VERSION < 0x031710) cdata->handle.MarkIndependent(); #elif (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); #else cdata->handle.MarkIndependent(); #endif } SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle valRef, void **ptr, swig_type_info *info, int flags) { SWIGV8_HANDLESCOPE(); /* special case: JavaScript null => C NULL pointer */ if(valRef->IsNull()) { *ptr=0; return SWIG_OK; } if(!valRef->IsObject()) { return SWIG_TypeError; } v8::Handle objRef = valRef->ToObject(); return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags); } SWIGRUNTIME v8::Handle SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) { SWIGV8_HANDLESCOPE_ESC(); v8::Handle class_templ; if (ptr == NULL) { #if (SWIG_V8_VERSION < 0x031903) SWIGV8_ESCAPE(SWIGV8_NULL()); #else v8::Local result = SWIGV8_NULL(); SWIGV8_ESCAPE(result); #endif } #if (SWIG_V8_VERSION < 0x031903) if(info->clientdata != 0) { class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ; } else { class_templ = SWIGV8_SWIGTYPE_Proxy_class_templ; } #else v8::Isolate *isolate = v8::Isolate::GetCurrent(); if(info->clientdata != 0) { class_templ = v8::Local::New(isolate, ((SWIGV8_ClientData*) info->clientdata)->class_templ); } else { class_templ = v8::Local::New(isolate, SWIGV8_SWIGTYPE_Proxy_class_templ); } #endif // v8::Handle result = class_templ->InstanceTemplate()->NewInstance(); v8::Local result = class_templ->InstanceTemplate()->NewInstance(); SWIGV8_SetPrivateData(result, ptr, info, flags); SWIGV8_ESCAPE(result); } #define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_V8_ConvertPtr(obj, ptr, info, flags) #define SWIG_NewPointerObj(ptr, info, flags) SWIG_V8_NewPointerObj(ptr, info, flags) #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_V8_ConvertInstancePtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_V8_NewPointerObj(thisvalue, type, flags) #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_V8_ConvertPtr(obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_V8_NewPointerObj(ptr, type, 0) #define SWIG_GetInstancePtr(obj, ptr) SWIG_V8_GetInstancePtr(obj, ptr) SWIGRUNTIME SwigV8ReturnValue _SWIGV8_wrap_equals(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); v8::Handle jsresult; void *arg1 = (void *) 0 ; void *arg2 = (void *) 0 ; bool result; int res1; int res2; if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for equals."); res1 = SWIG_GetInstancePtr(args.Holder(), &arg1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ERROR, "Could not get pointer from 'this' object for equals."); } res2 = SWIG_GetInstancePtr(args[0], &arg2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "equals" "', argument " "1"" of type '" "void *""'"); } result = (bool)(arg1 == arg2); jsresult = SWIGV8_BOOLEAN_NEW(result); SWIGV8_RETURN(jsresult); goto fail; fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } SWIGRUNTIME SwigV8ReturnValue _wrap_getCPtr(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); v8::Handle jsresult; void *arg1 = (void *) 0 ; long result; int res1; res1 = SWIG_GetInstancePtr(args.Holder(), &arg1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getCPtr" "', argument " "1"" of type '" "void *""'"); } result = (long)arg1; jsresult = SWIGV8_NUMBER_NEW(result); SWIGV8_RETURN(jsresult); goto fail; fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } /* --------------------------------------------------------------------------- * PackedData object * * ---------------------------------------------------------------------------*/ class SwigV8PackedData { public: SwigV8PackedData(void *data, size_t size, swig_type_info *type): data(data), size(size), type(type) {}; ~SwigV8PackedData() { }; void *data; size_t size; swig_type_info *type; v8::Persistent handle; }; SWIGRUNTIMEINLINE int SwigV8Packed_Check(v8::Handle valRef) { SWIGV8_HANDLESCOPE(); v8::Handle objRef = valRef->ToObject(); if(objRef->InternalFieldCount() < 1) return false; v8::Handle flag = objRef->GetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__")); return (flag->IsBoolean() && flag->BooleanValue()); } SWIGRUNTIME swig_type_info *SwigV8Packed_UnpackData(v8::Handle valRef, void *ptr, size_t size) { if (SwigV8Packed_Check(valRef)) { SWIGV8_HANDLESCOPE(); SwigV8PackedData *sobj; v8::Handle objRef = valRef->ToObject(); #if (SWIG_V8_VERSION < 0x031511) v8::Handle cdataRef = objRef->GetInternalField(0); sobj = static_cast(v8::External::Unwrap(cdataRef)); #else sobj = static_cast(objRef->GetAlignedPointerFromInternalField(0)); #endif if (sobj == NULL || sobj->size != size) return 0; memcpy(ptr, sobj->data, size); return sobj->type; } else { return 0; } } SWIGRUNTIME int SWIGV8_ConvertPacked(v8::Handle valRef, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigV8Packed_UnpackData(valRef, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } #if (SWIG_V8_VERSION < 0x031710) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) { SwigV8PackedData *cdata = static_cast(parameter); #elif (SWIG_V8_VERSION < 0x031900) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent object, void *parameter) { SwigV8PackedData *cdata = static_cast(parameter); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent *object, SwigV8PackedData *cdata) { #else SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SwigV8PackedData *cdata = data.GetParameter(); #endif delete cdata; #if (SWIG_V8_VERSION < 0x031710) object.Clear(); object.Dispose(); #elif (SWIG_V8_VERSION < 0x031900) object.Clear(); object.Dispose(isolate); #elif (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) object->Dispose(); #else object.Clear(); #endif } SWIGRUNTIME v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) { SWIGV8_HANDLESCOPE_ESC(); SwigV8PackedData *cdata = new SwigV8PackedData(data, size, type); // v8::Handle obj = SWIGV8_OBJECT_NEW(); v8::Local obj = SWIGV8_OBJECT_NEW(); obj->SetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"), SWIGV8_BOOLEAN_NEW(true)); #if (SWIG_V8_VERSION < 0x031511) obj->SetPointerInInternalField(0, cdata); #else obj->SetAlignedPointerInInternalField(0, cdata); #endif #if (SWIG_V8_VERSION < 0x031710) cdata->handle = v8::Persistent::New(obj); #elif (SWIG_V8_VERSION < 0x031900) cdata->handle = v8::Persistent::New(v8::Isolate::GetCurrent(), obj); #else cdata->handle.Reset(v8::Isolate::GetCurrent(), obj); #endif #if (SWIG_V8_VERSION < 0x031710) cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete); #elif (SWIG_V8_VERSION < 0x031918) cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete); #else cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete); // v8::V8::SetWeak(&cdata->handle, cdata, _wrap_SwigV8PackedData_delete); #endif #if (SWIG_V8_VERSION < 0x031710) cdata->handle.MarkIndependent(); #elif (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); #else cdata->handle.MarkIndependent(); #endif SWIGV8_ESCAPE(obj); } #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIGV8_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIGV8_NewPackedObj(ptr, sz, type) /* --------------------------------------------------------------------------- * Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg) * * ---------------------------------------------------------------------------*/ SWIGRUNTIME #if (SWIG_V8_VERSION < 0x031903) v8::Handle SWIGV8_AppendOutput(v8::Handle result, v8::Handle obj) { #else v8::Handle SWIGV8_AppendOutput(v8::Local result, v8::Handle obj) { #endif SWIGV8_HANDLESCOPE_ESC(); if (result->IsUndefined()) { result = SWIGV8_ARRAY_NEW(); } #if (SWIG_V8_VERSION < 0x031903) v8::Handle arr = v8::Handle::Cast(result); #else v8::Local arr = v8::Local::Cast(result); #endif arr->Set(arr->Length(), obj); SWIGV8_ESCAPE(arr); } swig-3.0.8/Lib/javascript/v8/std_except.i0000664000175000017500000000004312641054563020103 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/v8/cdata.i0000664000175000017500000000003612641054563017017 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/v8/exception.i0000664000175000017500000000004212641054563017736 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/v8/std_deque.i0000664000175000017500000000003412641054563017716 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/v8/javascriptcomplex.swg0000664000175000017500000000640012641054563022052 0ustar williamwilliam/* Defines the As/From converters for double/float complex, you need to provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex accessor methods. See the std_complex.i and ccomplex.i for concrete examples. */ /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header", fragment=SWIG_From_frag(double)) { SWIGINTERNINLINE v8::Handle SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) { SWIGV8_HANDLESCOPE_ESC(); v8::Local vals = SWIGV8_ARRAY_NEW(2); vals->Set(0, SWIG_From(double)(Real(c))); vals->Set(1, SWIG_From(double)(Imag(c))); SWIGV8_ESCAPE(vals); } } %enddef /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal_dec(Type) (v8::Handle o, Type* val) { SWIGV8_HANDLESCOPE(); if (o->IsArray()) { v8::Handle array = v8::Handle::Cast(o); if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2]."); double re, im; int res; res = SWIG_AsVal(double)(array->Get(0), &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } res = SWIG_AsVal(double)(array->Get(1), &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } if (val) *val = Constructor(re, im); return SWIG_OK; } else if(o->IsNumber()){ double d; int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef /* the float case */ %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int SWIG_AsVal_dec(Type) (v8::Handle o, Type* val) { SWIGV8_HANDLESCOPE(); if (o->IsArray()) { v8::Handle array = v8::Handle::Cast(o); if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2]."); double re, im; int res; res = SWIG_AsVal(double)(array->Get(0), &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } res = SWIG_AsVal(double)(array->Get(1), &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else { return SWIG_OverflowError; } } else if(o->IsNumber()){ float re; int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(re, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.8/Lib/javascript/v8/std_common.i0000664000175000017500000000014612641054563020107 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.8/Lib/javascript/v8/complex.i0000664000175000017500000000012012641054563017404 0ustar williamwilliam#ifdef __cplusplus %include #else %include #endif swig-3.0.8/Lib/javascript/v8/javascript.swg0000664000175000017500000000066712641054563020473 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javascript.swg * * Javascript typemaps * ----------------------------------------------------------------------------- */ %include %include %include %include %include %include %include swig-3.0.8/Lib/javascript/v8/javascripthelpers.swg0000664000175000017500000000657712641054563022064 0ustar williamwilliam%insert(runtime) %{ // Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed #if (SWIG_V8_VERSION < 0x031903) typedef v8::InvocationCallback SwigV8FunctionCallback; typedef v8::AccessorGetter SwigV8AccessorGetterCallback; typedef v8::AccessorSetter SwigV8AccessorSetterCallback; typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid; #else typedef v8::FunctionCallback SwigV8FunctionCallback; typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback; typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback; typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfoVoid; #endif /** * Creates a class template for a class with specified initialization function. */ SWIGRUNTIME v8::Handle SWIGV8_CreateClassTemplate(const char* symbol) { SWIGV8_HANDLESCOPE_ESC(); v8::Local class_templ = SWIGV8_FUNCTEMPLATE_NEW_VOID(); class_templ->SetClassName(SWIGV8_SYMBOL_NEW(symbol)); v8::Handle inst_templ = class_templ->InstanceTemplate(); inst_templ->SetInternalFieldCount(1); v8::Handle equals_templ = class_templ->PrototypeTemplate(); equals_templ->Set(SWIGV8_SYMBOL_NEW("equals"), SWIGV8_FUNCTEMPLATE_NEW(_SWIGV8_wrap_equals)); v8::Handle cptr_templ = class_templ->PrototypeTemplate(); cptr_templ->Set(SWIGV8_SYMBOL_NEW("getCPtr"), SWIGV8_FUNCTEMPLATE_NEW(_wrap_getCPtr)); SWIGV8_ESCAPE(class_templ); } /** * Registers a class method with given name for a given class template. */ SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Handle class_templ, const char* symbol, SwigV8FunctionCallback _func) { v8::Handle proto_templ = class_templ->PrototypeTemplate(); proto_templ->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)); } /** * Registers a class property with given name for a given class template. */ SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Handle class_templ, const char* symbol, SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) { v8::Handle proto_templ = class_templ->InstanceTemplate(); proto_templ->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter); } /** * Registers a class method with given name for a given object. */ SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle obj, const char* symbol, const SwigV8FunctionCallback& _func) { obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction()); } /** * Registers a class method with given name for a given object. */ SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle obj, const char* symbol, SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) { obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter); } SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid& info) { char buffer[256]; char msg[512]; int res; property->WriteUtf8(buffer, 256); res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); if(res<0) { SWIG_exception(SWIG_ERROR, "Tried to write read-only variable."); } else { SWIG_exception(SWIG_ERROR, msg); } } %} // v8_helper_functions swig-3.0.8/Lib/javascript/v8/javascriptinit.swg0000664000175000017500000000666612641054563021364 0ustar williamwilliam%insert(init) %{ #include SWIGRUNTIME void SWIG_V8_SetModule(void *, swig_module_info *swig_module) { v8::Local global_obj = SWIGV8_CURRENT_CONTEXT()->Global(); v8::Local mod = SWIGV8_EXTERNAL_NEW(swig_module); assert(!mod.IsEmpty()); global_obj->SetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data"), mod); } SWIGRUNTIME swig_module_info * SWIG_V8_GetModule(void *) { v8::Local global_obj = SWIGV8_CURRENT_CONTEXT()->Global(); v8::Local moduleinfo = global_obj->GetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data")); if (moduleinfo.IsEmpty()) { // It's not yet loaded return 0; } v8::Local moduleinfo_extern = v8::Local::Cast(moduleinfo); if (moduleinfo_extern.IsEmpty()) { // Something's not right return 0; } void *ptr = moduleinfo_extern->Value(); assert(ptr); swig_module_info *retptr = static_cast(ptr); assert(retptr); return retptr; } #define SWIG_GetModule(clientdata) SWIG_V8_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_V8_SetModule(clientdata, pointer) %} %insert(init) "swiginit.swg" // Open the initializer function definition here %fragment ("js_initializer_define", "templates") %{ #define SWIGV8_INIT $jsname_initialize %} %insert(init) %{ // Note: 'extern "C"'' disables name mangling which makes it easier to load the symbol manually // TODO: is it ok to do that? extern "C" #if (NODE_MODULE_VERSION < 0x000C) void SWIGV8_INIT (v8::Handle exports) #else void SWIGV8_INIT (v8::Handle exports, v8::Handle /*module*/) #endif { SWIG_InitializeModule(static_cast(&exports)); SWIGV8_HANDLESCOPE(); v8::Handle exports_obj = exports; %} /* ----------------------------------------------------------------------------- * js_initializer: template for the module initializer function * - $jsname: module name * - $jsv8nspaces: part with code creating namespace objects * - $jsv8classtemplates: part with code creating class templates * - $jsv8wrappers: part with code that registers wrapper functions * - $jsv8inheritance: part with inherit statements * - $jsv8classinstances: part with code creating class objects * - $jsv8staticwrappers: part with code adding static functions to class objects * - $jsv8registerclasses: part with code that registers class objects in namespaces * - $jsv8registernspaces: part with code that registers namespaces in parent namespaces * ----------------------------------------------------------------------------- */ %fragment("js_initializer", "templates") %{ // a class template for creating proxies of undefined types SWIGV8_SET_CLASS_TEMPL(SWIGV8_SWIGTYPE_Proxy_class_templ, SWIGV8_CreateClassTemplate("SwigProxy")); /* create objects for namespaces */ $jsv8nspaces /* create class templates */ $jsv8classtemplates /* register wrapper functions */ $jsv8wrappers /* setup inheritances */ $jsv8inheritance /* class instances */ $jsv8classinstances /* add static class functions and variables */ $jsv8staticwrappers /* register classes */ $jsv8registerclasses /* create and register namespace objects */ $jsv8registernspaces } #if defined(BUILDING_NODE_EXTENSION) NODE_MODULE($jsname, $jsname_initialize) #endif %} swig-3.0.8/Lib/javascript/v8/javascriptruntime.swg0000664000175000017500000000235212641054563022070 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javascriptruntime.swg * * ----------------------------------------------------------------------------- */ // V8 Version Macro // ---------------- // v8 does not (until now) provide a version macro - which is still discussed and may come soon. // Until then, we set a default version which can be overridden via command line using V8_VERSION: // swig -javascript -v8 -DV8_VERSION=0x031110 // Or code in the interface file using SWIG_V8_VERSION: // %begin %{#define SWIG_V8_VERSION 0x031110%} %define %swig_v8_define_version(version) %insert("runtime") %{ #ifndef SWIG_V8_VERSION #define SWIG_V8_VERSION version #endif %} %enddef #ifdef V8_VERSION %swig_v8_define_version(V8_VERSION) #else // HACK: defining a default version %swig_v8_define_version(0x031110) #endif // Node support // ------------ #ifdef BUILDING_NODE_EXTENSION %insert("runtime") %{ #include %} #endif // V8 runtime // ---------- %insert(runtime) %{ #include #include #include #include %} %insert(runtime) "swigrun.swg"; /* SWIG API */ %insert(runtime) "swigerrors.swg"; /* SWIG errors */ %insert(runtime) "javascriptrun.swg" swig-3.0.8/Lib/javascript/v8/std_map.i0000664000175000017500000000444112641054563017376 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.8/Lib/javascript/v8/javascriptstrings.swg0000664000175000017500000000333112641054563022074 0ustar williamwilliam /* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize", "header", fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(v8::Handle valRef, char** cptr, size_t* psize, int *alloc) { if(valRef->IsString()) { v8::Handle js_str = valRef->ToString(); size_t len = js_str->Utf8Length() + 1; char* cstr = new char[len]; js_str->WriteUtf8(cstr, len); if(alloc) *alloc = SWIG_NEWOBJ; if(psize) *psize = len; if(cptr) *cptr = cstr; return SWIG_OK; } else { if(valRef->IsObject()) { v8::Handle obj = valRef->ToObject(); // try if the object is a wrapped char[] swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } return SWIG_TypeError; } else { return SWIG_TypeError; } } } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE v8::Handle SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { // TODO: handle extra long strings return SWIGV8_UNDEFINED(); } else { v8::Handle js_str = SWIGV8_STRING_NEW2(carray, size); return js_str; } } else { return SWIGV8_UNDEFINED(); } } } swig-3.0.8/Lib/javascript/v8/arrays_javascript.i0000664000175000017500000000626312641054563021502 0ustar williamwilliam/* ----------------------------------------------------------------------------- * arrays_javascript.i * * These typemaps give more natural support for arrays. The typemaps are not efficient * as there is a lot of copying of the array values whenever the array is passed to C/C++ * from JavaScript and vice versa. The JavaScript array is expected to be the same size as the C array. * An exception is thrown if they are not. * * Example usage: * Wrapping: * * %include * %inline %{ * extern int FiddleSticks[3]; * %} * * Use from JavaScript like this: * * var fs = [10, 11, 12]; * example.FiddleSticks = fs; * fs = example.FiddleSticks; * ----------------------------------------------------------------------------- */ %fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {} %fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_frag(double)) {} %typemap(in, fragment="SWIG_JSCGetIntProperty") int[], int[ANY] (int length = 0, v8::Local array, v8::Local jsvalue, int i = 0, int res = 0, $*1_ltype temp) { if ($input->IsArray()) { // Convert into Array array = v8::Local::Cast($input); length = $1_dim0; $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length); // Get each element from array for (i = 0; i < length; i++) { jsvalue = array->Get(i); // Get primitive value from JSObject res = SWIG_AsVal(int)(jsvalue, &temp); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double"); } arg$argnum[i] = temp; } } else { SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef"); } } %typemap(freearg) int[], int[ANY] { free($1); } %typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0) { length = $1_dim0; v8::Local array = v8::Array::New(length); for (i = 0; i < length; i++) { array->Set(i, SWIG_From(int)($1[i])); } $result = array; } %typemap(in, fragment="SWIG_JSCGetNumberProperty") double[], double[ANY] (int length = 0, v8::Local array, v8::Local jsvalue, int i = 0, int res = 0, $*1_ltype temp) { if ($input->IsArray()) { // Convert into Array array = v8::Local::Cast($input); length = $1_dim0; $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length); // Get each element from array for (i = 0; i < length; i++) { jsvalue = array->Get(i); // Get primitive value from JSObject res = SWIG_AsVal(double)(jsvalue, &temp); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double"); } arg$argnum[i] = temp; } } else { SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef"); } } %typemap(freearg) double[], double[ANY] { free($1); } %typemap(out, fragment=SWIG_From_frag(double)) double[], double[ANY] (int length = 0, int i = 0) { length = $1_dim0; v8::Local array = v8::Array::New(length); for (i = 0; i < length; i++) { array->Set(i, SWIG_From(double)($1[i])); } $result = array; } swig-3.0.8/Lib/javascript/v8/std_string.i0000664000175000017500000000004312641054563020121 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/v8/javascriptfragments.swg0000664000175000017500000000105712641054563022374 0ustar williamwilliam/* Create a file with this name, 'javascriptfragments.swg', in your working directory and add all the %fragments you want to take precedence over the default ones defined by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(PyObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.8/Lib/javascript/v8/stl.i0000664000175000017500000000044312641054563016547 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/javascript/v8/typemaps.i0000664000175000017500000001047612641054563017616 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * These mappings provide support for input/output arguments and common * uses for C/C++ pointers. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Python tuple. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Python output of the function would be a tuple containing both output values. */ // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Python tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Python). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Python variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %include swig-3.0.8/Lib/javascript/v8/std_vector.i0000664000175000017500000000511112641054563020116 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i * ----------------------------------------------------------------------------- */ %include %{ #include %} /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) %swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); swig-3.0.8/Lib/javascript/v8/javascriptprimtypes.swg0000664000175000017500000001016612641054563022443 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(bool)(bool value) { return SWIGV8_BOOLEAN_NEW(value); } } %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(v8::Handle obj, bool *val) { if(!obj->IsBoolean()) { return SWIG_ERROR; } if (val) *val = obj->BooleanValue(); return SWIG_OK; } } /* int */ %fragment(SWIG_From_frag(int),"header") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(int)(int value) { return SWIGV8_INT32_NEW(value); } } %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERN int SWIG_AsVal_dec(int)(v8::Handle valRef, int* val) { if (!valRef->IsNumber()) { return SWIG_TypeError; } if(val) *val = valRef->IntegerValue(); return SWIG_OK; } } /* long */ %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(long)(long value) { return SWIGV8_NUMBER_NEW(value); } } %fragment(SWIG_AsVal_frag(long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long)(v8::Handle obj, long* val) { if (!obj->IsNumber()) { return SWIG_TypeError; } if(val) *val = (long) obj->IntegerValue(); return SWIG_OK; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE v8::Handle SWIG_From_dec(unsigned long)(unsigned long value) { return (value > LONG_MAX) ? SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(v8::Handle obj, unsigned long *val) { if(!obj->IsNumber()) { return SWIG_TypeError; } long longVal = (long) obj->NumberValue(); if(longVal < 0) { return SWIG_OverflowError; } if(val) *val = longVal; return SWIG_OK; } } /* long long */ // Note: these are copied from 'long' and probably need fixing %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(long long)(long long value) { return SWIGV8_NUMBER_NEW(value); } } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val) { if (!obj->IsNumber()) { return SWIG_TypeError; } if(val) *val = (long long) obj->IntegerValue(); return SWIG_OK; } } /* unsigned long long */ // Note: these are copied from 'unsigned long' and probably need fixing %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERNINLINE v8::Handle SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(v8::Handle obj, unsigned long long *val) { if(!obj->IsNumber()) { return SWIG_TypeError; } long long longVal = (long long) obj->NumberValue(); if(longVal < 0) { return SWIG_OverflowError; } if(val) *val = longVal; return SWIG_OK; } } /* double */ %fragment(SWIG_From_frag(double),"header") { SWIGINTERN v8::Handle SWIG_From_dec(double) (double val) { return SWIGV8_NUMBER_NEW(val); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(v8::Handle obj, double *val) { if(!obj->IsNumber()) { return SWIG_TypeError; } if(val) *val = obj->NumberValue(); return SWIG_OK; } } swig-3.0.8/Lib/javascript/v8/javascriptkw.swg0000664000175000017500000000176712641054563021037 0ustar williamwilliam#ifndef JAVASCRIPT_JAVASCRIPTKW_SWG_ #define JAVASCRIPT_JAVASCRIPTKW_SWG_ /* Warnings for Java keywords */ #define JAVASCRIPTKW(x) %keywordwarn("'" `x` "' is a javascript keyword, renaming to '_"`x`"'",rename="_%s") `x` /* Taken from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words */ JAVASCRIPTKW(break); JAVASCRIPTKW(case); JAVASCRIPTKW(catch); JAVASCRIPTKW(continue); JAVASCRIPTKW(default); JAVASCRIPTKW(delete); JAVASCRIPTKW(do); JAVASCRIPTKW(else); JAVASCRIPTKW(finally); JAVASCRIPTKW(for); JAVASCRIPTKW(function); JAVASCRIPTKW(if); JAVASCRIPTKW(in); JAVASCRIPTKW(instanceof); JAVASCRIPTKW(new); JAVASCRIPTKW(return); JAVASCRIPTKW(switch); JAVASCRIPTKW(this); JAVASCRIPTKW(throw); JAVASCRIPTKW(try); JAVASCRIPTKW(typeof); JAVASCRIPTKW(var); JAVASCRIPTKW(void); JAVASCRIPTKW(while); JAVASCRIPTKW(with); /* others bad names if any*/ // for example %namewarn("321:clone() is a javascript bad method name") *::clone(); #undef JAVASCRIPTKW #endif //JAVASCRIPT_JAVASCRIPTKW_SWG_ swig-3.0.8/Lib/javascript/v8/javascriptcode.swg0000664000175000017500000004401212641054563021316 0ustar williamwilliam/* ----------------------------------------------------------------------------- * js_ctor: template for wrapping a ctor. * - $jswrapper: wrapper of called ctor * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * - $jsargcount: number of arguments * - $jsmangledtype: mangled type of class * ----------------------------------------------------------------------------- */ %fragment("js_ctor", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); v8::Handle self = args.Holder(); $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); SWIGV8_RETURN(self); goto fail; fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } %} /* ----------------------------------------------------------------------------- * js_veto_ctor: a vetoing ctor for abstract classes * - $jswrapper: name of wrapper * - $jsname: class name * ----------------------------------------------------------------------------- */ %fragment ("js_veto_ctor", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated"); SWIGV8_RETURN(SWIGV8_UNDEFINED()); } %} /* ----------------------------------------------------------------------------- * js_ctor_dispatcher: dispatcher for overloaded constructors * - $jswrapper: name of wrapper * - $jsname: class name * - $jsdispatchcases: part containing code for dispatching * ----------------------------------------------------------------------------- */ %fragment ("js_ctor_dispatcher", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); OverloadErrorHandler errorHandler; v8::Handle self; // switch all cases by means of series of if-returns. $jsdispatchcases // default: SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsmangledname"); fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } %} /* ----------------------------------------------------------------------------- * js_overloaded_ctor: template for wrapping a ctor. * - $jswrapper: wrapper of called ctor * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * - $jsargcount: number of arguments * - $jsmangledtype: mangled type of class * ----------------------------------------------------------------------------- */ %fragment("js_overloaded_ctor", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler &SWIGV8_ErrorHandler) { SWIGV8_HANDLESCOPE(); v8::Handle self = args.Holder(); $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); SWIGV8_RETURN(self); goto fail; fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } %} /* ----------------------------------------------------------------------------- * js_ctor_dispatch_case: template for a dispatch case for calling an overloaded ctor. * - $jsargcount: number of arguments of called ctor * - $jswrapper: wrapper of called ctor * * Note: a try-catch-like mechanism is used to switch cases * ----------------------------------------------------------------------------- */ %fragment ("js_ctor_dispatch_case", "templates") %{ if(args.Length() == $jsargcount) { errorHandler.err.Clear(); #if (SWIG_V8_VERSION < 0x031903) self = $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { SWIGV8_ESCAPE(self); } #else $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { return; } #endif } %} /* ----------------------------------------------------------------------------- * js_dtor: template for a destructor wrapper * - $jsmangledname: mangled class name * - $jstype: class type * ----------------------------------------------------------------------------- */ %fragment ("js_dtor", "templates") %{ #if (SWIG_V8_VERSION < 0x031710) static void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); #elif (SWIG_V8_VERSION < 0x031900) static void $jswrapper(v8::Isolate *isolate, v8::Persistent object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) static void $jswrapper(v8::Isolate *isolate, v8::Persistent *object, SWIGV8_Proxy *proxy) { #else static void $jswrapper(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SWIGV8_Proxy *proxy = data.GetParameter(); #endif if(proxy->swigCMemOwn && proxy->swigCObject) { #ifdef SWIGRUNTIME_DEBUG printf("Deleting wrapped instance: %s\n", proxy->info->name); #endif $jsfree proxy->swigCObject; } delete proxy; object.Clear(); #if (SWIG_V8_VERSION < 0x031710) object.Dispose(); #elif (SWIG_V8_VERSION < 0x031900) object.Dispose(isolate); #elif (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); #else object->Dispose(); #endif } %} /* ----------------------------------------------------------------------------- * js_dtoroverride: template for a destructor wrapper * - $jsmangledname: mangled class name * - $jstype: class type * - ${destructor_action}: The custom destructor action to invoke. * ----------------------------------------------------------------------------- */ %fragment ("js_dtoroverride", "templates") %{ #if (SWIG_V8_VERSION < 0x031710) static void $jswrapper(v8::Persistent object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); #elif (SWIG_V8_VERSION < 0x031900) static void $jswrapper(v8::Isolate *isolate, v8::Persistent object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) static void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object> *object, SWIGV8_Proxy *proxy) { #else static void $jswrapper(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SWIGV8_Proxy *proxy = data.GetParameter(); #endif if(proxy->swigCMemOwn && proxy->swigCObject) { $jstype arg1 = ($jstype)proxy->swigCObject; ${destructor_action} } delete proxy; #if (SWIG_V8_VERSION < 0x031710) object.Dispose(); #elif (SWIG_V8_VERSION < 0x031900) object.Dispose(isolate); #elif (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); #elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) object->Dispose(); #else object.Clear(); #endif } %} /* ----------------------------------------------------------------------------- * js_getter: template for getter function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment("js_getter", "templates") %{ static SwigV8ReturnValue $jswrapper(v8::Local property, const SwigV8PropertyCallbackInfo &info) { SWIGV8_HANDLESCOPE(); v8::Handle jsresult; $jslocals $jscode SWIGV8_RETURN_INFO(jsresult, info); goto fail; fail: SWIGV8_RETURN_INFO(SWIGV8_UNDEFINED(), info); } %} /* ----------------------------------------------------------------------------- * js_setter: template for setter function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment("js_setter", "templates") %{ static void $jswrapper(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid &info) { SWIGV8_HANDLESCOPE(); $jslocals $jscode goto fail; fail: return; } %} /* ----------------------------------------------------------------------------- * js_function: template for function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment("js_function", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); v8::Handle jsresult; $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode SWIGV8_RETURN(jsresult); goto fail; fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } %} /* ----------------------------------------------------------------------------- * js_function_dispatcher: template for a function dispatcher for overloaded functions * - $jswrapper: wrapper function name * - $jsname: name of the wrapped function * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment("js_function_dispatcher", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); v8::Handle jsresult; OverloadErrorHandler errorHandler; $jscode SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname."); goto fail; fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } %} /* ----------------------------------------------------------------------------- * js_overloaded_function: template for a overloaded function * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_overloaded_function", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler &SWIGV8_ErrorHandler) { SWIGV8_HANDLESCOPE(); v8::Handle jsresult; $jslocals $jscode SWIGV8_RETURN(jsresult); goto fail; fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } %} /* ----------------------------------------------------------------------------- * js_function_dispatch_case: template for a case used in the function dispatcher * - $jswrapper: wrapper function name * - $jsargcount: number of arguments of overloaded function * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_function_dispatch_case", "templates") %{ if(args.Length() == $jsargcount) { errorHandler.err.Clear(); #if (SWIG_V8_VERSION < 0x031903) jsresult = $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { SWIGV8_ESCAPE(jsresult); } #else $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { return; } #endif } %} /* ----------------------------------------------------------------------------- * jsv8_declare_class_template: template for a class template declaration. * - $jsmangledname: mangled class name * ----------------------------------------------------------------------------- */ %fragment("jsv8_declare_class_template", "templates") %{ SWIGV8_ClientData $jsmangledname_clientData; %} /* ----------------------------------------------------------------------------- * jsv8_define_class_template: template for a class template definition. * - $jsmangledname: mangled class name * - $jsmangledtype: mangled class type * - $jsdtor: the dtor wrapper * ----------------------------------------------------------------------------- */ %fragment("jsv8_define_class_template", "templates") %{ /* Name: $jsmangledname, Type: $jsmangledtype, Dtor: $jsdtor */ v8::Handle $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname"); SWIGV8_SET_CLASS_TEMPL($jsmangledname_clientData.class_templ, $jsmangledname_class); $jsmangledname_clientData.dtor = $jsdtor; if (SWIGTYPE_$jsmangledtype->clientdata == 0) { SWIGTYPE_$jsmangledtype->clientdata = &$jsmangledname_clientData; } %} /* ----------------------------------------------------------------------------- * jsv8_inherit: template for an class inherit statement. * - $jsmangledname: mangled class name * - $jsbaseclass: mangled name of the base class * ----------------------------------------------------------------------------- */ %fragment("jsv8_inherit", "templates") %{ if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty())) { #if (SWIG_V8_VERSION < 0x031903) $jsmangledname_class->Inherit(static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ); #else $jsmangledname_class->Inherit( v8::Local::New( v8::Isolate::GetCurrent(), static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ) ); #endif #ifdef SWIGRUNTIME_DEBUG printf("Inheritance successful $jsmangledname $jsbaseclass\n"); #endif } else { #ifdef SWIGRUNTIME_DEBUG printf("Unable to inherit baseclass, it didn't exist $jsmangledname $jsbaseclass\n"); #endif } %} /* ----------------------------------------------------------------------------- * jsv8_create_class_instance: template for creating an class object. * - $jsname: class name * - $jsmangledname: mangled class name * ----------------------------------------------------------------------------- */ %fragment("jsv8_create_class_instance", "templates") %{ /* Class: $jsname ($jsmangledname) */ v8::Handle $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname"); $jsmangledname_class_0->SetCallHandler($jsctor); $jsmangledname_class_0->Inherit($jsmangledname_class); $jsmangledname_class_0->SetHiddenPrototype(true); v8::Handle $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); %} /* ----------------------------------------------------------------------------- * jsv8_register_class: template for a statement that registers a class in a parent namespace. * - $jsname: class name * - $jsmangledname: mangled class name * - $jsparent: mangled name of parent namespace * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_class", "templates") %{ $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); %} /* ----------------------------------------------------------------------------- * jsv8_create_namespace: template for a statement that creates a namespace object. * - $jsmangledname: mangled namespace name * ----------------------------------------------------------------------------- */ %fragment("jsv8_create_namespace", "templates") %{ v8::Handle $jsmangledname_obj = SWIGV8_OBJECT_NEW(); %} /* ----------------------------------------------------------------------------- * jsv8_register_namespace: template for a statement that registers a namespace in a parent namespace. * - $jsname: name of namespace * - $jsmangledname: mangled name of namespace * - $jsparent: mangled name of parent namespace * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_namespace", "templates") %{ $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); %} /* ----------------------------------------------------------------------------- * jsv8_register_member_function: template for a statement that registers a member function. * - $jsmangledname: mangled class name * - $jsname: name of the function * - $jswrapper: wrapper of the member function * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_member_function", "templates") %{ SWIGV8_AddMemberFunction($jsmangledname_class, "$jsname", $jswrapper); %} /* ----------------------------------------------------------------------------- * jsv8_register_member_variable: template for a statement that registers a member variable. * - $jsmangledname: mangled class name * - $jsname: name of the function * - $jsgetter: wrapper of the getter function * - $jssetter: wrapper of the setter function * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_member_variable", "templates") %{ SWIGV8_AddMemberVariable($jsmangledname_class, "$jsname", $jsgetter, $jssetter); %} /* ----------------------------------------------------------------------------- * jsv8_register_static_function: template for a statement that registers a static class function. * - $jsname: function name * - $jswrapper: wrapper of the function * - $jsparent: mangled name of parent namespace * * Note: this template is also used for global functions. * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_static_function", "templates") %{ SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper); %} /* ----------------------------------------------------------------------------- * jsv8_register_static_variable: template for a statement that registers a static variable. * - $jsname: variable name * - $jsparent: mangled name of parent namespace * - $jsgetter: wrapper of the getter function * - $jssetter: wrapper of the setter function * * Note: this template is also used for global variables. * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_static_variable", "templates") %{ SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter); %} swig-3.0.8/Lib/javascript/v8/std_complex.i0000664000175000017500000000073212641054563020267 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.8/Lib/javascript/jsc/0000775000175000017500000000000012641054563016014 5ustar williamwilliamswig-3.0.8/Lib/javascript/jsc/std_pair.i0000664000175000017500000000131012641054563017766 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/javascript/jsc/javascripttypemaps.swg0000664000175000017500000000367412641054563022501 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Javascript * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* These macros are necessary to provide an extra parameter to SWIG_AsVal_dec functions (JSContextRef context). They must be defined before including `typemaps/fragments.swg` */ #define SWIG_FROM_DECL_ARGS SWIG_JSC_FROM_DECL_ARGS #define SWIG_FROM_CALL_ARGS SWIG_JSC_FROM_CALL_ARGS #define SWIG_AS_DECL_ARGS SWIG_JSC_AS_DECL_ARGS #define SWIG_AS_CALL_ARGS SWIG_JSC_AS_CALL_ARGS /* Include fundamental fragemt definitions */ %include /* Look for user fragments file. */ %include /* Javascript fragments for fundamental types */ %include /* Javascript fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ #define SWIG_Object JSValueRef #define VOID_Object JSValueMakeUndefined(context) /* append output */ #define SWIG_AppendOutput(result, obj) SWIGJSC_AppendOutput(context, result, obj) /* set constant */ #define SWIG_SetConstant(name, obj) /* raise */ #define SWIG_Raise(obj, type, desc) SWIG_Javascript_Raise(context, exception, type) %insert("runtime") %{ #define SWIG_JSC_FROM_DECL_ARGS(arg1) (JSContextRef context, arg1) #define SWIG_JSC_FROM_CALL_ARGS(arg1) (context, arg1) #define SWIG_JSC_AS_DECL_ARGS(arg1, arg2) (JSContextRef context, arg1, arg2) #define SWIG_JSC_AS_CALL_ARGS(arg1, arg2) (context, arg1, arg2) %} /* Include the unified typemap library */ %include swig-3.0.8/Lib/javascript/jsc/javascriptrun.swg0000664000175000017500000002373512641054563021443 0ustar williamwilliam/* ---------------------------------------------------------------------------- * Errors and exceptions * * ---------------------------------------------------------------------------*/ #define SWIG_Error(code, msg) SWIG_JSC_exception(context, exception, code, msg) #define SWIG_exception(code, msg) SWIG_JSC_exception(context, exception, code, msg) #define SWIG_fail goto fail SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) { JSStringRef message = JSStringCreateWithUTF8CString(type); JSValueRef error_arguments[1]; JSObjectRef exception_object; JSValueRef exception_value; exception_value = JSValueMakeString(context, message); /* Converting the result to an object will let JavascriptCore add "sourceURL" (file) and "line" (number) and "message" to the exception, instead of just returning a raw string. This is extremely important for debugging your errors. Using JSObjectMakeError is better than JSValueToObject because the latter only populates "sourceURL" and "line", but not "message" or any others I don't know about. */ error_arguments[0] = exception_value; exception_object = JSObjectMakeError(context, 1, error_arguments, NULL); /* Return the exception_object */ *exception = exception_object; JSStringRelease(message); } SWIGRUNTIME void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) { SWIG_Javascript_Raise(context, exception, msg); } /* ---------------------------------------------------------------------------- * The parent class of all Proxies * * ---------------------------------------------------------------------------*/ typedef struct { bool swigCMemOwn; void *swigCObject; swig_type_info *info; } SwigPrivData; SWIGRUNTIME JSValueRef _wrap_SwigObject_disown(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { JSValueRef jsresult; JSObjectRef obj = JSValueToObject(context, thisObject, NULL); SwigPrivData *cdata = (SwigPrivData *) JSObjectGetPrivate(obj); cdata->swigCMemOwn = false; jsresult = JSValueMakeUndefined(context); return jsresult; } SWIGRUNTIME JSValueRef _wrap_SwigObject_getCPtr(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { JSValueRef jsresult; long result; JSObjectRef obj = JSValueToObject(context, thisObject, NULL); SwigPrivData *cdata = (SwigPrivData*) JSObjectGetPrivate(obj); result = (long) cdata->swigCObject; jsresult = JSValueMakeNumber(context, result); return jsresult; } SWIGRUNTIME JSValueRef _wrap_SwigObject_equals(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { JSValueRef jsresult; bool result; JSObjectRef obj = JSValueToObject(context, thisObject, NULL); SwigPrivData *cdata = (SwigPrivData*) JSObjectGetPrivate(obj); JSObjectRef obj2 = JSValueToObject(context, argv[0], NULL); SwigPrivData *cdata2 = (SwigPrivData*) JSObjectGetPrivate(obj2); result = (cdata->swigCObject == cdata2->swigCObject); jsresult = JSValueMakeBoolean(context, result); return jsresult; } SWIGRUNTIME JSStaticValue _SwigObject_values[] = { { 0, 0, 0, 0 } }; SWIGRUNTIME JSStaticFunction _SwigObject_functions[] = { { "disown",_wrap_SwigObject_disown, kJSPropertyAttributeNone }, { "equals",_wrap_SwigObject_equals, kJSPropertyAttributeNone }, { "getCPtr",_wrap_SwigObject_getCPtr, kJSPropertyAttributeNone }, { 0, 0, 0 } }; SWIGRUNTIME JSClassDefinition _SwigObject_objectDefinition; SWIGRUNTIME JSClassRef _SwigObject_classRef; SWIGRUNTIME int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef objRef, void** ptr, swig_type_info *info, int flags) { SwigPrivData *cdata; cdata = (SwigPrivData *) JSObjectGetPrivate(objRef); if(cdata == NULL) { return SWIG_ERROR; } if(cdata->info != info) { bool type_valid = false; swig_cast_info *t = info->cast; while(t != NULL) { if(t->type == cdata->info) { type_valid = true; break; } t = t->next; } if(!type_valid) { return SWIG_TypeError; } } *ptr = cdata->swigCObject; if(flags & SWIG_POINTER_DISOWN) { cdata->swigCMemOwn = false; } return SWIG_OK; } SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, void** ptr, swig_type_info *info, int flags) { JSObjectRef objRef; /* special case: JavaScript null => C NULL pointer */ if(JSValueIsNull(context, valRef)) { *ptr=0; return SWIG_OK; } if(!JSValueIsObject(context, valRef)) { return SWIG_TypeError; } objRef = JSValueToObject(context, valRef, NULL); if(objRef == NULL) { return SWIG_ERROR; } return SWIG_JSC_ConvertInstancePtr(context, objRef, ptr, info, flags); } SWIGRUNTIME JSObjectRef SWIG_JSC_NewPointerObj(JSContextRef context, void *ptr, swig_type_info *info, int flags) { JSClassRef classRef; JSObjectRef result; SwigPrivData *cdata; if (ptr == NULL) { // HACK: it is not possible to use JSValueToObject (causing seg-fault) // This static cast turned out to be a workaround // In future, we should change the interface of this method // to return JSValueRef instead of JSObjectRef. return (JSObjectRef) JSValueMakeNull(context); } if(info->clientdata == NULL) { classRef = _SwigObject_classRef; } else { classRef = (JSClassRef) info->clientdata; } result = JSObjectMake(context, classRef, NULL); cdata = (SwigPrivData*) malloc(sizeof(SwigPrivData)); cdata->swigCObject = ptr; cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0; cdata->info = info; JSObjectSetPrivate(result, cdata); return result; } #define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_JSC_ConvertPtr(context, obj, ptr, info, flags) #define SWIG_NewPointerObj(ptr, info, flags) SWIG_JSC_NewPointerObj(context, ptr, info, flags) #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_JSC_ConvertInstancePtr(context, obj, pptr, type, flags) #define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_JSC_NewPointerObj(context, thisvalue, type, flags) #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_JSC_ConvertPtr(context, obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_JSC_NewPointerObj(context, ptr, type, 0) /* ---------------------------------------------------------------------------- * A class for packed data * * ---------------------------------------------------------------------------*/ typedef struct { void *data; size_t size; swig_type_info *type; } SwigPackedData; SWIGRUNTIME JSStaticValue _SwigPackedData_values[] = { { 0, 0, 0, 0 } }; SWIGRUNTIME JSStaticFunction _SwigPackedData_functions[] = { { 0, 0, 0 } }; SWIGRUNTIME JSClassDefinition _SwigPackedData_objectDefinition; SWIGRUNTIME JSClassRef _SwigPackedData_classRef; SWIGRUNTIMEINLINE int SwigJSCPacked_Check(JSContextRef context, JSValueRef valRef) { return JSValueIsObjectOfClass(context, valRef, _SwigPackedData_classRef); } SWIGRUNTIME swig_type_info* SwigJSCPacked_UnpackData(JSContextRef context, JSValueRef valRef, void *ptr, size_t size) { if (SwigJSCPacked_Check(context, valRef)) { JSObjectRef objRef = JSValueToObject(context, valRef, NULL); SwigPackedData *sobj = (SwigPackedData *) JSObjectGetPrivate(objRef); if (sobj->size != size) return 0; memcpy(ptr, sobj->data, size); return sobj->type; } else { return 0; } } SWIGRUNTIME int SWIG_JSC_ConvertPacked(JSContextRef context, JSValueRef valRef, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigJSCPacked_UnpackData(context, valRef, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } SWIGRUNTIME JSValueRef SWIG_JSC_NewPackedObj(JSContextRef context, void *data, size_t size, swig_type_info *type) { JSClassRef classRef = _SwigObject_classRef; JSObjectRef result = JSObjectMake(context, classRef, NULL); SwigPackedData* cdata = (SwigPackedData*) malloc(sizeof(SwigPackedData)); cdata->data = data; cdata->size = size; cdata->type = type; JSObjectSetPrivate(result, cdata); return result; } /* SwigPackedData wrappers */ SWIGRUNTIME void _wrap_SwigPackedData_delete(JSObjectRef obj) { SwigPackedData* cdata = (SwigPackedData*) JSObjectGetPrivate(obj); if (cdata) { free(cdata->data); } } /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_JSC_ConvertPacked(context, obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_JSC_NewPackedObj(context, ptr, sz, type) /* --------------------------------------------------------------------------- * Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg) * * ---------------------------------------------------------------------------*/ SWIGRUNTIME unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) { static JSStringRef LENGTH = 0; JSValueRef exception = NULL; JSValueRef js_length; double length; if (LENGTH == 0) { LENGTH = JSStringCreateWithUTF8CString("length"); } js_length = JSObjectGetProperty(context, arr, LENGTH, &exception); if (exception == 0 && JSValueIsNumber(context, js_length)) { length = JSValueToNumber(context, js_length, 0); return (unsigned int) length; } else { return 0; } } SWIGRUNTIME JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueRef obj) { JSObjectRef arr; unsigned int length; if (JSValueIsUndefined(context, value)) { arr = JSObjectMakeArray(context, 0, 0, 0); } else { arr = JSValueToObject(context, value, 0); } length = SWIGJSC_ArrayLength(context, arr); JSObjectSetPropertyAtIndex(context, arr, length, obj, 0); return arr; } swig-3.0.8/Lib/javascript/jsc/std_except.i0000664000175000017500000000004312641054563020325 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/jsc/cdata.i0000664000175000017500000000003612641054563017241 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/jsc/exception.i0000664000175000017500000000004212641054563020160 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/jsc/std_deque.i0000664000175000017500000000003412641054563020140 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/jsc/javascriptcomplex.swg0000664000175000017500000000721612641054563022302 0ustar williamwilliam/* Defines the As/From converters for double/float complex, you need to provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex accessor methods. See the std_complex.i and ccomplex.i for concrete examples. */ /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header", fragment=SWIG_From_frag(double)) { SWIGINTERNINLINE JSObjectRef SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) { JSValueRef vals[2]; vals[0] = SWIG_From(double)(Real(c)); vals[1] = SWIG_From(double)(Imag(c)); return JSObjectMakeArray(context, 2, vals, NULL); } } %enddef /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal_dec(Type) (JSValueRef o, Type* val) { if (JSValueIsObject(context, o)) { JSObjectRef array; JSValueRef exception, js_re, js_im; double re, im; int res; exception = 0; res = 0; array = JSValueToObject(context, o, &exception); if(exception != 0) return SWIG_TypeError; js_re = JSObjectGetPropertyAtIndex(context, array, 0, &exception); if(exception != 0) return SWIG_TypeError; js_im = JSObjectGetPropertyAtIndex(context, array, 1, &exception); if(exception != 0) return SWIG_TypeError; res = SWIG_AsVal(double)(js_re, &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } res = SWIG_AsVal(double)(js_im, &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } if (val) *val = Constructor(re, im); return SWIG_OK; } else { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef /* the float case */ %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int SWIG_AsVal_dec(Type)(JSValueRef o, Type *val) { if (JSValueIsObject(context, o)) { JSObjectRef array; JSValueRef exception, js_re, js_im; double re, im; int res; exception = 0; res = 0; array = JSValueToObject(context, o, &exception); if(exception != 0) return SWIG_TypeError; js_re = JSObjectGetPropertyAtIndex(context, array, 0, &exception); if(exception != 0) return SWIG_TypeError; js_im = JSObjectGetPropertyAtIndex(context, array, 1, &exception); if(exception != 0) return SWIG_TypeError; res = SWIG_AsVal(double)(js_re, &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } res = SWIG_AsVal(double)(js_im, &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else { return SWIG_OverflowError; } } else { float re; int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(re, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.8/Lib/javascript/jsc/std_common.i0000664000175000017500000000014612641054563020331 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.8/Lib/javascript/jsc/complex.i0000664000175000017500000000012012641054563017626 0ustar williamwilliam#ifdef __cplusplus %include #else %include #endif swig-3.0.8/Lib/javascript/jsc/javascript.swg0000664000175000017500000000066712641054563020715 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javascript.swg * * Javascript typemaps * ----------------------------------------------------------------------------- */ %include %include %include %include %include %include %include swig-3.0.8/Lib/javascript/jsc/javascripthelpers.swg0000664000175000017500000000450412641054563022272 0ustar williamwilliam%insert(wrapper) %{ SWIGINTERN bool JS_registerClass(JSGlobalContextRef context, JSObjectRef parentObject, const char* className, JSClassDefinition* definition) { JSStringRef js_className = JSStringCreateWithUTF8CString(className); JSObjectRef classObject = JSObjectMake(context, JSClassCreate(definition), NULL); JSObjectSetProperty(context, parentObject, js_className, classObject, kJSPropertyAttributeNone, NULL); JSStringRelease(js_className); return true; } SWIGINTERN bool JS_registerNamespace(JSGlobalContextRef context, JSObjectRef namespaceObj, JSObjectRef parentNamespace, const char* name) { JSStringRef js_name = JSStringCreateWithUTF8CString(name); JSObjectSetProperty(context, parentNamespace, js_name, namespaceObj, kJSPropertyAttributeNone, NULL); JSStringRelease(js_name); return true; } SWIGINTERN bool JS_registerFunction(JSGlobalContextRef context, JSObjectRef object, const char* functionName, JSObjectCallAsFunctionCallback callback) { JSStringRef js_functionName = JSStringCreateWithUTF8CString(functionName); JSObjectSetProperty(context, object, js_functionName, JSObjectMakeFunctionWithCallback(context, js_functionName, callback), kJSPropertyAttributeNone, NULL); JSStringRelease(js_functionName); return true; } SWIGINTERN bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { char buffer[256]; char msg[512]; int res; JSStringGetUTF8CString(propertyName, buffer, 256); res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); if(res<0) { SWIG_exception(SWIG_ERROR, "Tried to write read-only variable."); } else { SWIG_exception(SWIG_ERROR, msg); } return false; } SWIGINTERN JSValueRef JS_CharPtrToJSValue(JSContextRef context, char* cstr) { JSValueRef val; JSStringRef jsstring = JSStringCreateWithUTF8CString((char*) cstr); val = JSValueMakeString(context, jsstring); JSStringRelease(jsstring); return val; } %} swig-3.0.8/Lib/javascript/jsc/javascriptinit.swg0000664000175000017500000000402012641054563021564 0ustar williamwilliam%insert(init) %{ SWIGRUNTIME void SWIG_JSC_SetModule(swig_module_info *swig_module) {} SWIGRUNTIME swig_module_info * SWIG_JSC_GetModule(void) { return 0; } #define SWIG_GetModule(clientdata) SWIG_JSC_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(pointer) %} %insert(init) "swiginit.swg" %fragment ("js_initializer_define", "templates") %{ #define SWIGJSC_INIT $jsname_initialize %} // Open the initializer function %insert(init) %{ #ifdef __cplusplus extern "C" { #endif bool SWIGJSC_INIT (JSGlobalContextRef context, JSObjectRef *exports) { SWIG_InitializeModule(0); %} /* ----------------------------------------------------------------------------- * js_initializer: template for the module initializer function * - $jsname: module name * - $jscreatenamespaces: part with code for creating namespace objects * - $jscreateclasses: part with code for creating classes * - $jsregisternamespaces: part with code for registration of namespaces * ----------------------------------------------------------------------------- */ %fragment ("js_initializer", "templates") %{ /* Initialize the base swig type object */ _SwigObject_objectDefinition.staticFunctions = _SwigObject_functions; _SwigObject_objectDefinition.staticValues = _SwigObject_values; _SwigObject_classRef = JSClassCreate(&_SwigObject_objectDefinition); /* Initialize the PackedData class */ _SwigPackedData_objectDefinition.staticFunctions = _SwigPackedData_functions; _SwigPackedData_objectDefinition.staticValues = _SwigPackedData_values; _SwigPackedData_objectDefinition.finalize = _wrap_SwigPackedData_delete; _SwigPackedData_classRef = JSClassCreate(&_SwigPackedData_objectDefinition); /* Create objects for namespaces */ $jscreatenamespaces /* Register classes */ $jsregisterclasses /* Register namespaces */ $jsregisternamespaces *exports = exports_object; return true; } #ifdef __cplusplus } #endif %} swig-3.0.8/Lib/javascript/jsc/javascriptruntime.swg0000664000175000017500000000105512641054563022311 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javascriptruntime.swg * * Javascript support code * ----------------------------------------------------------------------------- */ %insert(runtime) %{ #include #include #include #include #include #include %} %insert(runtime) "swigrun.swg"; /* SWIG API */ %insert(runtime) "swigerrors.swg"; /* SWIG errors */ %insert(runtime) "javascriptrun.swg"; /* SWIG errors */ swig-3.0.8/Lib/javascript/jsc/std_map.i0000664000175000017500000000444112641054563017620 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.8/Lib/javascript/jsc/javascriptstrings.swg0000664000175000017500000001350012641054563022315 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_JSC_AsCharPtrAndSize(JSContextRef context, JSValueRef valRef, char** cptr, size_t* psize, int *alloc) { if(JSValueIsString(context, valRef)) { JSStringRef js_str = JSValueToStringCopy(context, valRef, NULL); size_t len = JSStringGetMaximumUTF8CStringSize(js_str); char* cstr = (char*) %new_array(len, char); /* JSStringGetUTF8CString returns the length including 0-terminator */ len = JSStringGetUTF8CString(js_str, cstr, len); if(alloc) *alloc = SWIG_NEWOBJ; if(psize) *psize = len; if(cptr) *cptr = cstr; return SWIG_OK; } else { if(JSValueIsObject(context, valRef)) { JSObjectRef obj = JSValueToObject(context, valRef, NULL); // try if the object is a wrapped char[] swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } return SWIG_TypeError; } else { return SWIG_TypeError; } } } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE JSValueRef SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { // TODO: handle extra long strings //swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); //return pchar_descriptor ? // SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); return JSValueMakeUndefined(context); } else { JSStringRef jsstring; JSValueRef result; if(size < 2) { char c[2]; int i; for(i=0;i * %inline %{ * extern int FiddleSticks[3]; * %} * * Use from JavaScript like this: * * var fs = [10, 11, 12]; * example.FiddleSticks = fs; * fs = example.FiddleSticks; * ----------------------------------------------------------------------------- */ %fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {} %fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_frag(double)) {} %typemap(in, fragment="SWIG_JSCGetIntProperty") int[], int[ANY] (int length = 0, JSObjectRef array, JSValueRef jsvalue, int i = 0, int res = 0, $*1_ltype temp) { if (JSValueIsObject(context, $input)) { // Convert into Array array = JSValueToObject(context, $input, NULL); length = $1_dim0; $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length); // Get each element from array for (i = 0; i < length; i++) { jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL); // Get primitive value from JSObject res = SWIG_AsVal(int)(jsvalue, &temp); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double"); } arg$argnum[i] = temp; } } else { SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef"); } } %typemap(freearg) int[], int[ANY] { free($1); } %typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0) { length = $1_dim0; JSValueRef values[length]; for (i = 0; i < length; i++) { values[i] = SWIG_From(int)($1[i]); } $result = JSObjectMakeArray(context, length, values, NULL); } %typemap(in, fragment="SWIG_JSCGetNumberProperty") double[], double[ANY] (int length = 0, JSObjectRef array, JSValueRef jsvalue, int i = 0, int res = 0, $*1_ltype temp) { if (JSValueIsObject(context, $input)) { // Convert into Array array = JSValueToObject(context, $input, NULL); length = $1_dim0; $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length); // Get each element from array for (i = 0; i < length; i++) { jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL); // Get primitive value from JSObject res = SWIG_AsVal(double)(jsvalue, &temp); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double"); } arg$argnum[i] = temp; } } else { SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef"); } } %typemap(freearg) double[], double[ANY] { free($1); } %typemap(out, fragment=SWIG_From_frag(double)) double[], double[ANY] (int length = 0, int i = 0) { length = $1_dim0; JSValueRef values[length]; for (i = 0; i < length; i++) { values[i] = SWIG_From(double)($1[i]); } $result = JSObjectMakeArray(context, length, values, NULL); } swig-3.0.8/Lib/javascript/jsc/std_string.i0000664000175000017500000000004312641054563020343 0ustar williamwilliam%include swig-3.0.8/Lib/javascript/jsc/javascriptfragments.swg0000664000175000017500000000105712641054563022616 0ustar williamwilliam/* Create a file with this name, 'javascriptfragments.swg', in your working directory and add all the %fragments you want to take precedence over the default ones defined by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(PyObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.8/Lib/javascript/jsc/stl.i0000664000175000017500000000044312641054563016771 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/javascript/jsc/typemaps.i0000664000175000017500000001047612641054563020040 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * These mappings provide support for input/output arguments and common * uses for C/C++ pointers. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Python tuple. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Python output of the function would be a tuple containing both output values. */ // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Python tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Python). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Python variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %include swig-3.0.8/Lib/javascript/jsc/std_vector.i0000664000175000017500000000511112641054563020340 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i * ----------------------------------------------------------------------------- */ %include %{ #include %} /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) %swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); swig-3.0.8/Lib/javascript/jsc/javascriptprimtypes.swg0000664000175000017500000001000112641054563022651 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE JSValueRef SWIG_From_dec(bool)(bool value) { return JSValueMakeBoolean(context, value); } } %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(JSValueRef obj, bool *val) { if(!JSValueIsBoolean(context, obj)) { return SWIG_ERROR; } if (val) *val = JSValueToBoolean(context, obj); return SWIG_OK; } } /* int */ %fragment(SWIG_From_frag(int),"header") { SWIGINTERNINLINE JSValueRef SWIG_From_dec(int)(int value) { return JSValueMakeNumber(context, value); } } /* long */ %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE JSValueRef SWIG_From_dec(long)(long value) { return JSValueMakeNumber(context, value); } } %fragment(SWIG_AsVal_frag(long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long)(JSValueRef obj, long* val) { if (!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } if(val) *val = (long) JSValueToNumber(context, obj, NULL); return SWIG_OK; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE JSValueRef SWIG_From_dec(unsigned long)(unsigned long value) { return (value > LONG_MAX) ? JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(JSValueRef obj, unsigned long *val) { long longVal; if(!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } longVal = (long) JSValueToNumber(context, obj, NULL); if(longVal < 0) { return SWIG_OverflowError; } if(val) *val = longVal; return SWIG_OK; } } /* long long */ // Note: these are copied from 'long' and probably need fixing %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE JSValueRef SWIG_From_dec(long long)(long long value) { return JSValueMakeNumber(context, value); } } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(long long)(JSValueRef obj, long long* val) { if (!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } if(val) *val = (long long) JSValueToNumber(context, obj, NULL); return SWIG_OK; } } /* unsigned long long */ // Note: these are copied from 'unsigned long' and probably need fixing %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERN JSValueRef SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(JSValueRef obj, unsigned long long *val) { long long longVal; if(!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } longVal = (unsigned long long) JSValueToNumber(context, obj, NULL); if(longVal < 0) { return SWIG_OverflowError; } if(val) *val = longVal; return SWIG_OK; } } /* double */ %fragment(SWIG_From_frag(double),"header") { SWIGINTERN JSValueRef SWIG_From_dec(double) (double val) { return JSValueMakeNumber(context, val); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(JSValueRef obj, double *val) { if(!JSValueIsNumber(context, obj)) { return SWIG_TypeError; } if(val) *val = JSValueToNumber(context, obj, NULL); return SWIG_OK; } } swig-3.0.8/Lib/javascript/jsc/javascriptkw.swg0000664000175000017500000000176712641054563021261 0ustar williamwilliam#ifndef JAVASCRIPT_JAVASCRIPTKW_SWG_ #define JAVASCRIPT_JAVASCRIPTKW_SWG_ /* Warnings for Java keywords */ #define JAVASCRIPTKW(x) %keywordwarn("'" `x` "' is a javascript keyword, renaming to '_"`x`"'",rename="_%s") `x` /* Taken from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words */ JAVASCRIPTKW(break); JAVASCRIPTKW(case); JAVASCRIPTKW(catch); JAVASCRIPTKW(continue); JAVASCRIPTKW(default); JAVASCRIPTKW(delete); JAVASCRIPTKW(do); JAVASCRIPTKW(else); JAVASCRIPTKW(finally); JAVASCRIPTKW(for); JAVASCRIPTKW(function); JAVASCRIPTKW(if); JAVASCRIPTKW(in); JAVASCRIPTKW(instanceof); JAVASCRIPTKW(new); JAVASCRIPTKW(return); JAVASCRIPTKW(switch); JAVASCRIPTKW(this); JAVASCRIPTKW(throw); JAVASCRIPTKW(try); JAVASCRIPTKW(typeof); JAVASCRIPTKW(var); JAVASCRIPTKW(void); JAVASCRIPTKW(while); JAVASCRIPTKW(with); /* others bad names if any*/ // for example %namewarn("321:clone() is a javascript bad method name") *::clone(); #undef JAVASCRIPTKW #endif //JAVASCRIPT_JAVASCRIPTKW_SWG_ swig-3.0.8/Lib/javascript/jsc/javascriptcode.swg0000664000175000017500000003667612641054563021561 0ustar williamwilliam/* ----------------------------------------------------------------------------- * js_ctor: template for wrapping a ctor. * - $jswrapper: wrapper of called ctor * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * - $jsargcount: number of arguments * - $jsmangledtype: mangled type of class * ----------------------------------------------------------------------------- */ %fragment ("js_ctor", "templates") %{ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { $jslocals if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); goto fail; fail: return NULL; } %} /* ----------------------------------------------------------------------------- * js_veto_ctor: a vetoing ctor for abstract classes * - $jswrapper: name of wrapper * - $jsname: class name * ----------------------------------------------------------------------------- */ %fragment ("js_veto_ctor", "templates") %{ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated"); return 0; } %} /* ----------------------------------------------------------------------------- * js_ctor_dispatcher: dispatcher for overloaded constructors * - $jswrapper: name of wrapper * - $jsname: class name * - $jsdispatchcases: part containing code for dispatching * ----------------------------------------------------------------------------- */ %fragment ("js_ctor_dispatcher", "templates") %{ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { JSObjectRef thisObject = NULL; // switch all cases by means of series of if-returns. $jsdispatchcases // default: SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsname"); fail: return thisObject; } %} /* ----------------------------------------------------------------------------- * js_overloaded_ctor: template for wrapping a ctor. * - $jswrapper: wrapper of called ctor * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * - $jsargcount: number of arguments * - $jsmangledtype: mangled type of class * ----------------------------------------------------------------------------- */ %fragment ("js_overloaded_ctor", "templates") %{ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { $jslocals $jscode return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); goto fail; fail: return NULL; } %} /* ----------------------------------------------------------------------------- * js_ctor_dispatch_case: template for a dispatch case for calling an overloaded ctor. * - $jsargcount: number of arguments of called ctor * - $jswrapper: wrapper of called ctor * * Note: a try-catch-like mechanism is used to switch cases * ----------------------------------------------------------------------------- */ %fragment ("js_ctor_dispatch_case", "templates") %{ if(argc == $jsargcount) { thisObject = $jswrapper(context, NULL, argc, argv, exception); if(thisObject != NULL) { *exception=0; return thisObject; } /* reset exception and return */ } %} /* ----------------------------------------------------------------------------- * js_dtor: template for a destructor wrapper * - $jsmangledname: mangled class name * - $jstype: class type * ----------------------------------------------------------------------------- */ %fragment ("js_dtor", "templates") %{ static void $jswrapper(JSObjectRef thisObject) { SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject); if(t) { if (t->swigCMemOwn) { free (($jstype)t->swigCObject); } JSObjectSetPrivate(thisObject, NULL); free(t); } } %} /* ----------------------------------------------------------------------------- * js_dtor: template for a destructor wrapper * - $jsmangledname: mangled class name * - $jstype: class type * - ${destructor_action}: The custom destructor action to invoke. * ----------------------------------------------------------------------------- */ %fragment ("js_dtoroverride", "templates") %{ static void $jswrapper(JSObjectRef thisObject) { SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject); if(t) { if (t->swigCMemOwn) { $jstype arg1 = ($jstype)t->swigCObject; ${destructor_action} } /* remove the private data to make sure that it isn't accessed elsewhere */ JSObjectSetPrivate(thisObject, NULL); free(t); } } %} /* ----------------------------------------------------------------------------- * js_getter: template for getter function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_getter", "templates") %{ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) { $jslocals JSValueRef jsresult; $jscode return jsresult; goto fail; fail: return JSValueMakeUndefined(context); } %} /* ----------------------------------------------------------------------------- * js_setter: template for setter function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_setter", "templates") %{ static bool $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { $jslocals $jscode return true; goto fail; fail: return false; } %} /* ----------------------------------------------------------------------------- * js_function: template for function wrappers * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_function", "templates") %{ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { $jslocals JSValueRef jsresult; if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode return jsresult; goto fail; fail: return JSValueMakeUndefined(context); } %} /* ----------------------------------------------------------------------------- * js_function_dispatcher: template for a function dispatcher for overloaded functions * - $jswrapper: wrapper function name * - $jsname: name of the wrapped function * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_function_dispatcher", "templates") %{ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) { $jslocals JSValueRef jsresult; int res; $jscode SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname."); return jsresult; goto fail; fail: return JSValueMakeUndefined(context); } %} /* ----------------------------------------------------------------------------- * js_overloaded_function: template for a overloaded function * - $jswrapper: wrapper function name * - $jslocals: locals part of wrapper * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_overloaded_function", "templates") %{ static int $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception, JSValueRef* p_result) { $jslocals JSValueRef jsresult; if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode *p_result = jsresult; return SWIG_OK; goto fail; fail: return SWIG_TypeError; } %} /* ----------------------------------------------------------------------------- * js_function_dispatch_case: template for a case used in the function dispatcher * - $jswrapper: wrapper function name * - $jsargcount: number of arguments of overloaded function * - $jscode: code part of wrapper * ----------------------------------------------------------------------------- */ %fragment ("js_function_dispatch_case", "templates") %{ if(argc == $jsargcount) { res = $jswrapper(context, function, thisObject, argc, argv, exception, &jsresult); if(res == SWIG_OK) { *exception = 0; return jsresult; } } %} /* ----------------------------------------------------------------------------- * jsc_variable_declaration: template for a variable table entry * - $jsname: name of the variable * - $jsgetter: wrapper of getter function * - $jssetter: wrapper of setter function * ----------------------------------------------------------------------------- */ %fragment ("jsc_variable_declaration", "templates") %{ {"$jsname", $jsgetter, $jssetter, kJSPropertyAttributeNone}, %} /* ----------------------------------------------------------------------------- * jsc_function_declaration: template for a function table entry * - $jsname: name of the variable * - $jswrapper: wrapper function * ----------------------------------------------------------------------------- */ %fragment ("jsc_function_declaration", "templates") %{ {"$jsname", $jswrapper, kJSPropertyAttributeNone}, %} /* ----------------------------------------------------------------------------- * jsc_classtemplate_declaration: template for a namespace declaration * - $jsmangledname: mangled class name * ----------------------------------------------------------------------------- */ %fragment ("jsc_class_declaration", "templates") %{ static JSClassDefinition $jsmangledname_classDefinition; static JSClassDefinition $jsmangledname_objectDefinition; static JSClassRef $jsmangledname_classRef; %} /* ----------------------------------------------------------------------------- * jsc_class_tables: template for a namespace declaration * - $jsmangledname: mangled class name * - $jsstaticclassvariables: list of static variable entries * - $jsstaticclassfunctions: list of static function entries * - $jsclassvariables: list of member variable entries * - $jsclassfunctions: list of member function entries * ----------------------------------------------------------------------------- */ %fragment ("jsc_class_tables", "templates") %{ static JSStaticValue $jsmangledname_staticValues[] = { $jsstaticclassvariables { 0, 0, 0, 0 } }; static JSStaticFunction $jsmangledname_staticFunctions[] = { $jsstaticclassfunctions { 0, 0, 0 } }; static JSStaticValue $jsmangledname_values[] = { $jsclassvariables { 0, 0, 0, 0 } }; static JSStaticFunction $jsmangledname_functions[] = { $jsclassfunctions { 0, 0, 0 } }; %} /* ----------------------------------------------------------------------------- * jsc_define_class_template: template for defining a class template * - $jsmangledname: mangled class name * - $jsmangledtype: mangled class type * - $jsctor: wrapper of ctor * - $jsbaseclass: mangled name of base class * ----------------------------------------------------------------------------- */ %fragment ("jsc_class_definition", "templates") %{ $jsmangledname_classDefinition.staticFunctions = $jsmangledname_staticFunctions; $jsmangledname_classDefinition.staticValues = $jsmangledname_staticValues; $jsmangledname_classDefinition.callAsConstructor = $jsctor; $jsmangledname_objectDefinition.finalize = $jsdtor; $jsmangledname_objectDefinition.staticValues = $jsmangledname_values; $jsmangledname_objectDefinition.staticFunctions = $jsmangledname_functions; $jsclass_inheritance $jsmangledname_classRef = JSClassCreate(&$jsmangledname_objectDefinition); SWIGTYPE_$jsmangledtype->clientdata = $jsmangledname_classRef; %} %fragment ("jsc_class_inherit", templates) %{ if (SWIGTYPE_p$jsbaseclassmangled != NULL) { $jsmangledname_objectDefinition.parentClass = (JSClassRef) SWIGTYPE_p$jsbaseclassmangled->clientdata; } %} %fragment ("jsc_class_noinherit", templates) %{ $jsmangledname_objectDefinition.parentClass = _SwigObject_classRef; %} /* ----------------------------------------------------------------------------- * jsc_register_class: template for registration of a class * - $jsname: class name * - $jsmangledname: mangled class name * - $jsnspace: mangled name of namespace * ----------------------------------------------------------------------------- */ %fragment ("jsc_class_registration", "templates") %{ JS_registerClass(context, $jsnspace_object, "$jsname", &$jsmangledname_classDefinition); %} /* ----------------------------------------------------------------------------- * jsc_nspace_declaration: template for a namespace declaration * - $jsnspace: mangled name of the namespace * - $jsglobalvariables: list of variable entries * - $jsglobalfunctions: list if fuction entries * ----------------------------------------------------------------------------- */ %fragment ("jsc_nspace_declaration", "templates") %{ static JSStaticValue $jsnspace_values[] = { $jsglobalvariables { 0, 0, 0, 0 } }; static JSStaticFunction $jsnspace_functions[] = { $jsglobalfunctions { 0, 0, 0 } }; static JSClassDefinition $jsnspace_classDefinition; static JSObjectRef $jsmangledname_object; %} /* ----------------------------------------------------------------------------- * jsc_nspace_definition: template for definition of a namespace object * - $jsmangledname: mangled name of namespace * ----------------------------------------------------------------------------- */ %fragment ("jsc_nspace_definition", "templates") %{ $jsmangledname_classDefinition.staticFunctions = $jsmangledname_functions; $jsmangledname_classDefinition.staticValues = $jsmangledname_values; $jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL); %} /* ----------------------------------------------------------------------------- * jsc_nspace_registration: template for registration of a namespace object * - $jsname: name of namespace * - $jsmangledname: mangled name of namespace * - $jsparent: mangled name of parent namespace * ----------------------------------------------------------------------------- */ %fragment ("jsc_nspace_registration", "templates") %{ JS_registerNamespace(context, $jsmangledname_object, $jsparent_object, "$jsname"); %} swig-3.0.8/Lib/javascript/jsc/std_complex.i0000664000175000017500000000073212641054563020511 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.8/Lib/ocaml/0000775000175000017500000000000012641054563014162 5ustar williamwilliamswig-3.0.8/Lib/ocaml/preamble.swg0000664000175000017500000000073112641054563016474 0ustar williamwilliam%insert(mli) %{ exception BadArgs of string exception BadMethodName of c_obj * string * string exception NotObject of c_obj exception NotEnumType of c_obj exception LabelNotFromThisEnum of c_obj exception InvalidDirectorCall of c_obj %} %insert(ml) %{ exception BadArgs of string exception BadMethodName of c_obj * string * string exception NotObject of c_obj exception NotEnumType of c_obj exception LabelNotFromThisEnum of c_obj exception InvalidDirectorCall of c_obj %}swig-3.0.8/Lib/ocaml/std_pair.i0000664000175000017500000000131012641054563016134 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/ocaml/ocaml.swg0000664000175000017500000003406612641054563016010 0ustar williamwilliam/* -*-c-*- */ /* SWIG pointer structure */ #include #include #ifdef __cplusplus extern "C" { #endif #define C_bool 0 #define C_char 1 #define C_uchar 2 #define C_short 3 #define C_ushort 4 #define C_int 5 #define C_uint 6 #define C_int32 7 #define C_int64 8 #define C_float 9 #define C_double 10 #define C_ptr 11 #define C_array 12 #define C_list 13 #define C_obj 14 #define C_string 15 #define C_enum 16 #define C_director_core 17 /* Cast a pointer if possible; returns 1 if successful */ SWIGSTATIC int SWIG_Cast (void *source, swig_type_info *source_type, void **ptr, swig_type_info *dest_type) { if( !source ) { // Special case for NULL. This is a popular question // for other modules on the list, so I want an easy way out... *ptr = 0; return 0; } #ifdef TYPE_CAST_VERBOSE fprintf( stderr, "Trying to cast %s to %s\n", source_type ? source_type->str : "", dest_type ? dest_type->str : "" ); #endif if (dest_type != source_type) { /* We have a type mismatch. Will have to look through our type mapping table to figure out whether or not we can accept this datatype. -- Ignore typechecks for void *. Allow any conversion. */ if( !dest_type || !source_type || !strcmp(dest_type->name,"_p_void") || !strcmp(source_type->name,"_p_void") ) { *ptr = source; return 0; } else { swig_cast_info *tc = SWIG_TypeCheckStruct(source_type, dest_type ); #ifdef TYPE_CAST_VERBOSE fprintf( stderr, "Typecheck -> %s\n", tc ? tc->str : "" ); #endif if( tc ) { int newmemory = 0; *ptr = SWIG_TypeCast(tc, source, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return 0; } else return -1; } } else { *ptr = source; return 0; } } /* Return 0 if successful. */ SWIGSTATIC int SWIG_GetPtr(void *inptr, void **outptr, swig_type_info *intype, swig_type_info *outtype) { if (intype) { return SWIG_Cast(inptr, intype, outptr, outtype) == -1; } else { *outptr = inptr; return 0; } } SWIGSTATIC void caml_print_list( CAML_VALUE v ); SWIGSTATIC void caml_print_val( CAML_VALUE v ) { switch( SWIG_Tag_val(v) ) { case C_bool: if( Bool_val(SWIG_Field(v,0)) ) fprintf( stderr, "true " ); else fprintf( stderr, "false " ); break; case C_char: case C_uchar: fprintf( stderr, "'%c' (\\%03d) ", (Int_val(SWIG_Field(v,0)) >= ' ' && Int_val(SWIG_Field(v,0)) < 127) ? Int_val(SWIG_Field(v,0)) : '.', Int_val(SWIG_Field(v,0)) ); break; case C_short: case C_ushort: case C_int: fprintf( stderr, "%d ", (int)caml_long_val(v) ); break; case C_uint: case C_int32: fprintf( stderr, "%ud ", (unsigned int)caml_long_val(v) ); break; case C_int64: fprintf( stderr, "%ld ", caml_long_val(v) ); break; case C_float: case C_double: fprintf( stderr, "%f ", caml_double_val(v) ); break; case C_ptr: { void *vout = 0; swig_type_info *ty = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1)); caml_ptr_val_internal(v,&vout,0); fprintf( stderr, "PTR(%p,%s) ", vout, ty ? ty->name : "(null)" ); } break; case C_array: { unsigned int i; for( i = 0; i < Wosize_val( SWIG_Field(v,0) ); i++ ) caml_print_val( SWIG_Field(SWIG_Field(v,0),i) ); } break; case C_list: caml_print_list( SWIG_Field(v,0) ); break; case C_obj: fprintf( stderr, "OBJ(%p) ", (void *)SWIG_Field(v,0) ); break; case C_string: { void *cout; caml_ptr_val_internal(v,&cout,0); fprintf( stderr, "'%s' ", (char *)cout ); } break; } } SWIGSTATIC void caml_print_list( CAML_VALUE v ) { CAMLparam1(v); while( v && Is_block(v) ) { fprintf( stderr, "[ " ); caml_print_val( SWIG_Field(v,0) ); fprintf( stderr, "]\n" ); v = SWIG_Field(v,1); } CAMLreturn0; } SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) { CAMLparam1(lst); int i = 0; while( i < n && lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); } if( lst == Val_unit ) CAMLreturn(Val_unit); else CAMLreturn(SWIG_Field(lst,0)); } SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) { CAMLparam2(lst,elt); SWIG_CAMLlocal3(v,vt,lh); lh = Val_unit; v = Val_unit; /* Appending C_void should have no effect */ if( !Is_block(elt) ) return lst; while( lst && Is_block(lst) ) { if( v && v != Val_unit ) { vt = alloc_tuple(2); SWIG_Store_field(v,1,vt); v = vt; } else { v = lh = alloc_tuple(2); } SWIG_Store_field(v,0,SWIG_Field(lst,0)); lst = SWIG_Field(lst,1); } if( v && Is_block(v) ) { vt = alloc_tuple(2); SWIG_Store_field(v,1,vt); v = vt; } else { v = lh = alloc_tuple(2); } SWIG_Store_field(v,0,elt); SWIG_Store_field(v,1,Val_unit); CAMLreturn(lh); } SWIGSTATIC int caml_list_length( CAML_VALUE lst ) { CAMLparam1(lst); int i = 0; while( lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); } CAMLreturn(i); } SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ) { CAMLparam2(arr,item); SWIG_Store_field(SWIG_Field(arr,0),n,item); CAMLreturn0; } SWIGSTATIC value caml_array_nth( CAML_VALUE arr, int n ) { CAMLparam1(arr); if( SWIG_Tag_val(arr) == C_array ) CAMLreturn(SWIG_Field(SWIG_Field(arr,0),n)); else if( SWIG_Tag_val(arr) == C_list ) CAMLreturn(caml_list_nth(arr,0)); else failwith("Need array or list"); } SWIGSTATIC int caml_array_len( CAML_VALUE arr ) { CAMLparam1(arr); if( SWIG_Tag_val(arr) == C_array ) CAMLreturn(Wosize_val(SWIG_Field(arr,0))); else if( SWIG_Tag_val(arr) == C_list ) CAMLreturn(caml_list_length(arr)); else failwith("Need array or list"); } SWIGSTATIC CAML_VALUE caml_swig_alloc(int x,int y) { return caml_alloc(x,y); } SWIGSTATIC value caml_array_new( int n ) { CAMLparam0(); SWIG_CAMLlocal1(vv); vv = caml_swig_alloc(1,C_array); SWIG_Store_field(vv,0,alloc_tuple(n)); CAMLreturn(vv); } SWIGSTATIC CAML_VALUE caml_val_bool( int b ) { CAMLparam0(); SWIG_CAMLlocal1(bv); bv = caml_swig_alloc(1,C_bool); SWIG_Store_field(bv,0,Val_bool(b)); CAMLreturn(bv); } SWIGSTATIC CAML_VALUE caml_val_char( char c ) { CAMLparam0(); SWIG_CAMLlocal1(cv); cv = caml_swig_alloc(1,C_char); SWIG_Store_field(cv,0,Val_int(c)); CAMLreturn(cv); } SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char uc ) { CAMLparam0(); SWIG_CAMLlocal1(ucv); ucv = caml_swig_alloc(1,C_uchar); SWIG_Store_field(ucv,0,Val_int(uc)); CAMLreturn(ucv); } SWIGSTATIC CAML_VALUE caml_val_short( short s ) { CAMLparam0(); SWIG_CAMLlocal1(sv); sv = caml_swig_alloc(1,C_short); SWIG_Store_field(sv,0,Val_int(s)); CAMLreturn(sv); } SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short us ) { CAMLparam0(); SWIG_CAMLlocal1(usv); usv = caml_swig_alloc(1,C_ushort); SWIG_Store_field(usv,0,Val_int(us)); CAMLreturn(usv); } SWIGSTATIC CAML_VALUE caml_val_int( int i ) { CAMLparam0(); SWIG_CAMLlocal1(iv); iv = caml_swig_alloc(1,C_int); SWIG_Store_field(iv,0,Val_int(i)); CAMLreturn(iv); } SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int ui ) { CAMLparam0(); SWIG_CAMLlocal1(uiv); uiv = caml_swig_alloc(1,C_int); SWIG_Store_field(uiv,0,Val_int(ui)); CAMLreturn(uiv); } SWIGSTATIC CAML_VALUE caml_val_long( long l ) { CAMLparam0(); SWIG_CAMLlocal1(lv); lv = caml_swig_alloc(1,C_int64); SWIG_Store_field(lv,0,copy_int64(l)); CAMLreturn(lv); } SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long ul ) { CAMLparam0(); SWIG_CAMLlocal1(ulv); ulv = caml_swig_alloc(1,C_int64); SWIG_Store_field(ulv,0,copy_int64(ul)); CAMLreturn(ulv); } SWIGSTATIC CAML_VALUE caml_val_float( float f ) { CAMLparam0(); SWIG_CAMLlocal1(fv); fv = caml_swig_alloc(1,C_float); SWIG_Store_field(fv,0,copy_double((double)f)); CAMLreturn(fv); } SWIGSTATIC CAML_VALUE caml_val_double( double d ) { CAMLparam0(); SWIG_CAMLlocal1(fv); fv = caml_swig_alloc(1,C_double); SWIG_Store_field(fv,0,copy_double(d)); CAMLreturn(fv); } SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) { CAMLparam0(); SWIG_CAMLlocal1(vv); vv = caml_swig_alloc(2,C_ptr); SWIG_Store_field(vv,0,copy_int64((long)p)); SWIG_Store_field(vv,1,copy_int64((long)info)); CAMLreturn(vv); } SWIGSTATIC CAML_VALUE caml_val_string( const char *p ) { CAMLparam0(); SWIG_CAMLlocal1(vv); if( !p ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); vv = caml_swig_alloc(1,C_string); SWIG_Store_field(vv,0,copy_string(p)); CAMLreturn(vv); } SWIGSTATIC CAML_VALUE caml_val_string_len( const char *p, int len ) { CAMLparam0(); SWIG_CAMLlocal1(vv); if( !p || len < 0 ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); vv = caml_swig_alloc(1,C_string); SWIG_Store_field(vv,0,alloc_string(len)); memcpy(String_val(SWIG_Field(vv,0)),p,len); CAMLreturn(vv); } #define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name) SWIGSTATIC CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) { CAMLparam0(); CAMLreturn(callback2(*caml_named_value("caml_create_object_fn"), caml_val_ptr(v,type), copy_string(name))); } SWIGSTATIC long caml_long_val_full( CAML_VALUE v, char *name ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_bool: case C_char: case C_uchar: case C_short: case C_ushort: case C_int: CAMLreturn(Int_val(SWIG_Field(v,0))); case C_uint: case C_int32: CAMLreturn(Int32_val(SWIG_Field(v,0))); case C_int64: CAMLreturn((long)SWIG_Int64_val(SWIG_Field(v,0))); case C_float: case C_double: CAMLreturn((long)Double_val(SWIG_Field(v,0))); case C_string: CAMLreturn((long)String_val(SWIG_Field(v,0))); case C_ptr: CAMLreturn((long)SWIG_Int64_val(SWIG_Field(SWIG_Field(v,0),0))); case C_enum: { SWIG_CAMLlocal1(ret); CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int"); if( !name ) failwith( "Not an enum conversion" ); ret = callback2(*enum_to_int,*caml_named_value(name),v); CAMLreturn(caml_long_val(ret)); } default: failwith("No conversion to int"); } } SWIGSTATIC long caml_long_val( CAML_VALUE v ) { return caml_long_val_full(v,0); } SWIGSTATIC double caml_double_val( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0.0; switch( SWIG_Tag_val(v) ) { case C_bool: case C_char: case C_uchar: case C_short: case C_ushort: case C_int: CAMLreturn_type(Int_val(SWIG_Field(v,0))); case C_uint: case C_int32: CAMLreturn_type(Int32_val(SWIG_Field(v,0))); case C_int64: CAMLreturn_type(SWIG_Int64_val(SWIG_Field(v,0))); case C_float: case C_double: CAMLreturn_type(Double_val(SWIG_Field(v,0))); default: fprintf( stderr, "Unknown block tag %d\n", SWIG_Tag_val(v) ); failwith("No conversion to double"); } } SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, swig_type_info *descriptor ) { CAMLparam1(v); void *outptr = NULL; swig_type_info *outdescr = NULL; if( v == Val_unit ) { *out = 0; CAMLreturn(0); } if( !Is_block(v) ) return -1; switch( SWIG_Tag_val(v) ) { case C_int: if( !caml_long_val( v ) ) { *out = 0; CAMLreturn(0); } else { *out = 0; CAMLreturn(1); } break; case C_obj: CAMLreturn (caml_ptr_val_internal (callback(*caml_named_value("caml_obj_ptr"),v), out,descriptor)); case C_string: outptr = (void *)String_val(SWIG_Field(v,0)); break; case C_ptr: outptr = (void *)(long)SWIG_Int64_val(SWIG_Field(v,0)); outdescr = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1)); break; default: *out = 0; CAMLreturn(1); break; } CAMLreturn(SWIG_GetPtr(outptr,out,outdescr,descriptor)); } SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) { CAMLparam0(); #ifdef TYPE_CAST_VERBOSE caml_print_val( v ); #endif void *out = NULL; if( !caml_ptr_val_internal( v, &out, descriptor ) ) CAMLreturn_type(out); else failwith( "No appropriate conversion found." ); } SWIGSTATIC char *caml_string_val( CAML_VALUE v ) { return (char *)caml_ptr_val( v, 0 ); } SWIGSTATIC int caml_string_len( CAML_VALUE v ) { switch( SWIG_Tag_val(v) ) { case C_string: return string_length(SWIG_Field(v,0)); default: return strlen((char *)caml_ptr_val(v,0)); } } SWIGSTATIC int caml_bool_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_bool: case C_ptr: case C_string: CAMLreturn(1); default: CAMLreturn(0); } } SWIGSTATIC int caml_int_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_char: case C_uchar: case C_short: case C_ushort: case C_int: case C_uint: case C_int32: case C_int64: CAMLreturn(1); default: CAMLreturn(0); } } SWIGSTATIC int caml_float_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_float: case C_double: CAMLreturn(1); default: CAMLreturn(0); } } SWIGSTATIC int caml_ptr_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; switch( SWIG_Tag_val(v) ) { case C_string: case C_ptr: case C_int64: CAMLreturn(1); default: CAMLreturn(0); } } static swig_module_info *SWIG_Ocaml_GetModule(void *SWIGUNUSEDPARM(clientdata)) { CAML_VALUE pointer; pointer = callback(*caml_named_value("swig_find_type_info"), caml_val_int(0)); if (Is_block(pointer) && SWIG_Tag_val(pointer) == C_ptr) { return (swig_module_info *)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0)); } return 0; } static void SWIG_Ocaml_SetModule(swig_module_info *pointer) { CAML_VALUE mod_pointer; mod_pointer = caml_val_ptr(pointer, NULL); callback(*caml_named_value("swig_set_type_info"), mod_pointer); } #ifdef __cplusplus } #endif #undef value swig-3.0.8/Lib/ocaml/swig.ml0000664000175000017500000001111412641054563015463 0ustar williamwilliam(* -*- tuareg -*- *) open Int32 open Int64 type enum = [ `Int of int ] type 'a c_obj_t = C_void | C_bool of bool | C_char of char | C_uchar of char | C_short of int | C_ushort of int | C_int of int | C_uint of int32 | C_int32 of int32 | C_int64 of int64 | C_float of float | C_double of float | C_ptr of int64 * int64 | C_array of 'a c_obj_t array | C_list of 'a c_obj_t list | C_obj of (string -> 'a c_obj_t -> 'a c_obj_t) | C_string of string | C_enum of 'a | C_director_core of 'a c_obj_t * 'a c_obj_t option ref type c_obj = enum c_obj_t exception BadArgs of string exception BadMethodName of string * string exception NotObject of c_obj exception NotEnumType of c_obj exception LabelNotFromThisEnum of c_obj exception InvalidDirectorCall of c_obj exception NoSuchClass of string let rec invoke obj = match obj with C_obj o -> o | C_director_core (o,r) -> invoke o | _ -> raise (NotObject (Obj.magic obj)) let _ = Callback.register "swig_runmethod" invoke let fnhelper arg = match arg with C_list l -> l | C_void -> [] | _ -> [ arg ] let rec get_int x = match x with C_bool b -> if b then 1 else 0 | C_char c | C_uchar c -> (int_of_char c) | C_short s | C_ushort s | C_int s -> s | C_uint u | C_int32 u -> (Int32.to_int u) | C_int64 u -> (Int64.to_int u) | C_float f -> (int_of_float f) | C_double d -> (int_of_float d) | C_ptr (p,q) -> (Int64.to_int p) | C_obj o -> (try (get_int (o "int" C_void)) with _ -> (get_int (o "&" C_void))) | _ -> raise (Failure "Can't convert to int") let rec get_float x = match x with C_char c | C_uchar c -> (float_of_int (int_of_char c)) | C_short s -> (float_of_int s) | C_ushort s -> (float_of_int s) | C_int s -> (float_of_int s) | C_uint u | C_int32 u -> (float_of_int (Int32.to_int u)) | C_int64 u -> (float_of_int (Int64.to_int u)) | C_float f -> f | C_double d -> d | C_obj o -> (try (get_float (o "float" C_void)) with _ -> (get_float (o "double" C_void))) | _ -> raise (Failure "Can't convert to float") let rec get_char x = (char_of_int (get_int x)) let rec get_string x = match x with C_string str -> str | _ -> raise (Failure "Can't convert to string") let rec get_bool x = match x with C_bool b -> b | _ -> (try if get_int x != 0 then true else false with _ -> raise (Failure "Can't convert to bool")) let disown_object obj = match obj with C_director_core (o,r) -> r := None | _ -> raise (Failure "Not a director core object") let _ = Callback.register "caml_obj_disown" disown_object let addr_of obj = match obj with C_obj _ -> (invoke obj) "&" C_void | C_director_core (self,r) -> (invoke self) "&" C_void | C_ptr _ -> obj | _ -> raise (Failure "Not a pointer.") let _ = Callback.register "caml_obj_ptr" addr_of let make_float f = C_float f let make_double f = C_double f let make_string s = C_string s let make_bool b = C_bool b let make_char c = C_char c let make_char_i c = C_char (char_of_int c) let make_uchar c = C_uchar c let make_uchar_i c = C_uchar (char_of_int c) let make_short i = C_short i let make_ushort i = C_ushort i let make_int i = C_int i let make_uint i = C_uint (Int32.of_int i) let make_int32 i = C_int32 (Int32.of_int i) let make_int64 i = C_int64 (Int64.of_int i) let new_derived_object cfun x_class args = begin let get_object ob = match !ob with None -> raise (NotObject C_void) | Some o -> o in let ob_ref = ref None in let class_fun class_f ob_r = (fun meth args -> class_f (get_object ob_r) meth args) in let new_class = class_fun x_class ob_ref in let dircore = C_director_core (C_obj new_class,ob_ref) in let obj = cfun (match args with C_list argl -> (C_list ((dircore :: argl))) | C_void -> (C_list [ dircore ]) | a -> (C_list [ dircore ; a ])) in ob_ref := Some obj ; obj end let swig_current_type_info = ref C_void let find_type_info obj = !swig_current_type_info let _ = Callback.register "swig_find_type_info" find_type_info let set_type_info obj = match obj with C_ptr _ -> swig_current_type_info := obj ; obj | _ -> raise (Failure "Internal error: passed non pointer to set_type_info") let _ = Callback.register "swig_set_type_info" set_type_info let class_master_list = Hashtbl.create 20 let register_class_byname nm co = Hashtbl.replace class_master_list nm (Obj.magic co) let create_class nm arg = try (Obj.magic (Hashtbl.find class_master_list nm)) arg with _ -> raise (NoSuchClass nm) swig-3.0.8/Lib/ocaml/std_deque.i0000664000175000017500000000132212641054563016307 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_deque.i * * Default std_deque wrapper * ----------------------------------------------------------------------------- */ %module std_deque %rename(__getitem__) std::deque::getitem; %rename(__setitem__) std::deque::setitem; %rename(__delitem__) std::deque::delitem; %rename(__getslice__) std::deque::getslice; %rename(__setslice__) std::deque::setslice; %rename(__delslice__) std::deque::delslice; %extend std::deque { int __len__() { return (int) self->size(); } int __nonzero__() { return ! self->empty(); } void append(const T &x) { self->push_back(x); } }; %include swig-3.0.8/Lib/ocaml/carray.i0000664000175000017500000000626412641054563015625 0ustar williamwilliam%insert(mli) %{ type _value = c_obj %} %insert(ml) %{ type _value = c_obj %} %define %array_tmap_out(type,what,out_f) %typemap(type) what [ANY] { int i; /* $*1_type */ $result = caml_array_new($1_dim0); for( i = 0; i < $1_dim0; i++ ) { caml_array_set($result,i,out_f($1[i])); } } %enddef %define %array_tmap_in(type,what,in_f) %typemap(type) what [ANY] { int i; /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = in_f(caml_array_nth($input,i)); } } %typemap(free) what [ANY] { free( (void *)$1 ); } %enddef %define %make_simple_array_typemap(type,out_f,in_f) %array_tmap_out(out,type,out_f); %array_tmap_out(varout,type,out_f); %array_tmap_out(directorin,type,out_f); %array_tmap_in(in,type,in_f); %array_tmap_in(varin,type,in_f); %array_tmap_in(directorout,type,in_f); %enddef %make_simple_array_typemap(bool,caml_val_bool,caml_long_val); %make_simple_array_typemap(short,caml_val_short,caml_long_val); %make_simple_array_typemap(unsigned short,caml_val_ushort,caml_long_val); %make_simple_array_typemap(int,caml_val_int,caml_long_val); %make_simple_array_typemap(unsigned int,caml_val_uint,caml_long_val); %make_simple_array_typemap(long,caml_val_long,caml_long_val); %make_simple_array_typemap(unsigned long,caml_val_ulong,caml_long_val); %make_simple_array_typemap(size_t,caml_val_int,caml_long_val); %make_simple_array_typemap(float,caml_val_float,caml_double_val); %make_simple_array_typemap(double,caml_val_double,caml_double_val); #ifdef __cplusplus %typemap(in) SWIGTYPE [] { int i; /* $*1_type */ $1 = new $*1_type [$1_dim0]; for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = *(($*1_ltype *) caml_ptr_val(caml_array_nth($input,i), $*1_descriptor)) ; } } #else %typemap(in) SWIGTYPE [] { int i; /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = *(($*1_ltype) caml_ptr_val(caml_array_nth($input), $*1_descriptor)); } } #endif %typemap(out) SWIGTYPE [] { int i; CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); $result = caml_array_new($1_dim0); for( i = 0; i < $1_dim0; i++ ) { if( fromval ) { caml_array_set ($result, i, callback(*fromval,caml_val_ptr((void *)&$1[i],$*1_descriptor))); } else { caml_array_set ($result, i, caml_val_ptr ((void *)&$1[i],$&1_descriptor)); } } } %typemap(in) enum SWIGTYPE [] { int i; /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = ($type) caml_long_val_full(caml_array_nth($input), "$type_marker"); } } %typemap(out) enum SWIGTYPE [] { int i; $result = caml_array_new($1_dim0); for( i = 0; i < $1_dim0; i++ ) { caml_array_set ($result, i, callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"), *caml_named_value("$type_marker"), Val_int($1[i]))); } } #ifdef __cplusplus %typemap(freearg) SWIGTYPE [ANY] { delete [] $1; } #else %typemap(freearg) SWIGTYPE [ANY] { free( (void *)$1 ); } #endif swig-3.0.8/Lib/ocaml/std_common.i0000664000175000017500000000102312641054563016472 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; %{ #include CAML_VALUE SwigString_FromString(const std::string& s) { return caml_val_string((char *)s.c_str()); } std::string SwigString_AsString(CAML_VALUE o) { return std::string((char *)caml_ptr_val(o,0)); } %} swig-3.0.8/Lib/ocaml/extra-install.list0000664000175000017500000000013512641054563017645 0ustar williamwilliam# see top-level Makefile.in # libswigocaml is not needed anymore. swigp4.ml swig.mli swig.ml swig-3.0.8/Lib/ocaml/libswigocaml.h0000664000175000017500000000070612641054563017012 0ustar williamwilliam/* Ocaml runtime support */ #ifdef __cplusplus extern "C" { #endif typedef int oc_bool; extern void *nullptr; extern oc_bool isnull( void *v ); extern void *get_char_ptr( char *str ); extern void *make_ptr_array( int size ); extern void *get_ptr( void *arrayptr, int elt ); extern void set_ptr( void *arrayptr, int elt, void *elt_v ); extern void *offset_ptr( void *ptr, int n ); #ifdef __cplusplus }; #endif swig-3.0.8/Lib/ocaml/std_list.i0000664000175000017500000001034412641054563016163 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_list.i * * SWIG typemaps for std::list types * ----------------------------------------------------------------------------- */ %include %module std_list %{ #include #include %} namespace std{ template class list { public: typedef T &reference; typedef const T& const_reference; typedef T &iterator; typedef const T& const_iterator; list(); list(unsigned int size, const T& value = T()); list(const list &); ~list(); void assign(unsigned int n, const T& value); void swap(list &x); const_reference front(); const_reference back(); const_iterator begin(); const_iterator end(); void resize(unsigned int n, T c = T()); bool empty() const; void push_front(const T& x); void push_back(const T& x); void pop_front(); void pop_back(); void clear(); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, const T& value); void remove(const T& value); void unique(); void reverse(); void sort(); %extend { const_reference __getitem__(int i) throw (std::out_of_range) { std::list::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && i::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && i::iterator first = self->begin(); int size = int(self->size()); if (i<0) i += size; if (i>=0 && ierase(first); } else throw std::out_of_range("list index out of range"); } std::list __getslice__(int i,int j) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; if (i>=j) i=j; if (i>=0 && i=0) { for (int k=0;k tmp(j-i); if (j>i) std::copy(first,end,tmp.begin()); return tmp; } else throw std::out_of_range("list index out of range"); } void __delslice__(int i,int j) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; for (int k=0;kerase(first,end); } void __setslice__(int i,int j, const std::list& v) { std::list::iterator first = self->begin(); std::list::iterator end = self->end(); int size = int(self->size()); if (i<0) i += size; if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; for (int k=0;kerase(first,end); if (i+1 <= int(self->size())) { first = self->begin(); for (int k=0;kinsert(first,v.begin(),v.end()); } else self->insert(self->end(),v.begin(),v.end()); } } unsigned int __len__() { return self->size(); } bool __nonzero__() { return !(self->empty()); } void append(const T& x) { self->push_back(x); } void pop() { self->pop_back(); } }; }; } swig-3.0.8/Lib/ocaml/std_map.i0000664000175000017500000000444012641054563015765 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.8/Lib/ocaml/class.swg0000664000175000017500000000326612641054563016020 0ustar williamwilliam(*Stream:class_ctors*) let create_$classname_from_ptr raw_ptr = C_obj begin let h = Hashtbl.create 20 in List.iter (fun (nm,fn) -> Hashtbl.replace h nm fn) [ "nop", (fun args -> C_void) ; $classbody "&", (fun args -> raw_ptr) ; ":parents", (fun args -> C_list (let out = ref [] in Hashtbl.iter (fun x y -> out := (x,y) :: !out) h ; (List.map (fun (x,y) -> C_string (String.sub x 2 ((String.length x) - 2))) (List.filter (fun (x,y) -> ((String.length x) > 2) && x.[0] == ':' && x.[1] == ':') !out)))) ; ":classof", (fun args -> C_string "$realname") ; ":methods", (fun args -> C_list (let out = ref [] in Hashtbl.iter (fun x y -> out := (C_string x) :: !out) h ; !out)) ] ; let rec invoke_inner raw_ptr mth arg = begin try let application = Hashtbl.find h mth in application (match arg with C_list l -> (C_list (raw_ptr :: l)) | C_void -> (C_list [ raw_ptr ]) | v -> (C_list [ raw_ptr ; v ])) with Not_found -> (* Try parent classes *) begin let parent_classes = [ $baselist ] in let rec try_parent plist raw_ptr = match plist with p :: tl -> begin try (invoke (p raw_ptr)) mth arg with (BadMethodName (p,m,s)) -> try_parent tl raw_ptr end | [] -> raise (BadMethodName (raw_ptr,mth,"$realname")) in try_parent parent_classes raw_ptr end end in (fun mth arg -> invoke_inner raw_ptr mth arg) end let _ = Callback.register "create_$normalized_from_ptr" create_$classname_from_ptr (*Stream:mli*) val create_$classname_from_ptr : c_obj -> c_obj swig-3.0.8/Lib/ocaml/swig.mli0000664000175000017500000000324012641054563015635 0ustar williamwilliam(* -*- tuareg -*- *) type enum = [ `Int of int ] type 'a c_obj_t = C_void | C_bool of bool | C_char of char | C_uchar of char | C_short of int | C_ushort of int | C_int of int | C_uint of int32 | C_int32 of int32 | C_int64 of int64 | C_float of float | C_double of float | C_ptr of int64 * int64 | C_array of 'a c_obj_t array | C_list of 'a c_obj_t list | C_obj of (string -> 'a c_obj_t -> 'a c_obj_t) | C_string of string | C_enum of 'a | C_director_core of 'a c_obj_t * 'a c_obj_t option ref type c_obj = enum c_obj_t exception InvalidDirectorCall of c_obj exception NoSuchClass of string val invoke : ('a c_obj_t) -> (string -> 'a c_obj_t -> 'a c_obj_t) val fnhelper : 'a c_obj_t -> 'a c_obj_t list val get_int : 'a c_obj_t -> int val get_float : 'a c_obj_t -> float val get_string : 'a c_obj_t -> string val get_char : 'a c_obj_t -> char val get_bool : 'a c_obj_t -> bool val make_float : float -> 'a c_obj_t val make_double : float -> 'a c_obj_t val make_string : string -> 'a c_obj_t val make_bool : bool -> 'a c_obj_t val make_char : char -> 'a c_obj_t val make_char_i : int -> 'a c_obj_t val make_uchar : char -> 'a c_obj_t val make_uchar_i : int -> 'a c_obj_t val make_short : int -> 'a c_obj_t val make_ushort : int -> 'a c_obj_t val make_int : int -> 'a c_obj_t val make_uint : int -> 'a c_obj_t val make_int32 : int -> 'a c_obj_t val make_int64 : int -> 'a c_obj_t val new_derived_object: ('a c_obj_t -> 'a c_obj_t) -> ('a c_obj_t -> string -> 'a c_obj_t -> 'a c_obj_t) -> 'a c_obj_t -> 'a c_obj_t val register_class_byname : string -> ('a c_obj_t -> 'a c_obj_t) -> unit val create_class : string -> 'a c_obj_t -> 'a c_obj_t swig-3.0.8/Lib/ocaml/std_string.i0000664000175000017500000000620212641054563016514 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ // std::string is typemapped by value // This can prevent exporting methods which return a string // in order for the user to modify it. // However, I think I'll wait until someone asks for it... // ------------------------------------------------------------------------ %{ #include #include %} %include %include namespace std { %naturalvar string; %naturalvar wstring; class string; class wstring; /* Overloading check */ %typemap(in) string { /* %typemap(in) string */ if (caml_ptr_check($input)) $1.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); else SWIG_exception(SWIG_TypeError, "string expected"); } %typemap(in) const string & ($*1_ltype temp) { /* %typemap(in) const string & */ if (caml_ptr_check($input)) { temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = &temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(in) string & ($*1_ltype temp) { /* %typemap(in) string & */ if (caml_ptr_check($input)) { temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = &temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(in) string * ($*1_ltype *temp) { /* %typemap(in) string * */ if (caml_ptr_check($input)) { temp = new $*1_ltype((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(free) string * ($*1_ltype *temp) { delete temp; } %typemap(argout) string & { /* %typemap(argout) string & */ swig_result = caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), (*$1).size())); } %typemap(directorout) string { /* %typemap(directorout) string */ $result.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); } %typemap(out) string { /* %typemap(out) string */ $result = caml_val_string_len($1.c_str(),$1.size()); } %typemap(out) string * { /* %typemap(out) string * */ $result = caml_val_string_len((*$1).c_str(),(*$1).size()); } } #ifdef ENABLE_CHARPTR_ARRAY char **c_charptr_array( const std::vector &str_v ); %{ SWIGEXT char **c_charptr_array( const std::vector &str_v ) { char **out = new char *[str_v.size() + 1]; out[str_v.size()] = 0; for( int i = 0; i < str_v.size(); i++ ) { out[i] = (char *)str_v[i].c_str(); } return out; } %} #endif #ifdef ENABLE_STRING_VECTOR %template (StringVector) std::vector; %insert(ml) %{ (* Some STL convenience items *) let string_array_to_vector sa = let nv = _new_StringVector C_void in array_to_vector nv (fun x -> C_string x) sa ; nv let c_string_array ar = _c_charptr_array (string_array_to_vector ar) %} %insert(mli) %{ val c_string_array: string array -> c_obj %} #endif swig-3.0.8/Lib/ocaml/typeregister.swg0000664000175000017500000000006712641054563017435 0ustar williamwilliamSWIGEXT void SWIG_init() { SWIG_InitializeModule(0); swig-3.0.8/Lib/ocaml/stl.i0000664000175000017500000000054512641054563015142 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/ocaml/ocamlkw.swg0000664000175000017500000000205212641054563016340 0ustar williamwilliam#ifndef OCAML_OCAMLKW_SWG_ #define OCAML_OCAMLKW_SWG_ /* Warnings for Ocaml keywords */ #define OCAMLKW(x) %namewarn("314: '" #x "' is an ocaml keyword and it will be appropriately renamed") #x /* from http://caml.inria.fr/ocaml/htmlman/manual044.html */ OCAMLKW(and); OCAMLKW(as); OCAMLKW(assert); OCAMLKW(begin); OCAMLKW(class); OCAMLKW(constraint); OCAMLKW(do); OCAMLKW(done); OCAMLKW(downto); OCAMLKW(else); OCAMLKW(end); OCAMLKW(exception); OCAMLKW(external); OCAMLKW(false); OCAMLKW(for); OCAMLKW(fun); OCAMLKW(function); OCAMLKW(functor); OCAMLKW(if); OCAMLKW(in); OCAMLKW(include); OCAMLKW(inherit); OCAMLKW(initializer); OCAMLKW(lazy); OCAMLKW(let); OCAMLKW(match); OCAMLKW(method); OCAMLKW(module); OCAMLKW(mutable); OCAMLKW(new); OCAMLKW(object); OCAMLKW(of); OCAMLKW(open); OCAMLKW(or); OCAMLKW(private); OCAMLKW(rec); OCAMLKW(sig); OCAMLKW(struct); OCAMLKW(then); OCAMLKW(to); OCAMLKW(true); OCAMLKW(try); OCAMLKW(type); OCAMLKW(val); OCAMLKW(virtual); OCAMLKW(when); OCAMLKW(while); OCAMLKW(with); #undef OCAMLKW #endif //OCAML_OCAMLKW_SWG_ swig-3.0.8/Lib/ocaml/director.swg0000664000175000017500000000570412641054563016525 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Ocaml proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #include #include # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) namespace Swig { /* base class for director exceptions */ class DirectorException : public std::exception { protected: std::string swig_msg; public: DirectorException(const char *msg="") : swig_msg(msg) { } virtual ~DirectorException() throw() { } const char *what() const throw() { return swig_msg.c_str(); } }; /* type mismatch in the return value from a Ocaml method call */ class DirectorTypeMismatchException : public DirectorException { public: DirectorTypeMismatchException(const char *msg="") : DirectorException(msg) { } }; /* any Ocaml exception that occurs during a director method call */ class DirectorMethodException : public DirectorException {}; /* attempt to call a pure virtual method via a director method */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg="") : DirectorException(msg) { } static void raise(const char *msg) { throw DirectorPureVirtualException(msg); } }; /* simple thread abstraction for pthreads on win32 */ #ifdef __THREAD__ #define __PTHREAD__ #if defined(_WIN32) || defined(__WIN32__) #define pthread_mutex_lock EnterCriticalSection #define pthread_mutex_unlock LeaveCriticalSection #define pthread_mutex_t CRITICAL_SECTION #define MUTEX_INIT(var) CRITICAL_SECTION var #else #include #define MUTEX_INIT(var) pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER #endif #endif /* director base class */ class Director { private: /* pointer to the wrapped ocaml object */ CAML_VALUE swig_self; /* flag indicating whether the object is owned by ocaml or c++ */ mutable bool swig_disown_flag; public: /* wrap a ocaml object. */ Director(CAML_VALUE self) : swig_self(self), swig_disown_flag(false) { register_global_root(&swig_self); } /* discard our reference at destruction */ virtual ~Director() { remove_global_root(&swig_self); swig_disown(); // Disown is safe here because we're just divorcing a reference that points to us. } /* return a pointer to the wrapped ocaml object */ CAML_VALUE swig_get_self() const { return swig_self; } /* acquire ownership of the wrapped ocaml object (the sense of "disown" is from ocaml) */ void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag=true; callback(*caml_named_value("caml_obj_disown"),swig_self); } } }; } swig-3.0.8/Lib/ocaml/typemaps.i0000664000175000017500000002354512641054563016207 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * The Ocaml module handles all types uniformly via typemaps. Here * are the definitions. * ----------------------------------------------------------------------------- */ /* Pointers */ %typemap(in) void "" %typemap(out) void "$result = Val_int(0);" %typemap(in) void * { $1 = caml_ptr_val($input,$descriptor); } %typemap(varin) void * { $1 = ($ltype)caml_ptr_val($input,$descriptor); } %typemap(out) void * { $result = caml_val_ptr($1,$descriptor); } %typemap(varout) void * { $result = caml_val_ptr($1,$descriptor); } #ifdef __cplusplus %typemap(in) SWIGTYPE & { /* %typemap(in) SWIGTYPE & */ $1 = ($ltype) caml_ptr_val($input,$1_descriptor); } %typemap(in) SWIGTYPE && { /* %typemap(in) SWIGTYPE && */ $1 = ($ltype) caml_ptr_val($input,$1_descriptor); } %typemap(varin) SWIGTYPE & { /* %typemap(varin) SWIGTYPE & */ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } %typemap(varin) SWIGTYPE && { /* %typemap(varin) SWIGTYPE && */ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } %typemap(out) SWIGTYPE & { /* %typemap(out) SWIGTYPE & */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *) &$1,$1_descriptor); } } %typemap(out) SWIGTYPE && { /* %typemap(out) SWIGTYPE && */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *) &$1,$1_descriptor); } } #if 0 %typemap(argout) SWIGTYPE & { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { swig_result = caml_list_append(swig_result, callback(*fromval,caml_val_ptr((void *) $1, $1_descriptor))); } else { swig_result = caml_list_append(swig_result, caml_val_ptr ((void *) $1,$1_descriptor)); } } %typemap(argout) SWIGTYPE && { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { swig_result = caml_list_append(swig_result, callback(*fromval,caml_val_ptr((void *) $1, $1_descriptor))); } else { swig_result = caml_list_append(swig_result, caml_val_ptr ((void *) $1,$1_descriptor)); } } #endif %typemap(argout) const SWIGTYPE & { } %typemap(argout) const SWIGTYPE && { } %typemap(in) SWIGTYPE { $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; } %typemap(out) SWIGTYPE { /* %typemap(out) SWIGTYPE */ $&1_ltype temp = new $ltype((const $1_ltype &) $1); CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); } else { $result = caml_val_ptr ((void *)temp,$&1_descriptor); } } %typemap(in) char *& (char *temp) { /* %typemap(in) char *& */ temp = (char*)caml_val_ptr($1,$descriptor); $1 = &temp; } %typemap(argout) char *& { /* %typemap(argout) char *& */ swig_result = caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1))); } #else %typemap(in) SWIGTYPE { $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; } %typemap(out) SWIGTYPE { /* %typemap(out) SWIGTYPE */ void *temp = calloc(1,sizeof($ltype)); CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); memmove( temp, &$1, sizeof( $1_type ) ); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); } else { $result = caml_val_ptr ((void *)temp,$&1_descriptor); } } %apply SWIGTYPE { const SWIGTYPE & }; %apply SWIGTYPE { const SWIGTYPE && }; #endif /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. */ %define SIMPLE_MAP(C_NAME, C_TO_MZ, MZ_TO_C) /* In */ %typemap(in) C_NAME { $1 = MZ_TO_C($input); } %typemap(varin) C_NAME { $1 = MZ_TO_C($input); } %typemap(in) C_NAME & ($*1_ltype temp) { temp = ($*1_ltype) MZ_TO_C($input); $1 = &temp; } %typemap(varin) C_NAME & { $1 = MZ_TO_C($input); } %typemap(directorout) C_NAME { $1 = MZ_TO_C($input); } %typemap(in) C_NAME *INPUT ($*1_ltype temp) { temp = ($*1_ltype) MZ_TO_C($input); $1 = &temp; } %typemap(in,numinputs=0) C_NAME *OUTPUT ($*1_ltype temp) { $1 = &temp; } /* Out */ %typemap(out) C_NAME { $result = C_TO_MZ($1); } %typemap(varout) C_NAME { $result = C_TO_MZ($1); } %typemap(varout) C_NAME & { /* %typemap(varout) C_NAME & (generic) */ $result = C_TO_MZ($1); } %typemap(argout) C_NAME *OUTPUT { swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); } %typemap(out) C_NAME & { /* %typemap(out) C_NAME & (generic) */ $result = C_TO_MZ(*$1); } %typemap(argout) C_NAME & { swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); } %typemap(directorin) C_NAME { args = caml_list_append(args,C_TO_MZ($1)); } %enddef SIMPLE_MAP(bool, caml_val_bool, caml_long_val); SIMPLE_MAP(oc_bool, caml_val_bool, caml_long_val); SIMPLE_MAP(char, caml_val_char, caml_long_val); SIMPLE_MAP(signed char, caml_val_char, caml_long_val); SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val); SIMPLE_MAP(int, caml_val_int, caml_long_val); SIMPLE_MAP(short, caml_val_short, caml_long_val); SIMPLE_MAP(wchar_t, caml_val_short, caml_long_val); SIMPLE_MAP(long, caml_val_long, caml_long_val); SIMPLE_MAP(ptrdiff_t, caml_val_int, caml_long_val); SIMPLE_MAP(unsigned int, caml_val_uint, caml_long_val); SIMPLE_MAP(unsigned short, caml_val_ushort, caml_long_val); SIMPLE_MAP(unsigned long, caml_val_ulong, caml_long_val); SIMPLE_MAP(size_t, caml_val_int, caml_long_val); SIMPLE_MAP(float, caml_val_float, caml_double_val); SIMPLE_MAP(double, caml_val_double, caml_double_val); SIMPLE_MAP(long long,caml_val_ulong,caml_long_val); SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); /* Void */ %typemap(out) void "$result = Val_unit;"; /* Pass through value */ %typemap (in) value,caml::value,CAML_VALUE "$1=$input;"; %typemap (out) value,caml::value,CAML_VALUE "$result=$1;"; /* Arrays */ %typemap(in) ArrayCarrier * { $1 = ($ltype)caml_ptr_val($input,$1_descriptor); } %typemap(out) ArrayCarrier * { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *)$1,$1_descriptor); } } #if 0 %include #endif /* Handle char arrays as strings */ %define %char_ptr_in(how) %typemap(how) char *, signed char *, unsigned char * { /* %typemap(how) char * ... */ $1 = ($ltype)caml_string_val($input); } /* Again work around the empty array bound bug */ %typemap(how) char [ANY], signed char [ANY], unsigned char [ANY] { /* %typemap(how) char [ANY] ... */ char *temp = caml_string_val($input); strcpy((char *)$1,temp); /* strncpy would be better but we might not have an array size */ } %enddef %char_ptr_in(in); %char_ptr_in(varin); %char_ptr_in(directorout); %define %char_ptr_out(how) %typemap(how) char *, signed char *, unsigned char *, const char *, const signed char *, const unsigned char * { $result = caml_val_string((char *)$1); } /* I'd like to use the length here but can't because it might be empty */ %typemap(how) char [ANY], signed char [ANY], unsigned char [ANY], const char [ANY], const signed char [ANY], const unsigned char [ANY] { $result = caml_val_string((char *)$1); } %enddef %char_ptr_out(out); %char_ptr_out(varout); %char_ptr_out(directorin); %define %swigtype_ptr_in(how) %typemap(how) SWIGTYPE * { /* %typemap(how) SWIGTYPE * */ $1 = ($ltype)caml_ptr_val($input,$1_descriptor); } %typemap(how) SWIGTYPE (CLASS::*) { /* %typemap(how) SWIGTYPE (CLASS::*) */ void *v = caml_ptr_val($input,$1_descriptor); memcpy(& $1, &v, sizeof(v)); } %enddef %define %swigtype_ptr_out(how) %typemap(out) SWIGTYPE * { /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *)$1,$1_descriptor); } } %typemap(how) SWIGTYPE (CLASS::*) { /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ void *v; memcpy(&v,& $1, sizeof(void *)); $result = caml_val_ptr (v,$1_descriptor); } %enddef %swigtype_ptr_in(in); %swigtype_ptr_in(varin); %swigtype_ptr_in(directorout); %swigtype_ptr_out(out); %swigtype_ptr_out(varout); %swigtype_ptr_out(directorin); %define %swigtype_array_fail(how,msg) %typemap(how) SWIGTYPE [] { failwith(msg); } %enddef %swigtype_array_fail(in,"Array arguments for arbitrary types need a typemap"); %swigtype_array_fail(varin,"Assignment to global arrays for arbitrary types need a typemap"); %swigtype_array_fail(out,"Array arguments for arbitrary types need a typemap"); %swigtype_array_fail(varout,"Array variables need a typemap"); %swigtype_array_fail(directorin,"Array results with arbitrary types need a typemap"); %swigtype_array_fail(directorout,"Array arguments with arbitrary types need a typemap"); /* C++ References */ /* Enums */ %define %swig_enum_in(how) %typemap(how) enum SWIGTYPE { $1 = ($type)caml_long_val_full($input,"$type_marker"); } %enddef %define %swig_enum_out(how) %typemap(how) enum SWIGTYPE { $result = callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1)); } %enddef %swig_enum_in(in) %swig_enum_in(varin) %swig_enum_in(directorout) %swig_enum_out(out) %swig_enum_out(varout) %swig_enum_out(directorin) /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-3.0.8/Lib/ocaml/std_vector.i0000664000175000017500000000530212641054563016510 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector types * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // Python as much as possible, namely, to allow the user to pass and // be returned Python tuples or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&), f(const std::vector*): // the parameter being read-only, either a Python sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(): // the vector is returned by copy; therefore, a Python sequence of T:s // is returned which is most easily used in other Python functions // -- std::vector& f(), std::vector* f(), const std::vector& f(), // const std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class vector { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); unsigned int size() const; bool empty() const; void clear(); void push_back(const T& x); T operator [] ( int f ); vector &operator = ( vector &other ); %extend { void set( int i, const T &x ) { self->resize(i+1); (*self)[i] = x; } }; %extend { T *to_array() { T *array = new T[self->size() + 1]; for( int i = 0; i < self->size(); i++ ) array[i] = (*self)[i]; return array; } }; }; }; %insert(ml) %{ let array_to_vector v argcons array = for i = 0 to (Array.length array) - 1 do (invoke v) "set" (C_list [ C_int i ; (argcons array.(i)) ]) done ; v let vector_to_array v argcons array = for i = 0; to (get_int ((invoke v) "size" C_void)) - 1 do array.(i) <- argcons ((invoke v) "[]" (C_int i)) done ; v %} %insert(mli) %{ val array_to_vector : c_obj -> ('a -> c_obj) -> 'a array -> c_obj val vector_to_array : c_obj -> (c_obj -> 'a) -> 'a array -> c_obj %} swig-3.0.8/Lib/ocaml/ocaml.i0000664000175000017500000000265212641054563015434 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ocaml.i * * SWIG Configuration File for Ocaml * ----------------------------------------------------------------------------- */ %runtime %{ #define SWIGSTATIC static %} /* Insert common stuff */ %insert(runtime) "swigrun.swg" /* Include headers */ %insert(runtime) "ocamldec.swg" /* Type registration */ %insert(init) "swiginit.swg" %insert(init) "typeregister.swg" %insert(mlitail) %{ val swig_val : c_enum_type -> c_obj -> Swig.c_obj %} %insert(mltail) %{ let rec swig_val t v = match v with C_enum e -> enum_to_int t v | C_list l -> Swig.C_list (List.map (swig_val t) l) | C_array a -> Swig.C_array (Array.map (swig_val t) a) | _ -> Obj.magic v %} /*#ifndef SWIG_NOINCLUDE*/ %insert(runtime) "ocaml.swg" /*#endif*/ %insert(classtemplate) "class.swg" /* Definitions */ #define SWIG_malloc(size) swig_malloc(size, FUNC_NAME) #define SWIG_free(mem) free(mem) /* Read in standard typemaps. */ %include %include %include %include %include /* ocaml keywords */ /* There's no need to use this, because of my rewriting machinery. C++ * words never collide with ocaml keywords */ /* still we include the file, but the warning says that the offending name will be properly renamed. Just to let the user to know about it. */ %include swig-3.0.8/Lib/ocaml/ocamldec.swg0000664000175000017500000001226612641054563016462 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ocamldec.swg * * Ocaml runtime code -- declarations * ----------------------------------------------------------------------------- */ #include #include #include #ifdef __cplusplus #define SWIGEXT extern "C" SWIGEXT { #else #define SWIGEXT #endif #define value caml_value_t #define CAML_VALUE caml_value_t #include #include #include #include #include #include #include #define caml_array_set swig_caml_array_set // Adapted from memory.h and mlvalues.h #define SWIG_CAMLlocal1(x) \ caml_value_t x = 0; \ CAMLxparam1 (x) #define SWIG_CAMLlocal2(x, y) \ caml_value_t x = 0, y = 0; \ CAMLxparam2 (x, y) #define SWIG_CAMLlocal3(x, y, z) \ caml_value_t x = 0, y = 0, z = 0; \ CAMLxparam3 (x, y, z) #define SWIG_CAMLlocal4(x, y, z, t) \ caml_value_t x = 0, y = 0, z = 0, t = 0; \ CAMLxparam4 (x, y, z, t) #define SWIG_CAMLlocal5(x, y, z, t, u) \ caml_value_t x = 0, y = 0, z = 0, t = 0, u = 0; \ CAMLxparam5 (x, y, z, t, u) #define SWIG_CAMLlocalN(x, size) \ caml_value_t x [(size)] = { 0, /* 0, 0, ... */ }; \ CAMLxparamN (x, (size)) #define SWIG_Field(x, i) (((caml_value_t *)(x)) [i]) /* Also an l-value. */ #define SWIG_Store_field(block, offset, val) do{ \ mlsize_t caml__temp_offset = (offset); \ caml_value_t caml__temp_val = (val); \ modify (&SWIG_Field ((block), caml__temp_offset), caml__temp_val); \ }while(0) #define SWIG_Data_custom_val(v) ((void *) &SWIG_Field((v), 1)) #ifdef ARCH_BIG_ENDIAN #define SWIG_Tag_val(val) (((unsigned char *) (val)) [-1]) /* Also an l-value. */ #define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [sizeof(caml_value_t)-1]) /* Also an l-value. */ #else #define SWIG_Tag_val(val) (((unsigned char *) (val)) [-sizeof(caml_value_t)]) /* Also an l-value. */ #define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [0]) /* Also an l-value. */ #endif #ifdef CAMLreturn0 #undef CAMLreturn0 #endif #define CAMLreturn0 do{ \ caml_local_roots = caml__frame; \ return; \ }while (0) #ifdef CAMLreturn #undef CAMLreturn #endif #define CAMLreturn(result) do{ \ caml_value_t caml__temp_result = (result); \ caml_local_roots = caml__frame; \ return (caml__temp_result); \ }while(0) #define CAMLreturn_type(result) do{ \ caml_local_roots = caml__frame; \ return result; \ }while(0) #ifdef CAMLnoreturn #undef CAMLnoreturn #endif #define CAMLnoreturn ((void) caml__frame) #ifndef ARCH_ALIGN_INT64 #define SWIG_Int64_val(v) (*((int64 *) SWIG_Data_custom_val(v))) #else CAMLextern int64 Int64_val(caml_value_t v); #define SWIG_Int64_val(v) Int64_val(v) #endif #define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type) #define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer) #define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else SWIGSTATIC int SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type); SWIGSTATIC void * SWIG_MustGetPtr (CAML_VALUE v, swig_type_info *type); SWIGSTATIC CAML_VALUE _wrap_delete_void( CAML_VALUE ); SWIGSTATIC int enum_to_int( char *name, CAML_VALUE v ); SWIGSTATIC CAML_VALUE int_to_enum( char *name, int v ); SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ); SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ); SWIGSTATIC int caml_list_length( CAML_VALUE lst ); SWIGSTATIC CAML_VALUE caml_array_new( int n ); SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ); SWIGSTATIC CAML_VALUE caml_array_nth( CAML_VALUE arr, int n ); SWIGSTATIC int caml_array_len( CAML_VALUE arr ); SWIGSTATIC CAML_VALUE caml_val_char( char c ); SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char c ); SWIGSTATIC CAML_VALUE caml_val_short( short s ); SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short s ); SWIGSTATIC CAML_VALUE caml_val_int( int x ); SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int x ); SWIGSTATIC CAML_VALUE caml_val_long( long x ); SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long x ); SWIGSTATIC CAML_VALUE caml_val_float( float f ); SWIGSTATIC CAML_VALUE caml_val_double( double d ); SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor ); SWIGSTATIC CAML_VALUE caml_val_string( const char *str ); SWIGSTATIC CAML_VALUE caml_val_string_len( const char *str, int len ); SWIGSTATIC long caml_long_val( CAML_VALUE v ); SWIGSTATIC double caml_double_val( CAML_VALUE v ); SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, swig_type_info *descriptor ); SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ); SWIGSTATIC char *caml_string_val( CAML_VALUE v ); SWIGSTATIC int caml_string_len( CAML_VALUE v ); #ifdef __cplusplus } #endif swig-3.0.8/Lib/ocaml/typecheck.i0000664000175000017500000001115412641054563016315 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typecheck.i * * Typechecking rules * ----------------------------------------------------------------------------- */ %typecheck(SWIG_TYPECHECK_INTEGER) char, signed char, const char &, const signed char & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_char: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, const unsigned char & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_uchar: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) short, signed short, const short &, const signed short &, wchar_t { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_short: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) unsigned short, const unsigned short & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_ushort: $1 = 1; break; default: $1 = 0; break; } } } // XXX arty // Will move enum SWIGTYPE later when I figure out what to do with it... %typecheck(SWIG_TYPECHECK_INTEGER) int, signed int, const int &, const signed int &, enum SWIGTYPE { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_int: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) unsigned int, const unsigned int & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_uint: $1 = 1; break; case C_int32: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) long, signed long, unsigned long, long long, signed long long, unsigned long long, const long &, const signed long &, const unsigned long &, const long long &, const signed long long &, const unsigned long long & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_int64: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_INTEGER) bool, oc_bool, BOOL, const bool &, const oc_bool &, const BOOL & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_bool: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_DOUBLE) float, const float & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_float: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_double: $1 = 1; break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_STRING) char * { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { case C_string: $1 = 1; break; case C_ptr: { swig_type_info *typeinfo = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field($input,1)); $1 = SWIG_TypeCheck("char *",typeinfo) || SWIG_TypeCheck("signed char *",typeinfo) || SWIG_TypeCheck("unsigned char *",typeinfo) || SWIG_TypeCheck("const char *",typeinfo) || SWIG_TypeCheck("const signed char *",typeinfo) || SWIG_TypeCheck("const unsigned char *",typeinfo) || SWIG_TypeCheck("std::string",typeinfo); } break; default: $1 = 0; break; } } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; $1 = !caml_ptr_val_internal($input, &ptr,$descriptor); } #if 0 %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; $1 = !caml_ptr_val_internal($input, &ptr, $&1_descriptor); } #endif %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; $1 = !caml_ptr_val_internal($input, &ptr, 0); } /* ------------------------------------------------------------ * Exception handling * ------------------------------------------------------------ */ %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short { SWIG_exception($1,"Thrown exception from C++ (int)"); } %typemap(throws) SWIGTYPE CLASS { $&1_ltype temp = new $1_ltype($1); SWIG_exception((int)temp,"Thrown exception from C++ (object)"); } %typemap(throws) SWIGTYPE { (void)$1; SWIG_exception(0,"Thrown exception from C++ (unknown)"); } %typemap(throws) char * { SWIG_exception(0,$1); } swig-3.0.8/Lib/ocaml/cstring.i0000664000175000017500000001366712641054563016022 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cstring.i * * This file provides typemaps and macros for dealing with various forms * of C character string handling. The primary use of this module * is in returning character data that has been allocated or changed in * some way. * ----------------------------------------------------------------------------- */ /* %cstring_input_binary(TYPEMAP, SIZE) * * Macro makes a function accept binary string data along with * a size. */ %define %cstring_input_binary(TYPEMAP, SIZE) %apply (char *STRING, int LENGTH) { (TYPEMAP, SIZE) }; %enddef /* * %cstring_bounded_output(TYPEMAP, MAX) * * This macro is used to return a NULL-terminated output string of * some maximum length. For example: * * %cstring_bounded_output(char *outx, 512); * void foo(char *outx) { * sprintf(outx,"blah blah\n"); * } * */ %define %cstring_bounded_output(TYPEMAP,MAX) %typemap(ignore) TYPEMAP(char temp[MAX+1]) { $1 = ($1_ltype) temp; } %typemap(argout) TYPEMAP { $1[MAX] = 0; $result = caml_list_append($result,caml_val_string(str)); } %enddef /* * %cstring_chunk_output(TYPEMAP, SIZE) * * This macro is used to return a chunk of binary string data. * Embedded NULLs are okay. For example: * * %cstring_chunk_output(char *outx, 512); * void foo(char *outx) { * memmove(outx, somedata, 512); * } * */ %define %cstring_chunk_output(TYPEMAP,SIZE) %typemap(ignore) TYPEMAP(char temp[SIZE]) { $1 = ($1_ltype) temp; } %typemap(argout) TYPEMAP { $result = caml_list_append($result,caml_val_string_len($1,SIZE)); } %enddef /* * %cstring_bounded_mutable(TYPEMAP, SIZE) * * This macro is used to wrap a string that's going to mutate. * * %cstring_bounded_mutable(char *in, 512); * void foo(in *x) { * while (*x) { * *x = toupper(*x); * x++; * } * } * */ %define %cstring_bounded_mutable(TYPEMAP,MAX) %typemap(in) TYPEMAP(char temp[MAX+1]) { char *t = (char *)caml_ptr_val($input); strncpy(temp,t,MAX); $1 = ($1_ltype) temp; } %typemap(argout) TYPEMAP { $result = caml_list_append($result,caml_val_string_len($1,MAX)); } %enddef /* * %cstring_mutable(TYPEMAP [, expansion]) * * This macro is used to wrap a string that will mutate in place. * It may change size up to a user-defined expansion. * * %cstring_mutable(char *in); * void foo(in *x) { * while (*x) { * *x = toupper(*x); * x++; * } * } * */ %define %cstring_mutable(TYPEMAP,...) %typemap(in) TYPEMAP { char *t = String_val($input); int n = string_length($input); $1 = ($1_ltype) t; #if #__VA_ARGS__ == "" #ifdef __cplusplus $1 = ($1_ltype) new char[n+1]; #else $1 = ($1_ltype) malloc(n+1); #endif #else #ifdef __cplusplus $1 = ($1_ltype) new char[n+1+__VA_ARGS__]; #else $1 = ($1_ltype) malloc(n+1+__VA_ARGS__); #endif #endif memmove($1,t,n); $1[n] = 0; } %typemap(argout) TYPEMAP { $result = caml_list_append($result,caml_val_string($1)); #ifdef __cplusplus delete[] $1; #else free($1); #endif } %enddef /* * %cstring_output_maxsize(TYPEMAP, SIZE) * * This macro returns data in a string of some user-defined size. * * %cstring_output_maxsize(char *outx, int max) { * void foo(char *outx, int max) { * sprintf(outx,"blah blah\n"); * } */ %define %cstring_output_maxsize(TYPEMAP, SIZE) %typemap(in) (TYPEMAP, SIZE) { $2 = caml_val_long($input); #ifdef __cplusplus $1 = ($1_ltype) new char[$2+1]; #else $1 = ($1_ltype) malloc($2+1); #endif } %typemap(argout) (TYPEMAP,SIZE) { $result = caml_list_append($result,caml_val_string($1)); #ifdef __cplusplus delete [] $1; #else free($1); #endif } %enddef /* * %cstring_output_withsize(TYPEMAP, SIZE) * * This macro is used to return character data along with a size * parameter. * * %cstring_output_maxsize(char *outx, int *max) { * void foo(char *outx, int *max) { * sprintf(outx,"blah blah\n"); * *max = strlen(outx); * } */ %define %cstring_output_withsize(TYPEMAP, SIZE) %typemap(in) (TYPEMAP, SIZE) { int n = caml_val_long($input); #ifdef __cplusplus $1 = ($1_ltype) new char[n+1]; $2 = ($2_ltype) new $*1_ltype; #else $1 = ($1_ltype) malloc(n+1); $2 = ($2_ltype) malloc(sizeof($*1_ltype)); #endif *$2 = n; } %typemap(argout) (TYPEMAP,SIZE) { $result = caml_list_append($result,caml_val_string_len($1,$2)); #ifdef __cplusplus delete [] $1; delete $2; #else free($1); free($2); #endif } %enddef /* * %cstring_output_allocate(TYPEMAP, RELEASE) * * This macro is used to return character data that was * allocated with new or malloc. * * %cstring_output_allocated(char **outx, free($1)); * void foo(char **outx) { * *outx = (char *) malloc(512); * sprintf(outx,"blah blah\n"); * } */ %define %cstring_output_allocate(TYPEMAP, RELEASE) %typemap(ignore) TYPEMAP($*1_ltype temp = 0) { $1 = &temp; } %typemap(argout) TYPEMAP { if (*$1) { $result = caml_list_append($result,caml_val_string($1)); RELEASE; } else { $result = caml_list_append($result,caml_val_ptr($1)); } } %enddef /* * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) * * This macro is used to return character data that was * allocated with new or malloc. * * %cstring_output_allocated(char **outx, int *sz, free($1)); * void foo(char **outx, int *sz) { * *outx = (char *) malloc(512); * sprintf(outx,"blah blah\n"); * *sz = strlen(outx); * } */ %define %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) %typemap(ignore) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { $1 = &temp; $2 = &tempn; } %typemap(argout)(TYPEMAP,SIZE) { if (*$1) { $result = caml_list_append($result,caml_val_string_len($1,$2)); RELEASE; } else $result = caml_list_append($result,caml_val_ptr($1)); } %enddef swig-3.0.8/Lib/ocaml/swigp4.ml0000664000175000017500000001477412641054563015746 0ustar williamwilliamopen Camlp4 module Id : Sig.Id = struct let name = "swigp4" let version = "0.1" end module Make (Syntax : Sig.Camlp4Syntax) = struct open Sig include Syntax let _loc = Loc.ghost let lap x y = x :: y let c_ify e loc = match e with <:expr< $int:_$ >> -> <:expr< (C_int $e$) >> | <:expr< $str:_$ >> -> <:expr< (C_string $e$) >> | <:expr< $chr:_$ >> -> <:expr< (C_char $e$) >> | <:expr< $flo:_$ >> -> <:expr< (C_double $e$) >> | <:expr< True >> -> <:expr< (C_bool $e$) >> | <:expr< False >> -> <:expr< (C_bool $e$) >> | _ -> <:expr< $e$ >> let mk_list args loc f = let rec mk_list_inner args loc f = match args with [] -> <:expr< [] >> | x :: xs -> (let loc = Ast.loc_of_expr x in <:expr< [ ($f x _loc$) ] @ ($mk_list_inner xs loc f$) >>) in match args with [] -> <:expr< (Obj.magic C_void) >> | [ a ] -> <:expr< (Obj.magic $f a _loc$) >> | _ -> <:expr< (Obj.magic (C_list ($mk_list_inner args loc f$))) >> ;; EXTEND Gram GLOBAL: expr; expr: LEVEL "top" [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" -> <:expr< (invoke $e1$) "[]" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $str:l$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $str:u$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $s$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "." ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) "()" ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:l$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:u$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $s$ ($mk_list args _loc c_ify$) >> | e1 = expr ; "'" ; "++" -> <:expr< (invoke $e1$) "++" C_void >> | e1 = expr ; "'" ; "--" -> <:expr< (invoke $e1$) "--" C_void >> | e1 = expr ; "'" ; "-" ; e2 = expr -> <:expr< (invoke $e1$) "-" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "+" ; e2 = expr -> <:expr< (invoke $e1$) "+" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "*" ; e2 = expr -> <:expr< (invoke $e1$) "*" (C_list [ $c_ify e2 _loc$ ]) >> | "'" ; "&" ; e1 = expr -> <:expr< (invoke $e1$) "&" C_void >> | "'" ; "!" ; e1 = expr -> <:expr< (invoke $e1$) "!" C_void >> | "'" ; "~" ; e1 = expr -> <:expr< (invoke $e1$) "~" C_void >> | e1 = expr ; "'" ; "/" ; e2 = expr -> <:expr< (invoke $e1$) "/" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "%" ; e2 = expr -> <:expr< (invoke $e1$) "%" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "lsl" ; e2 = expr -> <:expr< (invoke $e1$) ("<" ^ "<") (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "lsr" ; e2 = expr -> <:expr< (invoke $e1$) (">" ^ ">") (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "<" ; e2 = expr -> <:expr< (invoke $e1$) "<" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "<=" ; e2 = expr -> <:expr< (invoke $e1$) "<=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; ">" ; e2 = expr -> <:expr< (invoke $e1$) ">" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; ">=" ; e2 = expr -> <:expr< (invoke $e1$) ">=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "==" ; e2 = expr -> <:expr< (invoke $e1$) "==" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "!=" ; e2 = expr -> <:expr< (invoke $e1$) "!=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "&" ; e2 = expr -> <:expr< (invoke $e1$) "&" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "^" ; e2 = expr -> <:expr< (invoke $e1$) "^" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "|" ; e2 = expr -> <:expr< (invoke $e1$) "|" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "&&" ; e2 = expr -> <:expr< (invoke $e1$) "&&" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "||" ; e2 = expr -> <:expr< (invoke $e1$) "||" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) "=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "+=" ; e2 = expr -> <:expr< (invoke $e1$) "+=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "-=" ; e2 = expr -> <:expr< (invoke $e1$) "-=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "*=" ; e2 = expr -> <:expr< (invoke $e1$) "*=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "/=" ; e2 = expr -> <:expr< (invoke $e1$) "/=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "%=" ; e2 = expr -> <:expr< (invoke $e1$) "%=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "lsl" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) ("<" ^ "<=") (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "lsr" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) (">" ^ ">=") (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "&=" ; e2 = expr -> <:expr< (invoke $e1$) "&=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "^=" ; e2 = expr -> <:expr< (invoke $e1$) "^=" (C_list [ $c_ify e2 _loc$ ]) >> | e1 = expr ; "'" ; "|=" ; e2 = expr -> <:expr< (invoke $e1$) "|=" (C_list [ $c_ify e2 _loc$ ]) >> | "'" ; e = expr -> c_ify e _loc | c = expr ; "as" ; id = LIDENT -> <:expr< $lid:"get_" ^ id$ $c$ >> | c = expr ; "to" ; id = LIDENT -> <:expr< $uid:"C_" ^ id$ $c$ >> | "`" ; "`" ; l = LIDENT -> <:expr< C_enum `$lid:l$ >> | "`" ; "`" ; u = UIDENT -> <:expr< C_enum `$uid:u$ >> | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< $f$ ($mk_list args _loc c_ify$) >> ] ] ; END ;; end module M = Register.OCamlSyntaxExtension(Id)(Make) swig-3.0.8/Lib/ocaml/std_complex.i0000664000175000017500000000301412641054563016653 0ustar williamwilliam// -*- C++ -*- #ifndef SWIG_STD_COMPLEX_I_ #define SWIG_STD_COMPLEX_I_ #ifdef SWIG %{ #include %} namespace std { template class complex; %define specialize_std_complex(T) %typemap(in) complex { if (PyComplex_Check($input)) { $1 = std::complex(PyComplex_RealAsDouble($input), PyComplex_ImagAsDouble($input)); } else if (PyFloat_Check($input)) { $1 = std::complex(PyFloat_AsDouble($input), 0); } else if (PyInt_Check($input)) { $1 = std::complex(PyInt_AsLong($input), 0); } else { PyErr_SetString(PyExc_TypeError,"Expected a complex"); SWIG_fail; } } %typemap(in) const complex& (std::complex temp) { if (PyComplex_Check($input)) { temp = std::complex(PyComplex_RealAsDouble($input), PyComplex_ImagAsDouble($input)); $1 = &temp; } else if (PyFloat_Check($input)) { temp = std::complex(PyFloat_AsDouble($input), 0); $1 = &temp; } else if (PyInt_Check($input)) { temp = std::complex(PyInt_AsLong($input), 0); $1 = &temp; } else { PyErr_SetString(PyExc_TypeError,"Expected a complex"); SWIG_fail; } } %typemap(out) complex { $result = PyComplex_FromDoubles($1.real(), $1.imag()); } %typemap(out) const complex & { $result = PyComplex_FromDoubles($1->real(), $1->imag()); } %enddef specialize_std_complex(double); specialize_std_complex(float); } #endif // SWIG #endif //SWIG_STD_COMPLEX_I_ swig-3.0.8/Lib/xml/0000775000175000017500000000000012641054563013667 5ustar williamwilliamswig-3.0.8/Lib/xml/xml.swg0000664000175000017500000000002512641054563015206 0ustar williamwilliam/* nothing special */swig-3.0.8/Lib/xml/typemaps.i0000664000175000017500000000026312641054563015704 0ustar williamwilliam// -------------------------------------------------------------------- // Empty file for %include to work // -------------------------------------------------------------------- swig-3.0.8/Lib/cwstring.i0000664000175000017500000000041112641054563015075 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cwstring.i * ----------------------------------------------------------------------------- */ %echo "cwstring.i not implemented for this target" #define SWIG_CWSTRING_UNIMPL swig-3.0.8/Lib/pike/0000775000175000017500000000000012641054563014017 5ustar williamwilliamswig-3.0.8/Lib/pike/pikekw.swg0000664000175000017500000000152112641054563016032 0ustar williamwilliam#ifndef PIKE_PIKEKW_SWG_ #define PIKE_PIKEKW_SWG_ /* Warnings for Pike keywords */ #define PIKEKW(x) %namewarn("314: '" #x "' is a pike keyword") #x /* from http://www.http://docs.linux.cz/pike/tutorial_C.html */ PIKEKW(array); PIKEKW(break); PIKEKW(case); PIKEKW(catch); PIKEKW(continue); PIKEKW(default); PIKEKW(do); PIKEKW(else); PIKEKW(float); PIKEKW(for); PIKEKW(foreach); PIKEKW(function); PIKEKW(gauge); PIKEKW(if); PIKEKW(inherit); PIKEKW(inline); PIKEKW(int); PIKEKW(lambda); PIKEKW(mapping); PIKEKW(mixed); PIKEKW(multiset); PIKEKW(nomask); PIKEKW(object); PIKEKW(predef); PIKEKW(private); PIKEKW(program); PIKEKW(protected); PIKEKW(public); PIKEKW(return); PIKEKW(sscanf); PIKEKW(static); PIKEKW(string); PIKEKW(switch); PIKEKW(typeof); PIKEKW(varargs); PIKEKW(void); PIKEKW(while); #undef PIKEKW #endif //PIKE_PIKEKW_SWG_ swig-3.0.8/Lib/pike/pikerun.swg0000664000175000017500000000403712641054563016222 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pikerun.swg * * This file contains the runtime support for Pike modules * and includes code for managing global variables and pointer * type checking. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif #include "pike/object.h" #include "pike/program.h" #ifdef __cplusplus } #endif #include /* Stores information about a wrapped object */ typedef struct swig_object_wrapper { void *self; swig_type_info *type; } swig_object_wrapper; #ifdef THIS #undef THIS #endif #define THIS (((swig_object_wrapper *) Pike_fp->current_storage)->self) #define SWIG_ConvertPtr SWIG_Pike_ConvertPtr #define SWIG_NewPointerObj SWIG_Pike_NewPointerObj #define SWIG_GetModule(clientdata) SWIG_Pike_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Pike_SetModule(pointer) /* These need to be filled in before type sharing between modules will work */ static swig_module_info *SWIG_Pike_GetModule(void *SWIGUNUSEDPARM(clientdata)) { return 0; } static void SWIG_Pike_SetModule(swig_module_info *pointer) { } /* Convert a pointer value */ static int SWIG_Pike_ConvertPtr(struct object *obj, void **ptr, swig_type_info *ty, int flags) { struct program *pr; swig_cast_info *tc; swig_object_wrapper *obj_wrapper; if (ty) { pr = (struct program *) ty->clientdata; obj_wrapper = (swig_object_wrapper *) get_storage(obj, pr); if (obj_wrapper && obj_wrapper->type) { tc = SWIG_TypeCheckStruct(obj_wrapper->type, ty); if (tc) { int newmemory = 0; *ptr = SWIG_TypeCast(tc, obj_wrapper->self, &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return 0; } } } return -1; } /* Create a new pointer object */ static struct object * SWIG_Pike_NewPointerObj(void *ptr, swig_type_info *type, int own) { return 0; } swig-3.0.8/Lib/pike/std_string.i0000664000175000017500000000310712641054563016352 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; class string; /* Overloading check */ %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; %typemap(in, pikedesc="tStr") string { if ($input.type != T_STRING) Pike_error("Bad argument: Expected a string.\n"); $1.assign(STR0($input.u.string)); } %typemap(in, pikedesc="tStr") const string & ($*1_ltype temp) { if ($input.type != T_STRING) Pike_error("Bad argument: Expected a string.\n"); temp.assign(STR0($input.u.string)); $1 = &temp; } %typemap(out, pikedesc="tStr") string "push_text($1.c_str());"; %typemap(out, pikedesc="tStr") const string & "push_text($1->c_str());"; %typemap(directorin) string, const string &, string & "$1.c_str()"; %typemap(directorin) string *, const string * "$1->c_str()"; %typemap(directorout) string { if ($input.type == T_STRING) $result.assign(STR0($input.u.string)); else throw Swig::DirectorTypeMismatchException("string expected"); } %typemap(directorout) const string & ($*1_ltype temp) { if ($input.type == T_STRING) { temp.assign(STR0($input.u.string)); $result = &temp; } else { throw Swig::DirectorTypeMismatchException("string expected"); } } } swig-3.0.8/Lib/pike/pike.swg0000664000175000017500000002254712641054563015503 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pike.swg * * Pike configuration module. * ----------------------------------------------------------------------------- */ %insert(runtime) "swigrun.swg"; // Common C API type-checking code %insert(runtime) "pikerun.swg"; // Pike run-time code %insert(runtime) %{ #ifdef __cplusplus extern "C" { #endif #include #include #include #ifdef __cplusplus } #endif %} /* ----------------------------------------------------------------------------- * standard typemaps * ----------------------------------------------------------------------------- */ /* --- Input arguments --- */ /* Primitive datatypes. */ %typemap(in, pikedesc="tInt") int, unsigned int, short, unsigned short, long, unsigned long, char, signed char, unsigned char, bool, enum SWIGTYPE, long long, unsigned long long { if ($input.type != T_INT) Pike_error("Bad argument: Expected an integer.\n"); $1 = ($1_ltype) $input.u.integer; } %typemap(in, pikedesc="tFloat") float, double { if ($input.type != T_FLOAT) Pike_error("Bad argument: Expected a float.\n"); $1 = ($1_ltype) $input.u.float_number; } %typemap(in, pikedesc="tStr") char *, char [ANY] { if ($input.type != T_STRING) Pike_error("Bad argument: Expected a string.\n"); $1 = ($1_ltype) STR0($input.u.string); } /* Pointers, references and arrays */ %typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "SWIG_ConvertPtr($input.u.object, (void **) &$1, $1_descriptor, 1);" /* Void pointer. Accepts any kind of pointer */ %typemap(in) void * "/* FIXME */"; /* Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_ltype argp) "/* FIXME */"; /* Pointer to a class member */ %typemap(in) SWIGTYPE (CLASS::*) "/* FIXME */"; /* Const primitive references. Passed by value */ %typemap(in, pikedesc="tInt") const int & (int temp), const short & (short temp), const long & (long temp), const unsigned int & (unsigned int temp), const unsigned short & (unsigned short temp), const unsigned long & (unsigned long temp), const char & (char temp), const signed char & (signed char temp), const unsigned char & (unsigned char temp), const bool & (bool temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const enum SWIGTYPE & ($*1_ltype temp), const enum SWIGTYPE && ($*1_ltype temp) { if ($input.type != T_INT) Pike_error("Bad argument: Expected an integer.\n"); temp = ($*1_ltype) $input.u.integer; $1 = &temp; } %typemap(in, pikedesc="tFloat") const float & (float temp), const double & (double temp) { if ($input.type != T_FLOAT) Pike_error("Bad argument: Expected a float.\n"); temp = ($*1_ltype) $input.u.float_number; $1 = &temp; } /* ----------------------------------------------------------------------------- * Output Typemaps * ----------------------------------------------------------------------------- */ %typemap(out, pikedesc="tInt") int, unsigned int, short, unsigned short, long, unsigned long, char, signed char, unsigned char, bool, enum SWIGTYPE "push_int($1);"; %typemap(out, pikedesc="tInt") long long "push_int64($1);"; %typemap(out, pikedesc="tInt") unsigned long long "push_int64($1);"; %typemap(out, pikedesc="tFloat") float, double "push_float($1);"; %typemap(out, pikedesc="tStr") char * "push_text($1);"; /* Pointers, references, and arrays */ %typemap(out, pikedesc="tObj") SWIGTYPE*, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "push_object(SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));"; /* Void return value; don't push anything */ %typemap(out, pikedesc="tVoid") void ""; /* Dynamic casts */ %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC "/* FIXME */"; /* Member pointer */ %typemap(out) SWIGTYPE (CLASS::*) "/* FIXME */"; /* Special typemap for character array return values */ %typemap(out, pikedesc="tStr") char [ANY], const char [ANY] "push_text($1);"; /* Primitive types--return by value */ %typemap(out, pikedesc="tObj") SWIGTYPE #ifdef __cplusplus { $&1_ltype resultptr; resultptr = new $1_ltype((const $1_ltype &) $1); push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1)); } #else { $&1_ltype resultptr; resultptr = ($&1_ltype) malloc(sizeof($1_type)); memmove(resultptr, &$1, sizeof($1_type)); push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1)); } #endif /* References to primitive types. Return by value */ %typemap(out, pikedesc="tInt") const int &, const unsigned int &, const short &, const unsigned short &, const long &, const unsigned long &, const char &, const signed char &, const unsigned char &, const bool &, const long long &, const unsigned long long &, const enum SWIGTYPE & ($*1_ltype temp), const enum SWIGTYPE && ($*1_ltype temp) "push_int(*($1));"; %typemap(out, pikedesc="tFloat") const float &, const double & "push_float(*($1));"; /************************ Constant Typemaps *****************************/ %typemap(constant) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, bool, enum SWIGTYPE, long long, unsigned long long "add_integer_constant(\"$symname\", $1, 0);"; %typemap(constant) char "add_integer_constant(\"$symname\", '$1', 0);"; %typemap(constant) long long, unsigned long long "add_integer_constant(\"$symname\", $1, 0);"; %typemap(constant) float, double "add_float_constant(\"$symname\", $1, 0);"; %typemap(constant) char * "add_string_constant(\"$symname\", \"$1\", 0);"; /* ------------------------------------------------------------ * String & length * ------------------------------------------------------------ */ %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { if ($input.type != T_STRING) Pike_error("Bad argument: Expected a string.\n"); $1 = ($1_ltype) STR0($input.u.string); $2 = ($2_ltype) $input.u.string->length; } /* ------------------------------------------------------------ * ANSI C typemaps * ------------------------------------------------------------ */ %typemap(in, pikedesc="tInt") size_t { if ($input.type != T_INT) Pike_error("Bad argument: Expected an integer.\n"); $1 = ($1_ltype) $input.u.integer; } %typemap(out) size_t = long; /* ------------------------------------------------------------ * Typechecking rules * ------------------------------------------------------------ */ %typecheck(SWIG_TYPECHECK_INTEGER) int, short, long, unsigned int, unsigned short, unsigned long, signed char, unsigned char, long long, unsigned long long, const int &, const short &, const long &, const unsigned int &, const unsigned short &, const unsigned long &, const long long &, const unsigned long long &, enum SWIGTYPE, enum SWIGTYPE &, SWIGTYPE &&, bool, const bool & { $1 = ($input.type == T_INT) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) float, double, const float &, const double & { $1 = (($input.type == T_FLOAT) || ($input.type == T_INT)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = ($input.type == T_INT) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = ($input.type == T_STRING) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $1_descriptor, 0) == -1) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $&1_descriptor, 0) == -1) { $1 = 0; } else { $1 = 1; } } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, 0, 0) == -1) { $1 = 0; } else { $1 = 1; } } /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus %rename("`+") *::operator+; %rename("`-") *::operator-; %rename("`*") *::operator*; %rename("`/") *::operator/; %rename("`%") *::operator%; %rename("`<<") *::operator<<; %rename("`>>") *::operator>>; %rename("`&") *::operator&; %rename("`|") *::operator|; %rename("`^") *::operator^; %rename("`~") *::operator~; %rename("`<") *::operator<; %rename("`>") *::operator>; %rename("`==") *::operator==; /* Special cases */ %rename("`()") *::operator(); #endif /* ------------------------------------------------------------ * The start of the Pike initialization function * ------------------------------------------------------------ */ %init "swiginit.swg" %init %{ #ifdef __cplusplus extern "C" #endif PIKE_MODULE_EXIT {} #ifdef __cplusplus extern "C" #endif PIKE_MODULE_INIT { struct program *pr; SWIG_InitializeModule(0); %} /* pike keywords */ %include swig-3.0.8/Lib/tcl/0000775000175000017500000000000012641054563013651 5ustar williamwilliamswig-3.0.8/Lib/tcl/std_pair.i0000664000175000017500000000130312641054563015625 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * Typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/tcl/tcluserdir.swg0000664000175000017500000000030312641054563016547 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Special user directives * ----------------------------------------------------------------------------- */ swig-3.0.8/Lib/tcl/tclmacros.swg0000664000175000017500000000004612641054563016362 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/tclsh.i0000664000175000017500000000351712641054563015146 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclsh.i * * SWIG File for building new tclsh program * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %subsection "tclsh.i" %text %{ This module provides the Tcl_AppInit() function needed to build a new version of the tclsh executable. This file should not be used when using dynamic loading. To make an interface file work with both static and dynamic loading, put something like this in your interface file : #ifdef STATIC %include #endif %} #endif %{ /* A TCL_AppInit() function that lets you build a new copy * of tclsh. * * The macro SWIG_init contains the name of the initialization * function in the wrapper file. */ #ifndef SWIG_RcFileName char *SWIG_RcFileName = "~/.myapprc"; #endif #ifdef MAC_TCL extern int MacintoshInit _ANSI_ARGS_((void)); #endif int Tcl_AppInit(Tcl_Interp *interp){ if (Tcl_Init(interp) == TCL_ERROR) return TCL_ERROR; /* Now initialize our functions */ if (SWIG_init(interp) == TCL_ERROR) return TCL_ERROR; #if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5 Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY); #else tcl_RcFileName = SWIG_RcFileName; #endif #ifdef SWIG_RcRsrcName Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL); #endif return TCL_OK; } #if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 4 int main(int argc, char **argv) { #ifdef MAC_TCL char *newArgv[2]; if (MacintoshInit() != TCL_OK) { Tcl_Exit(1); } argc = 1; newArgv[0] = "tclsh"; newArgv[1] = NULL; argv = newArgv; #endif Tcl_Main(argc, argv, Tcl_AppInit); return(0); } #else extern int main(); #endif %} swig-3.0.8/Lib/tcl/std_except.i0000664000175000017500000000004312641054563016162 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/tcl8.swg0000664000175000017500000000273412641054563015253 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tcl8.swg * * Tcl configuration module. * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * Inner macros * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The runtime part * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Special user directives * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Typemap specializations * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Warnings for Tcl keywords * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Tcl initialization function * ------------------------------------------------------------ */ %include swig-3.0.8/Lib/tcl/cdata.i0000664000175000017500000000003612641054563015076 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/carrays.i0000664000175000017500000000004312641054563015464 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/tclresult.i0000664000175000017500000000125412641054563016046 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclresult.i * ----------------------------------------------------------------------------- */ /* int Tcl_Result Makes the integer return code of a function the return value of a SWIG generated wrapper function. For example : int foo() { ... do stuff ... return TCL_OK; } could be wrapped as follows : %include typemaps.i %apply int Tcl_Result { int foo }; int foo(); */ // If return code is a Tcl_Result, simply pass it on %typemap(out) int Tcl_Result { return $1; } swig-3.0.8/Lib/tcl/exception.i0000664000175000017500000000022112641054563016014 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); return TCL_ERROR;)) } swig-3.0.8/Lib/tcl/std_deque.i0000664000175000017500000000003412641054563015775 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/std_common.i0000664000175000017500000000072312641054563016167 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %types(std::size_t); %apply size_t { std::size_t }; %apply const unsigned long& { const std::size_t& }; %types(std::ptrdiff_t); %apply long { std::ptrdiff_t }; %apply const long& { const std::ptrdiff_t& }; swig-3.0.8/Lib/tcl/cni.i0000664000175000017500000000005212641054563014571 0ustar williamwilliam%include %include swig-3.0.8/Lib/tcl/factory.i0000664000175000017500000000004012641054563015464 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/tclkw.swg0000664000175000017500000000036712641054563015525 0ustar williamwilliam#ifndef TCL_TCLKW_SWG_ #define TCL_TCLKW_SWG_ // Some special reserved words in classes %keywordwarn("cget is a tcl reserved method name") *::cget; %keywordwarn("configure is a tcl reserved method name") *::configure; #endif //_TCL_TCLKW_SWG_ swig-3.0.8/Lib/tcl/tclerrors.swg0000664000175000017500000000323712641054563016417 0ustar williamwilliam/* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGINTERN const char* SWIG_Tcl_ErrorType(int code) { const char* type = 0; switch(code) { case SWIG_MemoryError: type = "MemoryError"; break; case SWIG_IOError: type = "IOError"; break; case SWIG_RuntimeError: type = "RuntimeError"; break; case SWIG_IndexError: type = "IndexError"; break; case SWIG_TypeError: type = "TypeError"; break; case SWIG_DivisionByZero: type = "ZeroDivisionError"; break; case SWIG_OverflowError: type = "OverflowError"; break; case SWIG_SyntaxError: type = "SyntaxError"; break; case SWIG_ValueError: type = "ValueError"; break; case SWIG_SystemError: type = "SystemError"; break; case SWIG_AttributeError: type = "AttributeError"; break; default: type = "RuntimeError"; } return type; } SWIGINTERN void SWIG_Tcl_SetErrorObj(Tcl_Interp *interp, const char *ctype, Tcl_Obj *obj) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, obj); Tcl_SetErrorCode(interp, "SWIG", ctype, NULL); } SWIGINTERN void SWIG_Tcl_SetErrorMsg(Tcl_Interp *interp, const char *ctype, const char *mesg) { Tcl_ResetResult(interp); Tcl_SetErrorCode(interp, "SWIG", ctype, NULL); Tcl_AppendResult(interp, ctype, " ", mesg, NULL); /* Tcl_AddErrorInfo(interp, ctype); Tcl_AddErrorInfo(interp, " "); Tcl_AddErrorInfo(interp, mesg); */ } SWIGINTERNINLINE void SWIG_Tcl_AddErrorMsg(Tcl_Interp *interp, const char* mesg) { Tcl_AddErrorInfo(interp, mesg); } swig-3.0.8/Lib/tcl/tclrun.swg0000664000175000017500000005332012641054563015705 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclrun.swg * * This file contains the runtime support for Tcl modules and includes * code for managing global variables and pointer type checking. * ----------------------------------------------------------------------------- */ /* Common SWIG API */ /* for raw pointers */ #define SWIG_ConvertPtr(oc, ptr, ty, flags) SWIG_Tcl_ConvertPtr(interp, oc, ptr, ty, flags) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Tcl_NewPointerObj(ptr, type, flags) /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Tcl_ConvertPacked(interp, obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, flags) #define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_Tcl_NewInstanceObj(interp, thisvalue, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Tcl_NewPointerObj(ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Tcl_ConvertPacked(interp,obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata)) #define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer) /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Tcl_ErrorType(code) #define SWIG_Error(code, msg) SWIG_Tcl_SetErrorMsg(interp, SWIG_Tcl_ErrorType(code), msg) #define SWIG_fail goto fail /* Tcl-specific SWIG API */ #define SWIG_Acquire(ptr) SWIG_Tcl_Acquire(ptr) #define SWIG_MethodCommand SWIG_Tcl_MethodCommand #define SWIG_Disown(ptr) SWIG_Tcl_Disown(ptr) #define SWIG_ConvertPtrFromString(c, ptr, ty, flags) SWIG_Tcl_ConvertPtrFromString(interp, c, ptr, ty, flags) #define SWIG_MakePtr(c, ptr, ty, flags) SWIG_Tcl_MakePtr(c, ptr, ty, flags) #define SWIG_PointerTypeFromString(c) SWIG_Tcl_PointerTypeFromString(c) #define SWIG_GetArgs SWIG_Tcl_GetArgs #define SWIG_GetConstantObj(key) SWIG_Tcl_GetConstantObj(key) #define SWIG_ObjectConstructor SWIG_Tcl_ObjectConstructor #define SWIG_Thisown(ptr) SWIG_Tcl_Thisown(ptr) #define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete #define SWIG_TCL_DECL_ARGS_2(arg1, arg2) (Tcl_Interp *interp SWIGUNUSED, arg1, arg2) #define SWIG_TCL_CALL_ARGS_2(arg1, arg2) (interp, arg1, arg2) /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #define SWIG_GetConstant SWIG_GetConstantObj #define SWIG_Tcl_GetConstant SWIG_Tcl_GetConstantObj #if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 5 #define SWIG_TCL_HASHTABLE_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #else #define SWIG_TCL_HASHTABLE_INIT {0} #endif #include "assert.h" #ifdef __cplusplus extern "C" { #endif /* Object support */ SWIGRUNTIME Tcl_HashTable* SWIG_Tcl_ObjectTable(void) { static Tcl_HashTable swigobjectTable; static int swigobjectTableinit = 0; if (!swigobjectTableinit) { Tcl_InitHashTable(&swigobjectTable, TCL_ONE_WORD_KEYS); swigobjectTableinit = 1; } return &swigobjectTable; } /* Acquire ownership of a pointer */ SWIGRUNTIME void SWIG_Tcl_Acquire(void *ptr) { int newobj; Tcl_CreateHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr, &newobj); } SWIGRUNTIME int SWIG_Tcl_Thisown(void *ptr) { if (Tcl_FindHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr)) { return 1; } return 0; } /* Disown a pointer. Returns 1 if we owned it to begin with */ SWIGRUNTIME int SWIG_Tcl_Disown(void *ptr) { Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr); if (entryPtr) { Tcl_DeleteHashEntry(entryPtr); return 1; } return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swig_type_info *ty, int flags) { swig_cast_info *tc; /* Pointer values must start with leading underscore */ while (*c != '_') { *ptr = (void *) 0; if (strcmp(c,"NULL") == 0) return SWIG_OK; /* Empty string: not a pointer */ if (*c == 0) return SWIG_ERROR; /* Hmmm. It could be an object name. */ /* Check if this is a command at all. Prevents cget -this */ /* from being called when c is not a command, firing the unknown proc */ if (Tcl_VarEval(interp,"info commands ", c, (char *) NULL) == TCL_OK) { Tcl_Obj *result = Tcl_GetObjResult(interp); if (*(Tcl_GetStringFromObj(result, NULL)) == 0) { /* It's not a command, so it can't be a pointer */ Tcl_ResetResult(interp); return SWIG_ERROR; } } else { /* This will only fail if the argument is multiple words. */ /* Multiple words are also not commands. */ Tcl_ResetResult(interp); return SWIG_ERROR; } /* Check if this is really a SWIG pointer */ if (Tcl_VarEval(interp,c," cget -this", (char *) NULL) != TCL_OK) { Tcl_ResetResult(interp); return SWIG_ERROR; } c = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), NULL); } c++; c = SWIG_UnpackData(c,ptr,sizeof(void *)); if (ty) { tc = c ? SWIG_TypeCheck(c,ty) : 0; if (!tc) { return SWIG_ERROR; } if (flags & SWIG_POINTER_DISOWN) { SWIG_Disown((void *) *ptr); } { int newmemory = 0; *ptr = SWIG_TypeCast(tc,(void *) *ptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } } return SWIG_OK; } /* Convert a pointer value */ SWIGRUNTIMEINLINE int SWIG_Tcl_ConvertPtr(Tcl_Interp *interp, Tcl_Obj *oc, void **ptr, swig_type_info *ty, int flags) { return SWIG_Tcl_ConvertPtrFromString(interp, Tcl_GetStringFromObj(oc,NULL), ptr, ty, flags); } /* Convert a pointer value */ SWIGRUNTIME char * SWIG_Tcl_PointerTypeFromString(char *c) { char d; /* Pointer values must start with leading underscore. NULL has no type */ if (*c != '_') { return 0; } c++; /* Extract hex value from pointer */ while ((d = *c)) { if (!(((d >= '0') && (d <= '9')) || ((d >= 'a') && (d <= 'f')))) break; c++; } return c; } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Tcl_ConvertPacked(Tcl_Interp *SWIGUNUSEDPARM(interp) , Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; const char *c; if (!obj) goto type_error; c = Tcl_GetStringFromObj(obj,NULL); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; c = SWIG_UnpackData(c,ptr,sz); if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; } return SWIG_OK; type_error: return SWIG_ERROR; } /* Take a pointer and convert it to a string */ SWIGRUNTIME void SWIG_Tcl_MakePtr(char *c, void *ptr, swig_type_info *ty, int flags) { if (ptr) { *(c++) = '_'; c = SWIG_PackData(c,&ptr,sizeof(void *)); strcpy(c,ty->name); } else { strcpy(c,(char *)"NULL"); } flags = 0; } /* Create a new pointer object */ SWIGRUNTIMEINLINE Tcl_Obj * SWIG_Tcl_NewPointerObj(void *ptr, swig_type_info *type, int flags) { Tcl_Obj *robj; char result[SWIG_BUFFER_SIZE]; SWIG_MakePtr(result,ptr,type,flags); robj = Tcl_NewStringObj(result,-1); return robj; } SWIGRUNTIME Tcl_Obj * SWIG_Tcl_NewPackedObj(void *ptr, int sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); strcpy(r,type->name); return Tcl_NewStringObj(result,-1); } /* -----------------------------------------------------------------------------* * Get type list * -----------------------------------------------------------------------------*/ SWIGRUNTIME swig_module_info * SWIG_Tcl_GetModule(Tcl_Interp *interp) { const char *data; swig_module_info *ret = 0; /* first check if pointer already created */ data = Tcl_GetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TCL_GLOBAL_ONLY); if (data) { SWIG_UnpackData(data, &ret, sizeof(swig_type_info **)); } return ret; } SWIGRUNTIME void SWIG_Tcl_SetModule(Tcl_Interp *interp, swig_module_info *module) { char buf[SWIG_BUFFER_SIZE]; char *data; /* create a new pointer */ data = SWIG_PackData(buf, &module, sizeof(swig_type_info **)); *data = 0; Tcl_SetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, TCL_GLOBAL_ONLY); } /* -----------------------------------------------------------------------------* * Object auxiliars * -----------------------------------------------------------------------------*/ SWIGRUNTIME void SWIG_Tcl_ObjectDelete(ClientData clientData) { swig_instance *si = (swig_instance *) clientData; if ((si) && (si->destroy) && (SWIG_Disown(si->thisvalue))) { if (si->classptr->destructor) { (si->classptr->destructor)(si->thisvalue); } } Tcl_DecrRefCount(si->thisptr); free(si); } /* Function to invoke object methods given an instance */ SWIGRUNTIME int SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST _objv[]) { char *method, *attrname; swig_instance *inst = (swig_instance *) clientData; swig_method *meth; swig_attribute *attr; Tcl_Obj *oldarg; Tcl_Obj **objv; int rcode; swig_class *cls; swig_class *cls_stack[64]; int cls_stack_bi[64]; int cls_stack_top = 0; int numconf = 2; int bi; objv = (Tcl_Obj **) _objv; if (objc < 2) { Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); return TCL_ERROR; } method = Tcl_GetStringFromObj(objv[1],NULL); if (strcmp(method,"-acquire") == 0) { inst->destroy = 1; SWIG_Acquire(inst->thisvalue); return TCL_OK; } if (strcmp(method,"-disown") == 0) { if (inst->destroy) { SWIG_Disown(inst->thisvalue); } inst->destroy = 0; return TCL_OK; } if (strcmp(method,"-delete") == 0) { Tcl_DeleteCommandFromToken(interp,inst->cmdtok); return TCL_OK; } cls_stack[cls_stack_top] = inst->classptr; cls_stack_bi[cls_stack_top] = -1; cls = inst->classptr; while (1) { Tcl_HashEntry* hashentry; bi = cls_stack_bi[cls_stack_top]; cls = cls_stack[cls_stack_top]; if (bi != -1) { if (!cls->bases[bi] && cls->base_names[bi]) { /* lookup and cache the base class */ swig_type_info *info = SWIG_TypeQueryModule(cls->module, cls->module, cls->base_names[bi]); if (info) cls->bases[bi] = (swig_class *) info->clientdata; } cls = cls->bases[bi]; if (cls) { cls_stack_bi[cls_stack_top]++; cls_stack_top++; cls_stack[cls_stack_top] = cls; cls_stack_bi[cls_stack_top] = -1; continue; } } if (!cls) { cls_stack_top--; if (cls_stack_top < 0) break; else continue; } cls_stack_bi[cls_stack_top]++; hashentry = Tcl_FindHashEntry(&(cls->hashtable), method); if (hashentry) { ClientData cd = Tcl_GetHashValue(hashentry); swig_wrapper method_wrapper = (swig_wrapper)cd; oldarg = objv[1]; objv[1] = inst->thisptr; Tcl_IncrRefCount(inst->thisptr); rcode = (method_wrapper)(clientData,interp,objc,objv); objv[1] = oldarg; Tcl_DecrRefCount(inst->thisptr); return rcode; } /* Check class methods for a match */ if (strcmp(method,"cget") == 0) { if (objc < 3) { Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); return TCL_ERROR; } attrname = Tcl_GetStringFromObj(objv[2],NULL); attr = cls->attributes; while (attr && attr->name) { if ((strcmp(attr->name, attrname) == 0) && (attr->getmethod)) { oldarg = objv[1]; objv[1] = inst->thisptr; Tcl_IncrRefCount(inst->thisptr); rcode = (*attr->getmethod)(clientData,interp,2, objv); objv[1] = oldarg; Tcl_DecrRefCount(inst->thisptr); return rcode; } attr++; } if (strcmp(attrname, "-this") == 0) { Tcl_SetObjResult(interp, Tcl_DuplicateObj(inst->thisptr)); return TCL_OK; } if (strcmp(attrname, "-thisown") == 0) { if (SWIG_Thisown(inst->thisvalue)) { Tcl_SetResult(interp,(char*)"1",TCL_STATIC); } else { Tcl_SetResult(interp,(char*)"0",TCL_STATIC); } return TCL_OK; } } else if (strcmp(method, "configure") == 0) { int i; if (objc < 4) { Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); return TCL_ERROR; } i = 2; while (i < objc) { attrname = Tcl_GetStringFromObj(objv[i],NULL); attr = cls->attributes; while (attr && attr->name) { if ((strcmp(attr->name, attrname) == 0) && (attr->setmethod)) { oldarg = objv[i]; objv[i] = inst->thisptr; Tcl_IncrRefCount(inst->thisptr); rcode = (*attr->setmethod)(clientData,interp,3, &objv[i-1]); objv[i] = oldarg; Tcl_DecrRefCount(inst->thisptr); if (rcode != TCL_OK) return rcode; numconf += 2; } attr++; } i+=2; } } } if (strcmp(method,"configure") == 0) { if (numconf >= objc) { return TCL_OK; } else { Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC); return TCL_ERROR; } } if (strcmp(method,"cget") == 0) { Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC); return TCL_ERROR; } Tcl_SetResult(interp, (char *) "Invalid method. Must be one of: configure cget -acquire -disown -delete", TCL_STATIC); cls = inst->classptr; bi = 0; while (cls) { meth = cls->methods; while (meth && meth->name) { char *cr = (char *) Tcl_GetStringResult(interp); size_t meth_len = strlen(meth->name); char* where = strchr(cr,':'); while(where) { where = strstr(where, meth->name); if(where) { if(where[-1] == ' ' && (where[meth_len] == ' ' || where[meth_len]==0)) { break; } else { where++; } } } if (!where) Tcl_AppendElement(interp, (char *) meth->name); meth++; } cls = inst->classptr->bases[bi++]; } return TCL_ERROR; } /* This function takes the current result and turns it into an object command */ SWIGRUNTIME Tcl_Obj * SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) { Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0); /* Check to see if this pointer belongs to a class or not */ if (thisvalue && (type->clientdata) && (interp)) { Tcl_CmdInfo ci; char *name; name = Tcl_GetStringFromObj(robj,NULL); if (!Tcl_GetCommandInfo(interp,name, &ci) || (flags)) { swig_instance *newinst = (swig_instance *) malloc(sizeof(swig_instance)); newinst->thisptr = Tcl_DuplicateObj(robj); Tcl_IncrRefCount(newinst->thisptr); newinst->thisvalue = thisvalue; newinst->classptr = (swig_class *) type->clientdata; newinst->destroy = flags; newinst->cmdtok = Tcl_CreateObjCommand(interp, Tcl_GetStringFromObj(robj,NULL), (swig_wrapper_func) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete); if (flags) { SWIG_Acquire(thisvalue); } } } return robj; } /* Function to create objects */ SWIGRUNTIME int SWIG_Tcl_ObjectConstructor(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *newObj = 0; void *thisvalue = 0; swig_instance *newinst = 0; swig_class *classptr = (swig_class *) clientData; swig_wrapper cons = 0; char *name = 0; int firstarg = 0; int thisarg = 0; int destroy = 1; if (!classptr) { Tcl_SetResult(interp, (char *) "swig: internal runtime error. No class object defined.", TCL_STATIC); return TCL_ERROR; } cons = classptr->constructor; if (objc > 1) { char *s = Tcl_GetStringFromObj(objv[1],NULL); if (strcmp(s,"-this") == 0) { thisarg = 2; cons = 0; } else if (strcmp(s,"-args") == 0) { firstarg = 1; } else if (objc == 2) { firstarg = 1; name = s; } else if (objc >= 3) { char *s1; name = s; s1 = Tcl_GetStringFromObj(objv[2],NULL); if (strcmp(s1,"-this") == 0) { thisarg = 3; cons = 0; } else { firstarg = 1; } } } if (cons) { int result; result = (*cons)(0, interp, objc-firstarg, &objv[firstarg]); if (result != TCL_OK) { return result; } newObj = Tcl_DuplicateObj(Tcl_GetObjResult(interp)); if (!name) name = Tcl_GetStringFromObj(newObj,NULL); } else if (thisarg > 0) { if (thisarg < objc) { destroy = 0; newObj = Tcl_DuplicateObj(objv[thisarg]); if (!name) name = Tcl_GetStringFromObj(newObj,NULL); } else { Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); return TCL_ERROR; } } else { Tcl_SetResult(interp, (char *) "No constructor available.", TCL_STATIC); return TCL_ERROR; } if (SWIG_Tcl_ConvertPtr(interp,newObj, (void **) &thisvalue, *(classptr->type), 0) != SWIG_OK) { Tcl_DecrRefCount(newObj); return TCL_ERROR; } newinst = (swig_instance *) malloc(sizeof(swig_instance)); newinst->thisptr = newObj; Tcl_IncrRefCount(newObj); newinst->thisvalue = thisvalue; newinst->classptr = classptr; newinst->destroy = destroy; if (destroy) { SWIG_Acquire(thisvalue); } newinst->cmdtok = Tcl_CreateObjCommand(interp,name, (swig_wrapper) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete); return TCL_OK; } /* -----------------------------------------------------------------------------* * Get arguments * -----------------------------------------------------------------------------*/ SWIGRUNTIME int SWIG_Tcl_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char *fmt, ...) { int argno = 0, opt = 0; long tempi; double tempd; const char *c; va_list ap; void *vptr; Tcl_Obj *obj = 0; swig_type_info *ty; va_start(ap,fmt); for (c = fmt; (*c && (*c != ':') && (*c != ';')); c++,argno++) { if (*c == '|') { opt = 1; c++; } if (argno >= (objc-1)) { if (!opt) { Tcl_SetResult(interp, (char *) "Wrong number of arguments ", TCL_STATIC); goto argerror; } else { va_end(ap); return TCL_OK; } } vptr = va_arg(ap,void *); if (vptr) { if (isupper(*c)) { obj = SWIG_Tcl_GetConstantObj(Tcl_GetStringFromObj(objv[argno+1],0)); if (!obj) obj = objv[argno+1]; } else { obj = objv[argno+1]; } switch(*c) { case 'i': case 'I': case 'l': case 'L': case 'h': case 'H': case 'b': case 'B': if (Tcl_GetLongFromObj(interp,obj,&tempi) != TCL_OK) goto argerror; if ((*c == 'i') || (*c == 'I')) *((int *)vptr) = (int)tempi; else if ((*c == 'l') || (*c == 'L')) *((long *)vptr) = (long)tempi; else if ((*c == 'h') || (*c == 'H')) *((short*)vptr) = (short)tempi; else if ((*c == 'b') || (*c == 'B')) *((unsigned char *)vptr) = (unsigned char)tempi; break; case 'f': case 'F': case 'd': case 'D': if (Tcl_GetDoubleFromObj(interp,obj,&tempd) != TCL_OK) goto argerror; if ((*c == 'f') || (*c == 'F')) *((float *) vptr) = (float)tempd; else if ((*c == 'd') || (*c == 'D')) *((double*) vptr) = tempd; break; case 's': case 'S': if (*(c+1) == '#') { int *vlptr = (int *) va_arg(ap, void *); *((char **) vptr) = Tcl_GetStringFromObj(obj, vlptr); c++; } else { *((char **)vptr) = Tcl_GetStringFromObj(obj,NULL); } break; case 'c': case 'C': *((char *)vptr) = *(Tcl_GetStringFromObj(obj,NULL)); break; case 'p': case 'P': ty = (swig_type_info *) va_arg(ap, void *); if (SWIG_Tcl_ConvertPtr(interp, obj, (void **) vptr, ty, 0) != SWIG_OK) goto argerror; break; case 'o': case 'O': *((Tcl_Obj **)vptr) = objv[argno+1]; break; default: break; } } } if ((*c != ';') && ((objc-1) > argno)) { Tcl_SetResult(interp, (char *) "Wrong # args.", TCL_STATIC); goto argerror; } va_end(ap); return TCL_OK; argerror: { char temp[32]; sprintf(temp,"%d", argno+1); c = strchr(fmt,':'); if (!c) c = strchr(fmt,';'); if (!c) c = (char *)""; Tcl_AppendResult(interp,c," argument ", temp, NULL); va_end(ap); return TCL_ERROR; } } #ifdef __cplusplus } #endif swig-3.0.8/Lib/tcl/std_wstring.i0000664000175000017500000000007712641054563016376 0ustar williamwilliam%include %include swig-3.0.8/Lib/tcl/jstring.i0000664000175000017500000000175012641054563015506 0ustar williamwilliam%include %fragment(SWIG_AsVal_frag(jstring),"header") { SWIGINTERN int SWIG_AsVal_dec(jstring)(Tcl_Obj * obj, jstring *val) { int len = 0; const char *cstr = Tcl_GetStringFromObj(obj, &len); if (!cstr || (strcmp(cstr,"NULL") == 0)) { if (val) *val = 0; return SWIG_OK; } else { int len = 0; const Tcl_UniChar *ucstr = Tcl_GetUnicodeFromObj(obj,&len); if (val) { *val = JvNewString((const jchar*)ucstr, len); } } return SWIG_NEWOBJ; } } %fragment(SWIG_From_frag(jstring),"header") { SWIGINTERNINLINE Tcl_Obj * SWIG_From_dec(jstring)(jstring val) { if (!val) { return Tcl_NewStringObj("NULL",-1); } else { return Tcl_NewUnicodeObj((Tcl_UniChar *)JvGetStringChars(val),JvGetStringUTFLength(val)); } } } %typemaps_asvalfrom(%checkcode(STRING), %arg(SWIG_AsVal(jstring)), %arg(SWIG_From(jstring)), %arg(SWIG_AsVal_frag(jstring)), %arg(SWIG_From_frag(jstring)), java::lang::String *); swig-3.0.8/Lib/tcl/cwstring.i0000664000175000017500000000007412641054563015664 0ustar williamwilliam%include %include swig-3.0.8/Lib/tcl/std_map.i0000664000175000017500000000422512641054563015455 0ustar williamwilliam// // SWIG typemaps for std::map // // Common implementation %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.8/Lib/tcl/attribute.i0000664000175000017500000000004212641054563016022 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/tclopers.swg0000664000175000017500000000275012641054563016232 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclopers.swg * * C++ overloaded operators. * * These declarations define how SWIG is going to rename C++ * overloaded operators in Tcl. Since Tcl allows identifiers * to be essentially any valid string, we'll just use the * normal operator names. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus %rename("+") *::operator+; //%rename("u+") *::operator+(); // Unary + //%rename("u+") *::operator+() const; // Unary + %rename("-") *::operator-; //%rename("u-") *::operator-(); // Unary - //%rename("u-") *::operator-() const; // Unary - %rename("*") *::operator*; %rename("/") *::operator/; %rename("<<") *::operator<<; %rename(">>") *::operator>>; %rename("&") *::operator&; %rename("|") *::operator|; %rename("^") *::operator^; %rename("%") *::operator%; %rename("=") *::operator=; /* Ignored operators */ %ignoreoperator(NOTEQUAL) operator!=; %ignoreoperator(PLUSEQ) operator+=; %ignoreoperator(MINUSEQ) operator-=; %ignoreoperator(MULEQ) operator*=; %ignoreoperator(DIVEQ) operator/=; %ignoreoperator(MODEQ) operator%=; %ignoreoperator(LSHIFTEQ) operator<<=; %ignoreoperator(RSHIFTEQ) operator>>=; %ignoreoperator(ANDEQ) operator&=; %ignoreoperator(OREQ) operator|=; %ignoreoperator(XOREQ) operator^=; #endif swig-3.0.8/Lib/tcl/tclprimtypes.swg0000664000175000017500000001274612641054563017144 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header") { %define_as(SWIG_From_dec(bool), Tcl_NewBooleanObj) } %fragment(SWIG_AsVal_frag(bool),"header") { SWIGINTERN int SWIG_AsVal_dec(bool)(Tcl_Obj *obj, bool *val) { int v; if (Tcl_GetBooleanFromObj(0, obj, &v) == TCL_OK) { if (val) *val = v ? true : false; return SWIG_OK; } return SWIG_TypeError; } } /* long */ %fragment(SWIG_From_frag(long),"header", fragment="") { SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(long)(long value) { if (((long) INT_MIN <= value) && (value <= (long) INT_MAX)) { return Tcl_NewIntObj(%numeric_cast(value,int)); } else { return Tcl_NewLongObj(value); } } } %fragment(SWIG_AsVal_frag(long),"header") { SWIGINTERN int SWIG_AsVal_dec(long)(Tcl_Obj *obj, long* val) { long v; if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { if (val) *val = (long) v; return SWIG_OK; } return SWIG_TypeError; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(unsigned long)(unsigned long value) { if (value < (unsigned long) LONG_MAX) { return SWIG_From(long)(%numeric_cast(value, long)); } else { char temp[256]; sprintf(temp, "%lu", value); return Tcl_NewStringObj(temp,-1); } } } %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(Tcl_Obj *obj, unsigned long *val) { long v; if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { if (v >= 0) { if (val) *val = (unsigned long) v; return SWIG_OK; } /* If v is negative, then this could be a negative number, or an unsigned value which doesn't fit in a signed long, so try to get it as a string so we can distinguish these cases. */ } { int len = 0; const char *nptr = Tcl_GetStringFromObj(obj, &len); if (nptr && len > 0) { char *endptr; unsigned long v; if (*nptr == '-') return SWIG_OverflowError; errno = 0; v = strtoul(nptr, &endptr,0); if (nptr[0] == '\0' || *endptr != '\0') return SWIG_TypeError; if (v == ULONG_MAX && errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_OK; } } } } return SWIG_TypeError; } } /* long long */ %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="", fragment="") { SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(long long)(long long value) { if (((long long) LONG_MIN <= value) && (value <= (long long) LONG_MAX)) { return SWIG_From(long)(%numeric_cast(value,long)); } else { char temp[256]; sprintf(temp, "%lld", value); return Tcl_NewStringObj(temp,-1); } } } %fragment(SWIG_AsVal_frag(long long),"header", fragment="", fragment="") { SWIGINTERN int SWIG_AsVal_dec(long long)(Tcl_Obj *obj, long long *val) { long v; if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { if (val) *val = v; return SWIG_OK; } else { int len = 0; const char *nptr = Tcl_GetStringFromObj(obj, &len); if (nptr && len > 0) { char *endptr; long long v; errno = 0; v = strtoll(nptr, &endptr,0); if (nptr[0] == '\0' || *endptr != '\0') return SWIG_TypeError; if ((v == LLONG_MAX || v == LLONG_MIN) && errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_OK; } } } } return SWIG_TypeError; } } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="", fragment="") { SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(unsigned long long)(unsigned long long value) { if (value < (unsigned long long) LONG_MAX) { return SWIG_From(long long)(%numeric_cast(value, long long)); } else { char temp[256]; sprintf(temp, "%llu", value); return Tcl_NewStringObj(temp,-1); } } } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="", fragment="") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(Tcl_Obj *obj, unsigned long long *val) { long v; if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { if (val) *val = (unsigned long) v; return SWIG_OK; } else { int len = 0; const char *nptr = Tcl_GetStringFromObj(obj, &len); if (nptr && len > 0) { char *endptr; unsigned long long v; if (*nptr == '-') return SWIG_OverflowError; errno = 0; v = strtoull(nptr, &endptr,0); if (nptr[0] == '\0' || *endptr != '\0') return SWIG_TypeError; if (v == ULLONG_MAX && errno == ERANGE) { errno = 0; return SWIG_OverflowError; } else { if (*endptr == '\0') { if (val) *val = v; return SWIG_OK; } } } } return SWIG_TypeError; } } /* double */ %fragment(SWIG_From_frag(double),"header") { %define_as(SWIG_From(double), Tcl_NewDoubleObj) } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(Tcl_Obj *obj, double *val) { double v; if (Tcl_GetDoubleFromObj(0, obj, &v) == TCL_OK) { if (val) *val = v; return SWIG_OK; } return SWIG_TypeError; } } swig-3.0.8/Lib/tcl/Makefile.in0000664000175000017500000000704712641054563015726 0ustar williamwilliam# --------------------------------------------------------------- # SWIG Tcl Makefile # # This file can be used to build various Tcl extensions with SWIG. # By default this file is set up for dynamic loading, but it can # be easily customized for static extensions by modifying various # portions of the file. # # SRCS = C source files # CXXSRCS = C++ source files # OBJCSRCS = Objective-C source files # OBJS = Additional .o files (compiled previously) # INTERFACE = SWIG interface file # TARGET = Name of target module or executable # # Many portions of this file were created by the SWIG configure # script and should already reflect your machine. However, you # may need to modify the Makefile to reflect your specific # application. #---------------------------------------------------------------- SRCS = CXXSRCS = OBJCSRCS = OBJS = INTERFACE = WRAPFILE = $(INTERFACE:.i=_wrap.c) WRAPOBJ = $(INTERFACE:.i=_wrap.o) TARGET = module@SO@ # Use this kind of target for dynamic loading #TARGET = my_tclsh # Use this target for static linking prefix = @prefix@ exec_prefix = @exec_prefix@ CC = @CC@ CXX = @CXX@ OBJC = @CC@ -Wno-import # -Wno-import needed for gcc CFLAGS = INCLUDES = LIBS = # SWIG Options # SWIG = location of the SWIG executable # SWIGOPT = SWIG compiler options # SWIGCC = Compiler used to compile the wrapper file SWIG = $(exec_prefix)/bin/swig SWIGOPT = -tcl # use -tcl8 for Tcl 8.0 SWIGCC = $(CC) # SWIG Library files. Uncomment if rebuilding tclsh #SWIGLIBS = -ltclsh.i # Rules for creating .o files from source. COBJS = $(SRCS:.c=.o) CXXOBJS = $(CXXSRCS:.cxx=.o) OBJCOBJS = $(OBJCSRCS:.m=.o) ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) # Command that will be used to build the final extension. BUILD = $(SWIGCC) # Uncomment the following if you are using dynamic loading CCSHARED = @CCSHARED@ BUILD = @LDSHARED@ # Uncomment the following if you are using dynamic loading with C++ and # need to provide additional link libraries (this is not always required). #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc # Tcl installation (where is Tcl located) TCL_INCLUDE = @TCLINCLUDE@ TCL_LIB = @TCLLIB@ # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ # Build options (uncomment only one of these) BUILD_LIBS = $(LIBS) # Dynamic loading #BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh # Compilation rules for non-SWIG components .SUFFIXES: .c .cxx .m .c.o: $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< .cxx.o: $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< .m.o: $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< # ---------------------------------------------------------------------- # Rules for building the extension # ---------------------------------------------------------------------- all: $(TARGET) # Convert the wrapper file into an object file $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(TCL_INCLUDE) $(WRAPFILE) : $(INTERFACE) $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-3.0.8/Lib/tcl/tcltypemaps.swg0000664000175000017500000000543712641054563016751 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Tcl * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* In Tcl we need to pass the interp value, so we define the decl/call macros as needed. */ #define SWIG_AS_DECL_ARGS SWIG_TCL_DECL_ARGS_2 #define SWIG_AS_CALL_ARGS SWIG_TCL_CALL_ARGS_2 /* Include fundamental fragment definitions */ %include /* Look for user fragments file. */ %include /* Tcl fragments for primitive types */ %include /* Tcl fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* No director support in Tcl */ #ifdef SWIG_DIRECTOR_TYPEMAPS #undef SWIG_DIRECTOR_TYPEMAPS #endif /* Tcl types */ #define SWIG_Object Tcl_Obj * /* Overload of the output/constant/exception handling */ /* output */ #define %set_output(obj) Tcl_SetObjResult(interp,obj) /* append output */ #define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj) /* set constant */ #define SWIG_SetConstant(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj) /* raise */ #define SWIG_Raise(obj,type,desc) SWIG_Tcl_SetErrorObj(interp,type,obj) /* Include the unified typemap library */ %include /* ------------------------------------------------------------ * Tcl extra typemaps / typemap overrides * ------------------------------------------------------------ */ #if 1 // Old 1.3.25 typemaps needed to avoid premature object deletion %typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE &&INSTANCE, SWIGTYPE INSTANCE[] { Tcl_SetObjResult(interp, SWIG_NewInstanceObj( %as_voidptr($1), $1_descriptor,0)); } %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,%as_voidptrptr(&$1)); Tcl_SetObjResult(interp,SWIG_NewInstanceObj(%as_voidptr($1), ty,0)); } #endif %typemap(throws,noblock=1) SWIGTYPE CLASS { SWIG_set_result(SWIG_NewInstanceObj(%as_voidptr(SWIG_new_copy($1, $1_ltype)), $&1_descriptor, 1)); SWIG_fail; } %typemap(out) SWIGTYPE = SWIGTYPE INSTANCE; %typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE; %typemap(out) SWIGTYPE *const = SWIGTYPE *; %typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE; %typemap(out) SWIGTYPE && = SWIGTYPE &&INSTANCE; %typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[]; %typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE; swig-3.0.8/Lib/tcl/tclinit.swg0000664000175000017500000000774312641054563016054 0ustar williamwilliam/* ------------------------------------------------------------ * The start of the Tcl initialization function * ------------------------------------------------------------ */ %insert(init) "swiginit.swg" /* This initialization code exports the module initialization function */ %header %{ #ifdef __cplusplus extern "C" { #endif #ifdef MAC_TCL #pragma export on #endif SWIGEXPORT int SWIG_init(Tcl_Interp *); #ifdef MAC_TCL #pragma export off #endif #ifdef __cplusplus } #endif /* Compatibility version for TCL stubs */ #ifndef SWIG_TCL_STUBS_VERSION #define SWIG_TCL_STUBS_VERSION "8.1" #endif %} %init %{ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ SWIGINTERN void SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) { size_t i; Tcl_Obj *obj; if (!swigconstTableinit) { Tcl_InitHashTable(&swigconstTable, TCL_STRING_KEYS); swigconstTableinit = 1; } for (i = 0; constants[i].type; i++) { switch(constants[i].type) { case SWIG_TCL_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_TCL_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { SWIG_Tcl_SetConstantObj(interp, constants[i].name, obj); } } } /* Create fast method lookup tables */ SWIGINTERN void SWIG_Tcl_InstallMethodLookupTables(void) { size_t i; for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = swig_module.type_initial[i]; if (type->clientdata) { swig_class* klass = (swig_class*) type->clientdata; swig_method* meth; Tcl_InitHashTable(&(klass->hashtable), TCL_STRING_KEYS); for (meth = klass->methods; meth && meth->name; ++meth) { int newEntry; Tcl_HashEntry* hashentry = Tcl_CreateHashEntry(&(klass->hashtable), meth->name, &newEntry); Tcl_SetHashValue(hashentry, (ClientData)meth->method); } } } } #ifdef __cplusplus } #endif /* -----------------------------------------------------------------------------* * Partial Init method * -----------------------------------------------------------------------------*/ SWIGEXPORT int SWIG_init(Tcl_Interp *interp) { size_t i; if (interp == 0) return TCL_ERROR; #ifdef USE_TCL_STUBS /* (char*) cast is required to avoid compiler warning/error for Tcl < 8.4. */ if (Tcl_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) { return TCL_ERROR; } #endif #ifdef USE_TK_STUBS /* (char*) cast is required to avoid compiler warning/error. */ if (Tk_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) { return TCL_ERROR; } #endif Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version); #ifdef SWIG_namespace Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }"); #endif SWIG_InitializeModule((void *) interp); SWIG_PropagateClientData(); for (i = 0; swig_commands[i].name; i++) { Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper, swig_commands[i].clientdata, NULL); } for (i = 0; swig_variables[i].name; i++) { Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) "", TCL_GLOBAL_ONLY); Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, (Tcl_VarTraceProc *) swig_variables[i].get, (ClientData) swig_variables[i].addr); Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, (Tcl_VarTraceProc *) swig_variables[i].set, (ClientData) swig_variables[i].addr); } SWIG_Tcl_InstallConstants(interp, swig_constants); SWIG_Tcl_InstallMethodLookupTables(); %} /* Note: the initialization function is closed after all code is generated */ swig-3.0.8/Lib/tcl/std_string.i0000664000175000017500000000004412641054563016201 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/stl.i0000664000175000017500000000054512641054563014631 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ /* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-3.0.8/Lib/tcl/mactkinit.c0000664000175000017500000001236612641054563016010 0ustar williamwilliam/* ----------------------------------------------------------------------------- * mactkinit.c * * This is a support file needed to build a new version of Wish. * Normally, this capability is found in TkAppInit.c, but this creates * tons of namespace problems for many applications. * ----------------------------------------------------------------------------- */ #include #include #include #include #include #include #include "tk.h" #include "tkInt.h" #include "tkMacInt.h" typedef int (*TclMacConvertEventPtr) _ANSI_ARGS_((EventRecord *eventPtr)); Tcl_Interp *gStdoutInterp = NULL; void TclMacSetEventProc _ANSI_ARGS_((TclMacConvertEventPtr procPtr)); int TkMacConvertEvent _ANSI_ARGS_((EventRecord *eventPtr)); /* * Prototypes for functions the ANSI library needs to link against. */ short InstallConsole _ANSI_ARGS_((short fd)); void RemoveConsole _ANSI_ARGS_((void)); long WriteCharsToConsole _ANSI_ARGS_((char *buff, long n)); long ReadCharsFromConsole _ANSI_ARGS_((char *buff, long n)); char * __ttyname _ANSI_ARGS_((long fildes)); short SIOUXHandleOneEvent _ANSI_ARGS_((EventRecord *event)); /* * Forward declarations for procedures defined later in this file: */ /* *---------------------------------------------------------------------- * * MacintoshInit -- * * This procedure calls Mac specific initilization calls. Most of * these calls must be made as soon as possible in the startup * process. * * Results: * Returns TCL_OK if everything went fine. If it didn't the * application should probably fail. * * Side effects: * Inits the application. * *---------------------------------------------------------------------- */ int MacintoshInit() { int i; long result, mask = 0x0700; /* mask = system 7.x */ /* * Tk needs us to set the qd pointer it uses. This is needed * so Tk doesn't have to assume the availablity of the qd global * variable. Which in turn allows Tk to be used in code resources. */ tcl_macQdPtr = &qd; InitGraf(&tcl_macQdPtr->thePort); InitFonts(); InitWindows(); InitMenus(); InitDialogs((long) NULL); InitCursor(); /* * Make sure we are running on system 7 or higher */ if ((NGetTrapAddress(_Gestalt, ToolTrap) == NGetTrapAddress(_Unimplemented, ToolTrap)) || (((Gestalt(gestaltSystemVersion, &result) != noErr) || (mask != (result & mask))))) { panic("Tcl/Tk requires System 7 or higher."); } /* * Make sure we have color quick draw * (this means we can't run on 68000 macs) */ if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr) || (result < gestalt32BitQD13))) { panic("Tk requires Color QuickDraw."); } FlushEvents(everyEvent, 0); SetEventMask(everyEvent); /* * Set up stack & heap sizes */ /* TODO: stack size size = StackSpace(); SetAppLimit(GetAppLimit() - 8192); */ MaxApplZone(); for (i = 0; i < 4; i++) { (void) MoreMasters(); } TclMacSetEventProc(TkMacConvertEvent); TkConsoleCreate(); return TCL_OK; } /* *---------------------------------------------------------------------- * * SetupMainInterp -- * * This procedure calls initalization routines require a Tcl * interp as an argument. This call effectively makes the passed * iterpreter the "main" interpreter for the application. * * Results: * Returns TCL_OK if everything went fine. If it didn't the * application should probably fail. * * Side effects: * More initilization. * *---------------------------------------------------------------------- */ int SetupMainInterp( Tcl_Interp *interp) { /* * Initialize the console only if we are running as an interactive * application. */ TkMacInitAppleEvents(interp); TkMacInitMenus(interp); if (strcmp(Tcl_GetVar(interp, "tcl_interactive", TCL_GLOBAL_ONLY), "1") == 0) { if (TkConsoleInit(interp) == TCL_ERROR) { goto error; } } /* * Attach the global interpreter to tk's expected global console */ gStdoutInterp = interp; return TCL_OK; error: panic(interp->result); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * InstallConsole, RemoveConsole, etc. -- * * The following functions provide the UI for the console package. * Users wishing to replace SIOUX with their own console package * need only provide the four functions below in a library. * * Results: * See SIOUX documentation for details. * * Side effects: * See SIOUX documentation for details. * *---------------------------------------------------------------------- */ short InstallConsole(short fd) { #pragma unused (fd) return 0; } void RemoveConsole(void) { } long WriteCharsToConsole(char *buffer, long n) { TkConsolePrint(gStdoutInterp, TCL_STDOUT, buffer, n); return n; } long ReadCharsFromConsole(char *buffer, long n) { return 0; } extern char * __ttyname(long fildes) { static char *devicename = "null device"; if (fildes >= 0 && fildes <= 2) { return (devicename); } return (0L); } short SIOUXHandleOneEvent(EventRecord *event) { return 0; } swig-3.0.8/Lib/tcl/tclruntime.swg0000664000175000017500000000074412641054563016566 0ustar williamwilliam/* tcl.h has to appear first */ %insert(runtime) %{ #include #include #include #include #include #include %} %insert(runtime) "swigrun.swg"; /* Common C API type-checking code */ %insert(runtime) "swigerrors.swg" /* SWIG errors */ %insert(runtime) "tclerrors.swg"; /* Tcl Errors */ %insert(runtime) "tclapi.swg"; /* Tcl API */ %insert(runtime) "tclrun.swg"; /* Tcl run-time code */ swig-3.0.8/Lib/tcl/tclstrings.swg0000664000175000017500000000143112641054563016566 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header") { SWIGINTERN int SWIG_AsCharPtrAndSize(Tcl_Obj *obj, char** cptr, size_t* psize, int *alloc) { int len = 0; char *cstr = Tcl_GetStringFromObj(obj, &len); if (cstr) { if (cptr) *cptr = cstr; if (psize) *psize = len + 1; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header", fragment="") { SWIGINTERNINLINE Tcl_Obj * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { return (size < INT_MAX) ? Tcl_NewStringObj(carray, %numeric_cast(size,int)) : NULL; } } swig-3.0.8/Lib/tcl/typemaps.i0000664000175000017500000003727212641054563015700 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * SWIG typemap library for Tcl8. This file contains various sorts * of typemaps for modifying SWIG's code generation. * ----------------------------------------------------------------------------- */ #if !defined(SWIG_USE_OLD_TYPEMAPS) %include #else /* The SWIG typemap library provides a language independent mechanism for supporting output arguments, input values, and other C function calling mechanisms. The primary use of the library is to provide a better interface to certain C function--especially those involving pointers. */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include typemaps.i double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include typemaps.i %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ %typemap(in) double *INPUT(double temp), double &INPUT(double temp) { if (Tcl_GetDoubleFromObj(interp,$input,&temp) == TCL_ERROR) { SWIG_fail; } $1 = &temp; } %typemap(in) float *INPUT(double dvalue, float temp), float &INPUT(double dvalue, float temp) { if (Tcl_GetDoubleFromObj(interp,$input,&dvalue) == TCL_ERROR) { SWIG_fail; } temp = (float) dvalue; $1 = &temp; } %typemap(in) int *INPUT(int temp), int &INPUT(int temp) { if (Tcl_GetIntFromObj(interp,$input,&temp) == TCL_ERROR) { SWIG_fail; } $1 = &temp; } %typemap(in) short *INPUT(int ivalue, short temp), short &INPUT(int ivalue, short temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (short) ivalue; $1 = &temp; } %typemap(in) long *INPUT(int ivalue, long temp), long &INPUT(int ivalue, long temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (long) ivalue; $1 = &temp; } %typemap(in) unsigned int *INPUT(int ivalue, unsigned int temp), unsigned int &INPUT(int ivalue, unsigned int temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (unsigned int) ivalue; $1 = &temp; } %typemap(in) unsigned short *INPUT(int ivalue, unsigned short temp), unsigned short &INPUT(int ivalue, unsigned short temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (unsigned short) ivalue; $1 = &temp; } %typemap(in) unsigned long *INPUT(int ivalue, unsigned long temp), unsigned long &INPUT(int ivalue, unsigned long temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (unsigned long) ivalue; $1 = &temp; } %typemap(in) unsigned char *INPUT(int ivalue, unsigned char temp), unsigned char &INPUT(int ivalue, unsigned char temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (unsigned char) ivalue; $1 = &temp; } %typemap(in) signed char *INPUT(int ivalue, signed char temp), signed char &INPUT(int ivalue, signed char temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = (signed char) ivalue; $1 = &temp; } %typemap(in) bool *INPUT(int ivalue, bool temp), bool &INPUT(int ivalue, bool temp) { if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { SWIG_fail; } temp = ivalue ? true : false; $1 = &temp; } %typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) { temp = ($*1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0); $1 = &temp; } %typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { temp = ($*1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL),0,0); $1 = &temp; } // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Tcl list. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include typemaps.i double modf(double x, double *OUTPUT); or you can use the %apply directive : %include typemaps.i %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Tcl output of the function would be a list containing both output values. */ %typemap(in,numinputs=0) int *OUTPUT(int temp), short *OUTPUT(short temp), long *OUTPUT(long temp), unsigned int *OUTPUT(unsigned int temp), unsigned short *OUTPUT(unsigned short temp), unsigned long *OUTPUT(unsigned long temp), unsigned char *OUTPUT(unsigned char temp), signed char *OUTPUT(signed char temp), bool *OUTPUT(bool temp), float *OUTPUT(float temp), double *OUTPUT(double temp), long long *OUTPUT($*1_ltype temp), unsigned long long *OUTPUT($*1_ltype temp), int &OUTPUT(int temp), short &OUTPUT(short temp), long &OUTPUT(long temp), unsigned int &OUTPUT(unsigned int temp), unsigned short &OUTPUT(unsigned short temp), unsigned long &OUTPUT(unsigned long temp), signed char &OUTPUT(signed char temp), bool &OUTPUT(bool temp), unsigned char &OUTPUT(unsigned char temp), float &OUTPUT(float temp), double &OUTPUT(double temp), long long &OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp) "$1 = &temp;"; %typemap(argout) int *OUTPUT, int &OUTPUT, short *OUTPUT, short &OUTPUT, long *OUTPUT, long &OUTPUT, unsigned int *OUTPUT, unsigned int &OUTPUT, unsigned short *OUTPUT, unsigned short &OUTPUT, unsigned long *OUTPUT, unsigned long &OUTPUT, unsigned char *OUTPUT, unsigned char &OUTPUT, signed char *OUTPUT, signed char &OUTPUT, bool *OUTPUT, bool &OUTPUT { Tcl_Obj *o; o = Tcl_NewIntObj((int) *($1)); Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); } %typemap(argout) float *OUTPUT, float &OUTPUT, double *OUTPUT, double &OUTPUT { Tcl_Obj *o; o = Tcl_NewDoubleObj((double) *($1)); Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); } %typemap(argout) long long *OUTPUT, long long &OUTPUT { char temp[256]; Tcl_Obj *o; sprintf(temp,"%lld",(long long)*($1)); o = Tcl_NewStringObj(temp,-1); Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); } %typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { char temp[256]; Tcl_Obj *o; sprintf(temp,"%llu",(unsigned long long)*($1)); o = Tcl_NewStringObj(temp,-1); Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); } // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Tcl list. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include typemaps.i void neg(double *INOUT); or you can use the %apply directive : %include typemaps.i %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Tcl). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Tcl variable you might do this : set x [neg $x] */ %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) unsigned int *INOUT = unsigned int *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) signed char *INOUT = signed char *INPUT; %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) int &INOUT = int &INPUT; %typemap(in) short &INOUT = short &INPUT; %typemap(in) long &INOUT = long &INPUT; %typemap(in) unsigned int &INOUT = unsigned int &INPUT; %typemap(in) unsigned short &INOUT = unsigned short &INPUT; %typemap(in) unsigned long &INOUT = unsigned long &INPUT; %typemap(in) unsigned char &INOUT = unsigned char &INPUT; %typemap(in) signed char &INOUT = signed char &INPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(in) float &INOUT = float &INPUT; %typemap(in) double &INOUT = double &INPUT; %typemap(in) long long &INOUT = long long &INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT = long *OUTPUT; %typemap(argout) unsigned int *INOUT = unsigned int *OUTPUT; %typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) signed char *INOUT = signed char *OUTPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT = double *OUTPUT; %typemap(argout) long long *INOUT = long long *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) int &INOUT = int &OUTPUT; %typemap(argout) short &INOUT = short &OUTPUT; %typemap(argout) long &INOUT = long &OUTPUT; %typemap(argout) unsigned int &INOUT = unsigned int &OUTPUT; %typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; %typemap(argout) signed char &INOUT = signed char &OUTPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; %typemap(argout) float &INOUT = float &OUTPUT; %typemap(argout) double &INOUT = double &OUTPUT; %typemap(argout) long long &INOUT = long long &OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; /* Overloading information */ %typemap(typecheck) double *INPUT = double; %typemap(typecheck) bool *INPUT = bool; %typemap(typecheck) signed char *INPUT = signed char; %typemap(typecheck) unsigned char *INPUT = unsigned char; %typemap(typecheck) unsigned long *INPUT = unsigned long; %typemap(typecheck) unsigned short *INPUT = unsigned short; %typemap(typecheck) unsigned int *INPUT = unsigned int; %typemap(typecheck) long *INPUT = long; %typemap(typecheck) short *INPUT = short; %typemap(typecheck) int *INPUT = int; %typemap(typecheck) float *INPUT = float; %typemap(typecheck) long long *INPUT = long long; %typemap(typecheck) unsigned long long *INPUT = unsigned long long; %typemap(typecheck) double &INPUT = double; %typemap(typecheck) bool &INPUT = bool; %typemap(typecheck) signed char &INPUT = signed char; %typemap(typecheck) unsigned char &INPUT = unsigned char; %typemap(typecheck) unsigned long &INPUT = unsigned long; %typemap(typecheck) unsigned short &INPUT = unsigned short; %typemap(typecheck) unsigned int &INPUT = unsigned int; %typemap(typecheck) long &INPUT = long; %typemap(typecheck) short &INPUT = short; %typemap(typecheck) int &INPUT = int; %typemap(typecheck) float &INPUT = float; %typemap(typecheck) long long &INPUT = long long; %typemap(typecheck) unsigned long long &INPUT = unsigned long long; %typemap(typecheck) double *INOUT = double; %typemap(typecheck) bool *INOUT = bool; %typemap(typecheck) signed char *INOUT = signed char; %typemap(typecheck) unsigned char *INOUT = unsigned char; %typemap(typecheck) unsigned long *INOUT = unsigned long; %typemap(typecheck) unsigned short *INOUT = unsigned short; %typemap(typecheck) unsigned int *INOUT = unsigned int; %typemap(typecheck) long *INOUT = long; %typemap(typecheck) short *INOUT = short; %typemap(typecheck) int *INOUT = int; %typemap(typecheck) float *INOUT = float; %typemap(typecheck) long long *INOUT = long long; %typemap(typecheck) unsigned long long *INOUT = unsigned long long; %typemap(typecheck) double &INOUT = double; %typemap(typecheck) bool &INOUT = bool; %typemap(typecheck) signed char &INOUT = signed char; %typemap(typecheck) unsigned char &INOUT = unsigned char; %typemap(typecheck) unsigned long &INOUT = unsigned long; %typemap(typecheck) unsigned short &INOUT = unsigned short; %typemap(typecheck) unsigned int &INOUT = unsigned int; %typemap(typecheck) long &INOUT = long; %typemap(typecheck) short &INOUT = short; %typemap(typecheck) int &INOUT = int; %typemap(typecheck) float &INOUT = float; %typemap(typecheck) long long &INOUT = long long; %typemap(typecheck) unsigned long long &INOUT = unsigned long long; #endif // -------------------------------------------------------------------- // Special types // -------------------------------------------------------------------- %include %include swig-3.0.8/Lib/tcl/std_vector.i0000664000175000017500000003641412641054563016207 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // Tcl as much as possible, namely, to allow the user to pass and // be returned Tcl lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector< T >), f(const std::vector< T >&), f(const std::vector< T >*): // the parameter being read-only, either a Tcl list or a // previously wrapped std::vector< T > can be passed. // -- f(std::vector< T >&), f(std::vector< T >*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector< T > f(): // the vector is returned by copy; therefore, a Tcl list of T:s // is returned which is most easily used in other Tcl functions procs // -- std::vector< T >& f(), std::vector< T >* f(), const std::vector< T >& f(), // const std::vector< T >* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %fragment(""); %fragment(""); %fragment(""); %{ #include Tcl_Obj* SwigString_FromString(const std::string &s) { return Tcl_NewStringObj(s.data(), (int)s.length()); } int Tcl_GetBoolFromObj(Tcl_Interp *interp, Tcl_Obj *o, bool *val) { int v; int res = Tcl_GetBooleanFromObj(interp, o, &v); if (res == TCL_OK) { *val = v ? true : false; } return res; } int SwigString_AsString(Tcl_Interp *interp, Tcl_Obj *o, std::string *val) { int len; const char* temp = Tcl_GetStringFromObj(o, &len); if (temp == NULL) return TCL_ERROR; val->assign(temp, len); return TCL_OK; } // behaviour of this is such as the real Tcl_GetIntFromObj template int SwigInt_As(Tcl_Interp *interp, Tcl_Obj *o, Type *val) { int temp_val, return_val; return_val = Tcl_GetIntFromObj(interp, o, &temp_val); *val = (Type) temp_val; return return_val; } // behaviour of this is such as the real Tcl_GetDoubleFromObj template int SwigDouble_As(Tcl_Interp *interp, Tcl_Obj *o, Type *val) { int return_val; double temp_val; return_val = Tcl_GetDoubleFromObj(interp, o, &temp_val); *val = (Type) temp_val; return return_val; } %} // exported class namespace std { template class vector { %typemap(in) vector< T > (std::vector< T > *v) { Tcl_Obj **listobjv; int nitems; int i; T* temp; if (SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0){ $1 = *v; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, \ &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; $1 = std::vector< T >(); for (i = 0; i < nitems; i++) { if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp, $descriptor(T *),0)) != 0) { char message[] = "list of " #T " expected"; Tcl_SetResult(interp, message, TCL_VOLATILE); return TCL_ERROR; } $1.push_back(*temp); } } } %typemap(in) const vector< T >* (std::vector< T > *v, std::vector< T > w), const vector< T >& (std::vector< T > *v, std::vector< T > w) { Tcl_Obj **listobjv; int nitems; int i; T* temp; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0) { $1 = v; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; w = std::vector< T >(); for (i = 0; i < nitems; i++) { if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp, $descriptor(T *),0)) != 0) { char message[] = "list of " #T " expected"; Tcl_SetResult(interp, message, TCL_VOLATILE); return TCL_ERROR; } w.push_back(*temp); } $1 = &w; } } %typemap(out) vector< T > { for (unsigned int i=0; i<$1.size(); i++) { T* ptr = new T((($1_type &)$1)[i]); Tcl_ListObjAppendElement(interp, $result, \ SWIG_NewInstanceObj(ptr, $descriptor(T *), 0)); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector< T > { Tcl_Obj **listobjv; int nitems; T* temp; std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0) { /* wrapped vector */ $1 = 1; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; else if (nitems == 0) $1 = 1; //check the first value to see if it is of correct type else if ((SWIG_ConvertPtr(listobjv[0], (void **) &temp, $descriptor(T *),0)) != 0) $1 = 0; else $1 = 1; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector< T >&, const vector< T >* { Tcl_Obj **listobjv; int nitems; T* temp; std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; else if (nitems == 0) $1 = 1; //check the first value to see if it is of correct type else if ((SWIG_ConvertPtr(listobjv[0], (void **) &temp, $descriptor(T *),0)) != 0) $1 = 0; else $1 = 1; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector< T > &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(const T& x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T& get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i += size; if (i>=0 && isize()); if (i<0) i+= size; if (i>=0 && i class vector< T > { %typemap(in) vector< T > (std::vector< T > *v){ Tcl_Obj **listobjv; int nitems; int i; T temp; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0) { $1 = *v; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; $1 = std::vector< T >(); for (i = 0; i < nitems; i++) { if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR) return TCL_ERROR; $1.push_back(temp); } } } %typemap(in) const vector< T >& (std::vector< T > *v,std::vector< T > w), const vector< T >* (std::vector< T > *v,std::vector< T > w) { Tcl_Obj **listobjv; int nitems; int i; T temp; if(SWIG_ConvertPtr($input, (void **) &v, \ $1_descriptor, 0) == 0) { $1 = v; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; w = std::vector< T >(); for (i = 0; i < nitems; i++) { if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR) return TCL_ERROR; w.push_back(temp); } $1 = &w; } } %typemap(out) vector< T > { for (unsigned int i=0; i<$1.size(); i++) { Tcl_ListObjAppendElement(interp, $result, \ CONVERT_TO((($1_type &)$1)[i])); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector< T > { Tcl_Obj **listobjv; int nitems; T temp; std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; else if (nitems == 0) $1 = 1; //check the first value to see if it is of correct type if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR) $1 = 0; else $1 = 1; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector< T >&, const vector< T >*{ Tcl_Obj **listobjv; int nitems; T temp; std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; else if (nitems == 0) $1 = 1; //check the first value to see if it is of correct type if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR) $1 = 0; else $1 = 1; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector< T > &); unsigned int size() const; bool empty() const; void clear(); %rename(push) push_back; void push_back(T x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i += size; if (i>=0 && isize()); if (i<0) i+= size; if (i>=0 && i,Tcl_NewIntObj); specialize_std_vector(int, Tcl_GetIntFromObj,Tcl_NewIntObj); specialize_std_vector(short, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(long, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(unsigned char, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(unsigned int, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(unsigned short, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(unsigned long, SwigInt_As, Tcl_NewIntObj); specialize_std_vector(double, Tcl_GetDoubleFromObj, Tcl_NewDoubleObj); specialize_std_vector(float, SwigDouble_As, Tcl_NewDoubleObj); specialize_std_vector(std::string, SwigString_AsString, SwigString_FromString); } swig-3.0.8/Lib/tcl/tclwstrings.swg0000664000175000017500000000345412641054563016764 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclwstrings.wg * * Utility methods for wchar strings * ----------------------------------------------------------------------------- */ %{ #include %} %fragment("SWIG_AsWCharPtrAndSize","header") { SWIGINTERN int SWIG_AsWCharPtrAndSize(Tcl_Obj *obj, wchar_t** cptr, size_t* psize, int *alloc) { int len = 0; Tcl_UniChar *ustr = Tcl_GetUnicodeFromObj(obj, &len); if (ustr) { if (cptr) { Tcl_Encoding encoding = NULL; char *src = (char *) ustr; int srcLen = (len)*sizeof(Tcl_UniChar); int dstLen = sizeof(wchar_t)*(len + 1); char *dst = %new_array(dstLen, char); int flags = 0; Tcl_EncodingState *statePtr = 0; int srcRead = 0; int dstWrote = 0; int dstChars = 0; Tcl_UtfToExternal(0, encoding, src, srcLen, flags, statePtr, dst, dstLen, &srcRead, &dstWrote, &dstChars); if (alloc) *alloc = SWIG_NEWOBJ; } if (psize) *psize = len + 1; return SWIG_OK; } return SWIG_TypeError; } } %fragment("SWIG_FromWCharPtrAndSize","header") { SWIGINTERNINLINE Tcl_Obj * SWIG_FromWCharPtrAndSize(const wchar_t* carray, size_t size) { Tcl_Obj *res = NULL; if (size < INT_MAX) { Tcl_Encoding encoding = NULL; char *src = (char *) carray; int srcLen = (int)(size*sizeof(wchar_t)); int dstLen = (int)(size*sizeof(Tcl_UniChar)); char *dst = %new_array(dstLen, char); int flags = 0; Tcl_EncodingState *statePtr = 0; int srcRead = 0; int dstWrote = 0; int dstChars = 0; Tcl_ExternalToUtf(0, encoding, src, srcLen, flags, statePtr, dst, dstLen, &srcRead, &dstWrote, &dstChars); res = Tcl_NewUnicodeObj((Tcl_UniChar*)dst, (int)size); %delete_array(dst); } return res; } } swig-3.0.8/Lib/tcl/tclinterp.i0000664000175000017500000000115112641054563016025 0ustar williamwilliam/* ----------------------------------------------------------------------------- * tclinterp.i * * Tcl_Interp *interp * * Passes the current Tcl_Interp value directly to a C function. * This can be used to work with existing wrapper functions or * if you just need the interp value for some reason. When used, * the 'interp' parameter becomes hidden in the Tcl interface--that * is, you don't specify it explicitly. SWIG fills in its value * automatically. * ----------------------------------------------------------------------------- */ %typemap(in,numinputs=0) Tcl_Interp *interp { $1 = interp; } swig-3.0.8/Lib/tcl/tclfragments.swg0000664000175000017500000000105312641054563017063 0ustar williamwilliam/* Create a file with this name, 'tclfragments.swg', in your working directory and add all the %fragments you want to take precedence over the ones defined by default by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(int)(TclObject *obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.8/Lib/tcl/cmalloc.i0000664000175000017500000000004012641054563015427 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/cstring.i0000664000175000017500000000004012641054563015466 0ustar williamwilliam%include swig-3.0.8/Lib/tcl/tclapi.swg0000664000175000017500000000603412641054563015652 0ustar williamwilliam/* ----------------------------------------------------------------------------- * SWIG API. Portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_TCL_POINTER 4 #define SWIG_TCL_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; typedef int (*swig_wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); typedef int (*swig_wrapper_func)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); typedef char *(*swig_variable_func)(ClientData, Tcl_Interp *, char *, char *, int); typedef void (*swig_delete_func)(ClientData); typedef struct swig_method { const char *name; swig_wrapper method; } swig_method; typedef struct swig_attribute { const char *name; swig_wrapper getmethod; swig_wrapper setmethod; } swig_attribute; typedef struct swig_class { const char *name; swig_type_info **type; swig_wrapper constructor; void (*destructor)(void *); swig_method *methods; swig_attribute *attributes; struct swig_class **bases; const char **base_names; swig_module_info *module; Tcl_HashTable hashtable; } swig_class; typedef struct swig_instance { Tcl_Obj *thisptr; void *thisvalue; swig_class *classptr; int destroy; Tcl_Command cmdtok; } swig_instance; /* Structure for command table */ typedef struct { const char *name; int (*wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); ClientData clientdata; } swig_command_info; /* Structure for variable linking table */ typedef struct { const char *name; void *addr; char * (*get)(ClientData, Tcl_Interp *, char *, char *, int); char * (*set)(ClientData, Tcl_Interp *, char *, char *, int); } swig_var_info; /* -----------------------------------------------------------------------------* * Install a constant object * -----------------------------------------------------------------------------*/ static Tcl_HashTable swigconstTable; static int swigconstTableinit = 0; SWIGINTERN void SWIG_Tcl_SetConstantObj(Tcl_Interp *interp, const char* name, Tcl_Obj *obj) { int newobj; Tcl_ObjSetVar2(interp,Tcl_NewStringObj(name,-1), NULL, obj, TCL_GLOBAL_ONLY); Tcl_SetHashValue(Tcl_CreateHashEntry(&swigconstTable, name, &newobj), (ClientData) obj); } SWIGINTERN Tcl_Obj * SWIG_Tcl_GetConstantObj(const char *key) { Tcl_HashEntry *entryPtr; if (!swigconstTableinit) return 0; entryPtr = Tcl_FindHashEntry(&swigconstTable, key); if (entryPtr) { return (Tcl_Obj *) Tcl_GetHashValue(entryPtr); } return 0; } #ifdef __cplusplus } #endif swig-3.0.8/Lib/tcl/wish.i0000664000175000017500000000655412641054563015007 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wish.i * * SWIG File for making wish * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %subsection "wish.i" %text %{ This module provides the Tk_AppInit() function needed to build a new version of the wish executable. Like tclsh.i, this file should not be used with dynamic loading. To make an interface file work with both static and dynamic loading, put something like this in your interface file : #ifdef STATIC %include #endif A startup file may be specified by defining the symbol SWIG_RcFileName as follows (this should be included in a code-block) : #define SWIG_RcFileName "~/.mywishrc" %} #endif %{ /* Initialization code for wish */ #include #ifndef SWIG_RcFileName char *SWIG_RcFileName = "~/.wishrc"; #endif #ifdef MAC_TCL extern int MacintoshInit _ANSI_ARGS_((void)); extern int SetupMainInterp _ANSI_ARGS_((Tcl_Interp *interp)); #endif /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in interp->result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(Tcl_Interp *interp) { #ifndef MAC_TCL Tk_Window main; main = Tk_MainWindow(interp); #endif /* * Call the init procedures for included packages. Each call should * look like this: * * if (Mod_Init(interp) == TCL_ERROR) { * return TCL_ERROR; * } * * where "Mod" is the name of the module. */ if (Tcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; } if (Tk_Init(interp) == TCL_ERROR) { return TCL_ERROR; } /* * Call Tcl_CreateCommand for application-specific commands, if * they weren't already created by the init procedures called above. */ if (SWIG_init(interp) == TCL_ERROR) { return TCL_ERROR; } #ifdef MAC_TCL SetupMainInterp(interp); #endif /* * Specify a user-specific startup file to invoke if the application * is run interactively. Typically the startup file is "~/.apprc" * where "app" is the name of the application. If this line is deleted * then no user-specific startup file will be run under any conditions. */ #if TCL_MAJOR_VERSION >= 8 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5 Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY); #else tcl_RcFileName = SWIG_RcFileName; #endif /* For Macintosh might also want this */ #ifdef MAC_TCL #ifdef SWIG_RcRsrcName Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL_ONLY); #endif #endif return TCL_OK; } #if TK_MAJOR_VERSION >= 4 int main(int argc, char **argv) { #ifdef MAC_TCL char *newArgv[2]; if (MacintoshInit() != TCL_OK) { Tcl_Exit(1); } argc = 1; newArgv[0] = "Wish"; newArgv[1] = NULL; argv = newArgv; #endif Tk_Main(argc, argv, Tcl_AppInit); return(0); } #else extern int main(); #endif %} swig-3.0.8/Lib/tcl/cpointer.i0000664000175000017500000000004112641054563015641 0ustar williamwilliam%include swig-3.0.8/Lib/swigwarn.swg0000664000175000017500000003344712641164620015461 0ustar williamwilliam/* SWIG warning codes */ %define SWIGWARN_NONE 0 %enddef /* -- Deprecated features -- */ %define SWIGWARN_DEPRECATED_EXTERN 101 %enddef %define SWIGWARN_DEPRECATED_VAL 102 %enddef %define SWIGWARN_DEPRECATED_OUT 103 %enddef %define SWIGWARN_DEPRECATED_DISABLEDOC 104 %enddef %define SWIGWARN_DEPRECATED_ENABLEDOC 105 %enddef %define SWIGWARN_DEPRECATED_DOCONLY 106 %enddef %define SWIGWARN_DEPRECATED_STYLE 107 %enddef %define SWIGWARN_DEPRECATED_LOCALSTYLE 108 %enddef %define SWIGWARN_DEPRECATED_TITLE 109 %enddef %define SWIGWARN_DEPRECATED_SECTION 110 %enddef %define SWIGWARN_DEPRECATED_SUBSECTION 111 %enddef %define SWIGWARN_DEPRECATED_SUBSUBSECTION 112 %enddef %define SWIGWARN_DEPRECATED_ADDMETHODS 113 %enddef %define SWIGWARN_DEPRECATED_READONLY 114 %enddef %define SWIGWARN_DEPRECATED_READWRITE 115 %enddef %define SWIGWARN_DEPRECATED_EXCEPT 116 %enddef %define SWIGWARN_DEPRECATED_NEW 117 %enddef %define SWIGWARN_DEPRECATED_EXCEPT_TM 118 %enddef %define SWIGWARN_DEPRECATED_IGNORE_TM 119 %enddef %define SWIGWARN_DEPRECATED_OPTC 120 %enddef %define SWIGWARN_DEPRECATED_NAME 121 %enddef %define SWIGWARN_DEPRECATED_NOEXTERN 122 %enddef %define SWIGWARN_DEPRECATED_NODEFAULT 123 %enddef %define SWIGWARN_DEPRECATED_TYPEMAP_LANG 124 %enddef %define SWIGWARN_DEPRECATED_INPUT_FILE 125 %enddef %define SWIGWARN_DEPRECATED_NESTED_WORKAROUND 126 %enddef /* -- Preprocessor -- */ %define SWIGWARN_PP_MISSING_FILE 201 %enddef %define SWIGWARN_PP_EVALUATION 202 %enddef %define SWIGWARN_PP_INCLUDEALL_IMPORTALL 203 %enddef %define SWIGWARN_PP_CPP_WARNING 204 %enddef %define SWIGWARN_PP_CPP_ERROR 205 %enddef %define SWIGWARN_PP_UNEXPECTED_TOKENS 206 %enddef /* -- C/C++ Parser -- */ %define SWIGWARN_PARSE_CLASS_KEYWORD 301 %enddef %define SWIGWARN_PARSE_REDEFINED 302 %enddef %define SWIGWARN_PARSE_EXTEND_UNDEF 303 %enddef %define SWIGWARN_PARSE_UNSUPPORTED_VALUE 304 %enddef %define SWIGWARN_PARSE_BAD_VALUE 305 %enddef %define SWIGWARN_PARSE_PRIVATE 306 %enddef %define SWIGWARN_PARSE_BAD_DEFAULT 307 %enddef %define SWIGWARN_PARSE_NAMESPACE_ALIAS 308 %enddef %define SWIGWARN_PARSE_PRIVATE_INHERIT 309 %enddef %define SWIGWARN_PARSE_TEMPLATE_REPEAT 310 %enddef %define SWIGWARN_PARSE_TEMPLATE_PARTIAL 311 %enddef %define SWIGWARN_PARSE_UNNAMED_NESTED_CLASS 312 %enddef %define SWIGWARN_PARSE_UNDEFINED_EXTERN 313 %enddef %define SWIGWARN_PARSE_KEYWORD 314 %enddef %define SWIGWARN_PARSE_USING_UNDEF 315 %enddef %define SWIGWARN_PARSE_MODULE_REPEAT 316 %enddef %define SWIGWARN_PARSE_TEMPLATE_SP_UNDEF 317 %enddef %define SWIGWARN_PARSE_TEMPLATE_AMBIG 318 %enddef %define SWIGWARN_PARSE_NO_ACCESS 319 %enddef %define SWIGWARN_PARSE_EXPLICIT_TEMPLATE 320 %enddef %define SWIGWARN_PARSE_BUILTIN_NAME 321 %enddef %define SWIGWARN_PARSE_REDUNDANT 322 %enddef %define SWIGWARN_PARSE_REC_INHERITANCE 323 %enddef %define SWIGWARN_PARSE_NESTED_TEMPLATE 324 %enddef %define SWIGWARN_PARSE_NAMED_NESTED_CLASS 325 %enddef %define SWIGWARN_PARSE_EXTEND_NAME 326 %enddef %define SWIGWARN_CPP11_LAMBDA 340 %enddef %define SWIGWARN_CPP11_ALIAS_DECLARATION 341 %enddef %define SWIGWARN_CPP11_ALIAS_TEMPLATE 342 %enddef %define SWIGWARN_CPP11_VARIADIC_TEMPLATE 343 %enddef %define SWIGWARN_IGNORE_OPERATOR_NEW 350 %enddef /* new */ %define SWIGWARN_IGNORE_OPERATOR_DELETE 351 %enddef /* delete */ %define SWIGWARN_IGNORE_OPERATOR_PLUS 352 %enddef /* + */ %define SWIGWARN_IGNORE_OPERATOR_MINUS 353 %enddef /* - */ %define SWIGWARN_IGNORE_OPERATOR_MUL 354 %enddef /* * */ %define SWIGWARN_IGNORE_OPERATOR_DIV 355 %enddef /* / */ %define SWIGWARN_IGNORE_OPERATOR_MOD 356 %enddef /* % */ %define SWIGWARN_IGNORE_OPERATOR_XOR 357 %enddef /* ^ */ %define SWIGWARN_IGNORE_OPERATOR_AND 358 %enddef /* & */ %define SWIGWARN_IGNORE_OPERATOR_OR 359 %enddef /* | */ %define SWIGWARN_IGNORE_OPERATOR_NOT 360 %enddef /* ~ */ %define SWIGWARN_IGNORE_OPERATOR_LNOT 361 %enddef /* ! */ %define SWIGWARN_IGNORE_OPERATOR_EQ 362 %enddef /* = */ %define SWIGWARN_IGNORE_OPERATOR_LT 363 %enddef /* < */ %define SWIGWARN_IGNORE_OPERATOR_GT 364 %enddef /* > */ %define SWIGWARN_IGNORE_OPERATOR_PLUSEQ 365 %enddef /* += */ %define SWIGWARN_IGNORE_OPERATOR_MINUSEQ 366 %enddef /* -= */ %define SWIGWARN_IGNORE_OPERATOR_MULEQ 367 %enddef /* *= */ %define SWIGWARN_IGNORE_OPERATOR_DIVEQ 368 %enddef /* /= */ %define SWIGWARN_IGNORE_OPERATOR_MODEQ 369 %enddef /* %= */ %define SWIGWARN_IGNORE_OPERATOR_XOREQ 370 %enddef /* ^= */ %define SWIGWARN_IGNORE_OPERATOR_ANDEQ 371 %enddef /* &= */ %define SWIGWARN_IGNORE_OPERATOR_OREQ 372 %enddef /* |= */ %define SWIGWARN_IGNORE_OPERATOR_LSHIFT 373 %enddef /* << */ %define SWIGWARN_IGNORE_OPERATOR_RSHIFT 374 %enddef /* >> */ %define SWIGWARN_IGNORE_OPERATOR_LSHIFTEQ 375 %enddef /* <<= */ %define SWIGWARN_IGNORE_OPERATOR_RSHIFTEQ 376 %enddef /* >>= */ %define SWIGWARN_IGNORE_OPERATOR_EQUALTO 377 %enddef /* == */ %define SWIGWARN_IGNORE_OPERATOR_NOTEQUAL 378 %enddef /* != */ %define SWIGWARN_IGNORE_OPERATOR_LTEQUAL 379 %enddef /* <= */ %define SWIGWARN_IGNORE_OPERATOR_GTEQUAL 380 %enddef /* >= */ %define SWIGWARN_IGNORE_OPERATOR_LAND 381 %enddef /* && */ %define SWIGWARN_IGNORE_OPERATOR_LOR 382 %enddef /* || */ %define SWIGWARN_IGNORE_OPERATOR_PLUSPLUS 383 %enddef /* ++ */ %define SWIGWARN_IGNORE_OPERATOR_MINUSMINUS 384 %enddef /* -- */ %define SWIGWARN_IGNORE_OPERATOR_COMMA 385 %enddef /* , */ %define SWIGWARN_IGNORE_OPERATOR_ARROWSTAR 386 %enddef /* ->* */ %define SWIGWARN_IGNORE_OPERATOR_ARROW 387 %enddef /* -> */ %define SWIGWARN_IGNORE_OPERATOR_CALL 388 %enddef /* () */ %define SWIGWARN_IGNORE_OPERATOR_INDEX 389 %enddef /* [] */ %define SWIGWARN_IGNORE_OPERATOR_UPLUS 390 %enddef /* + */ %define SWIGWARN_IGNORE_OPERATOR_UMINUS 391 %enddef /* - */ %define SWIGWARN_IGNORE_OPERATOR_UMUL 392 %enddef /* * */ %define SWIGWARN_IGNORE_OPERATOR_UAND 393 %enddef /* & */ %define SWIGWARN_IGNORE_OPERATOR_NEWARR 394 %enddef /* new [] */ %define SWIGWARN_IGNORE_OPERATOR_DELARR 395 %enddef /* delete [] */ %define SWIGWARN_IGNORE_OPERATOR_REF 396 %enddef /* operator *() */ /* 394-399 are reserved */ /* -- Type system and typemaps -- */ %define SWIGWARN_TYPE_UNDEFINED_CLASS 401 %enddef %define SWIGWARN_TYPE_INCOMPLETE 402 %enddef %define SWIGWARN_TYPE_ABSTRACT 403 %enddef %define SWIGWARN_TYPE_REDEFINED 404 %enddef %define SWIGWARN_TYPEMAP_SOURCETARGET 450 %enddef %define SWIGWARN_TYPEMAP_CHARLEAK 451 %enddef %define SWIGWARN_TYPEMAP_SWIGTYPE 452 %enddef %define SWIGWARN_TYPEMAP_APPLY_UNDEF 453 %enddef %define SWIGWARN_TYPEMAP_SWIGTYPELEAK 454 %enddef %define SWIGWARN_TYPEMAP_IN_UNDEF 460 %enddef %define SWIGWARN_TYPEMAP_OUT_UNDEF 461 %enddef %define SWIGWARN_TYPEMAP_VARIN_UNDEF 462 %enddef %define SWIGWARN_TYPEMAP_VAROUT_UNDEF 463 %enddef %define SWIGWARN_TYPEMAP_CONST_UNDEF 464 %enddef %define SWIGWARN_TYPEMAP_UNDEF 465 %enddef %define SWIGWARN_TYPEMAP_VAR_UNDEF 466 %enddef %define SWIGWARN_TYPEMAP_TYPECHECK 467 %enddef %define SWIGWARN_TYPEMAP_THROW 468 %enddef %define SWIGWARN_TYPEMAP_DIRECTORIN_UNDEF 469 %enddef %define SWIGWARN_TYPEMAP_THREAD_UNSAFE 470 %enddef /* mostly used in directorout typemaps */ %define SWIGWARN_TYPEMAP_DIRECTOROUT_UNDEF 471 %enddef %define SWIGWARN_TYPEMAP_TYPECHECK_UNDEF 472 %enddef %define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR 473 %enddef %define SWIGWARN_TYPEMAP_OUT_OPTIMAL_IGNORED 474 %enddef %define SWIGWARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE 475 %enddef %define SWIGWARN_TYPEMAP_INITIALIZER_LIST 476 %enddef %define SWIGWARN_TYPEMAP_DIRECTORTHROWS_UNDEF 477 %enddef /* -- Fragments -- */ %define SWIGWARN_FRAGMENT_NOT_FOUND 490 %enddef /* -- General code generation -- */ %define SWIGWARN_LANG_OVERLOAD_DECL 501 %enddef %define SWIGWARN_LANG_OVERLOAD_CONSTRUCT 502 %enddef %define SWIGWARN_LANG_IDENTIFIER 503 %enddef %define SWIGWARN_LANG_RETURN_TYPE 504 %enddef %define SWIGWARN_LANG_VARARGS 505 %enddef %define SWIGWARN_LANG_VARARGS_KEYWORD 506 %enddef %define SWIGWARN_LANG_NATIVE_UNIMPL 507 %enddef %define SWIGWARN_LANG_DEREF_SHADOW 508 %enddef %define SWIGWARN_LANG_OVERLOAD_SHADOW 509 %enddef %define SWIGWARN_LANG_FRIEND_IGNORE 510 %enddef %define SWIGWARN_LANG_OVERLOAD_KEYWORD 511 %enddef %define SWIGWARN_LANG_OVERLOAD_CONST 512 %enddef %define SWIGWARN_LANG_CLASS_UNNAMED 513 %enddef %define SWIGWARN_LANG_DIRECTOR_VDESTRUCT 514 %enddef %define SWIGWARN_LANG_DISCARD_CONST 515 %enddef %define SWIGWARN_LANG_OVERLOAD_IGNORED 516 %enddef %define SWIGWARN_LANG_DIRECTOR_ABSTRACT 517 %enddef %define SWIGWARN_LANG_PORTABILITY_FILENAME 518 %enddef %define SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE 519 %enddef %define SWIGWARN_LANG_SMARTPTR_MISSING 520 %enddef %define SWIGWARN_LANG_ILLEGAL_DESTRUCTOR 521 %enddef %define SWIGWARN_LANG_EXTEND_CONSTRUCTOR 522 %enddef %define SWIGWARN_LANG_EXTEND_DESTRUCTOR 523 %enddef /* -- Reserved (600-799) -- */ /* -- Language module specific warnings (700 - 899) -- */ %define SWIGWARN_D_TYPEMAP_CTYPE_UNDEF 700 %enddef %define SWIGWARN_D_TYPEMAP_IMTYPE_UNDEF 701 %enddef %define SWIGWARN_D_TYPEMAP_DTYPE_UNDEF 702 %enddef %define SWIGWARN_D_MULTIPLE_INHERITANCE 703 %enddef %define SWIGWARN_D_TYPEMAP_CLASSMOD_UNDEF 704 %enddef %define SWIGWARN_D_TYPEMAP_DBODY_UNDEF 705 %enddef %define SWIGWARN_D_TYPEMAP_DOUT_UNDEF 706 %enddef %define SWIGWARN_D_TYPEMAP_DIN_UNDEF 707 %enddef %define SWIGWARN_D_TYPEMAP_DDIRECTORIN_UNDEF 708 %enddef %define SWIGWARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF 709 %enddef %define SWIGWARN_D_EXCODE_MISSING 710 %enddef %define SWIGWARN_D_CANTHROW_MISSING 711 %enddef %define SWIGWARN_D_NO_DIRECTORCONNECT_ATTR 712 %enddef %define SWIGWARN_D_NAME_COLLISION 713 %enddef /* please leave 700-719 free for D */ %define SWIGWARN_SCILAB_TRUNCATED_NAME 720 %enddef /* please leave 720-739 free for Scilab */ %define SWIGWARN_PYTHON_INDENT_MISMATCH 740 %enddef /* please leave 740-759 free for Python */ %define SWIGWARN_RUBY_WRONG_NAME 801 %enddef %define SWIGWARN_RUBY_MULTIPLE_INHERITANCE 802 %enddef /* please leave 800-809 free for Ruby */ %define SWIGWARN_JAVA_TYPEMAP_JNI_UNDEF 810 %enddef %define SWIGWARN_JAVA_TYPEMAP_JTYPE_UNDEF 811 %enddef %define SWIGWARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812 %enddef %define SWIGWARN_JAVA_MULTIPLE_INHERITANCE 813 %enddef %define SWIGWARN_JAVA_TYPEMAP_GETCPTR_UNDEF 814 %enddef %define SWIGWARN_JAVA_TYPEMAP_CLASSMOD_UNDEF 815 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVABODY_UNDEF 816 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVAOUT_UNDEF 817 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF 819 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVADIRECTOROUT_UNDEF 820 %enddef %define SWIGWARN_JAVA_COVARIANT_RET 822 %enddef %define SWIGWARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF 823 %enddef %define SWIGWARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824 %enddef %define SWIGWARN_JAVA_NO_DIRECTORCONNECT_ATTR 825 %enddef %define SWIGWARN_JAVA_NSPACE_WITHOUT_PACKAGE 826 %enddef /* please leave 810-829 free for Java */ %define SWIGWARN_CSHARP_TYPEMAP_CTYPE_UNDEF 830 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSTYPE_UNDEF 831 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF 832 %enddef %define SWIGWARN_CSHARP_MULTIPLE_INHERITANCE 833 %enddef %define SWIGWARN_CSHARP_TYPEMAP_GETCPTR_UNDEF 834 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF 835 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSBODY_UNDEF 836 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSOUT_UNDEF 837 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSIN_UNDEF 838 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF 839 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSDIRECTOROUT_UNDEF 840 %enddef %define SWIGWARN_CSHARP_COVARIANT_RET 842 %enddef %define SWIGWARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF 843 %enddef %define SWIGWARN_CSHARP_EXCODE 844 %enddef %define SWIGWARN_CSHARP_CANTHROW 845 %enddef %define SWIGWARN_CSHARP_NO_DIRECTORCONNECT_ATTR 846 %enddef /* please leave 830-849 free for C# */ %define SWIGWARN_MODULA3_TYPEMAP_TYPE_UNDEF 850 %enddef %define SWIGWARN_MODULA3_TYPEMAP_GETCPTR_UNDEF 851 %enddef %define SWIGWARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF 852 %enddef %define SWIGWARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF 853 %enddef %define SWIGWARN_MODULA3_TYPEMAP_MULTIPLE_RETURN 854 %enddef %define SWIGWARN_MODULA3_MULTIPLE_INHERITANCE 855 %enddef %define SWIGWARN_MODULA3_TYPECONSTRUCTOR_UNKNOWN 856 %enddef %define SWIGWARN_MODULA3_UNKNOWN_PRAGMA 857 %enddef %define SWIGWARN_MODULA3_BAD_ENUMERATION 858 %enddef %define SWIGWARN_MODULA3_DOUBLE_ID 859 %enddef %define SWIGWARN_MODULA3_BAD_IMPORT 860 %enddef /* please leave 850-869 free for Modula 3 */ %define SWIGWARN_PHP_MULTIPLE_INHERITANCE 870 %enddef %define SWIGWARN_PHP_UNKNOWN_PRAGMA 871 %enddef %define SWIGWARN_PHP_PUBLIC_BASE 872 %enddef /* please leave 870-889 free for PHP */ %define SWIGWARN_GO_NAME_CONFLICT 890 %enddef /* please leave 890-899 free for Go */ /* -- User defined warnings (900 - 999) -- */ swig-3.0.8/Lib/math.i0000664000175000017500000000404612641054563014176 0ustar williamwilliam/* ----------------------------------------------------------------------------- * math.i * * SWIG library file for floating point operations. * ----------------------------------------------------------------------------- */ %module math %{ #include %} extern double cos(double x); /* Cosine of x */ extern double sin(double x); /* Sine of x */ extern double tan(double x); /* Tangent of x */ extern double acos(double x); /* Inverse cosine in range [-PI/2,PI/2], x in [-1,1]. */ extern double asin(double x); /* Inverse sine in range [0,PI], x in [-1,1]. */ extern double atan(double x); /* Inverse tangent in range [-PI/2,PI/2]. */ extern double atan2(double y, double x); /* Inverse tangent of y/x in range [-PI,PI]. */ extern double cosh(double x); /* Hyperbolic cosine of x */ extern double sinh(double x); /* Hyperbolic sine of x */ extern double tanh(double x); /* Hyperbolic tangent of x */ extern double exp(double x); /* Natural exponential function e^x */ extern double log(double x); /* Natural logarithm ln(x), x > 0 */ extern double log10(double x); /* Base 10 logarithm, x > 0 */ extern double pow(double x, double y); /* Power function x^y. */ extern double sqrt(double x); /* Square root. x >= 0 */ extern double fabs(double x); /* Absolute value of x */ extern double ceil(double x); /* Smallest integer not less than x, as a double */ extern double floor(double x); /* Largest integer not greater than x, as a double */ extern double fmod(double x, double y); /* Floating-point remainder of x/y, with the same sign as x. */ #define M_E 2.7182818284590452354 #define M_LOG2E 1.4426950408889634074 #define M_LOG10E 0.43429448190325182765 #define M_LN2 0.69314718055994530942 #define M_LN10 2.30258509299404568402 #define M_PI 3.14159265358979323846 #define M_PI_2 1.57079632679489661923 #define M_PI_4 0.78539816339744830962 #define M_1_PI 0.31830988618379067154 #define M_2_PI 0.63661977236758134308 #define M_2_SQRTPI 1.12837916709551257390 #define M_SQRT2 1.41421356237309504880 #define M_SQRT1_2 0.70710678118654752440 swig-3.0.8/Lib/octave/0000775000175000017500000000000012641054563014350 5ustar williamwilliamswig-3.0.8/Lib/octave/std_pair.i0000664000175000017500000000607412641054563016336 0ustar williamwilliam// Pairs %include //#define SWIG_STD_PAIR_ASVAL %fragment("StdPairTraits","header",fragment="StdTraits") { namespace swig { #ifdef SWIG_STD_PAIR_ASVAL template struct traits_asval > { typedef std::pair value_type; static int get_pair(const octave_value& first, octave_value second, std::pair *val) { if (val) { T *pfirst = &(val->first); int res1 = swig::asval(first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(val->second); int res2 = swig::asval(second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } else { T *pfirst = 0; int res1 = swig::asval(first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((PyObject*)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asval(const octave_value& obj, std::pair *val) { if (obj.is_cell()) { Cell c=obj.cell_value(); if (c.numel()<2) { error("pair from Cell array requires at least two elements"); return SWIG_ERROR; } return get_pair(c(0),c(1),val); } else { value_type *p; int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = *p; return res; } return SWIG_ERROR; } }; #else template struct traits_asptr > { typedef std::pair value_type; static int get_pair(const octave_value& first, octave_value second, std::pair **val) { if (val) { value_type *vp = %new_instance(std::pair); T *pfirst = &(vp->first); int res1 = swig::asval(first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(vp->second); int res2 = swig::asval(second, psecond); if (!SWIG_IsOK(res2)) return res2; *val = vp; return SWIG_AddNewMask(res1 > res2 ? res1 : res2); } else { T *pfirst = 0; int res1 = swig::asval(first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval(second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } return SWIG_ERROR; } static int asptr(const octave_value& obj, std::pair **val) { if (obj.is_cell()) { Cell c=obj.cell_value(); if (c.numel()<2) { error("pair from Cell array requires at least two elements"); return SWIG_ERROR; } return get_pair(c(0),c(1),val); } else { value_type *p; int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; return res; } return SWIG_ERROR; } }; #endif template struct traits_from > { static octave_value from(const std::pair& val) { Cell c(1,2); c(0)=swig::from(val.first); c(1)=swig::from(val.second); return c; } }; } } %define %swig_pair_methods(pair...) %enddef %include swig-3.0.8/Lib/octave/std_container.i0000664000175000017500000000007312641054563017356 0ustar williamwilliam%include %include swig-3.0.8/Lib/octave/std_except.i0000664000175000017500000000004312641054563016661 0ustar williamwilliam%include swig-3.0.8/Lib/octave/cdata.i0000664000175000017500000000003612641054563015575 0ustar williamwilliam%include swig-3.0.8/Lib/octave/octrun.swg0000664000175000017500000013202112641054563016403 0ustar williamwilliam #include // Macro for enabling features which require Octave version >= major.minor.patch #define SWIG_OCTAVE_PREREQ(major, minor, patch) \ ( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + OCTAVE_PATCH_VERSION >= ((major)<<16) + ((minor)<<8) + (patch) ) // Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1 #if !defined(OCTAVE_MAJOR_VERSION) # if !defined(OCTAVE_API_VERSION_NUMBER) // Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet // introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER # include # if defined(octave_ov_h) # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 8 # define OCTAVE_PATCH_VERSION 0 # else // Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed # define ComplexLU __ignore # include # undef ComplexLU # if defined(octave_Complex_LU_h) // We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 1 # define OCTAVE_PATCH_VERSION 99 # else // OCTAVE_API_VERSION_NUMBER == 37 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 2 # define OCTAVE_PATCH_VERSION 0 # endif // defined(octave_Complex_LU_h) # endif // defined(octave_ov_h) // Correlation between Octave API and version numbers extracted from Octave's // ChangeLogs; version is the *earliest* released Octave with that API number # elif OCTAVE_API_VERSION_NUMBER >= 48 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 6 # define OCTAVE_PATCH_VERSION 0 # elif OCTAVE_API_VERSION_NUMBER >= 45 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 4 # define OCTAVE_PATCH_VERSION 1 # elif OCTAVE_API_VERSION_NUMBER >= 42 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 54 # elif OCTAVE_API_VERSION_NUMBER >= 41 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 53 # elif OCTAVE_API_VERSION_NUMBER >= 40 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 52 # elif OCTAVE_API_VERSION_NUMBER >= 39 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 51 # else // OCTAVE_API_VERSION_NUMBER == 38 # define OCTAVE_MAJOR_VERSION 3 # define OCTAVE_MINOR_VERSION 3 # define OCTAVE_PATCH_VERSION 50 # endif // !defined(OCTAVE_API_VERSION_NUMBER) #endif // !defined(OCTAVE_MAJOR_VERSION) #if !SWIG_OCTAVE_PREREQ(3,2,0) #define SWIG_DEFUN(cname, wname, doc) DEFUNX_DLD(#cname, wname, FS ## cname, args, nargout, doc) #else #define SWIG_DEFUN(cname, wname, doc) DEFUNX_DLD(#cname, wname, G ## cname, args, nargout, doc) #endif SWIGRUNTIME bool SWIG_check_num_args(const char *func_name, int num_args, int max_args, int min_args, int varargs) { if (num_args > max_args && !varargs) error("function %s takes at most %i arguments", func_name, max_args); else if (num_args < min_args) error("function %s requires at least %i arguments", func_name, min_args); else return true; return false; } SWIGRUNTIME octave_value_list *SWIG_Octave_AppendOutput(octave_value_list *ovl, const octave_value &ov) { ovl->append(ov); return ovl; } SWIGRUNTIME octave_value SWIG_ErrorType(int code) { switch (code) { case SWIG_MemoryError: return "SWIG_MemoryError"; case SWIG_IOError: return "SWIG_IOError"; case SWIG_RuntimeError: return "SWIG_RuntimeError"; case SWIG_IndexError: return "SWIG_IndexError"; case SWIG_TypeError: return "SWIG_TypeError"; case SWIG_DivisionByZero: return "SWIG_DivisionByZero"; case SWIG_OverflowError: return "SWIG_OverflowError"; case SWIG_SyntaxError: return "SWIG_SyntaxError"; case SWIG_ValueError: return "SWIG_ValueError"; case SWIG_SystemError: return "SWIG_SystemError"; case SWIG_AttributeError: return "SWIG_AttributeError"; } return "SWIG unknown error"; } SWIGRUNTIME octave_value SWIG_Error(int code, const char *msg) { octave_value type(SWIG_ErrorType(code)); std::string r = msg; r += " (" + type.string_value() + ")"; error(r.c_str()); return octave_value(r); } #define SWIG_fail goto fail #define SWIG_Octave_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Octave_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Octave_NewPointerObj(ptr, type, flags) #define swig_owntype int #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Octave_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Octave_NewPackedObj(ptr, sz, type) #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Octave_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Octave_NewPackedObj(ptr, sz, type) #define SWIG_GetModule(clientdata) SWIG_Octave_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Octave_SetModule(clientdata,pointer); #define SWIG_MODULE_CLIENTDATA_TYPE void* #define Octave_Error_Occurred() 0 #define SWIG_Octave_AddErrorMsg(msg) {;} SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata); SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer); // For backward compatibility only #define SWIG_POINTER_EXCEPTION 0 #define SWIG_arg_fail(arg) 0 // Runtime API implementation #include #include #include typedef octave_value_list(*octave_func) (const octave_value_list &, int); class octave_swig_type; namespace Swig { #ifdef SWIG_DIRECTORS class Director; typedef std::map < void *, Director * > rtdir_map; SWIGINTERN rtdir_map* get_rtdir_map(); SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d); SWIGINTERNINLINE void erase_rtdir(void *vptr); SWIGINTERNINLINE Director *get_rtdir(void *vptr); SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d); SWIGRUNTIME octave_swig_type *swig_director_get_self(Director *d); SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self); #endif SWIGRUNTIME octave_base_value *swig_value_ref(octave_swig_type *ost); SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov); SWIGRUNTIME octave_swig_type *swig_value_deref(const octave_base_value &ov); } #ifdef SWIG_DIRECTORS SWIGRUNTIME void swig_acquire_ownership(void *vptr); SWIGRUNTIME void swig_acquire_ownership_array(void *vptr); SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); #endif struct swig_octave_member { const char *name; octave_func method; octave_func get_method; octave_func set_method; int flags; // 1 static, 2 global const char *doc; bool is_static() const { return flags &1; } bool is_global() const { return flags &2; } }; struct swig_octave_class { const char *name; swig_type_info **type; int director; octave_func constructor; const char *constructor_doc; octave_func destructor; const swig_octave_member *members; const char **base_names; const swig_type_info **base; }; // octave_swig_type plays the role of both the shadow class and the class // representation within Octave, since there is no support for classes. // // These should really be decoupled, with the class support added to Octave // and the shadow class given by an m-file script. That would dramatically // reduce the runtime complexity, and be more in line w/ other modules. class octave_swig_type:public octave_base_value { struct cpp_ptr { void *ptr; bool destroyed; cpp_ptr(void *_ptr):ptr(_ptr), destroyed(false) { }}; typedef std::pair < const swig_type_info *, cpp_ptr > type_ptr_pair; mutable swig_module_info *module; const swig_type_info *construct_type; // type of special type object std::vector < type_ptr_pair > types; // our c++ base classes int own; // whether we call c++ destructors when we die typedef std::pair < const swig_octave_member *, octave_value > member_value_pair; typedef std::map < std::string, member_value_pair > member_map; member_map members; bool always_static; const swig_octave_member *find_member(const swig_type_info *type, const std::string &name) { if (!type->clientdata) return 0; swig_octave_class *c = (swig_octave_class *) type->clientdata; const swig_octave_member *m; for (m = c->members; m->name; ++m) if (m->name == name) return m; for (int j = 0; c->base_names[j]; ++j) { if (!c->base[j]) { if (!module) module = SWIG_GetModule(0); assert(module); c->base[j] = SWIG_MangledTypeQueryModule(module, module, c->base_names[j]); } if (!c->base[j]) return 0; if ((m = find_member(c->base[j], name))) return m; } return 0; } member_value_pair *find_member(const std::string &name, bool insert_if_not_found) { member_map::iterator it = members.find(name); if (it != members.end()) return &it->second; const swig_octave_member *m; for (unsigned int j = 0; j < types.size(); ++j) if ((m = find_member(types[j].first, name))) return &members.insert(std::make_pair(name, std::make_pair(m, octave_value()))).first->second; if (!insert_if_not_found) return 0; return &members[name]; } const swig_type_info *find_base(const std::string &name, const swig_type_info *base) { if (!base) { for (unsigned int j = 0; j < types.size(); ++j) { assert(types[j].first->clientdata); swig_octave_class *cj = (swig_octave_class *) types[j].first->clientdata; if (cj->name == name) return types[j].first; } return 0; } assert(base->clientdata); swig_octave_class *c = (swig_octave_class *) base->clientdata; for (int j = 0; c->base_names[j]; ++j) { if (!c->base[j]) { if (!module) module = SWIG_GetModule(0); assert(module); c->base[j] = SWIG_MangledTypeQueryModule(module, module, c->base_names[j]); } if (!c->base[j]) return 0; assert(c->base[j]->clientdata); swig_octave_class *cj = (swig_octave_class *) c->base[j]->clientdata; if (cj->name == name) return c->base[j]; } return 0; } void load_members(const swig_octave_class* c,member_map& out) const { for (const swig_octave_member *m = c->members; m->name; ++m) { if (out.find(m->name) == out.end()) out.insert(std::make_pair(m->name, std::make_pair(m, octave_value()))); } for (int j = 0; c->base_names[j]; ++j) { if (!c->base[j]) { if (!module) module = SWIG_GetModule(0); assert(module); c->base[j] = SWIG_MangledTypeQueryModule(module, module, c->base_names[j]); } if (!c->base[j]) continue; assert(c->base[j]->clientdata); const swig_octave_class *cj = (const swig_octave_class *) c->base[j]->clientdata; load_members(cj,out); } } void load_members(member_map& out) const { out=members; for (unsigned int j = 0; j < types.size(); ++j) if (types[j].first->clientdata) load_members((const swig_octave_class *) types[j].first->clientdata, out); } octave_value_list member_invoke(member_value_pair *m, const octave_value_list &args, int nargout) { if (m->second.is_defined()) return m->second.subsref("(", std::list < octave_value_list > (1, args), nargout); else if (m->first && m->first->method) return m->first->method(args, nargout); error("member not defined or not invocable"); return octave_value_list(); } bool dispatch_unary_op(const std::string &symbol, octave_value &ret) { member_value_pair *m = find_member(symbol, false); if (!m || m->first->is_static() || m->first->is_global()) return false; octave_value_list args; args.append(as_value()); octave_value_list argout(member_invoke(m, args, 1)); if (argout.length() < 1) return false; ret = argout(0); return true; } bool dispatch_binary_op(const std::string &symbol, const octave_base_value &rhs, octave_value &ret) { member_value_pair *m = find_member(symbol, false); if (!m || m->first->is_static() || m->first->is_global()) return false; octave_value_list args; args.append(as_value()); args.append(make_value_hack(rhs)); octave_value_list argout(member_invoke(m, args, 1)); if (argout.length() < 1) return false; ret = argout(0); return true; } bool dispatch_index_op(const std::string &symbol, const octave_value_list &rhs, octave_value_list &ret) { member_value_pair *m = find_member(symbol, false); if (!m || m->first->is_static() || m->first->is_global()) return false; octave_value_list args; args.append(as_value()); args.append(rhs); octave_value_list argout(member_invoke(m, args, 1)); if (argout.length() >= 1) ret = argout(0); return true; } octave_value_list member_deref(member_value_pair *m, const octave_value_list &args) { if (m->second.is_defined()) return m->second; else if (m->first) { if (m->first->get_method) return m->first->get_method(args, 1); else if (m->first->method) return octave_value(new octave_builtin(m->first->method)); } error("undefined member"); return octave_value_list(); } static octave_value make_value_hack(const octave_base_value &x) { ((octave_swig_type &) x).count++; return octave_value((octave_base_value *) &x); } octave_swig_type(const octave_swig_type &x); octave_swig_type &operator=(const octave_swig_type &rhs); public: octave_swig_type(void *_ptr = 0, const swig_type_info *_type = 0, int _own = 0, bool _always_static = false) : module(0), construct_type(_ptr ? 0 : _type), own(_own), always_static(_always_static) { if (_type || _ptr) types.push_back(std::make_pair(_type, _ptr)); #ifdef SWIG_DIRECTORS if (_ptr) { Swig::Director *d = Swig::get_rtdir(_ptr); if (d) Swig::swig_director_set_self(d, this); } #endif } ~octave_swig_type() { if (own) { ++count; for (unsigned int j = 0; j < types.size(); ++j) { if (!types[j].first || !types[j].first->clientdata) continue; swig_octave_class *c = (swig_octave_class *) types[j].first->clientdata; if (c->destructor && !types[j].second.destroyed && types[j].second.ptr) { c->destructor(as_value(), 0); } } } #ifdef SWIG_DIRECTORS for (unsigned int j = 0; j < types.size(); ++j) Swig::erase_rtdir(types[j].second.ptr); #endif } dim_vector dims(void) const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); // Find the __dims__ method of this object member_value_pair *m = nc_this->find_member("__dims__", false); if (!m) return dim_vector(1,1); // Call the __dims__ method of this object octave_value_list inarg; inarg.append(nc_this->as_value()); octave_value_list outarg = nc_this->member_invoke(m, inarg, 1); // __dims__ should return (at least) one output argument if (outarg.length() < 1) return dim_vector(1,1); octave_value & out = outarg(0); // Return value should be cell or matrix of integers if (out.is_cell()) { const Cell & c=out.cell_value(); int ndim = c.rows(); if (ndim==1 && c.columns()!=1) ndim = c.columns(); dim_vector d; d.resize(ndim < 2 ? 2 : ndim); d(0) = d(1) = 1; // Fill in dim_vector for (int k=0;k a = out.int_vector_value(); if (error_state) return dim_vector(1,1); dim_vector d; d.resize(a.numel() < 2 ? 2 : a.numel()); d(0) = d(1) = 1; for (int k=0;kclientdata) return 0; swig_octave_class *c = (swig_octave_class *) types[0].first->clientdata; return c->constructor_doc; } std::string swig_type_name() const { // * need some way to manually name subclasses. // * eg optional first arg to subclass(), or named_subclass() std::string ret; for (unsigned int j = 0; j < types.size(); ++j) { if (j) ret += "_"; if (types[j].first->clientdata) { swig_octave_class *c = (swig_octave_class *) types[j].first->clientdata; ret += c->name; } else ret += types[j].first->name; } return ret; } void merge(octave_swig_type &rhs) { rhs.own = 0; for (unsigned int j = 0; j < rhs.types.size(); ++j) { assert(!rhs.types[j].second.destroyed); #ifdef SWIG_DIRECTORS Swig::Director *d = Swig::get_rtdir(rhs.types[j].second.ptr); if (d) Swig::swig_director_set_self(d, this); #endif } types.insert(types.end(), rhs.types.begin(), rhs.types.end()); members.insert(rhs.members.begin(), rhs.members.end()); rhs.types.clear(); rhs.members.clear(); } typedef member_map::const_iterator swig_member_const_iterator; swig_member_const_iterator swig_members_begin() { return members.begin(); } swig_member_const_iterator swig_members_end() { return members.end(); } int cast(void **vptr, swig_type_info *type, int *_own, int flags) { int res = SWIG_ERROR; if (_own) *_own = own; if (flags &SWIG_POINTER_DISOWN) own = 0; if (!type && types.size()) { if(vptr) *vptr = types[0].second.ptr; return SWIG_OK; } for (unsigned int j = 0; j < types.size(); ++j) if (type == types[j].first) { if(vptr) *vptr = types[j].second.ptr; return SWIG_OK; } for (unsigned int j = 0; j < types.size(); ++j) { swig_cast_info *tc = SWIG_TypeCheck(types[j].first->name, type); if (!tc) continue; if(vptr) { int newmemory = 0; *vptr = SWIG_TypeCast(tc, types[j].second.ptr, &newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(_own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (_own) *_own = *_own | SWIG_CAST_NEW_MEMORY; } } res = SWIG_OK; break; } return res; } bool is_owned() const { return own; } #ifdef SWIG_DIRECTORS void director_destroyed(Swig::Director *d) { bool found = false; for (unsigned int j = 0; j < types.size(); ++j) { Swig::Director *dj = Swig::get_rtdir(types[j].second.ptr); if (dj == d) { types[j].second.destroyed = true; found = true; } } assert(found); } #endif void assign(const std::string &name, const octave_value &ov) { members[name] = std::make_pair((const swig_octave_member *) 0, ov); } void assign(const std::string &name, const swig_octave_member *m) { members[name] = std::make_pair(m, octave_value()); } octave_base_value *clone() const { // pass-by-value is probably not desired, and is harder; // requires calling copy constructors of contained types etc. assert(0); *(int *) 0 = 0; return 0; } octave_base_value *empty_clone() const { return new octave_swig_type(); } bool is_defined() const { return true; } virtual bool is_map() const { return true; } virtual octave_value subsref(const std::string &ops, const std::list < octave_value_list > &idx) { octave_value_list ovl = subsref(ops, idx, 1); return ovl.length()? ovl(0) : octave_value(); } virtual octave_value_list subsref(const std::string &ops, const std::list < octave_value_list > &idx, int nargout) { assert(ops.size() > 0); assert(ops.size() == idx.size()); std::list < octave_value_list >::const_iterator idx_it = idx.begin(); int skip = 0; octave_value_list sub_ovl; // constructor invocation if (ops[skip] == '(' && construct_type) { assert(construct_type->clientdata); swig_octave_class *c = (swig_octave_class *) construct_type->clientdata; if (!c->constructor) { error("cannot create instance"); return octave_value_list(); } octave_value_list args; if (c->director) args.append(Swig::swig_value_ref(new octave_swig_type(this, 0, 0))); args.append(*idx_it++); ++skip; sub_ovl = c->constructor(args, nargout); } // member dereference or invocation else if (ops[skip] == '.') { std::string subname; const swig_type_info *base = 0; // eg, a.base.base_cpp_mem for (;;) { octave_value_list subname_ovl(*idx_it++); ++skip; assert(subname_ovl.length() == 1 && subname_ovl(0).is_string()); subname = subname_ovl(0).string_value(); const swig_type_info *next_base = find_base(subname, base); if (!next_base || skip >= (int) ops.size() || ops[skip] != '.') break; base = next_base; } member_value_pair tmp, *m = &tmp; if (!base || !(m->first = find_member(base, subname))) m = find_member(subname, false); if (!m) { error("member not found"); return octave_value_list(); } octave_value_list args; if (!always_static && (!m->first || (!m->first->is_static() && !m->first->is_global()))) args.append(as_value()); if (skip < (int) ops.size() && ops[skip] == '(' && ((m->first && m->first->method) || m->second.is_function() || m->second.is_function_handle())) { args.append(*idx_it++); ++skip; sub_ovl = member_invoke(m, args, nargout); } else { sub_ovl = member_deref(m, args); } } // index operator else { if (ops[skip] == '(' || ops[skip] == '{') { const char *op_name = ops[skip] == '(' ? "__paren__" : "__brace__"; octave_value_list args; args.append(*idx_it++); ++skip; if (!dispatch_index_op(op_name, args, sub_ovl)) { error("error evaluating index operator"); return octave_value_list(); } } else { error("unsupported subsref"); return octave_value_list(); } } if (skip >= (int) ops.size()) return sub_ovl; if (sub_ovl.length() < 1) { error("bad subs ref"); return octave_value_list(); } return sub_ovl(0).next_subsref(nargout, ops, idx, skip); } octave_value subsasgn(const std::string &ops, const std::list < octave_value_list > &idx, const octave_value &rhs) { assert(ops.size() > 0); assert(ops.size() == idx.size()); std::list < octave_value_list >::const_iterator idx_it = idx.begin(); int skip = 0; if (ops.size() > 1) { std::list < octave_value_list >::const_iterator last = idx.end(); --last; std::list < octave_value_list > next_idx(idx.begin(), last); octave_value next_ov = subsref(ops.substr(0, ops.size() - 1), next_idx); next_ov.subsasgn(ops.substr(ops.size() - 1), std::list < octave_value_list > (1, *last), rhs); } else if (ops[skip] == '(' || ops[skip] == '{') { const char *op_name = ops[skip] == '(' ? "__paren_asgn__" : "__brace_asgn__"; member_value_pair *m = find_member(op_name, false); if (m) { octave_value_list args; args.append(as_value()); args.append(*idx_it); args.append(rhs); member_invoke(m, args, 1); } else error("%s member not found", op_name); } else if (ops[skip] == '.') { octave_value_list subname_ovl(*idx_it++); ++skip; assert(subname_ovl.length() == 1 &&subname_ovl(0).is_string()); std::string subname = subname_ovl(0).string_value(); member_value_pair *m = find_member(subname, true); if (!m->first || !m->first->set_method) { m->first = 0; m->second = rhs; } else if (m->first->set_method) { octave_value_list args; if (!m->first->is_static() && !m->first->is_global()) args.append(as_value()); args.append(rhs); m->first->set_method(args, 1); } else error("member not assignable"); } else error("unsupported subsasgn"); return as_value(); } virtual bool is_object() const { return true; } virtual bool is_string() const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); return !!nc_this->find_member("__str__", false); } virtual std::string string_value(bool force = false) const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); member_value_pair *m = nc_this->find_member("__str__", false); if (!m) { error("__str__ method not defined"); return std::string(); } octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1); if (outarg.length() < 1 || !outarg(0).is_string()) { error("__str__ method did not return a string"); return std::string(); } return outarg(0).string_value(); } #if SWIG_OCTAVE_PREREQ(3,3,52) virtual octave_map map_value() const { return octave_map(); } #else virtual Octave_map map_value() const { return Octave_map(); } #endif virtual string_vector map_keys() const { member_map tmp; load_members(tmp); string_vector keys(tmp.size()); int k = 0; for (member_map::iterator it = tmp.begin(); it != tmp.end(); ++it) keys(k++) = it->first; return keys; } virtual bool save_ascii (std::ostream& os) { return true; } virtual bool load_ascii (std::istream& is) { return true; } virtual bool save_binary (std::ostream& os, bool& save_as_floats) { return true; } virtual bool load_binary (std::istream& is, bool swap, oct_mach_info::float_format fmt) { return true; } #if defined (HAVE_HDF5) # if SWIG_OCTAVE_PREREQ(4,0,0) virtual bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats) { return true; } virtual bool load_hdf5 (octave_hdf5_id loc_id, const char *name, bool have_h5giterate_bug) { return true; } # else virtual bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { return true; } virtual bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { return true; } # endif #endif virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const { return string_value(); } virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const { return string_value(); } static bool dispatch_global_op(const std::string &symbol, const octave_value_list &args, octave_value &ret) { // we assume that SWIG_op_prefix-prefixed functions are installed in global namespace // (rather than any module namespace). octave_function *fcn = is_valid_function(symbol, std::string(), false); if (!fcn) return false; ret = fcn->do_multi_index_op(1, args)(0); return true; } static octave_value dispatch_unary_op(const octave_base_value &x, const char *op_name) { octave_swig_type *ost = Swig::swig_value_deref(x); assert(ost); octave_value ret; if (ost->dispatch_unary_op(std::string("__") + op_name + std::string("__"), ret)) return ret; std::string symbol = SWIG_op_prefix + ost->swig_type_name() + "_" + op_name; octave_value_list args; args.append(make_value_hack(x)); if (dispatch_global_op(symbol, args, ret)) return ret; error("could not dispatch unary operator"); return octave_value(); } static octave_value dispatch_binary_op(const octave_base_value &lhs, const octave_base_value &rhs, const char *op_name) { octave_swig_type *lhs_ost = Swig::swig_value_deref(lhs); octave_swig_type *rhs_ost = Swig::swig_value_deref(rhs); octave_value ret; if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name + std::string("__"), rhs, ret)) return ret; if (rhs_ost) { if (strlen(op_name) == 2 && (op_name[1] == 't' || op_name[1] == 'e')) { if (op_name[0] == 'l' && rhs_ost->dispatch_binary_op(std::string("__g") + op_name[1] + std::string("__"), lhs, ret)) return ret; if (op_name[0] == 'g' && rhs_ost->dispatch_binary_op(std::string("__l") + op_name[1] + std::string("__"), lhs, ret)) return ret; } if (rhs_ost->dispatch_binary_op(std::string("__r") + op_name + std::string("__"), lhs, ret)) return ret; } std::string symbol; octave_value_list args; args.append(make_value_hack(lhs)); args.append(make_value_hack(rhs)); symbol = SWIG_op_prefix; symbol += lhs_ost ? lhs_ost->swig_type_name() : lhs.type_name(); symbol += "_"; symbol += op_name; symbol += "_"; symbol += rhs_ost ? rhs_ost->swig_type_name() : rhs.type_name(); if (dispatch_global_op(symbol, args, ret)) return ret; symbol = SWIG_op_prefix; symbol += lhs_ost ? lhs_ost->swig_type_name() : lhs.type_name(); symbol += "_"; symbol += op_name; symbol += "_"; symbol += "any"; if (dispatch_global_op(symbol, args, ret)) return ret; symbol = SWIG_op_prefix; symbol += "any"; symbol += "_"; symbol += op_name; symbol += "_"; symbol += rhs_ost ? rhs_ost->swig_type_name() : rhs.type_name(); if (dispatch_global_op(symbol, args, ret)) return ret; error("could not dispatch binary operator"); return octave_value(); } #if SWIG_OCTAVE_PREREQ(4,0,0) void print(std::ostream &os, bool pr_as_read_syntax = false) #else void print(std::ostream &os, bool pr_as_read_syntax = false) const #endif { if (is_string()) { os << string_value(); return; } member_map tmp; load_members(tmp); indent(os); os << "{"; newline(os); increment_indent_level(); for (unsigned int j = 0; j < types.size(); ++j) { indent(os); if (types[j].first->clientdata) { const swig_octave_class *c = (const swig_octave_class *) types[j].first->clientdata; os << c->name << ", ptr = " << types[j].second.ptr; newline(os); } else { os << types[j].first->name << ", ptr = " << types[j].second.ptr; newline(os); } } for (member_map::const_iterator it = tmp.begin(); it != tmp.end(); ++it) { indent(os); if (it->second.first) { const char *objtype = it->second.first->method ? "method" : "variable"; const char *modifier = (it->second.first->flags &1) ? "static " : (it->second.first->flags &2) ? "global " : ""; os << it->second.first->name << " (" << modifier << objtype << ")"; newline(os); assert(it->second.first->name == it->first); } else { os << it->first; newline(os); } } decrement_indent_level(); indent(os); os << "}"; newline(os); } }; // Octave tries hard to preserve pass-by-value semantics. Eg, assignments // will call clone() via make_unique() if there is more than one outstanding // reference to the lhs, and forces the clone's reference count to 1 // (so you can't just increment your own count and return this). // // One way to fix this (without modifying Octave) is to add a level of // indirection such that clone copies ref-counted pointer and we keep // pass-by-ref semantics (which are more natural/expected for C++ bindings). // // Supporting both pass-by-{ref,value} and toggling via %feature/option // might be nice. class octave_swig_ref:public octave_base_value { octave_swig_type *ptr; public: octave_swig_ref(octave_swig_type *_ptr = 0) :ptr(_ptr) { } ~octave_swig_ref() { if (ptr) ptr->decref(); } octave_swig_type *get_ptr() const { return ptr; } octave_base_value *clone() const { if (ptr) ptr->incref(); return new octave_swig_ref(ptr); } octave_base_value *empty_clone() const { return new octave_swig_ref(0); } dim_vector dims(void) const { return ptr->dims(); } bool is_defined() const { return ptr->is_defined(); } virtual bool is_map() const { return ptr->is_map(); } virtual octave_value subsref(const std::string &ops, const std::list < octave_value_list > &idx) { return ptr->subsref(ops, idx); } virtual octave_value_list subsref(const std::string &ops, const std::list < octave_value_list > &idx, int nargout) { return ptr->subsref(ops, idx, nargout); } octave_value subsasgn(const std::string &ops, const std::list < octave_value_list > &idx, const octave_value &rhs) { return ptr->subsasgn(ops, idx, rhs); } virtual bool is_object() const { return ptr->is_object(); } virtual bool is_string() const { return ptr->is_string(); } virtual std::string string_value(bool force = false) const { return ptr->string_value(force); } #if SWIG_OCTAVE_PREREQ(3,3,52) virtual octave_map map_value() const { return ptr->map_value(); } #else virtual Octave_map map_value() const { return ptr->map_value(); } #endif virtual string_vector map_keys() const { return ptr->map_keys(); } virtual bool save_ascii (std::ostream& os) { return ptr->save_ascii(os); } virtual bool load_ascii (std::istream& is) { return ptr->load_ascii(is); } virtual bool save_binary (std::ostream& os, bool& save_as_floats) { return ptr->save_binary(os, save_as_floats); } virtual bool load_binary (std::istream& is, bool swap, oct_mach_info::float_format fmt) { return ptr->load_binary(is, swap, fmt); } #if defined (HAVE_HDF5) # if SWIG_OCTAVE_PREREQ(4,0,0) virtual bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats) { return ptr->save_hdf5(loc_id, name, save_as_floats); } virtual bool load_hdf5 (octave_hdf5_id loc_id, const char *name, bool have_h5giterate_bug) { return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); } # else virtual bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { return ptr->save_hdf5(loc_id, name, save_as_floats); } virtual bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); } # endif #endif virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const { return ptr->convert_to_str(pad, force, type); } virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const { return ptr->convert_to_str_internal(pad, force, type); } #if SWIG_OCTAVE_PREREQ(4,0,0) void print(std::ostream &os, bool pr_as_read_syntax = false) #else void print(std::ostream &os, bool pr_as_read_syntax = false) const #endif { return ptr->print(os, pr_as_read_syntax); } private: #if !SWIG_OCTAVE_PREREQ(4,0,0) DECLARE_OCTAVE_ALLOCATOR; #endif DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; }; #if !SWIG_OCTAVE_PREREQ(4,0,0) DEFINE_OCTAVE_ALLOCATOR(octave_swig_ref); #endif DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_ref, "swig_ref", "swig_ref"); class octave_swig_packed:public octave_base_value { swig_type_info *type; std::vector < char > buf; public: octave_swig_packed(swig_type_info *_type = 0, const void *_buf = 0, size_t _buf_len = 0) : type(_type), buf((const char*)_buf, (const char*)_buf + _buf_len) { } bool copy(swig_type_info *outtype, void *ptr, size_t sz) const { if (outtype && outtype != type) return false; assert(sz <= buf.size()); std::copy(buf.begin(), buf.begin()+sz, (char*)ptr); return true; } octave_base_value *clone() const { return new octave_swig_packed(*this); } octave_base_value *empty_clone() const { return new octave_swig_packed(); } bool is_defined() const { return true; } #if SWIG_OCTAVE_PREREQ(4,0,0) void print(std::ostream &os, bool pr_as_read_syntax = false) #else void print(std::ostream &os, bool pr_as_read_syntax = false) const #endif { indent(os); os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size(); newline(os); } virtual bool save_ascii (std::ostream& os) { return true; } virtual bool load_ascii (std::istream& is) { return true; } virtual bool save_binary (std::ostream& os, bool& save_as_floats) { return true; } virtual bool load_binary (std::istream& is, bool swap, oct_mach_info::float_format fmt) { return true; } #if defined (HAVE_HDF5) # if SWIG_OCTAVE_PREREQ(4,0,0) virtual bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats) { return true; } virtual bool load_hdf5 (octave_hdf5_id loc_id, const char *name, bool have_h5giterate_bug) { return true; } # else virtual bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { return true; } virtual bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { return true; } # endif #endif private: #if !SWIG_OCTAVE_PREREQ(4,0,0) DECLARE_OCTAVE_ALLOCATOR; #endif DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; }; #if !SWIG_OCTAVE_PREREQ(4,0,0) DEFINE_OCTAVE_ALLOCATOR(octave_swig_packed); #endif DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_packed, "swig_packed", "swig_packed"); SWIGRUNTIME octave_value_list octave_set_immutable(const octave_value_list &args, int nargout) { error("attempt to set immutable member variable"); return octave_value_list(); } struct octave_value_ref { const octave_value_list &ovl; int j; octave_value_ref(const octave_value_list &_ovl, int _j) :ovl(_ovl), j(_j) { } operator octave_value() const { return ovl(j); } octave_value operator*() const { return ovl(j); } }; namespace Swig { SWIGRUNTIME octave_base_value *swig_value_ref(octave_swig_type *ost) { return new octave_swig_ref(ost); } SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov) { if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); return swig_value_deref(*ov.internal_rep()); } SWIGRUNTIME octave_swig_type *swig_value_deref(const octave_base_value &ov) { if (ov.type_id() != octave_swig_ref::static_type_id()) return 0; const octave_swig_ref *osr = static_cast < const octave_swig_ref *>(&ov); return osr->get_ptr(); } } #define swig_unary_op(name) \ SWIGRUNTIME octave_value swig_unary_op_##name(const octave_base_value &x) { \ return octave_swig_type::dispatch_unary_op(x,#name); \ } #define swig_binary_op(name) \ SWIGRUNTIME octave_value swig_binary_op_##name(const octave_base_value&lhs,const octave_base_value &rhs) { \ return octave_swig_type::dispatch_binary_op(lhs,rhs,#name); \ } #define swigreg_unary_op(name) \ if (!octave_value_typeinfo::lookup_unary_op(octave_value::op_##name,tid)) \ octave_value_typeinfo::register_unary_op(octave_value::op_##name,tid,swig_unary_op_##name); #define swigreg_binary_op(name) \ if (!octave_value_typeinfo::lookup_binary_op(octave_value::op_##name,tid1,tid2)) \ octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,swig_binary_op_##name); swig_unary_op(not); swig_unary_op(uplus); swig_unary_op(uminus); swig_unary_op(transpose); swig_unary_op(hermitian); swig_unary_op(incr); swig_unary_op(decr); swig_binary_op(add); swig_binary_op(sub); swig_binary_op(mul); swig_binary_op(div); swig_binary_op(pow); swig_binary_op(ldiv); swig_binary_op(lshift); swig_binary_op(rshift); swig_binary_op(lt); swig_binary_op(le); swig_binary_op(eq); swig_binary_op(ge); swig_binary_op(gt); swig_binary_op(ne); swig_binary_op(el_mul); swig_binary_op(el_div); swig_binary_op(el_pow); swig_binary_op(el_ldiv); swig_binary_op(el_and); swig_binary_op(el_or); SWIGRUNTIME void SWIG_InstallUnaryOps(int tid) { swigreg_unary_op(not); swigreg_unary_op(uplus); swigreg_unary_op(uminus); swigreg_unary_op(transpose); swigreg_unary_op(hermitian); swigreg_unary_op(incr); swigreg_unary_op(decr); } SWIGRUNTIME void SWIG_InstallBinaryOps(int tid1, int tid2) { swigreg_binary_op(add); swigreg_binary_op(sub); swigreg_binary_op(mul); swigreg_binary_op(div); swigreg_binary_op(pow); swigreg_binary_op(ldiv); swigreg_binary_op(lshift); swigreg_binary_op(rshift); swigreg_binary_op(lt); swigreg_binary_op(le); swigreg_binary_op(eq); swigreg_binary_op(ge); swigreg_binary_op(gt); swigreg_binary_op(ne); swigreg_binary_op(el_mul); swigreg_binary_op(el_div); swigreg_binary_op(el_pow); swigreg_binary_op(el_ldiv); swigreg_binary_op(el_and); swigreg_binary_op(el_or); } SWIGRUNTIME void SWIG_InstallOps(int tid) { // here we assume that tid are conseq integers increasing from zero, and // that our tid is the last one. might be better to have explicit string // list of types we should bind to, and use lookup_type to resolve their tid. SWIG_InstallUnaryOps(tid); SWIG_InstallBinaryOps(tid, tid); for (int j = 0; j < tid; ++j) { SWIG_InstallBinaryOps(j, tid); SWIG_InstallBinaryOps(tid, j); } } SWIGRUNTIME octave_value SWIG_Octave_NewPointerObj(void *ptr, swig_type_info *type, int flags) { int own = (flags &SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; #ifdef SWIG_DIRECTORS Swig::Director *d = Swig::get_rtdir(ptr); if (d && Swig::swig_director_get_self(d)) return Swig::swig_director_get_self(d)->as_value(); #endif return Swig::swig_value_ref(new octave_swig_type(ptr, type, own)); } SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_type_info *type, int flags, int *own) { if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); if (!ov.is_defined() || (ov.is_matrix_type() && ov.rows() == 0 && ov.columns() == 0) ) { if (ptr) *ptr = 0; return SWIG_OK; } if (ov.type_id() != octave_swig_ref::static_type_id()) return SWIG_ERROR; octave_swig_ref *osr = static_cast < octave_swig_ref *>(ov.internal_rep()); octave_swig_type *ost = osr->get_ptr(); return ost->cast(ptr, type, own, flags); } SWIGRUNTIME octave_value SWIG_Octave_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return new octave_swig_packed(type, (char *) ptr, sz); } SWIGRUNTIME int SWIG_Octave_ConvertPacked(const octave_value &ov, void *ptr, size_t sz, swig_type_info *type) { if (!ov.is_defined()) return SWIG_ERROR; if (ov.type_id() != octave_swig_packed::static_type_id()) return SWIG_ERROR; octave_swig_packed *ost = static_cast < octave_swig_packed *>(ov.internal_rep()); return ost->copy(type, (char *) ptr, sz) ? SWIG_OK : SWIG_ERROR; } SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) { module_ns->assign(name, ov); } SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) { return get_global_value(name, true); } SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) { set_global_value(name, value); } SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) { #if !SWIG_OCTAVE_PREREQ(3,2,0) link_to_global_variable(curr_sym_tab->lookup(name, true)); #else #if !SWIG_OCTAVE_PREREQ(3,8,0) symbol_table::varref(name); #endif symbol_table::mark_global(name); #endif } SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) { octave_value ov = SWIG_Octave_GetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION); if (!ov.is_defined() || ov.type_id() != octave_swig_packed::static_type_id()) return 0; const octave_swig_packed* osp = static_cast < const octave_swig_packed *> (ov.internal_rep()); swig_module_info *pointer = 0; osp->copy(0, &pointer, sizeof(swig_module_info *)); return pointer; } SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) { octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *)); SWIG_Octave_SetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION, ov); } swig-3.0.8/Lib/octave/carrays.i0000664000175000017500000000020112641054563016157 0ustar williamwilliam%define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__) %enddef %include swig-3.0.8/Lib/octave/octprimtypes.swg0000664000175000017500000001253712641054563017644 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ // boolean %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(bool)(bool value) { return octave_value(value); } } %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val) { if (!ov.is_bool_type()) return SWIG_ERROR; if (val) *val = ov.bool_value(); return SWIG_OK; } } // long %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(long) (long value) { return octave_value(value); } } %fragment(SWIG_AsVal_frag(long),"header") { SWIGINTERN int SWIG_AsVal_dec(long)(const octave_value& ov, long* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (ov.is_double_type()||ov.is_single_type()) { double v=ov.double_value(); if (v!=floor(v)) return SWIG_TypeError; } if (val) *val = ov.long_value(); return SWIG_OK; } } // unsigned long %fragment(SWIG_From_frag(unsigned long),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long) (unsigned long value) { return octave_value(value); } } %fragment(SWIG_AsVal_frag(unsigned long),"header") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(const octave_value& ov, unsigned long* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (ov.is_double_type()||ov.is_single_type()) { double v=ov.double_value(); if (v<0) return SWIG_OverflowError; if (v!=floor(v)) return SWIG_TypeError; } if (ov.is_int8_type()||ov.is_int16_type()|| ov.is_int32_type()) { long v=ov.long_value(); if (v<0) return SWIG_OverflowError; } if (ov.is_int64_type()) { long long v=ov.int64_scalar_value().value(); if (v<0) return SWIG_OverflowError; } if (val) *val = ov.ulong_value(); return SWIG_OK; } } // long long %fragment(SWIG_From_frag(long long),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(long long) (long long value) { return octave_int64(value); } } %fragment(SWIG_AsVal_frag(long long),"header") { SWIGINTERN int SWIG_AsVal_dec(long long)(const octave_value& ov, long long* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (ov.is_double_type()||ov.is_single_type()) { double v=ov.double_value(); if (v!=floor(v)) return SWIG_TypeError; } if (val) { if (ov.is_int64_type()) *val = ov.int64_scalar_value().value(); else if (ov.is_uint64_type()) *val = ov.uint64_scalar_value().value(); else *val = ov.long_value(); } return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned long long),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long long) (unsigned long long value) { return octave_uint64(value); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header") { SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(const octave_value& ov, unsigned long long* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (ov.is_double_type()||ov.is_single_type()) { double v=ov.double_value(); if (v<0) return SWIG_OverflowError; if (v!=floor(v)) return SWIG_TypeError; } if (ov.is_int8_type()||ov.is_int16_type()|| ov.is_int32_type()) { long v=ov.long_value(); if (v<0) return SWIG_OverflowError; } if (ov.is_int64_type()) { long long v=ov.int64_scalar_value().value(); if (v<0) return SWIG_OverflowError; } if (val) { if (ov.is_int64_type()) *val = ov.int64_scalar_value().value(); else if (ov.is_uint64_type()) *val = ov.uint64_scalar_value().value(); else *val = ov.long_value(); } return SWIG_OK; } } // double %fragment(SWIG_From_frag(double),"header") { SWIGINTERNINLINE octave_value SWIG_From_dec(double) (double value) { return octave_value(value); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN int SWIG_AsVal_dec(double)(const octave_value& ov, double* val) { if (!ov.is_scalar_type()) return SWIG_TypeError; if (ov.is_complex_scalar()) return SWIG_TypeError; if (val) *val = ov.double_value(); return SWIG_OK; } } // const char* (strings) %fragment("SWIG_AsCharPtrAndSize","header") { SWIGINTERN int SWIG_AsCharPtrAndSize(octave_value ov, char** cptr, size_t* psize, int *alloc) { if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); if (!ov.is_string()) return SWIG_TypeError; std::string str=ov.string_value(); size_t len=str.size(); char* cstr=(char*)str.c_str(); if (alloc) { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else if (cptr) *cptr = cstr; if (psize) *psize = len + 1; return SWIG_OK; } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE octave_value SWIG_FromCharPtrAndSize(const char* carray, size_t size) { return std::string(carray,carray+size); } } swig-3.0.8/Lib/octave/exception.i0000664000175000017500000000021312641054563016514 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-3.0.8/Lib/octave/std_alloc.i0000664000175000017500000000003312641054563016462 0ustar williamwilliam%include swig-3.0.8/Lib/octave/std_deque.i0000664000175000017500000000124712641054563016503 0ustar williamwilliam// Deques %fragment("StdDequeTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(octave_value obj, std::deque **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static octave_value from(const std::deque & vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_deque_methods(Type...) %swig_sequence_methods(Type) #define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/octave/std_common.i0000664000175000017500000000443012641054563016665 0ustar williamwilliam%include %include // Generate the traits for a 'primitive' type, such as 'double', // for which the SWIG_AsVal and SWIG_From methods are already defined. %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval< Type > { typedef Type value_type; static int asval(octave_value obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from< Type > { typedef Type value_type; static octave_value from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval< Type > { typedef Type value_type; static int asval(octave_value obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from< Type > { typedef Type value_type; static octave_value from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.8/Lib/octave/factory.i0000664000175000017500000000004012641054563016163 0ustar williamwilliam%include swig-3.0.8/Lib/octave/octiterators.swg0000664000175000017500000002164012641054563017617 0ustar williamwilliam/* ----------------------------------------------------------------------------- * octiterators.swg * * Users can derive form the OctSwigIterator to implemet their * own iterators. As an example (real one since we use it for STL/STD * containers), the template OctSwigIterator_T does the * implementation for generic C++ iterators. * ----------------------------------------------------------------------------- */ %include %fragment("OctSwigIterator","header",fragment="") { namespace swig { struct stop_iteration { }; struct OctSwigIterator { private: octave_value _seq; protected: OctSwigIterator(octave_value seq) : _seq(seq) { } public: virtual ~OctSwigIterator() {} virtual octave_value value() const = 0; virtual OctSwigIterator *incr(size_t n = 1) = 0; virtual OctSwigIterator *decr(size_t n = 1) { throw stop_iteration(); } virtual ptrdiff_t distance(const OctSwigIterator &x) const { throw std::invalid_argument("operation not supported"); } virtual bool equal (const OctSwigIterator &x) const { throw std::invalid_argument("operation not supported"); } virtual OctSwigIterator *copy() const = 0; octave_value next() { octave_value obj = value(); incr(); return obj; } octave_value previous() { decr(); return value(); } OctSwigIterator *advance(ptrdiff_t n) { return (n > 0) ? incr(n) : decr(-n); } bool operator == (const OctSwigIterator& x) const { return equal(x); } bool operator != (const OctSwigIterator& x) const { return ! operator==(x); } OctSwigIterator* operator ++ () { incr(); return this; } OctSwigIterator* operator -- () { decr(); return this; } OctSwigIterator* operator + (ptrdiff_t n) const { return copy()->advance(n); } OctSwigIterator* operator - (ptrdiff_t n) const { return copy()->advance(-n); } ptrdiff_t operator - (const OctSwigIterator& x) const { return x.distance(*this); } static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::OctSwigIterator *"); init = 1; } return desc; } }; } } %fragment("OctSwigIterator_T","header",fragment="",fragment="OctSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { template class OctSwigIterator_T : public OctSwigIterator { public: typedef OutIterator out_iterator; typedef typename std::iterator_traits::value_type value_type; typedef OctSwigIterator_T self_type; OctSwigIterator_T(out_iterator curr, octave_value seq) : OctSwigIterator(seq), current(curr) { } const out_iterator& get_current() const { return current; } bool equal (const OctSwigIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } ptrdiff_t distance(const OctSwigIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } protected: out_iterator current; }; template struct from_oper { typedef const ValueType& argument_type; typedef octave_value result_type; result_type operator()(argument_type v) const { return swig::from(v); } }; template::value_type, typename FromOper = from_oper > class OctSwigIteratorOpen_T : public OctSwigIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef OctSwigIterator_T base; typedef OctSwigIteratorOpen_T self_type; OctSwigIteratorOpen_T(out_iterator curr, octave_value seq) : OctSwigIterator_T(curr, seq) { } octave_value value() const { return from(static_cast(*(base::current))); } OctSwigIterator *copy() const { return new self_type(*this); } OctSwigIterator *incr(size_t n = 1) { while (n--) { ++base::current; } return this; } OctSwigIterator *decr(size_t n = 1) { while (n--) { --base::current; } return this; } }; template::value_type, typename FromOper = from_oper > class OctSwigIteratorClosed_T : public OctSwigIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef OctSwigIterator_T base; typedef OctSwigIteratorClosed_T self_type; OctSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, octave_value seq) : OctSwigIterator_T(curr, seq), begin(first), end(last) { } octave_value value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } OctSwigIterator *copy() const { return new self_type(*this); } OctSwigIterator *incr(size_t n = 1) { while (n--) { if (base::current == end) { throw stop_iteration(); } else { ++base::current; } } return this; } OctSwigIterator *decr(size_t n = 1) { while (n--) { if (base::current == begin) { throw stop_iteration(); } else { --base::current; } } return this; } private: out_iterator begin; out_iterator end; }; template inline OctSwigIterator* make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, octave_value seq = octave_value()) { return new OctSwigIteratorClosed_T(current, begin, end, seq); } template inline OctSwigIterator* make_output_iterator(const OutIter& current, octave_value seq = octave_value()) { return new OctSwigIteratorOpen_T(current, seq); } } } %fragment("OctSwigIterator"); namespace swig { // Throw a StopIteration exception %ignore stop_iteration; struct stop_iteration {}; %typemap(throws) stop_iteration { error("stop_iteration exception"); SWIG_fail; } // Mark methods that return new objects %newobject OctSwigIterator::copy; %newobject OctSwigIterator::operator + (ptrdiff_t n) const; %newobject OctSwigIterator::operator - (ptrdiff_t n) const; %nodirector OctSwigIterator; %catches(swig::stop_iteration) OctSwigIterator::value() const; %catches(swig::stop_iteration) OctSwigIterator::incr(size_t n = 1); %catches(swig::stop_iteration) OctSwigIterator::decr(size_t n = 1); %catches(std::invalid_argument) OctSwigIterator::distance(const OctSwigIterator &x) const; %catches(std::invalid_argument) OctSwigIterator::equal (const OctSwigIterator &x) const; %catches(swig::stop_iteration) OctSwigIterator::next(); %catches(swig::stop_iteration) OctSwigIterator::previous(); %catches(swig::stop_iteration) OctSwigIterator::advance(ptrdiff_t n); %catches(swig::stop_iteration) OctSwigIterator::operator += (ptrdiff_t n); %catches(swig::stop_iteration) OctSwigIterator::operator -= (ptrdiff_t n); %catches(swig::stop_iteration) OctSwigIterator::operator + (ptrdiff_t n) const; %catches(swig::stop_iteration) OctSwigIterator::operator - (ptrdiff_t n) const; struct OctSwigIterator { protected: OctSwigIterator(octave_value seq); public: virtual ~OctSwigIterator(); virtual octave_value value() const = 0; virtual OctSwigIterator *incr(size_t n = 1) = 0; virtual OctSwigIterator *decr(size_t n = 1); virtual ptrdiff_t distance(const OctSwigIterator &x) const; virtual bool equal (const OctSwigIterator &x) const; virtual OctSwigIterator *copy() const = 0; octave_value next(); octave_value previous(); OctSwigIterator *advance(ptrdiff_t n); bool operator == (const OctSwigIterator& x) const; bool operator != (const OctSwigIterator& x) const; OctSwigIterator* operator ++ (); OctSwigIterator* operator -- (); OctSwigIterator* operator + (ptrdiff_t n) const; OctSwigIterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const OctSwigIterator& x) const; }; } swig-3.0.8/Lib/octave/std_list.i0000664000175000017500000000124512641054563016351 0ustar williamwilliam// Lists %fragment("StdListTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(const octave_value& obj, std::list **lis) { return traits_asptr_stdseq >::asptr(obj, lis); } }; template struct traits_from > { static octave_value *from(const std::list & vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/octave/std_basic_string.i0000664000175000017500000000441512641054563020047 0ustar williamwilliam#if !defined(SWIG_STD_STRING) #define SWIG_STD_BASIC_STRING #define SWIG_STD_MODERN_STL %include #define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(octave_value obj, std::string **val) { if (obj.is_string()) { if (val) *val = new std::string(obj.string_value()); return SWIG_NEWOBJ; } if (val) error("a string is expected"); return 0; } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE octave_value SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } %ignore std::basic_string::operator +=; %include %typemaps_asptrfromn(%checkcode(STRING), std::basic_string); #endif #if !defined(SWIG_STD_WSTRING) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(PyObject* obj, std::wstring **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::wstring *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { PyErr_Clear(); wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::wstring(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } else { PyErr_Clear(); } if (val) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_TypeError,"a wstring is expected"); SWIG_PYTHON_THREAD_END_BLOCK; } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE PyObject* SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } %typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string); #endif swig-3.0.8/Lib/octave/octtypemaps.swg0000664000175000017500000000463212641054563017447 0ustar williamwilliam // Include fundamental fragment definitions %include // Look for user fragments file. %include // Octave fragments for primitive types %include // Octave fragments for char* strings //%include #ifndef SWIG_DIRECTOR_TYPEMAPS #define SWIG_DIRECTOR_TYPEMAPS #endif // Octave types #define SWIG_Object octave_value #define VOID_Object octave_value() /* // Octave allows implicit conversion #define %implicitconv_flag $implicitconv */ // append output #define SWIG_AppendOutput(result, obj) SWIG_Octave_AppendOutput(result, obj) // set constant #define SWIG_SetConstant(name, obj) SWIG_Octave_SetConstant(module_ns,name,obj) // raise #define SWIG_Octave_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE) #define SWIG_Raise(obj, type, desc) SWIG_Octave_Raise(obj, type, desc) // Include the unified typemap library %include %typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = (*$input).is_defined();"; %typecheck(SWIG_TYPECHECK_SWIGOBJECT) octave_value_list "$1 = true;"; %typemap(in) (octave_value_list varargs,...) { for (int j=$argnum-1;jappend($1); } %typemap(out,noblock=1) octave_map, Octave_map { $result=$1; } %typemap(out,noblock=1) NDArray { $result=$1; } %typemap(out,noblock=1) Cell { $result=$1; } /* // Smart Pointers %typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags); } %typemap(ret) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { octave_swig_type* lobj=Swig::swig_value_deref($result); if (lobj) { std::list idx; idx.push_back(octave_value("__deref__")); idx.push_back(octave_value_list()); octave_value_list ovl(lobj->subsref(".(",idx)); octave_swig_type* robj=ovl.length()>=1?Swig::swig_value_deref(ovl(0)):0; if (robj && !error_state) lobj->append(robj); } } */ swig-3.0.8/Lib/octave/std_char_traits.i0000664000175000017500000000004112641054563017672 0ustar williamwilliam%include swig-3.0.8/Lib/octave/std_map.i0000664000175000017500000001104612641054563016153 0ustar williamwilliam// Maps %include %fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { template struct from_key_oper { typedef const ValueType& argument_type; typedef octave_value result_type; result_type operator()(argument_type v) const { return swig::from(v.first); } }; template struct from_value_oper { typedef const ValueType& argument_type; typedef octave_value result_type; result_type operator()(argument_type v) const { return swig::from(v.second); } }; template struct OctMapIterator_T : OctSwigIteratorClosed_T { OctMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) : OctSwigIteratorClosed_T(curr, first, last, seq) { } }; template > struct OctMapKeyIterator_T : OctMapIterator_T { OctMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) : OctMapIterator_T(curr, first, last, seq) { } }; template inline OctSwigIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value()) { return new OctMapKeyIterator_T(current, begin, end, seq); } template > struct OctMapValueIterator_T : OctMapIterator_T { OctMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) : OctMapIterator_T(curr, first, last, seq) { } }; template inline OctSwigIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = 0) { return new OctMapValueIterator_T(current, begin, end, seq); } } } %fragment("StdMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const OctSeq& octseq, std::map *map) { typedef typename std::map::value_type value_type; typename OctSeq::const_iterator it = octseq.begin(); for (;it != octseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::map map_type; static int asptr(octave_value obj, map_type **val) { /* int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; */ return SWIG_ERROR; } }; template struct traits_from > { typedef std::map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; static octave_value from(const map_type& map) { /* swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); } else { size_type size = map.size(); int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject *obj = PyDict_New(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { swig::SwigVar_PyObject key = swig::from(i->first); swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; } */ return octave_value(); } }; } } %define %swig_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map); %enddef %define %swig_map_methods(Map...) %swig_map_common(Map) %enddef %include swig-3.0.8/Lib/octave/octruntime.swg0000664000175000017500000002466112641054563017274 0ustar williamwilliam%insert(runtime) %{ #include #include #include #include #include #include #include #include #include #include #include %} %insert(runtime) "swigrun.swg"; %insert(runtime) "swigerrors.swg"; %insert(runtime) "octrun.swg"; %insert(initbeforefunc) "swiginit.swg" %insert(initbeforefunc) %{ static bool SWIG_init_user(octave_swig_type* module_ns); SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) { bool retn; { #if !SWIG_OCTAVE_PREREQ(3,3,50) unwind_protect::begin_frame("SWIG_Octave_LoadModule"); unwind_protect_int(error_state); unwind_protect_int(warning_state); unwind_protect_bool(discard_error_messages); unwind_protect_bool(discard_warning_messages); #else unwind_protect frame; frame.protect_var(error_state); frame.protect_var(warning_state); frame.protect_var(discard_error_messages); frame.protect_var(discard_warning_messages); #endif error_state = 0; warning_state = 0; discard_error_messages = true; discard_warning_messages = true; feval(name, octave_value_list(), 0); retn = (error_state == 0); #if !SWIG_OCTAVE_PREREQ(3,3,50) unwind_protect::run_frame("SWIG_Octave_LoadModule"); #endif } if (!retn) { error(SWIG_name_d ": could not load module `%s'", name.c_str()); } return retn; } SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function *octloadfcn, std::string name) { bool retn; { #if !SWIG_OCTAVE_PREREQ(3,3,50) unwind_protect::begin_frame("SWIG_Octave_InstallFunction"); unwind_protect_int(error_state); unwind_protect_int(warning_state); unwind_protect_bool(discard_error_messages); unwind_protect_bool(discard_warning_messages); #else unwind_protect frame; frame.protect_var(error_state); frame.protect_var(warning_state); frame.protect_var(discard_error_messages); frame.protect_var(discard_warning_messages); #endif error_state = 0; warning_state = 0; discard_error_messages = true; discard_warning_messages = true; octave_value_list args; args.append(name); args.append(octloadfcn->fcn_file_name()); error_state = 0; feval("autoload", args, 0); retn = (error_state == 0); #if !SWIG_OCTAVE_PREREQ(3,3,50) unwind_protect::run_frame("SWIG_Octave_InstallFunction"); #endif } if (!retn) { error(SWIG_name_d ": could not load function `%s'", name.c_str()); } return retn; } static const char *const subclass_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Function} {} subclass()\n\ @deftypefnx{Loadable Function} {} subclass(@var{swigclass}, @var{name}, @var{fcn}, @dots{})\n\ Subclass a C++ class from within Octave, and provide implementations of its virtual methods.\n\ \n\ See the SWIG manual for usage examples.\n\ @end deftypefn"; DEFUN_DLD( subclass, args, nargout, subclass_usage ) { octave_swig_type *top = new octave_swig_type; for (int j = 0; j < args.length(); ++j) { if (args(j).type_id() == octave_swig_ref::static_type_id()) { octave_swig_ref *osr = static_cast < octave_swig_ref *>(args(j).internal_rep()); octave_swig_type *ost = osr->get_ptr(); if (!ost->is_owned()) { error("subclass: cannot subclass object not constructed on octave side"); return octave_value_list(); } top->merge(*ost); } else if (args(j).is_function_handle()) { top->assign(args(j).fcn_handle_value()->fcn_name(), args(j)); } else if (args(j).is_string()) { if (j + 1 >= args.length()) { error("subclass: member assignments must be of string,value form"); return octave_value_list(); } top->assign(args(j).string_value(), args(j + 1)); ++j; } else { error("subclass: invalid arguments to subclass()"); return octave_value_list(); } } return octave_value(Swig::swig_value_ref(top)); } static const char *const swig_type_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Function} {} swig_type(@var{swigref})\n\ Return the underlying C/C++ type name of a SWIG-wrapped object.\n\ @end deftypefn"; DEFUN_DLD( swig_type, args, nargout, swig_type_usage ) { if (args.length() != 1) { error("swig_type: must be called with only a single object"); return octave_value_list(); } octave_swig_type *ost = Swig::swig_value_deref(args(0)); if (!ost) { error("swig_type: object is not a swig_ref"); return octave_value_list(); } return octave_value(ost->swig_type_name()); } static const char *const swig_typequery_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Function} {} swig_typequery(@var{string})\n\ Return @var{string} if it is a recognised SWIG-wrapped C/C++ type name;\n\ otherwise return `'.\n\ @end deftypefn"; DEFUN_DLD( swig_typequery, args, nargout, swig_typequery_usage ) { if (args.length() != 1 || !args(0).is_string()) { error("swig_typequery: must be called with single string argument"); return octave_value_list(); } swig_module_info *module = SWIG_GetModule(0); swig_type_info *type = SWIG_TypeQueryModule(module, module, args(0).string_value().c_str()); if (!type) return octave_value(""); return octave_value(type->name); } static const char *const swig_this_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Function} {} swig_this(@var{swigref})\n\ Return the underlying C/C++ pointer of a SWIG-wrapped object.\n\ @end deftypefn"; DEFUN_DLD( swig_this, args, nargout, swig_this_usage ) { if (args.length() != 1) { error("swig_this: must be called with only a single object"); return octave_value_list(); } if (args(0).is_matrix_type() && args(0).rows() == 0 && args(0).columns() == 0) return octave_value(octave_uint64(0)); octave_swig_type *ost = Swig::swig_value_deref(args(0)); if (!ost) { error("swig_this: object is not a swig_ref"); return octave_value_list(); } return octave_value(octave_uint64((unsigned long long) ost->swig_this())); } static const char *const SWIG_name_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Module} {} " SWIG_name_d "\n\ Loads the SWIG-generated module `" SWIG_name_d "'.\n\ @end deftypefn"; DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { static octave_swig_type* module_ns = 0; // workaround to prevent octave seg-faulting on exit: set Octave exit function // octave_exit to _Exit, which exits immediately without trying to cleanup memory. // definitely affects version 3.2.*, not sure about 3.3.*, seems to be fixed in // version 3.4.* and above. can be turned off with macro definition. #ifndef SWIG_OCTAVE_NO_SEGFAULT_HACK #if SWIG_OCTAVE_PREREQ(3,2,0) && !SWIG_OCTAVE_PREREQ(3,4,1) octave_exit = ::_Exit; #endif #endif // check for no input and output args if (args.length() != 0 || nargout != 0) { print_usage(); return octave_value_list(); } // create module on first function call if (!module_ns) { // workaround bug in octave where installing global variable of custom type and then // exiting without explicitly clearing the variable causes octave to segfault. #if SWIG_OCTAVE_PREREQ(3,2,0) octave_value_list eval_args; eval_args.append("base"); eval_args.append("function __swig_atexit__; " " if mislocked() " " clear -all; " " else " " mlock(); " " endif; " "endfunction; " "__swig_atexit__; " "atexit(\"__swig_atexit__\", false); " "atexit(\"__swig_atexit__\")"); feval("evalin", eval_args, 0); #endif octave_swig_ref::register_type(); octave_swig_packed::register_type(); SWIG_InitializeModule(0); SWIG_PropagateClientData(); octave_function *me = octave_call_stack::current(); if (!SWIG_Octave_InstallFunction(me, "swig_type")) { return octave_value_list(); } if (!SWIG_Octave_InstallFunction(me, "swig_typequery")) { return octave_value_list(); } if (!SWIG_Octave_InstallFunction(me, "swig_this")) { return octave_value_list(); } if (!SWIG_Octave_InstallFunction(me, "subclass")) { return octave_value_list(); } octave_swig_type* cvar_ns=0; if (std::string(SWIG_global_name) != ".") { cvar_ns=new octave_swig_type; for (int j=0;swig_globals[j].name;++j) if (swig_globals[j].get_method) cvar_ns->assign(swig_globals[j].name,&swig_globals[j]); } module_ns=new octave_swig_type(0, 0, 0, true); if (std::string(SWIG_global_name) != ".") { module_ns->assign(SWIG_global_name,Swig::swig_value_ref(cvar_ns)); } else { for (int j=0;swig_globals[j].name;++j) if (swig_globals[j].get_method) module_ns->assign(swig_globals[j].name,&swig_globals[j]); } for (int j=0;swig_globals[j].name;++j) if (swig_globals[j].method) module_ns->assign(swig_globals[j].name,&swig_globals[j]); // * need better solution here; swig_type -> octave_class mapping is // * really n-to-1, in some cases such as template partial spec, etc. // * see failing tests. for (int j=0;swig_types[j];++j) if (swig_types[j]->clientdata) { swig_octave_class* c=(swig_octave_class*)swig_types[j]->clientdata; module_ns->assign(c->name, Swig::swig_value_ref (new octave_swig_type(0,swig_types[j]))); } if (!SWIG_init_user(module_ns)) { delete module_ns; module_ns=0; return octave_value_list(); } SWIG_InstallOps(octave_swig_ref::static_type_id()); octave_swig_type::swig_member_const_iterator mb; for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) { if (mb->second.first && mb->second.first->method) { if (!SWIG_Octave_InstallFunction(me, mb->first)) { return octave_value_list(); } } } #if !SWIG_OCTAVE_PREREQ(3,2,0) mlock(me->name()); #else mlock(); #endif } octave_swig_type::swig_member_const_iterator mb; for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) { if (mb->second.second.is_defined()) { SWIG_Octave_SetGlobalValue(mb->first, mb->second.second); SWIG_Octave_LinkGlobalValue(mb->first); } } SWIG_Octave_SetGlobalValue(SWIG_name_d, module_ns->as_value()); SWIG_Octave_LinkGlobalValue(SWIG_name_d); return octave_value_list(); } %} swig-3.0.8/Lib/octave/attribute.i0000664000175000017500000000004212641054563016521 0ustar williamwilliam%include swig-3.0.8/Lib/octave/octcomplex.swg0000664000175000017500000000450012641054563017246 0ustar williamwilliam/* Defines the As/From conversors for double/float complex, you need to provide complex Type, the Name you want to use in the conversors, the complex Constructor method, and the Real and Imag complex accesor methods. See the std_complex.i and ccomplex.i for concrete examples. */ /* the common from conversor */ %define %swig_fromcplx_conv(Type, OctConstructor, Real, Imag) %fragment(SWIG_From_frag(Type),"header") { SWIGINTERNINLINE octave_value SWIG_From(Type)(const Type& c) { return octave_value(OctConstructor(Real(c), Imag(c))); } } %enddef // the double case %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal(Type) (const octave_value& ov, Type* val) { if (ov.is_complex_scalar()) { if (val) { Complex c(ov.complex_value()); *val=Constructor(c.real(),c.imag()); } return SWIG_OK; } else { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(ov, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Complex, Real, Imag); %enddef // the float case %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int SWIG_AsVal(Type) (const octave_value& ov, Type* val) { if (ov.is_complex_scalar()) { if (val) { Complex c(ov.complex_value()); double re = c.real(); double im = c.imag(); if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else return SWIG_OverflowError; } } else { float d; int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, FloatComplex, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.8/Lib/octave/std_string.i0000664000175000017500000000004312641054563016677 0ustar williamwilliam%include swig-3.0.8/Lib/octave/stl.i0000664000175000017500000000026512641054563015327 0ustar williamwilliam/* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-3.0.8/Lib/octave/boost_shared_ptr.i0000664000175000017500000003703212641054563020070 0ustar williamwilliam%include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(out) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(varout) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE * { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE & { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; if (!argp) { %variable_nullref("$type", "$name"); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = *%const_cast(tempshared.get(), $1_ltype); } else { $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer by reference // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); temp = %const_cast(tempshared.get(), $*1_ltype); } else { temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); } $1 = &temp; } %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} %typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { int newmem = 0; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varout typemap not implemented" %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); if ($owner) delete $1; } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varout typemap not implemented" %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); temp = &tempshared; $1 = &temp; } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varout typemap not implemented" %} // Typecheck typemaps // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); $1 = SWIG_CheckState(res); } // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/octave/director.swg0000664000175000017500000000573412641054563016716 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Octave proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) #include namespace Swig { class Director { octave_swig_type *self; bool swig_disowned; Director(const Director &x); Director &operator=(const Director &rhs); public: Director(void *vptr):self(0), swig_disowned(false) { set_rtdir(vptr, this); } ~Director() { swig_director_destroyed(self, this); if (swig_disowned) self->decref(); } void swig_set_self(octave_swig_type *new_self) { assert(!swig_disowned); self = new_self; } octave_swig_type *swig_get_self() const { return self; } void swig_disown() { if (swig_disowned) return; swig_disowned = true; self->incref(); } }; struct DirectorTypeMismatchException { static void raise(const char *msg) { // ... todo throw(DirectorTypeMismatchException()); } static void raise(const octave_value &ov, const char *msg) { // ... todo raise(msg); } }; struct DirectorPureVirtualException { static void raise(const char *msg) { // ... todo throw(DirectorPureVirtualException()); } static void raise(const octave_value &ov, const char *msg) { // ... todo raise(msg); } }; SWIGINTERN rtdir_map *get_rtdir_map() { static swig_module_info *module = 0; if (!module) module = SWIG_GetModule(0); if (!module) return 0; if (!module->clientdata) module->clientdata = new rtdir_map; return (rtdir_map *) module->clientdata; } SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) { rtdir_map *rm = get_rtdir_map(); if (rm) (*rm)[vptr] = d; } SWIGINTERNINLINE void erase_rtdir(void *vptr) { rtdir_map *rm = get_rtdir_map(); if (rm) (*rm).erase(vptr); } SWIGINTERNINLINE Director *get_rtdir(void *vptr) { rtdir_map *rm = get_rtdir_map(); if (!rm) return 0; rtdir_map::const_iterator pos = rm->find(vptr); Director *rtdir = (pos != rm->end())? pos->second : 0; return rtdir; } SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d) { self->director_destroyed(d); } SWIGRUNTIME octave_swig_type *swig_director_get_self(Director *d) { return d->swig_get_self(); } SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self) { d->swig_set_self(self); } } SWIGRUNTIME void swig_acquire_ownership(void *vptr) { // assert(0); // ... todo } SWIGRUNTIME void swig_acquire_ownership_array(void *vptr) { // assert(0); // ... todo } SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own) { // assert(0); // ... todo } swig-3.0.8/Lib/octave/octcontainer.swg0000664000175000017500000003767512641054563017604 0ustar williamwilliam/* ----------------------------------------------------------------------------- * octcontainer.swg * * Octave cell <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of * the mapping between C++ and Octave, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should * be the case. * ----------------------------------------------------------------------------- */ %{ #include #include %} #if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) # if !defined(SWIG_EXPORT_ITERATOR_METHODS) # define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS # endif #endif %include // The Octave C++ Wrap %fragment(""); %include %fragment(SWIG_Traits_frag(octave_value),"header",fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "octave_value"; } }; template <> struct traits_from { typedef octave_value value_type; static octave_value from(const value_type& val) { return val; } }; template <> struct traits_check { static bool check(const octave_value&) { return true; } }; template <> struct traits_asval { typedef octave_value value_type; static int asval(const octave_value& obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; } } %fragment("OctSequence_Base","header",fragment="") { %#include namespace std { template <> struct less : public binary_function { bool operator()(const octave_value& v, const octave_value& w) const { octave_value res = do_binary_op(octave_value::op_le,v,w); return res.is_true(); } }; } namespace swig { inline size_t check_index(ptrdiff_t i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); } else if ( (size_t) i < size ) { return (size_t) i; } else if (insert && ((size_t) i == size)) { return size; } throw std::out_of_range("index out of range"); } inline size_t slice_index(ptrdiff_t i, size_t size) { if ( i < 0 ) { if ((size_t) (-i) <= size) { return (size_t) (i + size); } else { throw std::out_of_range("index out of range"); } } else { return ( (size_t) i < size ) ? ((size_t) i) : size; } } template inline typename Sequence::iterator getpos(Sequence* self, Difference i) { typename Sequence::iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline typename Sequence::const_iterator cgetpos(const Sequence* self, Difference i) { typename Sequence::const_iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::const_iterator vb = self->begin(); typename Sequence::const_iterator ve = self->begin(); std::advance(vb,ii); std::advance(ve,jj); return new Sequence(vb, ve); } else { return new Sequence(); } } template inline void setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj < ii) jj = ii; size_t ssize = jj - ii; if (ssize <= v.size()) { typename Sequence::iterator sb = self->begin(); typename InputSeq::const_iterator vmid = v.begin(); std::advance(sb,ii); std::advance(vmid, jj - ii); self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); } else { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); self->insert(sb, v.begin(), v.end()); } } template inline void delslice(Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); } } } } %fragment("OctSequence_Cont","header", fragment="StdTraits", fragment="OctSequence_Base", fragment="OctSwigIterator_T") { namespace swig { template struct OctSequence_Ref // * octave can't support these, because of how assignment works { OctSequence_Ref(const octave_value& seq, int index) : _seq(seq), _index(index) { } operator T () const { // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, _index); octave_value item; // * todo try { return swig::as(item, true); } catch (std::exception& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", _index); if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } SWIG_Octave_AddErrorMsg(msg); SWIG_Octave_AddErrorMsg(e.what()); throw; } } OctSequence_Ref& operator=(const T& v) { // OctSequence_SetItem(_seq, _index, swig::from(v)); // * todo return *this; } private: octave_value _seq; int _index; }; template struct OctSequence_ArrowProxy { OctSequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; template struct OctSequence_InputIterator { typedef OctSequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; typedef T value_type; typedef T* pointer; typedef int difference_type; OctSequence_InputIterator() { } OctSequence_InputIterator(const octave_value& seq, int index) : _seq(seq), _index(index) { } reference operator*() const { return reference(_seq, _index); } OctSequence_ArrowProxy operator->() const { return OctSequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const { return (_index == ri._index); } bool operator!=(const self& ri) const { return !(operator==(ri)); } self& operator ++ () { ++_index; return *this; } self& operator -- () { --_index; return *this; } self& operator += (difference_type n) { _index += n; return *this; } self operator +(difference_type n) const { return self(_seq, _index + n); } self& operator -= (difference_type n) { _index -= n; return *this; } self operator -(difference_type n) const { return self(_seq, _index - n); } difference_type operator - (const self& ri) const { return _index - ri._index; } bool operator < (const self& ri) const { return _index < ri._index; } reference operator[](difference_type n) const { return reference(_seq, _index + n); } private: octave_value _seq; difference_type _index; }; template struct OctSequence_Cont { typedef OctSequence_Ref reference; typedef const OctSequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef int difference_type; typedef int size_type; typedef const pointer const_pointer; typedef OctSequence_InputIterator iterator; typedef OctSequence_InputIterator const_iterator; OctSequence_Cont(const octave_value& seq) : _seq(seq) { // * assert that we have map type etc. /* if (!OctSequence_Check(seq)) { throw std::invalid_argument("a sequence is expected"); } _seq = seq; Py_INCREF(_seq); */ } ~OctSequence_Cont() { } size_type size() const { // return static_cast(OctSequence_Size(_seq)); return 0; // * todo } bool empty() const { return size() == 0; } iterator begin() { return iterator(_seq, 0); } const_iterator begin() const { return const_iterator(_seq, 0); } iterator end() { return iterator(_seq, size()); } const_iterator end() const { return const_iterator(_seq, size()); } reference operator[](difference_type n) { return reference(_seq, n); } const_reference operator[](difference_type n) const { return const_reference(_seq, n); } bool check(bool set_err = true) const { int s = size(); for (int i = 0; i < s; ++i) { // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, i); octave_value item; // * todo if (!swig::check(item)) { if (set_err) { char msg[1024]; sprintf(msg, "in sequence element %d", i); SWIG_Error(SWIG_RuntimeError, msg); } return false; } } return true; } private: octave_value _seq; }; } } %define %swig_sequence_iterator(Sequence...) #if defined(SWIG_EXPORT_ITERATOR_METHODS) class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; %typemap(out,noblock=1,fragment="OctSequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), swig::OctSwigIterator::descriptor(),SWIG_POINTER_OWN); } %typemap(out,fragment="OctSequence_Cont") std::pair, std::pair { octave_value_list tmpc; tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), swig::OctSwigIterator::descriptor(),SWIG_POINTER_OWN)); tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second), swig::OctSwigIterator::descriptor(),SWIG_POINTER_OWN)); $result = Cell(tmpc); } %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="OctSequence_Cont") {} %typemap(out,fragment="OctPairBoolOutputIterator") std::pair, std::pair { octave_value_list tmpc; tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), swig::OctSwigIterator::descriptor(),SWIG_POINTER_OWN)); tmpc.append(SWIG_From(bool)(%static_cast($1,const $type &).second)); $result = Cell(tmpc); } %typemap(in,noblock=1,fragment="OctSequence_Cont") iterator(swig::OctSwigIterator *iter = 0, int res), reverse_iterator(swig::OctSwigIterator *iter = 0, int res), const_iterator(swig::OctSwigIterator *iter = 0, int res), const_reverse_iterator(swig::OctSwigIterator *iter = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::OctSwigIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::OctSwigIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="OctSequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { swig::OctSwigIterator *iter = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::OctSwigIterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %fragment("OctSequence_Cont"); #endif //SWIG_EXPORT_ITERATOR_METHODS %enddef // The octave container methods %define %swig_container_methods(Container...) %enddef %define %swig_sequence_methods_common(Sequence...) %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) %fragment("OctSequence_Base"); %extend { value_type pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty container"); Sequence::value_type x = self->back(); self->pop_back(); return x; } value_type __paren__(difference_type i) throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __paren_asgn__(difference_type i, value_type x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } void append(value_type x) { self->push_back(x); } } %enddef %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %enddef // // Common fragments // %fragment("StdSequenceTraits","header", fragment="StdTraits", fragment="OctSequence_Cont") { namespace swig { template inline void assign(const OctSeq& octseq, Seq* seq) { %#ifdef SWIG_STD_NOASSIGN_STL typedef typename OctSeq::value_type value_type; typename OctSeq::const_iterator it = octseq.begin(); for (;it != octseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } %#else seq->assign(octseq.begin(), octseq.end()); %#endif } template struct traits_asptr_stdseq { typedef Seq sequence; typedef T value_type; static int asptr(const octave_value& obj, sequence **seq) { if (!obj.is_defined() || Swig::swig_value_deref(obj)) { sequence *p; if (SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } else if (obj.is_cell()) { try { OctSequence_Cont octseq(obj); if (seq) { sequence *pseq = new sequence(); assign(octseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { return octseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq&&!error_state) error("swig type error: %s",e.what()); return SWIG_ERROR; } } return SWIG_ERROR; } }; template struct traits_from_stdseq { typedef Seq sequence; typedef T value_type; typedef typename Seq::size_type size_type; typedef typename sequence::const_iterator const_iterator; static octave_value from(const sequence& seq) { #ifdef SWIG_OCTAVE_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } #endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { Cell c(size,1); int i = 0; for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { c(i) = swig::from(*it); } return c; } else { error("swig overflow error: sequence size not valid in octave"); return octave_value(); } return octave_value(); } }; } } swig-3.0.8/Lib/octave/std_shared_ptr.i0000664000175000017500000000010412641054563017522 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.8/Lib/octave/typemaps.i0000664000175000017500000000004112641054563016357 0ustar williamwilliam%include swig-3.0.8/Lib/octave/std_vector.i0000664000175000017500000000127412641054563016702 0ustar williamwilliam// Vectors %fragment("StdVectorTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(const octave_value& obj, std::vector **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static octave_value from(const std::vector& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/octave/octopers.swg0000664000175000017500000000515712641054563016740 0ustar williamwilliam/* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus // operators supported in Octave, and the methods they are routed to // __brace__ a{args} // __brace_asgn__ a{args} = rhs // __paren__ a(args) // __paren_asgn__ a(args) = rhs // __str__ generates string rep // __not__ !a // __uplus__ +a // __uminus__ -a // __transpose__ a.' // __hermitian__ a' // __incr__ a++ // __decr__ a-- // __add__ a + b // __sub__ a - b // __mul__ a * b // __div__ a / b // __pow__ a ^ b // __ldiv__ a \ b // __lshift__ a << b // __rshift__ a >> b // __lt__ a < b // __le__ a <= b // __eq__ a == b // __ge__ a >= b // __gt__ a > b // __ne__ a != b // __el_mul__ a .* b // __el_div__ a ./ b // __el_pow__ a .^ b // __el_ldiv__ a .\ b // __el_and__ a & b // __el_or__ a | b // operators supported in C++, and the methods that route to them %rename(__add__) *::operator+; %rename(__add__) *::operator+(); %rename(__add__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__uminus__) *::operator-(); %rename(__uminus__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__el_and__) *::operator&&; %rename(__el_or__) *::operator||; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__lt__) *::operator<; %rename(__le__) *::operator<=; %rename(__gt__) *::operator>; %rename(__ge__) *::operator>=; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__not__) *::operator!; %rename(__incr__) *::operator++; %rename(__decr__) *::operator--; %rename(__paren__) *::operator(); %rename(__brace__) *::operator[]; // Ignored inplace operators %ignoreoperator(PLUSEQ) operator+=; %ignoreoperator(MINUSEQ) operator-=; %ignoreoperator(MULEQ) operator*=; %ignoreoperator(DIVEQ) operator/=; %ignoreoperator(MODEQ) operator%=; %ignoreoperator(LSHIFTEQ) operator<<=; %ignoreoperator(RSHIFTEQ) operator>>=; %ignoreoperator(ANDEQ) operator&=; %ignoreoperator(OREQ) operator|=; %ignoreoperator(XOREQ) operator^=; // Ignored operators %ignoreoperator(EQ) operator=; %ignoreoperator(ARROWSTAR) operator->*; #endif /* __cplusplus */ swig-3.0.8/Lib/octave/octave.swg0000664000175000017500000000033612641054563016355 0ustar williamwilliam%include %include %include %include %include %include %define %docstring %feature("docstring") %enddef swig-3.0.8/Lib/octave/std_carray.i0000664000175000017500000000000012641054563016643 0ustar williamwilliamswig-3.0.8/Lib/octave/octstdcommon.swg0000664000175000017500000001405212641054563017605 0ustar williamwilliam%fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { // Traits that provides the from method template struct traits_from_ptr { static octave_value from(Type *val, int owner = 0) { return SWIG_NewPointerObj(val, type_info(), owner); } }; template struct traits_from { static octave_value from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static octave_value from(Type* val) { return traits_from_ptr::from(val, 0); } }; template struct traits_from { static octave_value from(const Type* val) { return traits_from_ptr::from(const_cast(val), 0); } }; template inline octave_value from(const Type& val) { return traits_from::from(val); } template inline octave_value from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } // Traits that provides the asval/as/check method template struct traits_asptr { static int asptr(const octave_value& obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(const octave_value& obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(const octave_value& obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(const octave_value& obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(const octave_value& obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(const octave_value& obj, bool throw_error) { Type v; int res = asval(obj, &v); if (!obj.is_defined() || !SWIG_IsOK(res)) { if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); } return v; } }; template struct traits_as { static Type as(const octave_value& obj, bool throw_error) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(const octave_value& obj, bool throw_error) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res)) { return v; } else { if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); return 0; } } }; template inline Type as(const octave_value& obj, bool te = false) { return traits_as::category>::as(obj, te); } template struct traits_check { static bool check(const octave_value& obj) { int res = asval(obj, (Type *)(0)); return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(const octave_value& obj) { int res = asptr(obj, (Type **)(0)); return SWIG_IsOK(res) ? true : false; } }; template inline bool check(const octave_value& obj) { return traits_check::category>::check(obj); } } } %define %specialize_std_container(Type,Check,As,From) %{ namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(const octave_value& obj, value_type *val) { if (Check(obj)) { if (val) *val = As(obj); return SWIG_OK; } return SWIG_ERROR; } }; template <> struct traits_from { typedef Type value_type; static octave_value from(const value_type& val) { return From(val); } }; template <> struct traits_check { static int check(const octave_value& obj) { int res = Check(obj); return obj && res ? res : 0; } }; } %} %enddef #define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) swig-3.0.8/Lib/octave/cmalloc.i0000664000175000017500000000004012641054563016126 0ustar williamwilliam%include swig-3.0.8/Lib/octave/implicit.i0000664000175000017500000000043712641054563016340 0ustar williamwilliam%include %include #warning "This file provides the %implicit directive, which is an old and fragile" #warning "way to implement the C++ implicit conversion mechanism." #warning "Try using the more robust '%implicitconv Type;' directive instead." swig-3.0.8/Lib/octave/std_complex.i0000664000175000017500000000072612641054563017050 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.8/Lib/octave/octfragments.swg0000664000175000017500000000000112641054563017555 0ustar williamwilliam swig-3.0.8/Lib/octave/octuserdir.swg0000664000175000017500000000342612641054563017262 0ustar williamwilliam/* ------------------------------------------------------------------------- * Special user directives * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ /* Implicit Conversion using the C++ constructor mechanism */ #define %implicitconv %feature("implicitconv") #define %noimplicitconv %feature("implicitconv", "0") #define %clearimplicitconv %feature("implicitconv", "") /* ------------------------------------------------------------------------- */ /* %extend_smart_pointer extend the smart pointer support. For example, if you have a smart pointer as: template class RCPtr { public: ... RCPtr(Type *p); Type * operator->() const; ... }; you use the %extend_smart_pointer directive as: %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; then, if you have something like: RCPtr make_ptr(); int foo(A *); you can do the following: a = make_ptr(); b = foo(a); ie, swig will accept a RCPtr object where a 'A *' is expected. Also, when using vectors %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; %template(vector_A) std::vector >; you can type a = A(); v = vector_A(2) v[0] = a ie, an 'A *' object is accepted, via implicit conversion, where a RCPtr object is expected. Additionally x = v[0] returns (and sets 'x' as) a copy of v[0], making reference counting possible and consistent. */ %define %extend_smart_pointer(Type...) %implicitconv Type; %apply const SWIGTYPE& SMARTPOINTER { const Type& }; %apply SWIGTYPE SMARTPOINTER { Type }; %enddef swig-3.0.8/Lib/attribute.i0000664000175000017500000000076012641054563015247 0ustar williamwilliam/* ----------------------------------------------------------------------------- * attribute.i * * SWIG library file for implementing attributes. * ----------------------------------------------------------------------------- */ /* we use a simple exception warning here */ %{ #include %} #define %attribute_exception(code,msg) printf("%s\n",msg) #ifndef %arg #define %arg(x...) x #endif #ifndef %mangle #define %mangle(Type...) #@Type #endif %include swig-3.0.8/Lib/constraints.i0000664000175000017500000001560712641054563015621 0ustar williamwilliam/* ----------------------------------------------------------------------------- * constraints.i * * SWIG constraints library. * * SWIG library file containing typemaps for implementing various kinds of * constraints. Depends upon the SWIG exception library for generating * errors in a language-independent manner. * ----------------------------------------------------------------------------- */ #ifdef AUTODOC %text %{ %include This library provides support for applying constraints to function arguments. Using a constraint, you can restrict arguments to be positive numbers, non-NULL pointers, and so on. The following constraints are available : Number POSITIVE - Positive number (not zero) Number NEGATIVE - Negative number (not zero) Number NONZERO - Nonzero number Number NONNEGATIVE - Positive number (including zero) Number NONPOSITIVE - Negative number (including zero) Pointer NONNULL - Non-NULL pointer Pointer ALIGN8 - 8-byte aligned pointer Pointer ALIGN4 - 4-byte aligned pointer Pointer ALIGN2 - 2-byte aligned pointer To use the constraints, you need to "apply" them to specific function arguments in your code. This is done using the %apply directive. For example : %apply Number NONNEGATIVE { double nonneg }; double sqrt(double nonneg); // Name of argument must match %apply Pointer NONNULL { void *ptr }; void *malloc(int POSITIVE); // May return a NULL pointer void free(void *ptr); // May not accept a NULL pointer Any function argument of the type you specify with the %apply directive will be checked with the appropriate constraint. Multiple types may be specified as follows : %apply Pointer NONNULL { void *, Vector *, List *, double *}; In this case, all of the types listed would be checked for non-NULL pointers. The common datatypes of int, short, long, unsigned int, unsigned long, unsigned short, unsigned char, signed char, float, and double can be checked without using the %apply directive by simply using the constraint name as the parameter name. For example : double sqrt(double NONNEGATIVE); double log(double POSITIVE); If you have used typedef to change type-names, you can also do this : %apply double { Real }; // Make everything defined for doubles // work for Reals. Real sqrt(Real NONNEGATIVE); Real log(Real POSITIVE); %} #endif %include #ifdef SWIGCSHARP // Required attribute for C# exception handling #define SWIGCSHARPCANTHROW , canthrow=1 #else #define SWIGCSHARPCANTHROW #endif // Positive numbers %typemap(check SWIGCSHARPCANTHROW) int POSITIVE, short POSITIVE, long POSITIVE, unsigned int POSITIVE, unsigned short POSITIVE, unsigned long POSITIVE, signed char POSITIVE, unsigned char POSITIVE, float POSITIVE, double POSITIVE, Number POSITIVE { if ($1 <= 0) { SWIG_exception(SWIG_ValueError,"Expected a positive value."); } } // Negative numbers %typemap(check SWIGCSHARPCANTHROW) int NEGATIVE, short NEGATIVE, long NEGATIVE, unsigned int NEGATIVE, unsigned short NEGATIVE, unsigned long NEGATIVE, signed char NEGATIVE, unsigned char NEGATIVE, float NEGATIVE, double NEGATIVE, Number NEGATIVE { if ($1 >= 0) { SWIG_exception(SWIG_ValueError,"Expected a negative value."); } } // Nonzero numbers %typemap(check SWIGCSHARPCANTHROW) int NONZERO, short NONZERO, long NONZERO, unsigned int NONZERO, unsigned short NONZERO, unsigned long NONZERO, signed char NONZERO, unsigned char NONZERO, float NONZERO, double NONZERO, Number NONZERO { if ($1 == 0) { SWIG_exception(SWIG_ValueError,"Expected a nonzero value."); } } // Nonnegative numbers %typemap(check SWIGCSHARPCANTHROW) int NONNEGATIVE, short NONNEGATIVE, long NONNEGATIVE, unsigned int NONNEGATIVE, unsigned short NONNEGATIVE, unsigned long NONNEGATIVE, signed char NONNEGATIVE, unsigned char NONNEGATIVE, float NONNEGATIVE, double NONNEGATIVE, Number NONNEGATIVE { if ($1 < 0) { SWIG_exception(SWIG_ValueError,"Expected a non-negative value."); } } // Nonpositive numbers %typemap(check SWIGCSHARPCANTHROW) int NONPOSITIVE, short NONPOSITIVE, long NONPOSITIVE, unsigned int NONPOSITIVE, unsigned short NONPOSITIVE, unsigned long NONPOSITIVE, signed char NONPOSITIVE, unsigned char NONPOSITIVE, float NONPOSITIVE, double NONPOSITIVE, Number NONPOSITIVE { if ($1 > 0) { SWIG_exception(SWIG_ValueError,"Expected a non-positive value."); } } // Non-NULL pointer %typemap(check SWIGCSHARPCANTHROW) void * NONNULL, Pointer NONNULL { if (!$1) { SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); } } // Aligned pointers %typemap(check SWIGCSHARPCANTHROW) void * ALIGN8, Pointer ALIGN8 { unsigned long long tmp; tmp = (unsigned long long) $1; if (tmp & 7) { SWIG_exception(SWIG_ValueError,"Pointer must be 8-byte aligned."); } } %typemap(check SWIGCSHARPCANTHROW) void * ALIGN4, Pointer ALIGN4 { unsigned long long tmp; tmp = (unsigned long long) $1; if (tmp & 3) { SWIG_exception(SWIG_ValueError,"Pointer must be 4-byte aligned."); } } %typemap(check SWIGCSHARPCANTHROW) void * ALIGN2, Pointer ALIGN2 { unsigned long long tmp; tmp = (unsigned long long) $1; if (tmp & 1) { SWIG_exception(SWIG_ValueError,"Pointer must be 2-byte aligned."); } } swig-3.0.8/Lib/swig.swg0000664000175000017500000006041012641054563014563 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swig.swg * * Common macro definitions for various SWIG directives. This file is always * included at the top of each input file. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * User Directives * ----------------------------------------------------------------------------- */ /* Deprecated SWIG-1.1 directives */ #define %disabledoc %warn "104:%disabledoc is deprecated" #define %enabledoc %warn "105:%enabledoc is deprecated" #define %doconly %warn "106:%doconly is deprecated" #define %style %warn "107:%style is deprecated" /##/ #define %localstyle %warn "108:%localstyle is deprecated" /##/ #define %title %warn "109:%title is deprecated" /##/ #define %section %warn "110:%section is deprecated" /##/ #define %subsection %warn "111:%subsection is deprecated" /##/ #define %subsubsection %warn "112:%subsubsection is deprecated" /##/ #define %new %warn "117:%new is deprecated. Use %newobject" #define %text %insert("null") /* Code insertion directives such as %wrapper %{ ... %} */ #define %begin %insert("begin") #define %runtime %insert("runtime") #define %header %insert("header") #define %wrapper %insert("wrapper") #define %init %insert("init") /* Class extension */ #define %addmethods %warn "113:%addmethods is now %extend" %extend /* %ignore directive */ #define %ignore %rename($ignore) #define %ignorewarn(x) %rename("$ignore:" x) /* Access control directives */ #define %readonly %warn "114:%readonly is deprecated. Use %immutable; " %feature("immutable"); #define %readwrite %warn "115:%readwrite is deprecated. Use %mutable; " %feature("immutable",""); #define %immutable %feature("immutable") #define %noimmutable %feature("immutable","0") #define %clearimmutable %feature("immutable","") #define %mutable %clearimmutable /* Generation of default constructors/destructors (old form, don't use) */ #define %nodefault %feature("nodefault","1") #define %default %feature("nodefault","0") #define %clearnodefault %feature("nodefault","") #define %makedefault %clearnodefault /* Disable the generation of implicit default constructor */ #define %nodefaultctor %feature("nodefaultctor","1") #define %defaultctor %feature("nodefaultctor","0") #define %clearnodefaultctor %feature("nodefaultctor","") /* Disable the generation of implicit default destructor (dangerous) */ #define %nodefaultdtor %feature("nodefaultdtor","1") #define %defaultdtor %feature("nodefaultdtor","0") #define %clearnodefaultdtor %feature("nodefaultdtor","") /* Enable the generation of copy constructor */ #define %copyctor %feature("copyctor","1") #define %nocopyctor %feature("copyctor","0") #define %clearcopyctor %feature("copyctor","") /* Force the old nodefault behavior, ie disable both constructor and destructor */ #define %oldnodefault %feature("oldnodefault","1") #define %nooldnodefault %feature("oldnodefault","0") #define %clearoldnodefault %feature("oldnodefault","") /* the %exception directive */ #if defined(SWIGCSHARP) || defined(SWIGD) #define %exception %feature("except", canthrow=1) #else #define %exception %feature("except") #endif #define %noexception %feature("except","0") #define %clearexception %feature("except","") /* the %allowexception directive allows the %exception feature to be applied to set/get variable methods */ #define %allowexception %feature("allowexcept") #define %noallowexception %feature("allowexcept","0") #define %clearallowexception %feature("allowexcept","") /* the %exceptionvar directive, as %exception but it is only applied to set/get variable methods. You don't need to use the %allowexception directive when using %exceptionvar. */ #if defined(SWIGCSHARP) || defined(SWIGD) #define %exceptionvar %feature("exceptvar", canthrow=1) #else #define %exceptionvar %feature("exceptvar") #endif #define %noexceptionvar %feature("exceptvar","0") #define %clearexceptionvar %feature("exceptvar","") /* the %catches directive */ #define %catches(tlist...) %feature("catches","("`tlist`")") #define %clearcatches %feature("catches","") /* the %exceptionclass directive */ #define %exceptionclass %feature("exceptionclass") #define %noexceptionclass %feature("exceptionclass","0") #define %clearexceptionclass %feature("exceptionclass","") /* the %newobject directive */ #define %newobject %feature("new") #define %nonewobject %feature("new","0") #define %clearnewobject %feature("new","") /* the %delobject directive */ #define %delobject %feature("del") #define %nodelobject %feature("del","0") #define %cleardelobject %feature("del","") /* the %refobject/%unrefobject directives */ #define %refobject %feature("ref") #define %norefobject %feature("ref","0") #define %clearrefobject %feature("ref","") #define %unrefobject %feature("unref") #define %nounrefobject %feature("unref","0") #define %clearunrefobject %feature("unref","") /* Directives for callback functions (experimental) */ #define %callback(x) %feature("callback",`x`) #define %nocallback %feature("callback","0") #define %clearcallback %feature("callback","") /* the %nestedworkaround directive (deprecated) */ #define %nestedworkaround %feature("nestedworkaround") #define %nonestedworkaround %feature("nestedworkaround","0") #define %clearnestedworkaround %feature("nestedworkaround","") /* the %flatnested directive */ #define %flatnested %feature("flatnested") #define %noflatnested %feature("flatnested","0") #define %clearflatnested %feature("flatnested","") /* the %fastdispatch directive */ #define %fastdispatch %feature("fastdispatch") #define %nofastdispatch %feature("fastdispatch","0") #define %clearfastdispatch %feature("fastdispatch","") /* directors directives */ #define %director %feature("director") #define %nodirector %feature("director","0") #define %cleardirector %feature("director","") /* naturalvar directives */ #define %naturalvar %feature("naturalvar") #define %nonaturalvar %feature("naturalvar","0") #define %clearnaturalvar %feature("naturalvar","") /* nspace directives */ #define %nspace %feature("nspace") #define %nonspace %feature("nspace","0") #define %clearnspace %feature("nspace","") /* valuewrapper directives */ #define %valuewrapper %feature("valuewrapper") #define %clearvaluewrapper %feature("valuewrapper","") #define %novaluewrapper %feature("novaluewrapper") #define %clearnovaluewrapper %feature("novaluewrapper","") /* Contract support - Experimental and undocumented */ #define %contract %feature("contract") #define %nocontract %feature("contract","0") #define %clearcontract %feature("contract","") /* Macro for setting a dynamic cast function */ %define DYNAMIC_CAST(mangle,func) %init %{ mangle->dcast = (swig_dycast_func) func; %} %enddef /* aggregation support */ /* This macro performs constant aggregation. Basically the idea of constant aggregation is that you can group a collection of constants together. For example, suppose you have some code like this: #define UP 1 #define DOWN 2 #define LEFT 3 #define RIGHT 4 Now, suppose you had a function like this: int move(int direction) In this case, you might want to restrict the direction argument to one of the supplied constant names. To do this, you could write some typemap code by hand. Alternatively, you can use the %aggregate_check macro defined here to create a simple check function for you. Here is an example: %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT); Now, using a typemap %typemap(check) int direction { if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction."); } or a contract (better) %contract move(int x) { require: check_direction(x); } */ %define %aggregate_check(TYPE, NAME, FIRST, ...) %wrapper %{ static int NAME(TYPE x) { static TYPE values[] = { FIRST, ##__VA_ARGS__ }; static int size = sizeof(values); int i,j; for (i = 0, j = 0; i < size; i+=sizeof(TYPE),j++) { if (x == values[j]) return 1; } return 0; } %} %enddef /* ----------------------------------------------------------------------------- * %rename predicates * ----------------------------------------------------------------------------- */ /* Predicates to be used with %rename, for example: - to rename all the functions: %rename("%(utitle)s", %$isfunction) ""; - to rename only the member methods: %rename("m_%(utitle)s", %$isfunction, %$ismember) ""; - to rename only the global functions: %rename("m_%(utitle)s", %$isfunction, %$not %$ismember) ""; or %rename("g_%(utitle)s", %$isfunction, %$isglobal) ""; - to ignore the enumitems in a given class: %rename("$ignore", %$isenumitem, %$classname="MyClass") ""; we use the prefix '%$' to avoid clashes with other swig macros/directives. */ %define %$not "not" %enddef %define %$isenum "match"="enum" %enddef %define %$isenumitem "match"="enumitem" %enddef %define %$isaccess "match"="access" %enddef %define %$isclass "match"="class","notmatch$template$templatetype"="class" %enddef %define %$isextend "match"="extend" %enddef %define %$isconstructor "match"="constructor" %enddef %define %$isdestructor "match"="destructor" %enddef %define %$isnamespace "match"="namespace" %enddef %define %$istemplate "match"="template" %enddef %define %$isconstant "match"="constant" %enddef /* %constant definition */ %define %$isunion "match$kind"="union" %enddef %define %$isfunction "match$kind"="function" %enddef %define %$isvariable "match$kind"="variable" %enddef %define %$isimmutable "match$feature:immutable"="1" %enddef %define %$hasconsttype "match$hasconsttype"="1" %enddef %define %$hasvalue "match$hasvalue"="1" %enddef %define %$isextension "match$isextension"="1" %enddef %define %$isstatic "match$storage"="static" %enddef %define %$isfriend "match$storage"="friend" %enddef %define %$istypedef "match$storage"="typedef" %enddef %define %$isvirtual "match$storage"="virtual" %enddef %define %$isexplicit "match$storage"="explicit" %enddef %define %$isextern "match$storage"="extern" %enddef %define %$ismember "match$ismember"="1" %enddef %define %$isglobal %$not %$ismember %enddef %define %$isextendmember "match$isextendmember"="1" %enddef %define %$innamespace "match$parentNode$nodeType"="namespace" %enddef %define %$ispublic "match$access"="public" %enddef %define %$isprotected "match$access"="protected" %enddef %define %$isprivate "match$access"="private" %enddef %define %$ismemberget "match$memberget"="1" %enddef %define %$ismemberset "match$memberset"="1" %enddef %define %$classname %$ismember,"match$parentNode$name" %enddef %define %$isnested "match$nested"="1" %enddef /* ----------------------------------------------------------------------------- * Include all the warnings labels and macros * ----------------------------------------------------------------------------- */ %include /* ----------------------------------------------------------------------------- * Overloading support * ----------------------------------------------------------------------------- */ /* * Function/method overloading support. This is done through typemaps, * but also involves a precedence level. */ /* Macro for overload resolution */ %define %typecheck(_x...) %typemap(typecheck, precedence=_x) %enddef /* Macros for precedence levels */ %define SWIG_TYPECHECK_POINTER 0 %enddef %define SWIG_TYPECHECK_ITERATOR 5 %enddef %define SWIG_TYPECHECK_VOIDPTR 10 %enddef %define SWIG_TYPECHECK_BOOL 15 %enddef %define SWIG_TYPECHECK_UINT8 20 %enddef %define SWIG_TYPECHECK_INT8 25 %enddef %define SWIG_TYPECHECK_UINT16 30 %enddef %define SWIG_TYPECHECK_INT16 35 %enddef %define SWIG_TYPECHECK_UINT32 40 %enddef %define SWIG_TYPECHECK_INT32 45 %enddef %define SWIG_TYPECHECK_SIZE 47 %enddef %define SWIG_TYPECHECK_PTRDIFF 48 %enddef %define SWIG_TYPECHECK_UINT64 50 %enddef %define SWIG_TYPECHECK_INT64 55 %enddef %define SWIG_TYPECHECK_UINT128 60 %enddef %define SWIG_TYPECHECK_INT128 65 %enddef %define SWIG_TYPECHECK_INTEGER 70 %enddef %define SWIG_TYPECHECK_FLOAT 80 %enddef %define SWIG_TYPECHECK_DOUBLE 90 %enddef %define SWIG_TYPECHECK_CPLXFLT 95 %enddef %define SWIG_TYPECHECK_CPLXDBL 100 %enddef %define SWIG_TYPECHECK_COMPLEX 105 %enddef %define SWIG_TYPECHECK_UNICHAR 110 %enddef %define SWIG_TYPECHECK_STDUNISTRING 115 %enddef %define SWIG_TYPECHECK_UNISTRING 120 %enddef %define SWIG_TYPECHECK_CHAR 130 %enddef %define SWIG_TYPECHECK_STDSTRING 135 %enddef %define SWIG_TYPECHECK_STRING 140 %enddef %define SWIG_TYPECHECK_PAIR 150 %enddef %define SWIG_TYPECHECK_STDARRAY 155 %enddef %define SWIG_TYPECHECK_VECTOR 160 %enddef %define SWIG_TYPECHECK_DEQUE 170 %enddef %define SWIG_TYPECHECK_LIST 180 %enddef %define SWIG_TYPECHECK_SET 190 %enddef %define SWIG_TYPECHECK_MULTISET 200 %enddef %define SWIG_TYPECHECK_MAP 210 %enddef %define SWIG_TYPECHECK_MULTIMAP 220 %enddef %define SWIG_TYPECHECK_STACK 230 %enddef %define SWIG_TYPECHECK_QUEUE 240 %enddef %define SWIG_TYPECHECK_BOOL_ARRAY 1015 %enddef %define SWIG_TYPECHECK_INT8_ARRAY 1025 %enddef %define SWIG_TYPECHECK_INT16_ARRAY 1035 %enddef %define SWIG_TYPECHECK_INT32_ARRAY 1045 %enddef %define SWIG_TYPECHECK_INT64_ARRAY 1055 %enddef %define SWIG_TYPECHECK_INT128_ARRAY 1065 %enddef %define SWIG_TYPECHECK_FLOAT_ARRAY 1080 %enddef %define SWIG_TYPECHECK_DOUBLE_ARRAY 1090 %enddef %define SWIG_TYPECHECK_CHAR_ARRAY 1130 %enddef %define SWIG_TYPECHECK_STRING_ARRAY 1140 %enddef %define SWIG_TYPECHECK_OBJECT_ARRAY 1150 %enddef %define SWIG_TYPECHECK_BOOL_PTR 2015 %enddef %define SWIG_TYPECHECK_UINT8_PTR 2020 %enddef %define SWIG_TYPECHECK_INT8_PTR 2025 %enddef %define SWIG_TYPECHECK_UINT16_PTR 2030 %enddef %define SWIG_TYPECHECK_INT16_PTR 2035 %enddef %define SWIG_TYPECHECK_UINT32_PTR 2040 %enddef %define SWIG_TYPECHECK_INT32_PTR 2045 %enddef %define SWIG_TYPECHECK_UINT64_PTR 2050 %enddef %define SWIG_TYPECHECK_INT64_PTR 2055 %enddef %define SWIG_TYPECHECK_FLOAT_PTR 2080 %enddef %define SWIG_TYPECHECK_DOUBLE_PTR 2090 %enddef %define SWIG_TYPECHECK_CHAR_PTR 2130 %enddef %define SWIG_TYPECHECK_SWIGOBJECT 5000 %enddef /* ----------------------------------------------------------------------------- * Default handling of certain overloaded operators * ----------------------------------------------------------------------------- */ #ifdef __cplusplus %ignoreoperator(NEW) operator new; %ignoreoperator(DELETE) operator delete; %ignoreoperator(NEWARR) operator new[]; %ignoreoperator(DELARR) operator delete[]; /* add C++ operator aliases */ %rename("operator &&") operator and; // `and' `&&' %rename("operator ||") operator or; // `or' `||' %rename("operator !") operator not; // `not' `!' %rename("operator &=") operator and_eq; // `and_eq' `&=' %rename("operator &") operator bitand; // `bitand' `&' %rename("operator |") operator bitor; // `bitor' `|' %rename("operator ~") operator compl; // `compl' `~' %rename("operator !=") operator not_eq; // `not_eq' `!=' %rename("operator |=") operator or_eq; // `or_eq' `|=' %rename("operator ^") operator xor; // `xor' `^' %rename("operator ^=") operator xor_eq; // `xor_eq' `^=' /* Smart pointer handling */ %rename(__deref__) *::operator->; %rename(__ref__) *::operator*(); %rename(__ref__) *::operator*() const; /* Define std namespace */ namespace std { /* Warn about std::initializer_list usage. The constructor/method where used should probably be ignored. See docs. */ template class initializer_list {}; %typemap(in, warning=SWIGWARN_TYPEMAP_INITIALIZER_LIST_MSG) initializer_list "" %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) initializer_list "" } #endif /* ----------------------------------------------------------------------------- * Default char * and C array typemaps * ----------------------------------------------------------------------------- */ /* Set up the typemap for handling new return strings */ #ifdef __cplusplus %typemap(newfree) char * "delete [] $1;"; #else %typemap(newfree) char * "free($1);"; #endif /* Default typemap for handling char * members */ #ifdef __cplusplus %typemap(memberin) char * { delete [] $1; if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(globalin) char * { delete [] $1; if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } #else %typemap(memberin) char * { free($1); if ($input) { $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { if ($input) { $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(globalin) char * { free($1); if ($input) { $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } %typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { if ($input) { $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { $1 = 0; } } #endif /* Character array handling */ %typemap(memberin) char [ANY] { if($input) { strncpy((char*)$1, (const char *)$input, $1_dim0-1); $1[$1_dim0-1] = 0; } else { $1[0] = 0; } } %typemap(globalin) char [ANY] { if($input) { strncpy((char*)$1, (const char *)$input, $1_dim0-1); $1[$1_dim0-1] = 0; } else { $1[0] = 0; } } %typemap(memberin) char [] { if ($input) strcpy((char *)$1, (const char *)$input); else $1[0] = 0; } %typemap(globalin) char [] { if ($input) strcpy((char *)$1, (const char *)$input); else $1[0] = 0; } /* memberin/globalin typemap for arrays. */ %typemap(memberin) SWIGTYPE [ANY] { size_t ii; $1_basetype *b = ($1_basetype *) $1; for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii); } %typemap(globalin) SWIGTYPE [ANY] { size_t ii; $1_basetype *b = ($1_basetype *) $1; for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii); } /* memberin/globalin typemap for double arrays. */ %typemap(memberin) SWIGTYPE [ANY][ANY] { $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); size_t ii = 0; for (; ii < $1_dim0; ++ii) { $basetype *ip = inp[ii]; $basetype *dp = dest[ii]; size_t jj = 0; for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj]; } } %typemap(globalin) SWIGTYPE [ANY][ANY] { $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); size_t ii = 0; for (; ii < $1_dim0; ++ii) { $basetype *ip = inp[ii]; $basetype *dp = dest[ii]; size_t jj = 0; for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj]; } } /* ----------------------------------------------------------------------------- * Runtime code * ----------------------------------------------------------------------------- */ /* The SwigValueWrapper class */ /* * This template wrapper is used to handle C++ objects that are passed or * returned by value. This is necessary to handle objects that define * no default-constructor (making it difficult for SWIG to properly declare * local variables). * * The wrapper is used as follows. First consider a function like this: * * Vector cross_product(Vector a, Vector b) * * Now, if Vector is defined as a C++ class with no default constructor, * code is generated as follows: * * Vector *wrap_cross_product(Vector *inarg1, Vector *inarg2) { * SwigValueWrapper arg1; * SwigValueWrapper arg2; * SwigValueWrapper result; * * arg1 = *inarg1; * arg2 = *inarg2; * ... * result = cross_product(arg1,arg2); * ... * return new Vector(result); * } * * In the wrappers, the template SwigValueWrapper simply provides a thin * layer around a Vector *. However, it does this in a way that allows * the object to be bound after the variable declaration (which is not possible * with the bare object when it lacks a default constructor). * * An observant reader will notice that the code after the variable declarations * is *identical* to the code used for classes that do define default constructors. * Thus, this neat trick allows us to fix this special case without having to * make massive changes to typemaps and other parts of the SWIG code generator. * * Note: this code is not included when SWIG runs in C-mode, when classes * define default constructors, or when pointers and references are used. * SWIG tries to avoid doing this except in very special circumstances. * * Note: This solution suffers from making a large number of copies * of the underlying object. However, this is needed in the interest of * safety and in order to cover all of the possible ways in which a value * might be assigned. For example: * * arg1 = *inarg1; // Assignment from a pointer * arg1 = Vector(1,2,3); // Assignment from a value * * The class offers a strong guarantee of exception safety. * With regards to the implementation, the private SwigMovePointer nested class is * a simple smart pointer with move semantics, much like std::auto_ptr. * * This wrapping technique was suggested by William Fulton and is henceforth * known as the "Fulton Transform" :-). */ #ifdef __cplusplus %insert("runtime") %{ #ifdef __cplusplus /* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { struct SwigMovePointer { T *ptr; SwigMovePointer(T *p) : ptr(p) { } ~SwigMovePointer() { delete ptr; } SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } } pointer; SwigValueWrapper& operator=(const SwigValueWrapper& rhs); SwigValueWrapper(const SwigValueWrapper& rhs); public: SwigValueWrapper() : pointer(0) { } SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } operator T&() const { return *pointer.ptr; } T *operator&() { return pointer.ptr; } };%} /* * SwigValueInit() is a generic initialisation solution as the following approach: * * T c_result = T(); * * doesn't compile for all types for example: * * unsigned int c_result = unsigned int(); */ %insert("runtime") %{ template T SwigValueInit() { return T(); } #endif %} #endif /* The swiglabels */ %insert("runtime") "swiglabels.swg" swig-3.0.8/Lib/stl.i0000664000175000017500000000037112641054563014044 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ #warning "stl.i not implemented for this target" #define SWIG_STL_UNIMPL swig-3.0.8/Lib/windows.i0000664000175000017500000001005712641054563014736 0ustar williamwilliam/* ----------------------------------------------------------------------------- * windows.i * * SWIG library file to support types found in windows.h as well as Microsoft * integral type extensions. The types are set for 32 bit Windows. * ----------------------------------------------------------------------------- */ // Support for non ISO (Windows) integral types %apply unsigned char { unsigned __int8 }; %apply const unsigned char& { const unsigned __int8& }; %apply signed char { __int8 }; %apply const signed char& { const __int8& }; %apply unsigned short { unsigned __int16 }; %apply const unsigned short& { const unsigned __int16& }; %apply short { __int16 }; %apply const short& { const __int16& }; %apply unsigned int { unsigned __int32 }; %apply const unsigned int& { const unsigned __int32& }; %apply int { __int32 }; %apply const int& { const __int32& }; %apply unsigned long long { unsigned __int64 }; %apply const unsigned long long& { const unsigned __int64& }; %apply long long { __int64 }; %apply const long long& { const __int64& }; // Workaround Microsoft calling conventions #define __cdecl #define __fastcall #define __far #define __forceinline #define __fortran #define __inline #define __pascal #define __stdcall #define __syscall #define _cdecl #define _fastcall #define _inline #define _pascal #define _stdcall #define WINAPI #define __declspec(WINDOWS_EXTENDED_ATTRIBUTE) #define __w64 // Types from windef.h typedef unsigned long ULONG; typedef ULONG *PULONG; typedef unsigned short USHORT; typedef USHORT *PUSHORT; typedef unsigned char UCHAR; typedef UCHAR *PUCHAR; typedef char *PSZ; typedef unsigned long DWORD; typedef int BOOL; typedef unsigned char BYTE; typedef unsigned short WORD; typedef float FLOAT; typedef FLOAT *PFLOAT; typedef BOOL *PBOOL; typedef BOOL *LPBOOL; typedef BYTE *PBYTE; typedef BYTE *LPBYTE; typedef int *PINT; typedef int *LPINT; typedef WORD *PWORD; typedef WORD *LPWORD; typedef long *LPLONG; typedef DWORD *PDWORD; typedef DWORD *LPDWORD; typedef void *LPVOID; typedef const void *LPCVOID; typedef int INT; typedef unsigned int UINT; typedef unsigned int *PUINT; // Types from basetsd.h typedef signed char INT8, *PINT8; typedef signed short INT16, *PINT16; typedef signed int INT32, *PINT32; typedef signed __int64 INT64, *PINT64; typedef unsigned char UINT8, *PUINT8; typedef unsigned short UINT16, *PUINT16; typedef unsigned int UINT32, *PUINT32; typedef unsigned __int64 UINT64, *PUINT64; typedef signed int LONG32, *PLONG32; typedef unsigned int ULONG32, *PULONG32; typedef unsigned int DWORD32, *PDWORD32; typedef __w64 int INT_PTR, *PINT_PTR; typedef __w64 unsigned int UINT_PTR, *PUINT_PTR; typedef __w64 long LONG_PTR, *PLONG_PTR; typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; typedef unsigned short UHALF_PTR, *PUHALF_PTR; typedef short HALF_PTR, *PHALF_PTR; typedef __w64 long SHANDLE_PTR; typedef __w64 unsigned long HANDLE_PTR; typedef ULONG_PTR SIZE_T, *PSIZE_T; typedef LONG_PTR SSIZE_T, *PSSIZE_T; typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; typedef __int64 LONG64, *PLONG64; typedef unsigned __int64 ULONG64, *PULONG64; typedef unsigned __int64 DWORD64, *PDWORD64; // Types from winnt.h typedef void *PVOID; typedef void *PVOID64; typedef char CHAR; typedef short SHORT; typedef long LONG; typedef CHAR *PCHAR; typedef CHAR *LPCH, *PCH; typedef const CHAR *LPCCH, *PCCH; typedef CHAR *NPSTR; typedef CHAR *LPSTR, *PSTR; typedef const CHAR *LPCSTR, *PCSTR; typedef char TCHAR, *PTCHAR; typedef unsigned char TBYTE , *PTBYTE ; typedef LPSTR LPTCH, PTCH; typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR; typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR; typedef SHORT *PSHORT; typedef LONG *PLONG; typedef void *HANDLE; typedef HANDLE *PHANDLE; typedef BYTE FCHAR; typedef WORD FSHORT; typedef DWORD FLONG; typedef LONG HRESULT; typedef char CCHAR; typedef DWORD LCID; typedef PDWORD PLCID; typedef WORD LANGID; typedef __int64 LONGLONG; typedef unsigned __int64 ULONGLONG; typedef LONGLONG *PLONGLONG; typedef ULONGLONG *PULONGLONG; typedef ULONGLONG DWORDLONG; typedef DWORDLONG *PDWORDLONG; typedef BYTE BOOLEAN; typedef BOOLEAN *PBOOLEAN; swig-3.0.8/Lib/ruby/0000775000175000017500000000000012641054563014050 5ustar williamwilliamswig-3.0.8/Lib/ruby/rubyclasses.swg0000664000175000017500000002617012641054563017137 0ustar williamwilliam#ifdef __cplusplus /* GC_VALUE is used as a replacement of Ruby's VALUE. GC_VALUE automatically handles registering and unregistering of the underlying Ruby object with the GC. It can be used if you want to create STL containers of VALUEs, such as: std::vector< GC_VALUE >; or as a member variable: struct A { GC_VALUE _obj; A(VALUE o) : _obj(o) { } }; or as a input/output value (not much use for this, as VALUE works just as well here, thou): GC_VALUE func(GC_VALUE obj) { GC_VALUE out = rb_obj_classname(obj); return out; } GC_VALUE is 'visible' at the wrapped side, so you can do: %template(RubyVector) std::vector; and all the proper typemaps will be used. */ %fragment("GC_VALUE_definition","header") { namespace swig { class SwigGCReferences { VALUE _hash; SwigGCReferences() : _hash(Qnil) { } ~SwigGCReferences() { if (_hash != Qnil) rb_gc_unregister_address(&_hash); } static void EndProcHandler(VALUE) { // Ruby interpreter ending - _hash can no longer be accessed. SwigGCReferences &s_references = instance(); s_references._hash = Qnil; } public: static SwigGCReferences& instance() { // Hash of all GC_VALUE's currently in use static SwigGCReferences s_references; return s_references; } static void initialize() { SwigGCReferences &s_references = instance(); if (s_references._hash == Qnil) { rb_set_end_proc(&EndProcHandler, Qnil); s_references._hash = rb_hash_new(); rb_gc_register_address(&s_references._hash); } } void GC_register(VALUE& obj) { if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) return; if (_hash != Qnil) { VALUE val = rb_hash_aref(_hash, obj); unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0; ++n; rb_hash_aset(_hash, obj, INT2NUM(n)); } } void GC_unregister(const VALUE& obj) { if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) return; // this test should not be needed but I've noticed some very erratic // behavior of none being unregistered in some very rare situations. if (BUILTIN_TYPE(obj) == T_NONE) return; if (_hash != Qnil) { VALUE val = rb_hash_aref(_hash, obj); unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1; --n; if (n) rb_hash_aset(_hash, obj, INT2NUM(n)); else rb_hash_delete(_hash, obj); } } }; class GC_VALUE { protected: VALUE _obj; static ID hash_id; static ID lt_id; static ID gt_id; static ID eq_id; static ID le_id; static ID ge_id; static ID pos_id; static ID neg_id; static ID inv_id; static ID add_id; static ID sub_id; static ID mul_id; static ID div_id; static ID mod_id; static ID and_id; static ID or_id; static ID xor_id; static ID lshift_id; static ID rshift_id; struct OpArgs { VALUE src; ID id; int nargs; VALUE target; }; public: GC_VALUE() : _obj(Qnil) { } GC_VALUE(const GC_VALUE& item) : _obj(item._obj) { SwigGCReferences::instance().GC_register(_obj); } GC_VALUE(VALUE obj) :_obj(obj) { SwigGCReferences::instance().GC_register(_obj); } ~GC_VALUE() { SwigGCReferences::instance().GC_unregister(_obj); } GC_VALUE & operator=(const GC_VALUE& item) { SwigGCReferences::instance().GC_unregister(_obj); _obj = item._obj; SwigGCReferences::instance().GC_register(_obj); return *this; } operator VALUE() const { return _obj; } VALUE inspect() const { return rb_inspect(_obj); } VALUE to_s() const { return rb_inspect(_obj); } static VALUE swig_rescue_swallow(VALUE) { /* VALUE errstr = rb_obj_as_string(rb_errinfo()); printf("Swallowing error: '%s'\n", RSTRING_PTR(StringValue(errstr))); */ return Qnil; /* Swallow Ruby exception */ } static VALUE swig_rescue_funcall(VALUE p) { OpArgs* args = (OpArgs*) p; return rb_funcall(args->src, args->id, args->nargs, args->target); } bool relational_equal_op(const GC_VALUE& other, const ID& op_id, bool (*op_func)(const VALUE& a, const VALUE& b)) const { if (FIXNUM_P(_obj) && FIXNUM_P(other._obj)) { return op_func(_obj, other._obj); } bool res = false; VALUE ret = Qnil; SWIG_RUBY_THREAD_BEGIN_BLOCK; if (rb_respond_to(_obj, op_id)) { OpArgs args; args.src = _obj; args.id = op_id; args.nargs = 1; args.target = VALUE(other); ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); } if (ret == Qnil) { VALUE a = rb_funcall( _obj, hash_id, 0 ); VALUE b = rb_funcall( VALUE(other), hash_id, 0 ); res = op_func(a, b); } else { res = RTEST(ret); } SWIG_RUBY_THREAD_END_BLOCK; return res; } static bool operator_eq(const VALUE& a, const VALUE& b) { return a == b; } static bool operator_lt(const VALUE& a, const VALUE& b) { return a < b; } static bool operator_le(const VALUE& a, const VALUE& b) { return a <= b; } static bool operator_gt(const VALUE& a, const VALUE& b) { return a > b; } static bool operator_ge(const VALUE& a, const VALUE& b) { return a >= b; } bool operator==(const GC_VALUE& other) const { return relational_equal_op(other, eq_id, operator_eq); } bool operator<(const GC_VALUE& other) const { return relational_equal_op(other, lt_id, operator_lt); } bool operator<=(const GC_VALUE& other) const { return relational_equal_op(other, le_id, operator_le); } bool operator>(const GC_VALUE& other) const { return relational_equal_op(other, gt_id, operator_gt); } bool operator>=(const GC_VALUE& other) const { return relational_equal_op(other, ge_id, operator_ge); } bool operator!=(const GC_VALUE& other) const { return !(this->operator==(other)); } GC_VALUE unary_op(const ID& op_id) const { VALUE ret = Qnil; SWIG_RUBY_THREAD_BEGIN_BLOCK; OpArgs args; args.src = _obj; args.id = op_id; args.nargs = 0; args.target = Qnil; ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); SWIG_RUBY_THREAD_END_BLOCK; return ret; } GC_VALUE operator+() const { return unary_op(pos_id); } GC_VALUE operator-() const { return unary_op(neg_id); } GC_VALUE operator~() const { return unary_op(inv_id); } GC_VALUE binary_op(const GC_VALUE& other, const ID& op_id) const { VALUE ret = Qnil; SWIG_RUBY_THREAD_BEGIN_BLOCK; OpArgs args; args.src = _obj; args.id = op_id; args.nargs = 1; args.target = VALUE(other); ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); SWIG_RUBY_THREAD_END_BLOCK; return GC_VALUE(ret); } GC_VALUE operator+(const GC_VALUE& other) const { return binary_op(other, add_id); } GC_VALUE operator-(const GC_VALUE& other) const { return binary_op(other, sub_id); } GC_VALUE operator*(const GC_VALUE& other) const { return binary_op(other, mul_id); } GC_VALUE operator/(const GC_VALUE& other) const { return binary_op(other, div_id); } GC_VALUE operator%(const GC_VALUE& other) const { return binary_op(other, mod_id); } GC_VALUE operator&(const GC_VALUE& other) const { return binary_op(other, and_id); } GC_VALUE operator^(const GC_VALUE& other) const { return binary_op(other, xor_id); } GC_VALUE operator|(const GC_VALUE& other) const { return binary_op(other, or_id); } GC_VALUE operator<<(const GC_VALUE& other) const { return binary_op(other, lshift_id); } GC_VALUE operator>>(const GC_VALUE& other) const { return binary_op(other, rshift_id); } }; ID GC_VALUE::hash_id = rb_intern("hash"); ID GC_VALUE::lt_id = rb_intern("<"); ID GC_VALUE::gt_id = rb_intern(">"); ID GC_VALUE::eq_id = rb_intern("=="); ID GC_VALUE::le_id = rb_intern("<="); ID GC_VALUE::ge_id = rb_intern(">="); ID GC_VALUE::pos_id = rb_intern("+@"); ID GC_VALUE::neg_id = rb_intern("-@"); ID GC_VALUE::inv_id = rb_intern("~"); ID GC_VALUE::add_id = rb_intern("+"); ID GC_VALUE::sub_id = rb_intern("-"); ID GC_VALUE::mul_id = rb_intern("*"); ID GC_VALUE::div_id = rb_intern("/"); ID GC_VALUE::mod_id = rb_intern("%"); ID GC_VALUE::and_id = rb_intern("&"); ID GC_VALUE::or_id = rb_intern("|"); ID GC_VALUE::xor_id = rb_intern("^"); ID GC_VALUE::lshift_id = rb_intern("<<"); ID GC_VALUE::rshift_id = rb_intern(">>"); typedef GC_VALUE LANGUAGE_OBJ; } // namespace swig } // %fragment(GC_VALUE_definition) namespace swig { %apply VALUE {GC_VALUE}; // Make sure this is the last typecheck done %typecheck(999999,fragment="GC_VALUE_definition",noblock=1) GC_VALUE, GC_VALUE&, const GC_VALUE& { $1 = 1; }; /* For input */ %typemap(in,fragment="GC_VALUE_definition",noblock=1) GC_VALUE* (GC_VALUE r), GC_VALUE& (GC_VALUE r) { r = $input; $1 = &r; } /* For output */ %typemap(out,fragment="GC_VALUE_definition",noblock=1) GC_VALUE { $result = (VALUE)$1; } %typemap(out,fragment="GC_VALUE_definition",noblock=1) GC_VALUE*, GC_VALUE const & { $result = (VALUE)*$1; } %nodirector GC_VALUE; // We ignore the constructor so that user can never create a GC_VALUE // manually %ignore GC_VALUE::GC_VALUE; struct GC_VALUE { VALUE inspect() const; VALUE to_s() const; GC_VALUE(); protected: GC_VALUE(const GC_VALUE&); ~GC_VALUE(); }; %exception GC_VALUE {}; %ignore LANGUAGE_OBJ; typedef GC_VALUE LANGUAGE_OBJ; } %init { swig::SwigGCReferences::initialize(); } // // Fragment that contains traits to properly deal with GC_VALUE. // These functions may be invoked as a need of the from(), asval(), // asptr() and as() template functors, usually used in %typemaps. // %fragment(SWIG_Traits_frag(swig::GC_VALUE),"header",fragment="StdTraits",fragment="GC_VALUE_definition") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return "GC_VALUE"; } }; template <> struct traits_from { typedef GC_VALUE value_type; static VALUE from(const value_type& val) { return static_cast(val); } }; template <> struct traits_check { static bool check(GC_VALUE) { return true; } }; template <> struct traits_asval { typedef GC_VALUE value_type; static int asval(VALUE obj, value_type *val) { if (val) *val = obj; return SWIG_OK; } }; } // swig } // %fragment(traits for swig::GC_VALUE) #endif // __cplusplus swig-3.0.8/Lib/ruby/std_pair.i0000664000175000017500000001233312641054563016031 0ustar williamwilliam/* Pairs */ %include //#define SWIG_STD_PAIR_ASVAL %fragment("StdPairTraits","header",fragment="StdTraits") { namespace swig { template struct traits_asval > { typedef std::pair value_type; static int get_pair(VALUE first, VALUE second, std::pair *val) { if (val) { T *pfirst = &(val->first); int res1 = swig::asval((VALUE)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(val->second); int res2 = swig::asval((VALUE)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } else { T *pfirst = 0; int res1 = swig::asval((VALUE)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((VALUE)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asval(VALUE obj, std::pair *val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_ARRAY ) { if (RARRAY_LEN(obj) == 2) { VALUE first = rb_ary_entry(obj,0); VALUE second = rb_ary_entry(obj,1); res = get_pair(first, second, val); } } else { value_type *p; res = SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = *p; } return res; } }; template struct traits_asptr > { typedef std::pair value_type; static int get_pair(VALUE first, VALUE second, std::pair **val) { if (val) { value_type *vp = %new_instance(std::pair); T *pfirst = &(vp->first); int res1 = swig::asval((VALUE)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = &(vp->second); int res2 = swig::asval((VALUE)second, psecond); if (!SWIG_IsOK(res2)) return res2; *val = vp; return SWIG_AddNewMask(res1 > res2 ? res1 : res2); } else { T *pfirst = 0; int res1 = swig::asval((VALUE)first, pfirst); if (!SWIG_IsOK(res1)) return res1; U *psecond = 0; int res2 = swig::asval((VALUE)second, psecond); if (!SWIG_IsOK(res2)) return res2; return res1 > res2 ? res1 : res2; } } static int asptr(VALUE obj, std::pair **val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_ARRAY ) { if ( RARRAY_LEN(obj) == 2) { VALUE first = rb_ary_entry(obj,0); VALUE second = rb_ary_entry(obj,1); res = get_pair(first, second, val); } } else { value_type *p; res = SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { static VALUE _wrap_pair_second( VALUE self ) { std::pair< typename swig::noconst_traits::noconst_type,U>* p = NULL; swig::asptr( self, &p ); return swig::from( p->second ); } static VALUE _wrap_pair_second_eq( VALUE self, VALUE arg ) { std::pair< typename swig::noconst_traits::noconst_type,U>* p = NULL; swig::asptr( self, &p ); return swig::from( p->second ); } static VALUE from(const std::pair& val) { VALUE obj = rb_ary_new2(2); rb_ary_push(obj, swig::from::noconst_type>(val.first)); rb_ary_push(obj, swig::from(val.second)); rb_define_singleton_method(obj, "second", VALUEFUNC(_wrap_pair_second), 0 ); rb_define_singleton_method(obj, "second=", VALUEFUNC(_wrap_pair_second_eq), 1 ); rb_obj_freeze(obj); // treat as immutable tuple return obj; } }; } } // Missing typemap %typemap(in) std::pair* (int res) { res = swig::asptr( $input, &$1 ); if (!SWIG_IsOK(res)) %argument_fail(res, "$1_type", $symname, $argnum); } %define %swig_pair_methods(pair...) %extend { VALUE inspect() const { VALUE tmp; const char *type_name = swig::type_name< pair >(); VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " (" ); tmp = swig::from( $self->first ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, "," ); tmp = swig::from( $self->second ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, ")" ); return str; } VALUE to_s() const { VALUE tmp; VALUE str = rb_str_new2( "(" ); tmp = swig::from( $self->first ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, "," ); tmp = swig::from( $self->second ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, ")" ); return str; } VALUE __getitem__( int index ) { if (( index % 2 ) == 0 ) return swig::from( $self->first ); else return swig::from( $self->second ); } VALUE __setitem__( int index, VALUE obj ) { int res; if (( index % 2 ) == 0 ) { res = swig::asval( obj, &($self->first) ); } else { res = swig::asval(obj, &($self->second) ); } if (!SWIG_IsOK(res)) rb_raise( rb_eArgError, "invalid item for " #pair ); return obj; } } // extend %enddef %include swig-3.0.8/Lib/ruby/rubystdautodoc.swg0000664000175000017500000000343312641054563017650 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubystdautodoc.swg * * This file contains autodocs for standard STL functions. * ----------------------------------------------------------------------------- */ // // For STL autodocumentation // AUTODOC(c_str, "Convert class to a String representation"); AUTODOC(begin, "Return an iterator to the beginning of the $class"); AUTODOC(end, "Return an iterator to past the end of the $class"); AUTODOC(rbegin, "Return a reverse iterator to the beginning (the end) of the $class"); AUTODOC(rend, "Return a reverse iterator to past the end (past the beginning) of the $class"); AUTODOC(length, "Size or Length of the $class"); AUTODOC(replace, "Replace all or a portion of the $class"); AUTODOC(resize, "Resize the size of the $class"); AUTODOC(capacity, "Reserved capacity of the $class"); AUTODOC(reserve, "Reserve memory in the $class for a number of elements"); AUTODOC(erase, "Delete a portion of the $class"); AUTODOC(max_size, "Maximum size of elements allowed in the $class"); AUTODOC(iterator, "Return an iterator to the $class"); AUTODOC(empty, "Check if the $class is empty or not"); AUTODOC(rfind, "Find an element in reverse usually starting from the end of the $class"); AUTODOC(assign, "Assign a new $class or portion of it"); AUTODOC(front, "Return the first element in $class"); AUTODOC(back, "Return the last element in $class"); AUTODOC(second, "Return the second element in $class"); AUTODOC(push_front, "Add an element at the beginning of the $class"); AUTODOC(push_back, "Add an element at the end of the $class"); AUTODOC(pop_front, "Remove and return element at the beginning of the $class"); AUTODOC(pop_back, "Remove and return an element at the end of the $class"); AUTODOC(clear, "Clear $class contents"); swig-3.0.8/Lib/ruby/std_container.i0000664000175000017500000000007412641054563017057 0ustar williamwilliam%include %include swig-3.0.8/Lib/ruby/std_except.i0000664000175000017500000000004312641054563016361 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/rubystdcommon.swg0000664000175000017500000001201512641054563017476 0ustar williamwilliam /* ------------------------------------------------------------ * The Ruby classes, for C++ * ------------------------------------------------------------ */ %include %fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { /* Traits that provides the from method */ template struct traits_from_ptr { static VALUE from(Type *val, int owner = 0) { return SWIG_NewPointerObj(val, type_info(), owner); } }; template struct traits_from { static VALUE from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static VALUE from(Type* val) { return traits_from_ptr::from(val, 0); } }; template struct traits_from { static VALUE from(const Type* val) { return traits_from_ptr::from(const_cast(val), 0); } }; template inline VALUE from(const Type& val) { return traits_from::from(val); } template inline VALUE from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } /* Traits that provides the asval/as/check method */ template struct traits_asptr { static int asptr(VALUE obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(VALUE obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(VALUE obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(VALUE obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(VALUE obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(VALUE obj, bool throw_error) { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } } return v; } }; template struct traits_as { static Type as(VALUE obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } static Type *v_def = (Type*) malloc(sizeof(Type)); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(VALUE obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res)) { return v; } else { if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } return 0; } } }; template inline Type as(VALUE obj, bool te = false) { return traits_as< Type, typename traits< Type >::category >::as(obj, te); } template struct traits_check { static bool check(VALUE obj) { int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(VALUE obj) { int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template inline bool check(VALUE obj) { return traits_check::category>::check(obj); } } } swig-3.0.8/Lib/ruby/rubyuserdir.swg0000664000175000017500000000122112641054563017145 0ustar williamwilliam#define %alias %feature("alias") #define %freefunc %feature("freefunc") #define %markfunc %feature("markfunc") #define %mixin %feature("mixin") #define %predicate %feature("predicate", "1") #define %bang %feature("bang", "1") #define %trackobjects %feature("trackobjects") #define %nooutput %feature("outputs","0") #define %initstack %feature("initstack", "1") #define %ignorestack %feature("initstack", "0") /* ------------------------------------------------------------------------- */ /* Enable keywords paramaters */ #define %kwargs %feature("kwargs") #define %nokwargs %feature("kwargs", "0") #define %clearkwargs %feature("kwargs", "") swig-3.0.8/Lib/ruby/cdata.i0000664000175000017500000000003612641054563015275 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/carrays.i0000664000175000017500000000020112641054563015657 0ustar williamwilliam%define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,__getitem__,__setitem__) %enddef %include swig-3.0.8/Lib/ruby/std_iostream.i0000664000175000017500000000034312641054563016717 0ustar williamwilliamnamespace std { %callback("%s") endl; %callback("%s") ends; %callback("%s") flush; } %warnfilter(365) operator+=; %warnfilter(802) std::basic_iostream; // turn off multiple inheritance warning %include swig-3.0.8/Lib/ruby/exception.i0000664000175000017500000000017612641054563016224 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg);)) } swig-3.0.8/Lib/ruby/std_alloc.i0000664000175000017500000000003312641054563016162 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/std_deque.i0000664000175000017500000000133412641054563016200 0ustar williamwilliam/* Deques */ %fragment("StdDequeTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::deque **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::deque & vec) { return traits_from_stdseq >::from(vec); } }; } %} %ignore std::deque::push_back; %ignore std::deque::pop_back; #define %swig_deque_methods(Type...) %swig_sequence_methods(Type) #define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/ruby/std_ios.i0000664000175000017500000000057412641054563015674 0ustar williamwilliam #pragma SWIG nowarn=801 %rename(ios_base_in) std::ios_base::in; AUTODOC(cerr, "Standard C++ error stream"); AUTODOC(cout, "Standard C++ output stream"); AUTODOC(cin, "Standard C++ input stream"); AUTODOC(clog, "Standard C++ logging stream"); AUTODOC(endl, "Add an end line to stream"); AUTODOC(ends, "Ends stream"); AUTODOC(flush, "Flush stream"); %include swig-3.0.8/Lib/ruby/std_common.i0000664000175000017500000000443612641054563016373 0ustar williamwilliam%include %include %include /* Generate the traits for a 'primitive' type, such as 'double', for which the SWIG_AsVal and SWIG_From methods are already defined. */ %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval< Type > { typedef Type value_type; static int asval(VALUE obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from< Type > { typedef Type value_type; static VALUE from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval< Type > { typedef Type value_type; static int asval(VALUE obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from< Type > { typedef Type value_type; static VALUE from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.8/Lib/ruby/extra-install.list0000664000175000017500000000006512641054563017535 0ustar williamwilliam# see top-level Makefile.in Makefile.swig extconf.rb swig-3.0.8/Lib/ruby/std_vectora.i0000664000175000017500000000166612641054563016550 0ustar williamwilliam/* Vectors + allocators */ %fragment("StdVectorATraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { typedef std::vector vector_type; typedef T value_type; static int asptr(VALUE obj, vector_type **vec) { return traits_asptr_stdseq::asptr(obj, vec); } }; template struct traits_from > { typedef std::vector vector_type; static VALUE from(const vector_type& vec) { return traits_from_stdseq::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %mixin std::vector "Enumerable"; %ignore std::vector::push_back; %ignore std::vector::pop_back; %alias std::vector::push "<<"; %include swig-3.0.8/Lib/ruby/cni.i0000664000175000017500000000005212641054563014770 0ustar williamwilliam%include %include swig-3.0.8/Lib/ruby/factory.i0000664000175000017500000000004012641054563015663 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/rubymacros.swg0000664000175000017500000000071012641054563016756 0ustar williamwilliam // Redefine these macros so argument index for ruby is done properly, // ignoring self and we get some more info about the input. #define %argfail_fmt(_type,_name,_argn) Ruby_Format_TypeError( "", _type, #_name, _argn, $input ) #define %argnullref_fmt(_type,_name,_argn) Ruby_Format_TypeError(%nullref_fmt(), _type, #_name, _argn, $input) %{ #define SWIG_RUBY_THREAD_BEGIN_BLOCK #define SWIG_RUBY_THREAD_END_BLOCK %} %include swig-3.0.8/Lib/ruby/std_multimap.i0000664000175000017500000001370512641054563016732 0ustar williamwilliam/* Multimaps */ %include %fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const RubySeq& rubyseq, std::multimap *multimap) { typedef typename std::multimap::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { multimap->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::multimap multimap_type; static int asptr(VALUE obj, std::multimap **val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_HASH ) { static ID id_to_a = rb_intern("to_a"); VALUE items = rb_funcall(obj, id_to_a, 0); return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::multimap multimap_type; typedef typename multimap_type::const_iterator const_iterator; typedef typename multimap_type::size_type size_type; static VALUE from(const multimap_type& multimap) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); } else { size_type size = multimap.size(); int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise(rb_eRuntimeError, "multimap size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE obj = rb_hash_new(); for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { VALUE key = swig::from(i->first); VALUE val = swig::from(i->second); VALUE oldval = rb_hash_aref( obj, key ); if ( oldval == Qnil ) rb_hash_aset(obj, key, val); else { // Multiple values for this key, create array if needed // and add a new element to it. VALUE ary; if ( TYPE(oldval) == T_ARRAY ) ary = oldval; else { ary = rb_ary_new2(2); rb_ary_push( ary, oldval ); rb_hash_aset( obj, key, ary ); } rb_ary_push( ary, val ); } } return obj; } } }; } } %define %swig_multimap_methods(MultiMap...) %swig_map_common(%arg(MultiMap)); %extend { VALUE __getitem__(const key_type& key) const { MultiMap::const_iterator i = self->find(key); if ( i != self->end() ) { MultiMap::const_iterator e = $self->upper_bound(key); VALUE ary = rb_ary_new(); for ( ; i != e; ++i ) { rb_ary_push( ary, swig::from( i->second ) ); } if ( RARRAY_LEN(ary) == 1 ) return RARRAY_PTR(ary)[0]; return ary; } else return Qnil; } void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { self->insert(MultiMap::value_type(key,x)); } VALUE inspect() { MultiMap::iterator i = $self->begin(); MultiMap::iterator e = $self->end(); const char *type_name = swig::type_name< MultiMap >(); VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " {" ); VALUE tmp; while ( i != e ) { const MultiMap::key_type& key = i->first; const MultiMap::key_type& oldkey = key; tmp = swig::from( key ); str = rb_str_buf_append( str, rb_inspect(tmp) ); str = rb_str_cat2( str, "=>" ); VALUE vals = rb_ary_new(); for ( ; i != e && key == oldkey; ++i ) { const MultiMap::mapped_type& val = i->second; tmp = swig::from( val ); rb_ary_push( vals, tmp ); } if ( RARRAY_LEN(vals) == 1 ) { str = rb_str_buf_append( str, rb_inspect(tmp) ); } else { str = rb_str_buf_append( str, rb_inspect(vals) ); } } str = rb_str_cat2( str, "}" ); return str; } VALUE to_a() { MultiMap::const_iterator i = $self->begin(); MultiMap::const_iterator e = $self->end(); VALUE ary = rb_ary_new2( std::distance( i, e ) ); VALUE tmp; while ( i != e ) { const MultiMap::key_type& key = i->first; const MultiMap::key_type& oldkey = key; tmp = swig::from( key ); rb_ary_push( ary, tmp ); VALUE vals = rb_ary_new(); for ( ; i != e && key == oldkey; ++i ) { const MultiMap::mapped_type& val = i->second; tmp = swig::from( val ); rb_ary_push( vals, tmp ); } if ( RARRAY_LEN(vals) == 1 ) { rb_ary_push( ary, tmp ); } else { rb_ary_push( ary, vals ); } } return ary; } VALUE to_s() { MultiMap::iterator i = $self->begin(); MultiMap::iterator e = $self->end(); VALUE str = rb_str_new2( "" ); VALUE tmp; while ( i != e ) { const MultiMap::key_type& key = i->first; const MultiMap::key_type& oldkey = key; tmp = swig::from( key ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); VALUE vals = rb_ary_new(); for ( ; i != e && key == oldkey; ++i ) { const MultiMap::mapped_type& val = i->second; tmp = swig::from( val ); rb_ary_push( vals, tmp ); } tmp = rb_obj_as_string( vals ); str = rb_str_buf_append( str, tmp ); } return str; } } %enddef %mixin std::multimap "Enumerable"; %rename("delete") std::multimap::__delete__; %rename("reject!") std::multimap::reject_bang; %rename("map!") std::multimap::map_bang; %rename("empty?") std::multimap::empty; %rename("include?" ) std::multimap::__contains__ const; %rename("has_key?" ) std::multimap::has_key const; %alias std::multimap::push "<<"; %include swig-3.0.8/Lib/ruby/Makefile.swig0000664000175000017500000000165612641054563016470 0ustar williamwilliam# File : Makefile.swig # Makefile for a SWIG module. Use this file if you are # producing a Ruby extension for general use or distribution. # # 1. Prepare extconf.rb. # 2. Modify this file as appropriate. # 3. Type 'make -f Makefile.swig' to generate wrapper code and Makefile. # 4. Type 'make' to build your extension. # 5. Type 'make install' to install your extension. # MODULE = yourmodule FEATURE = $(MODULE) INTERFACE = $(MODULE).i RUBY = ruby SWIG = swig # for C extension SWIGOPT = -ruby WRAPPER = $(MODULE)_wrap.c ## for C++ extension #SWIGOPT = -ruby -c++ #WRAPPER = $(MODULE)_wrap.cc swigall: $(WRAPPER) Makefile $(WRAPPER): $(INTERFACE) $(SWIG) $(SWIGOPT) -o $@ $(INTERFACE) Makefile: extconf.rb $(RUBY) extconf.rb @if [ -f Makefile ] ; then\ echo "include Makefile.swig" >> Makefile;\ fi swigclean: @if [ -f Makefile ] ; then\ make -f Makefile clean;\ fi rm -f Makefile $(WRAPPER) swig-3.0.8/Lib/ruby/rubyautodoc.swg0000664000175000017500000001041712641054563017135 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubyautodoc.swg * * This file implements autodoc typemaps for some common ruby methods. * ----------------------------------------------------------------------------- */ %define AUTODOC(func, str) %feature("autodoc", str) func; %enddef AUTODOC(to_i, "Convert $class to an Integer"); AUTODOC(to_f, "Convert $class to a Float"); AUTODOC(coerce, "Coerce class to a number"); AUTODOC(to_a, "Convert $class to an Array"); AUTODOC(to_s, "Convert class to a String representation"); AUTODOC(inspect, "Inspect class and its contents"); AUTODOC(at, "Return element at a certain index"); AUTODOC(__getitem__, "Element accessor/slicing"); AUTODOC(__setitem__, "Element setter/slicing"); AUTODOC(slice, "Return a slice (portion of) the $class"); AUTODOC(push, "Add an element at the end of the $class"); AUTODOC(pop, "Remove and return element at the end of the $class"); AUTODOC(shift, "Remove and return element at the beginning of the $class"); AUTODOC(unshift, "Add one or more elements at the beginning of the $class"); AUTODOC(first, "Return the first element in $class"); AUTODOC(last, "Return the last element in $class"); // // Common Object methods // AUTODOC(hash, "Hashing function for class"); AUTODOC(dup, "Create a duplicate of the class and unfreeze it if needed"); AUTODOC(clone, "Create a duplicate of the class"); // // Container methods // AUTODOC(empty, "Check if $class is empty"); AUTODOC(size, "Size or Length of the $class"); AUTODOC(insert, "Insert one or more new elements in the $class"); // // Iterator methods (block) // AUTODOC(each, "Iterate thru each element in the $class. A block must be provided"); AUTODOC(find, "Find an element in the class"); AUTODOC(each_key, "Iterate thru each key element in the $class. A block must be provided"); AUTODOC(each_value, "Iterate thru each key element in the $class. A block must be provided"); AUTODOC(reject, "Iterate thru each element in the $class and reject those that fail a condition returning a new $class. A block must be provided"); AUTODOC(reject_bang, "Iterate thru each element in the $class and reject those that fail a condition. A block must be provided. $class is modified in place"); AUTODOC(select, "Iterate thru each element in the $class and select those that match a condition. A block must be provided"); AUTODOC(delete_at, "Delete an element at a certain index"); AUTODOC(__delete__, "Delete a matching element"); // // Hash methods // AUTODOC(keys, "Return an Array of key elements"); AUTODOC(values, "Return an Array of value elements"); AUTODOC(values_at, "Return an Array of value elements matching the conditions"); // // Operators // #ifdef __cplusplus AUTODOC(operator==, "Equality comparison operator"); AUTODOC(operator<=, "Lower or equal comparison operator"); AUTODOC(operator>=, "Higher or equal comparison operator"); AUTODOC(operator<, "Lower than comparison operator"); AUTODOC(operator>, "Higher than comparison operator"); AUTODOC(operator<<, "Left shifting or appending operator"); AUTODOC(operator>>, "Right shifting operator or extracting operator"); AUTODOC(operator+, "Add operator"); AUTODOC(operator-, "Substraction operator"); AUTODOC(operator+(), "Positive operator"); AUTODOC(operator-(), "Negation operator"); AUTODOC(operator&, "AND operator"); AUTODOC(operator|, "OR operator"); AUTODOC(operator^, "XOR operator"); AUTODOC(operator~, "Invert operator"); #endif AUTODOC(__eq__, "Equality comparison operator"); AUTODOC(__le__, "Lower or equal comparison operator"); AUTODOC(__ge__, "Higher or equal comparison operator"); AUTODOC(__lt__, "Lower than comparison operator"); AUTODOC(__gt__, "Higher than comparison operator"); AUTODOC(__lshift__, "Left shifting or appending operator"); AUTODOC(__rshift__, "Right shifting operator or extracting operator"); AUTODOC(__add___, "Add operator"); AUTODOC(__sub__, "Substraction operator"); AUTODOC(__pos__, "Positive operator"); AUTODOC(__neg__, "Negation operator"); AUTODOC(__and__, "AND operator"); AUTODOC(__or__, "OR operator"); AUTODOC(__xor__, "XOR operator"); AUTODOC(__negate__, "Invert operator"); AUTODOC(__pow__, "Exponential operator"); AUTODOC(__divmod__, "Modulo of division"); AUTODOC(__cmp__, "Comparison operator. Returns < 0 for less than, 0 for equal or > 1 for higher than."); swig-3.0.8/Lib/ruby/rubyinit.swg0000664000175000017500000000004712641054563016440 0ustar williamwilliam%insert(initbeforefunc) "swiginit.swg" swig-3.0.8/Lib/ruby/rubydef.swg0000664000175000017500000000005212641054563016227 0ustar williamwilliam/* empty file added for backward comp. */ swig-3.0.8/Lib/ruby/rubycontainer_extended.swg0000664000175000017500000000672412641054563021347 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubycontainer_extended.swg * * This file contains additional functions that make containers * behave closer to ruby primitive types. * However, some of these functions place some restrictions on * the underlying object inside of the container and the iterator * (that it has to have an == comparison function, that it has to have * an = assignment operator, etc). * ----------------------------------------------------------------------------- */ /** * Macro used to add extend functions that require operator== in object. * * @param Container STL container * @param Type class inside container * */ %define %swig_container_with_equal_operator( Container, Type ) VALUE __delete__( const Type& val ) { VALUE r = Qnil; Container::iterator e = $self->end(); Container::iterator i = std::remove( $self->begin(), e, val ); // remove dangling elements now $self->erase( i, e ); if ( i != e ) r = swig::from< Type >( val ); else if ( rb_block_given_p() ) r = rb_yield(Qnil); return r; } %enddef // end of %swig_container_with_equal_operator /** * Macro used to add extend functions that require the assignment * operator (ie. = ) of contained class * * @param Container STL container * @param Type class inside container * */ %define %swig_container_with_assignment( Container, Type ) // // map! -- the equivalent of std::transform // Container< Type >* map_bang() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "No block given" ); VALUE r = Qnil; Container< Type >::iterator i = $self->begin(); Container< Type >::iterator e = $self->end(); try { for ( ; i != e; ++i ) { r = swig::from< Type >( *i ); r = rb_yield( r ); *i = swig::as< Type >( r ); } } catch ( const std::invalid_argument& ) { rb_raise(rb_eTypeError, "Yield block did not return a valid element for " "Container"); } return $self; } %enddef // end of %swig_container_with_assignment /** * Macro used to add all extended functions to a container * * @param Container STL container * @param Type class inside container * */ %define %swig_container_extend( Container, Type ) %extend Container< Type > { %swig_container_with_assignment( %arg(Container), Type ); %swig_container_with_equal_operator( %arg(Container), Type ); } %enddef /** * Private macro used to add all extended functions to C/C++ * primitive types * * @param Container an STL container, like std::vector (with no class template) * */ %define %__swig_container_extend_primtypes( Container ) %swig_container_extend( %arg( Container ), bool ); %swig_container_extend( %arg( Container ), char ); %swig_container_extend( %arg( Container ), short ); %swig_container_extend( %arg( Container ), int ); %swig_container_extend( %arg( Container ), unsigned short ); %swig_container_extend( %arg( Container ), unsigned int ); %swig_container_extend( %arg( Container ), float ); %swig_container_extend( %arg( Container ), double ); %swig_container_extend( %arg( Container ), std::complex ); %swig_container_extend( %arg( Container ), std::string ); %swig_container_extend( %arg( Container ), swig::GC_VALUE ); %enddef %__swig_container_extend_primtypes( std::vector ); %__swig_container_extend_primtypes( std::deque ); %__swig_container_extend_primtypes( std::list ); swig-3.0.8/Lib/ruby/embed.i0000664000175000017500000000025112641054563015274 0ustar williamwilliam%wrapper %{ #include int main(argc, argv) int argc; char **argv; { ruby_init(); ruby_options(argc, argv); ruby_run(); return 0; } %} swig-3.0.8/Lib/ruby/rubytypemaps.swg0000664000175000017500000000342012641054563017335 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Ruby * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* bool is dangerous in Ruby, change precedence */ #undef SWIG_TYPECHECK_BOOL %define SWIG_TYPECHECK_BOOL 10000 %enddef /* Include fundamental fragment definitions */ %include /* Look for user fragments file. */ %include /* Ruby fragments for primitive types */ %include /* Ruby fragments for char* strings */ %include /* Backward compatibility output helper */ %fragment("output_helper","header") %{ #define output_helper SWIG_Ruby_AppendOutput %} /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* Directors are supported in Ruby */ #ifndef SWIG_DIRECTOR_TYPEMAPS #define SWIG_DIRECTOR_TYPEMAPS #endif /* Ruby types */ #define SWIG_Object VALUE #define VOID_Object Qnil /* Overload of the output/constant/exception handling */ /* append output */ #define SWIG_AppendOutput(result,obj) SWIG_Ruby_AppendOutput(result, obj) /* set constant */ #define SWIG_SetConstant(name, obj) rb_define_const($module, name, obj) /* raise */ #define SWIG_Raise(obj, type, desc) rb_exc_raise(SWIG_Ruby_ExceptionType(desc, obj)) /* Get the address of the 'Ruby self' object */ %typemap(in,numinputs=0,noblock=1) VALUE* RUBY_SELF { $1 = &self; } /* Include the unified typemap library */ %include swig-3.0.8/Lib/ruby/std_list.i0000664000175000017500000000201512641054563016045 0ustar williamwilliam/* Lists */ %fragment("StdListTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::list **lis) { return traits_asptr_stdseq >::asptr(obj, lis); } }; template struct traits_from > { static VALUE from(const std::list & vec) { return traits_from_stdseq >::from(vec); } }; } %} %ignore std::list::push_back; %ignore std::list::pop_back; #define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %rename("delete") std::list::__delete__; %rename("reject!") std::list::reject_bang; %rename("map!") std::list::map_bang; %rename("empty?") std::list::empty; %rename("include?" ) std::list::__contains__ const; %rename("has_key?" ) std::list::has_key const; %alias std::list::push "<<"; %include swig-3.0.8/Lib/ruby/std_basic_string.i0000664000175000017500000000512012641054563017541 0ustar williamwilliam#if !defined(SWIG_STD_STRING) #define SWIG_STD_BASIC_STRING %include #define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) %traits_swigtype(std::basic_string); %fragment(SWIG_Traits_frag(std::basic_string)); %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(VALUE obj, std::string **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::string *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { char* buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::string(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } if (val) { rb_raise( rb_eTypeError, "a string is expected"); } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE VALUE SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } %include %typemaps_asptrfromn(%checkcode(STRING), std::basic_string); #endif #if !defined(SWIG_STD_WSTRING) %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int SWIG_AsPtr(std::basic_string)(VALUE obj, std::wstring **val) { static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); std::wstring *vptr; if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { if (buf) { if (val) *val = new std::wstring(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } if (val) { rb_raise( rb_eTypeError, "a string is expected"); } return 0; } } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE VALUE SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } %typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string); #endif swig-3.0.8/Lib/ruby/std_wstring.i0000664000175000017500000000010112641054563016561 0ustar williamwilliam%include %include swig-3.0.8/Lib/ruby/std_char_traits.i0000664000175000017500000000004112641054563017372 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/rubyopers.swg0000664000175000017500000000347412641054563016634 0ustar williamwilliam/* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ #ifdef __cplusplus %rename(__add__) *::operator+; %rename(__pos__) *::operator+(); %rename(__pos__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-(); %rename(__neg__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__and__) *::operator&; %rename(__or__) *::operator|; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__lt__) *::operator<; %rename(__le__) *::operator<=; %rename(__gt__) *::operator>; %rename(__ge__) *::operator>=; %rename(__eq__) *::operator==; /* Special cases */ %rename(__call__) *::operator(); /* Ignored inplace operators */ %ignoreoperator(NOTEQUAL) operator!=; %ignoreoperator(PLUSEQ) operator+=; %ignoreoperator(MINUSEQ) operator-=; %ignoreoperator(MULEQ) operator*=; %ignoreoperator(DIVEQ) operator/=; %ignoreoperator(MODEQ) operator%=; %ignoreoperator(LSHIFTEQ) operator<<=; %ignoreoperator(RSHIFTEQ) operator>>=; %ignoreoperator(ANDEQ) operator&=; %ignoreoperator(OREQ) operator|=; %ignoreoperator(XOREQ) operator^=; /* Ignored operators */ %ignoreoperator(LNOT) operator!; %ignoreoperator(LAND) operator&&; %ignoreoperator(LOR) operator||; %ignoreoperator(EQ) operator=; %ignoreoperator(PLUSPLUS) operator++; %ignoreoperator(MINUSMINUS) operator--; %ignoreoperator(ARROWSTAR) operator->*; %ignoreoperator(INDEX) operator[]; #endif /* __cplusplus */ swig-3.0.8/Lib/ruby/rubyfragments.swg0000664000175000017500000000105012641054563017456 0ustar williamwilliam/* Create a file with this name, 'rubyfragments.swg', in your working directory and add all the %fragments you want to take precedence over the ones defined by default by swig. For example, if you add: %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERNINLINE int SWIG_AsVal(int)(VALUE obj, int *val) { ; } } this will replace the code used to retrieve an integer value for all the typemaps that need it, including: int, std::vector, std::list >, etc. */ swig-3.0.8/Lib/ruby/jstring.i0000664000175000017500000000167012641054563015706 0ustar williamwilliam%include %fragment(SWIG_AsVal_frag(jstring),"header") { SWIGINTERN int SWIG_AsVal(jstring)(VALUE obj, jstring *val) { if (NIL_P(obj)){ if (val) *val = 0; return SWIG_OK; } if (TYPE(obj) == T_STRING) { if (val) { char *cstr = rb_string_value_ptr(&(obj)); jsize len = RSTRING_LEN(obj); *val = JvNewStringLatin1(cstr, len); } return SWIG_NEWOBJ; } return SWIG_TypeError; } } %fragment(SWIG_From_frag(jstring),"header") { SWIGINTERNINLINE VALUE SWIG_From(jstring)(jstring val) { if (!val) { return Qnil; } else { jint len = JvGetStringUTFLength(val); char buf[len]; JvGetStringUTFRegion(val, 0, len, buf); return rb_str_new(buf,len); } } } %typemaps_asvalfrom(%checkcode(STRING), %arg(SWIG_AsVal(jstring)), %arg(SWIG_From(jstring)), %arg(SWIG_AsVal_frag(jstring)), %arg(SWIG_From_frag(jstring)), java::lang::String *); swig-3.0.8/Lib/ruby/rubycontainer.swg0000664000175000017500000007036212641054563017466 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubycontainer.swg * * Ruby sequence <-> C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of * the mapping between C++ and Ruby, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should * be the case. * ----------------------------------------------------------------------------- */ %{ #include %} #if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) # if !defined(SWIG_EXPORT_ITERATOR_METHODS) # define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS # endif #endif %include /**** The RubySequence C++ Wrap ***/ %fragment(""); %include %fragment("RubySequence_Base","header") { %#include namespace swig { template < class T > struct yield : public std::unary_function< T, bool > { bool operator()( const T& v ) const { return RTEST( rb_yield( swig::from< T >(v) ) ); } }; inline size_t check_index(ptrdiff_t i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); } else if ( (size_t) i < size ) { return (size_t) i; } else if (insert && ((size_t) i == size)) { return size; } throw std::out_of_range("index out of range"); } inline size_t slice_index(ptrdiff_t i, size_t size) { if ( i < 0 ) { if ((size_t) (-i) <= size) { return (size_t) (i + size); } else { throw std::out_of_range("index out of range"); } } else { return ( (size_t) i < size ) ? ((size_t) i) : size; } } template inline typename Sequence::iterator getpos(Sequence* self, Difference i) { typename Sequence::iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline typename Sequence::const_iterator cgetpos(const Sequence* self, Difference i) { typename Sequence::const_iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline void resize(Sequence *seq, typename Sequence::size_type n, typename Sequence::value_type x) { seq->resize(n, x); } template inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, (i == size && j == size)); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::const_iterator vb = self->begin(); typename Sequence::const_iterator ve = self->begin(); std::advance(vb,ii); std::advance(ve,jj); return new Sequence(vb, ve); } else { return new Sequence(); } } template inline void setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj < ii) jj = ii; size_t ssize = jj - ii; if (ssize <= v.size()) { typename Sequence::iterator sb = self->begin(); typename InputSeq::const_iterator vmid = v.begin(); std::advance(sb,ii); std::advance(vmid, jj - ii); self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); } else { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); self->insert(sb, v.begin(), v.end()); } } template inline void delslice(Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); } } } } %fragment("RubySequence_Cont","header", fragment="", fragment="StdTraits", fragment="RubySequence_Base", fragment="ConstIterator_T") { namespace swig { /** * This class is a proxy class for references, used to return and set values * of an element of a Ruby Array of stuff. * It can be used by RubySequence_InputIterator to make it work with STL * algorithms. */ template struct RubySequence_Ref { RubySequence_Ref(VALUE seq, int index) : _seq(seq), _index(index) { } operator T () const { VALUE item = rb_ary_entry(_seq, _index ); try { return swig::as(item, true); } catch (std::exception& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", _index); VALUE lastErr = rb_gv_get("$!"); if ( lastErr == Qnil ) { %type_error(swig::type_name()); } VALUE str = rb_str_new2(msg); str = rb_str_cat2( str, e.what() ); SWIG_Ruby_ExceptionType( NULL, str ); throw; } } RubySequence_Ref& operator=(const T& v) { rb_ary_set(_seq, _index, swig::from< T >(v)); return *this; } private: VALUE _seq; int _index; }; /** * This class is a proxy to return a pointer to a class, usually * RubySequence_Ref. * It can be used by RubySequence_InputIterator to make it work with STL * algorithms. */ template struct RubySequence_ArrowProxy { RubySequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; /** * Input Iterator. This adapator class is a random access iterator that * allows you to use STL algorithms with a Ruby class (a Ruby Array by default). */ template > struct RubySequence_InputIterator { typedef RubySequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; typedef T value_type; typedef T* pointer; typedef ptrdiff_t difference_type; RubySequence_InputIterator() { } RubySequence_InputIterator(VALUE seq, int index) : _seq(seq), _index(index) { } reference operator*() const { return reference(_seq, _index); } RubySequence_ArrowProxy operator->() const { return RubySequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const { return (_index == ri._index) && (_seq == ri._seq); } bool operator!=(const self& ri) const { return !(operator==(ri)); } self& operator ++ () { ++_index; return *this; } self& operator -- () { --_index; return *this; } self& operator += (difference_type n) { _index += n; return *this; } self operator +(difference_type n) const { return self(_seq, _index + n); } self& operator -= (difference_type n) { _index -= n; return *this; } self operator -(difference_type n) const { return self(_seq, _index - n); } difference_type operator - (const self& ri) const { return _index - ri._index; } bool operator < (const self& ri) const { return _index < ri._index; } reference operator[](difference_type n) const { return reference(_seq, _index + n); } private: VALUE _seq; difference_type _index; }; /** * This adaptor class allows you to use a Ruby Array as if it was an STL * container, giving it begin(), end(), and iterators. */ template struct RubySequence_Cont { typedef RubySequence_Ref reference; typedef const RubySequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef int difference_type; typedef int size_type; typedef const pointer const_pointer; typedef RubySequence_InputIterator iterator; typedef RubySequence_InputIterator const_iterator; RubySequence_Cont(VALUE seq) : _seq(0) { if (!rb_obj_is_kind_of(seq, rb_cArray)) { throw std::invalid_argument("an Array is expected"); } _seq = seq; } ~RubySequence_Cont() { } size_type size() const { return RARRAY_LEN(_seq); } bool empty() const { return size() == 0; } iterator begin() { return iterator(_seq, 0); } const_iterator begin() const { return const_iterator(_seq, 0); } iterator end() { return iterator(_seq, size()); } const_iterator end() const { return const_iterator(_seq, size()); } reference operator[](difference_type n) { return reference(_seq, n); } const_reference operator[](difference_type n) const { return const_reference(_seq, n); } bool check(bool set_err = false) const { int s = (int) size(); for (int i = 0; i < s; ++i) { VALUE item = rb_ary_entry(_seq, i ); if (!swig::check(item)) { if (set_err) { char msg[1024]; sprintf(msg, "in sequence element %d", i); SWIG_Error(SWIG_RuntimeError, msg); } return false; } } return true; } private: VALUE _seq; }; } } /** * Macros used to typemap an STL iterator -> SWIGIterator conversion. */ %define %swig_sequence_iterator(Sequence...) #if defined(SWIG_EXPORT_ITERATOR_METHODS) %typemap(out,noblock=1,fragment="RubySequence_Cont") const_iterator, const_reverse_iterator { $result = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &), self), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); } %typemap(out,noblock=1,fragment="RubySequence_Cont") iterator, reverse_iterator { $result = SWIG_NewPointerObj(swig::make_nonconst_iterator(%static_cast($1,const $type &), self), swig::Iterator::descriptor(),SWIG_POINTER_OWN); } %typemap(out,noblock=1,fragment="RubySequence_Cont") std::pair { $result = rb_ary_new2(2); rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); } // std::map/multimap/set allow returning std::pair< iterator, iterator > from // equal_range, but we cannot still modify the key, so the iterator is // const. %typemap(out,noblock=1,fragment="RubySequence_Cont") std::pair { $result = rb_ary_new2(2); rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); } %typemap(in,noblock=1,fragment="RubySequence_Cont") const_iterator(swig::ConstIterator *iter = 0, int res), const_reverse_iterator(swig::ConstIterator *iter = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::ConstIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::ConstIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typemap(in,noblock=1,fragment="RubySequence_Cont") iterator(swig::Iterator *iter = 0, int res), reverse_iterator(swig::Iterator *iter = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::Iterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::Iterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont") const_iterator, const_reverse_iterator { swig::ConstIterator *iter = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::ConstIterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont") iterator, reverse_iterator { swig::ConstIterator *iter = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::Iterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %fragment("RubySequence_Cont"); // %newobject iterator; // %newobject const_iterator; // %extend { // swig::Iterator* iterator(VALUE* RUBY_SELF) { // return swig::make_nonconst_iterator($self->begin(), $self->begin(), // $self->end(), *RUBY_SELF); // } // swig::ConstIterator* const_iterator(VALUE* RUBY_SELF) { // return swig::make_const_iterator($self->begin(), $self->begin(), // $self->end(), *RUBY_SELF); // } // } #endif //SWIG_EXPORT_ITERATOR_METHODS %enddef /**** The Ruby container methods ****/ %define %swig_container_methods(Container...) %extend { %newobject dup; Container* dup() { return new Container(*$self); } } %enddef /** * Macro used to define common Ruby printing methods for STL container */ %define %swig_sequence_printing_methods(Sequence...) %extend { VALUE inspect() { Sequence::const_iterator i = $self->begin(); Sequence::const_iterator e = $self->end(); const char *type_name = swig::type_name< Sequence >(); VALUE str = rb_str_new2(type_name); str = rb_str_cat2( str, " [" ); bool comma = false; VALUE tmp; for ( ; i != e; ++i, comma = true ) { if (comma) str = rb_str_cat2( str, "," ); tmp = swig::from< Sequence::value_type >( *i ); tmp = rb_inspect( tmp ); str = rb_str_buf_append( str, tmp ); } str = rb_str_cat2( str, "]" ); return str; } VALUE to_a() { Sequence::const_iterator i = $self->begin(); Sequence::const_iterator e = $self->end(); VALUE ary = rb_ary_new2( std::distance( i, e ) ); VALUE tmp; for ( ; i != e; ++i ) { tmp = swig::from< Sequence::value_type >( *i ); rb_ary_push( ary, tmp ); } return ary; } VALUE to_s() { Sequence::iterator i = $self->begin(); Sequence::iterator e = $self->end(); VALUE str = rb_str_new2( "" ); VALUE tmp; for ( ; i != e; ++i ) { tmp = swig::from< Sequence::value_type >( *i ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); } return str; } } %enddef /** * Macro used to add common methods to all STL sequence-type containers */ %define %swig_sequence_methods_non_resizable_common(Sequence...) %swig_container_methods(%arg(Sequence)) %swig_sequence_iterator(%arg(Sequence)) %swig_sequence_printing_methods(%arg(Sequence)) %fragment("RubySequence_Base"); %extend { VALUE slice( difference_type i, difference_type length ) throw (std::invalid_argument) { if ( length < 0 ) return Qnil; std::size_t len = $self->size(); if ( i < 0 ) { if ( i + static_cast(len) < 0 ) return Qnil; else i = len + i; } Sequence::difference_type j = length + i; if ( j > static_cast(len) ) j = len; VALUE r = Qnil; try { r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); } catch( std::out_of_range ) { } return r; } Sequence* each() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given"); VALUE r; Sequence::const_iterator i = self->begin(); Sequence::const_iterator e = self->end(); for ( ; i != e; ++i ) { r = swig::from< Sequence::value_type >(*i); rb_yield(r); } return self; } VALUE __delete2__(const value_type& i) { VALUE r = Qnil; return r; } } %enddef %define %swig_sequence_methods_resizable_common(Sequence...) %extend { %newobject select; Sequence* select() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); Sequence* r = new Sequence(); Sequence::const_iterator i = $self->begin(); Sequence::const_iterator e = $self->end(); for ( ; i != e; ++i ) { VALUE v = swig::from< Sequence::value_type >(*i); if ( RTEST( rb_yield(v) ) ) $self->insert( r->end(), *i); } return r; } VALUE delete_at(difference_type i) { VALUE r = Qnil; try { Sequence::iterator at = swig::getpos(self, i); r = swig::from< Sequence::value_type >( *(at) ); $self->erase(at); } catch (std::out_of_range) { } return r; } } %enddef %define %swig_sequence_methods_common(Sequence...) %swig_sequence_methods_non_resizable_common(%arg(Sequence)) %swig_sequence_methods_resizable_common(%arg(Sequence)) %enddef /** * Macro used to add functions for back insertion of values in * STL sequence containers */ %define %swig_sequence_back_inserters( Sequence... ) %extend { VALUE pop() { if ($self->empty()) return Qnil; Sequence::value_type x = self->back(); $self->pop_back(); return swig::from< Sequence::value_type >( x ); } %alias push "<<"; const value_type push( const value_type& e ) { $self->push_back( e ); return e; } %newobject reject; Sequence* reject() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); Sequence* r = new Sequence(); std::remove_copy_if( $self->begin(), $self->end(), std::back_inserter(*r), swig::yield< Sequence::value_type >() ); return r; } } %enddef %define %swig_sequence_methods_extra(Sequence...) %extend { %alias reject_bang "delete_if"; Sequence* reject_bang() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); $self->erase( std::remove_if( $self->begin(), $self->end(), swig::yield< Sequence::value_type >() ), $self->end() ); return $self; } } %enddef %define %swig_sequence_methods_non_resizable_accessors(Sequence...) %extend { VALUE at(difference_type i) const { VALUE r = Qnil; try { r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); } catch( std::out_of_range ) { } return r; } VALUE __getitem__(difference_type i, difference_type length) const throw (std::invalid_argument) { if ( length < 0 ) return Qnil; std::size_t len = $self->size(); if ( i < 0 ) { if ( i + static_cast(len) < 0 ) return Qnil; else i = len + i; } Sequence::difference_type j = length + i; if ( j > static_cast(len) ) j = len; VALUE r = Qnil; try { r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); } catch( std::out_of_range ) { } return r; } VALUE __getitem__(difference_type i) const { VALUE r = Qnil; try { r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); } catch( std::out_of_range ) { } return r; } VALUE __getitem__(VALUE i) const throw (std::invalid_argument) { if ( rb_obj_is_kind_of( i, rb_cRange ) == Qfalse ) { rb_raise( rb_eTypeError, "not a valid index or range" ); } static ID id_end = rb_intern("end"); static ID id_start = rb_intern("begin"); static ID id_noend = rb_intern("exclude_end?"); VALUE start = rb_funcall( i, id_start, 0 ); VALUE end = rb_funcall( i, id_end, 0 ); bool noend = ( rb_funcall( i, id_noend, 0 ) == Qtrue ); int len = $self->size(); int s = NUM2INT( start ); if ( s < 0 ) { s = len + s; if ( s < 0 ) return Qnil; } else if ( s > len ) return Qnil; int e = NUM2INT( end ); if ( e < 0 ) e = len + e; if ( noend ) e -= 1; if ( e < 0 ) e = -1; if ( e >= len ) e = len - 1; if ( s == len ) e = len - 1; return swig::from< Sequence* >( swig::getslice(self, s, e+1) ); } VALUE __setitem__(difference_type i, const value_type& x) throw (std::invalid_argument, std::out_of_range) { if ( i >= static_cast( $self->size()) ) swig::resize( $self, i+1, x ); else *(swig::getpos($self, i)) = x; return swig::from< Sequence::value_type >( x ); } VALUE __setitem__(difference_type i, difference_type length, const Sequence& v) throw (std::invalid_argument) { if ( length < 0 ) return Qnil; std::size_t len = $self->size(); if ( i < 0 ) { if ( i + static_cast(len) < 0 ) return Qnil; else i = len + i; } Sequence::difference_type j = length + i; if ( j > static_cast(len) ) { swig::resize( $self, j, *(v.begin()) ); } VALUE r = Qnil; swig::setslice($self, i, j, v); r = swig::from< const Sequence* >( &v ); return r; } } %enddef /** * Macro used to add functions for non resizable sequences */ %define %swig_sequence_methods_non_resizable(Sequence...) %swig_sequence_methods_non_resizable_common(%arg(Sequence)) %swig_sequence_methods_non_resizable_accessors(%arg(Sequence)) %enddef /** * Macro used to add functions for sequences */ %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_non_resizable_common(%arg(Sequence)) %swig_sequence_methods_resizable_common(%arg(Sequence)) %swig_sequence_methods_non_resizable_accessors(%arg(Sequence)) %swig_sequence_methods_extra(%arg(Sequence)); %swig_sequence_back_inserters(%arg(Sequence)); %enddef %define %swig_sequence_methods_non_resizable_val(Sequence...) %swig_sequence_methods_non_resizable(%arg(Sequence)) %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods(%arg(Sequence)) %enddef /** * Macro used to add functions for front insertion of * elements in STL sequence containers that support it. */ %define %swig_sequence_front_inserters( Sequence... ) %extend { VALUE shift() { if ($self->empty()) return Qnil; Sequence::value_type x = self->front(); $self->erase( $self->begin() ); return swig::from< Sequence::value_type >( x ); } %typemap(in) (int argc, VALUE* argv) { $1 = argc - 1; $2 = argv + 1; } Sequence* insert( difference_type pos, int argc, VALUE* argv, ... ) { std::size_t len = $self->size(); std::size_t i = swig::check_index( pos, len, true ); Sequence::iterator start; VALUE elem = argv[0]; int idx = 0; try { Sequence::value_type val = swig::as( elem, true ); if ( i >= len ) { $self->resize(i-1, val); return $self; } start = $self->begin(); std::advance( start, i ); $self->insert( start++, val ); for ( ++idx; idx < argc; ++idx ) { elem = argv[idx]; val = swig::as( elem ); $self->insert( start++, val ); } } catch( std::invalid_argument ) { rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", swig::type_name(), __FUNCTION__, idx+2, elem )); } return $self; } %typemap(in) (int argc, VALUE* argv) { $1 = argc; $2 = argv; } Sequence* unshift( int argc, VALUE* argv, ... ) { for ( int idx = argc-1; idx >= 0; --idx ) { Sequence::iterator start = $self->begin(); VALUE elem = argv[idx]; try { Sequence::value_type val = swig::as( elem, true ); $self->insert( start, val ); } catch( std::invalid_argument ) { rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", swig::type_name(), __FUNCTION__, idx+2, elem )); } } return $self; } } %enddef // // Common fragments // %fragment("StdSequenceTraits","header", fragment="StdTraits", fragment="RubySequence_Cont", fragment="GC_VALUE_definition") { namespace swig { template inline void assign(const RubySeq& rubyseq, Seq* seq) { // seq->assign(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr_stdseq { typedef Seq sequence; typedef T value_type; static int asptr(VALUE obj, sequence **seq) { if (rb_obj_is_kind_of(obj, rb_cArray) == Qtrue) { try { RubySequence_Cont rubyseq(obj); if (seq) { sequence *pseq = new sequence(); assign(rubyseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { return rubyseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq) { VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { rb_raise(rb_eTypeError, "%s", e.what()); } } return SWIG_ERROR; } } else { sequence *p; if (SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } return SWIG_ERROR; } }; // Partial specialization for GC_VALUE's. No need to typecheck each // element. template< class Seq > struct traits_asptr_stdseq< Seq, swig::GC_VALUE > { typedef Seq sequence; typedef swig::GC_VALUE value_type; static int asptr(VALUE obj, sequence **seq) { if (rb_obj_is_kind_of(obj, rb_cArray) == Qtrue) { try { if (seq) { RubySequence_Cont rubyseq(obj); sequence *pseq = new sequence(); assign(rubyseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { return true; } } catch (std::exception& e) { if (seq) { VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { rb_raise(rb_eTypeError, "%s", e.what()); } } return SWIG_ERROR; } } else { sequence *p; if (SWIG_ConvertPtr(obj,(void**)&p, swig::type_info(),0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } return SWIG_ERROR; } }; template struct traits_from_stdseq { typedef Seq sequence; typedef T value_type; typedef typename Seq::size_type size_type; typedef typename sequence::const_iterator const_iterator; static VALUE from(const sequence& seq) { #ifdef SWIG_RUBY_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } #endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { VALUE obj = rb_ary_new2((int)size); int i = 0; for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { rb_ary_push(obj, swig::from< value_type >(*it)); } rb_obj_freeze(obj); // treat as immutable result return obj; } else { rb_raise(rb_eRangeError,"sequence size not valid in ruby"); return Qnil; } } }; } } %include swig-3.0.8/Lib/ruby/std_map.i0000664000175000017500000002576012641054563015663 0ustar williamwilliam// // Maps // %fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { template struct from_key_oper { typedef const ValueType& argument_type; typedef VALUE result_type; result_type operator()(argument_type v) const { return swig::from(v.first); } }; template struct from_value_oper { typedef const ValueType& argument_type; typedef VALUE result_type; result_type operator()(argument_type v) const { return swig::from(v.second); } }; template struct MapIterator_T : ConstIteratorClosed_T { MapIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) : ConstIteratorClosed_T(curr, first, last, seq) { } }; template > struct MapKeyIterator_T : MapIterator_T { MapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) : MapIterator_T(curr, first, last, seq) { } }; template inline ConstIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, VALUE seq = 0) { return new MapKeyIterator_T(current, begin, end, seq); } template > struct MapValueIterator_T : MapIterator_T { MapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) : MapIterator_T(curr, first, last, seq) { } }; template inline ConstIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, VALUE seq = 0) { return new MapValueIterator_T(current, begin, end, seq); } } } %fragment("StdMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template inline void assign(const RubySeq& rubyseq, std::map *map) { typedef typename std::map::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } template struct traits_asptr > { typedef std::map map_type; static int asptr(VALUE obj, map_type **val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_HASH ) { static ID id_to_a = rb_intern("to_a"); VALUE items = rb_funcall(obj, id_to_a, 0); res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } return res; } }; template struct traits_from > { typedef std::map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; static VALUE from(const map_type& map) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); } else { size_type size = map.size(); int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise( rb_eRuntimeError, "map size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE obj = rb_hash_new(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { VALUE key = swig::from(i->first); VALUE val = swig::from(i->second); rb_hash_aset(obj, key, val); } return obj; } } }; } } %define %swig_map_common(Map...) %swig_container_methods(%arg(Map)); // %swig_sequence_iterator(%arg(Map)); %extend { VALUE __delete__(const key_type& key) { Map::iterator i = self->find(key); if (i != self->end()) { self->erase(i); return swig::from( key ); } else { return Qnil; } } bool has_key(const key_type& key) const { Map::const_iterator i = self->find(key); return i != self->end(); } VALUE keys() { Map::size_type size = self->size(); int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE ary = rb_ary_new2(rubysize); Map::const_iterator i = self->begin(); Map::const_iterator e = self->end(); for ( ; i != e; ++i ) { rb_ary_push( ary, swig::from(i->first) ); } return ary; } Map* each() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given"); VALUE k, v; Map::iterator i = self->begin(); Map::iterator e = self->end(); for ( ; i != e; ++i ) { const Map::key_type& key = i->first; const Map::mapped_type& val = i->second; k = swig::from(key); v = swig::from(val); rb_yield_values(2, k, v); } return self; } %newobject select; Map* select() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); Map* r = new Map; Map::iterator i = $self->begin(); Map::iterator e = $self->end(); for ( ; i != e; ++i ) { VALUE k = swig::from(i->first); VALUE v = swig::from(i->second); if ( RTEST( rb_yield_values(2, k, v) ) ) $self->insert(r->end(), *i); } return r; } %typemap(in) (int argc, VALUE* argv) { $1 = argc; $2 = argv; } VALUE values_at(int argc, VALUE* argv, ...) { VALUE r = rb_ary_new(); ID id = rb_intern("[]"); swig_type_info* type = swig::type_info< Map >(); VALUE me = SWIG_NewPointerObj( $self, type, 0 ); for ( int i = 0; i < argc; ++i ) { VALUE key = argv[i]; VALUE tmp = rb_funcall( me, id, 1, key ); rb_ary_push( r, tmp ); } return r; } Map* each_key() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given"); VALUE r; Map::iterator i = self->begin(); Map::iterator e = self->end(); for ( ; i != e; ++i ) { r = swig::from( i->first ); rb_yield(r); } return self; } VALUE values() { Map::size_type size = self->size(); int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE ary = rb_ary_new2(rubysize); Map::const_iterator i = self->begin(); Map::const_iterator e = self->end(); for ( ; i != e; ++i ) { rb_ary_push( ary, swig::from(i->second) ); } return ary; } Map* each_value() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given"); VALUE r; Map::iterator i = self->begin(); Map::iterator e = self->end(); for ( ; i != e; ++i ) { r = swig::from( i->second ); rb_yield(r); } return self; } VALUE entries() { Map::size_type size = self->size(); int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; if (rubysize < 0) { SWIG_RUBY_THREAD_BEGIN_BLOCK; rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); SWIG_RUBY_THREAD_END_BLOCK; return Qnil; } VALUE ary = rb_ary_new2(rubysize); Map::const_iterator i = self->begin(); Map::const_iterator e = self->end(); for ( ; i != e; ++i ) { rb_ary_push( ary, swig::from >(*i) ); } return ary; } bool __contains__(const key_type& key) { return self->find(key) != self->end(); } %newobject key_iterator(VALUE *RUBY_SELF); swig::ConstIterator* key_iterator(VALUE *RUBY_SELF) { return swig::make_output_key_iterator($self->begin(), $self->begin(), $self->end(), *RUBY_SELF); } %newobject value_iterator(VALUE *RUBY_SELF); swig::ConstIterator* value_iterator(VALUE *RUBY_SELF) { return swig::make_output_value_iterator($self->begin(), $self->begin(), $self->end(), *RUBY_SELF); } } %enddef %define %swig_map_methods(Map...) %swig_map_common(Map) %extend { VALUE __getitem__(const key_type& key) const { Map::const_iterator i = self->find(key); if ( i != self->end() ) return swig::from( i->second ); else return Qnil; } void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { (*self)[key] = x; } VALUE inspect() { Map::const_iterator i = $self->begin(); Map::const_iterator e = $self->end(); const char *type_name = swig::type_name< Map >(); VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " {" ); bool comma = false; VALUE tmp; for ( ; i != e; ++i, comma = true ) { if (comma) str = rb_str_cat2( str, "," ); tmp = swig::from< Map::key_type >( i->first ); tmp = rb_inspect( tmp ); str = rb_str_buf_append( str, tmp ); str = rb_str_cat2( str, "=>" ); tmp = swig::from< Map::mapped_type >( i->second ); tmp = rb_inspect( tmp ); str = rb_str_buf_append( str, tmp ); } str = rb_str_cat2( str, "}" ); return str; } VALUE to_a() { Map::const_iterator i = $self->begin(); Map::const_iterator e = $self->end(); VALUE ary = rb_ary_new2( std::distance( i, e ) ); VALUE tmp; for ( ; i != e; ++i ) { // @todo: improve -- this should just be swig::from(*i) tmp = swig::from< std::pair >( *i ); rb_ary_push( ary, tmp ); } return ary; } VALUE to_s() { Map::iterator i = $self->begin(); Map::iterator e = $self->end(); VALUE str = rb_str_new2( "" ); VALUE tmp; for ( ; i != e; ++i ) { // @todo: improve -- this should just be swig::from(*i) tmp = swig::from< std::pair >( *i ); tmp = rb_obj_as_string( tmp ); str = rb_str_buf_append( str, tmp ); } return str; } } %enddef %mixin std::map "Enumerable"; %rename("delete") std::map::__delete__; %rename("reject!") std::map::reject_bang; %rename("map!") std::map::map_bang; %rename("empty?") std::map::empty; %rename("include?" ) std::map::__contains__ const; %rename("has_key?" ) std::map::has_key const; %alias std::map::push "<<"; %include swig-3.0.8/Lib/ruby/std_array.i0000664000175000017500000000671512641054563016223 0ustar williamwilliam/* std::array */ %fragment("StdArrayTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::array **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::array& vec) { return traits_from_stdseq >::from(vec); } }; template inline void assign(const RubySeq& rubyseq, std::array* seq) { if (rubyseq.size() < seq->size()) throw std::invalid_argument("std::array cannot be expanded in size"); else if (rubyseq.size() > seq->size()) throw std::invalid_argument("std::array cannot be reduced in size"); std::copy(rubyseq.begin(), rubyseq.end(), seq->begin()); } template inline void resize(std::array *seq, typename std::array::size_type n, typename std::array::value_type x) { throw std::invalid_argument("std::array is a fixed size container and does not support resizing"); } // Only limited slicing is supported as std::array is fixed in size template inline std::array* getslice(const std::array* self, Difference i, Difference j) { typedef std::array Sequence; typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, (i == size && j == size)); typename Sequence::size_type jj = swig::slice_index(j, size); if (ii == 0 && jj == size) { Sequence *sequence = new Sequence(); std::copy(self->begin(), self->end(), sequence->begin()); return sequence; } else { throw std::invalid_argument("std::array object only supports getting a slice that is the size of the array"); } } template inline void setslice(std::array* self, Difference i, Difference j, const InputSeq& v) { typedef std::array Sequence; typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (ii == 0 && jj == size) { std::copy(v.begin(), v.end(), self->begin()); } else { throw std::invalid_argument("std::array object only supports setting a slice that is the size of the array"); } } template inline void delslice(std::array* self, Difference i, Difference j) { throw std::invalid_argument("std::array object does not support item deletion"); } } %} %define %swig_array_methods(Type...) %swig_sequence_methods_non_resizable(Type) %enddef %define %swig_array_methods_val(Type...) %swig_sequence_methods_non_resizable_val(Type); %enddef %mixin std::array "Enumerable"; %ignore std::array::push_back; %ignore std::array::pop_back; %rename("delete") std::array::__delete__; %rename("reject!") std::array::reject_bang; %rename("map!") std::array::map_bang; %rename("empty?") std::array::empty; %rename("include?" ) std::array::__contains__ const; %rename("has_key?" ) std::array::has_key const; %include swig-3.0.8/Lib/ruby/std_set.i0000664000175000017500000001460312641054563015673 0ustar williamwilliam/* Sets */ %fragment("StdSetTraits","header",fragment="",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const RubySeq& rubyseq, std::set* seq) { // seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(VALUE obj, std::set **s) { return traits_asptr_stdseq >::asptr(obj, s); } }; template struct traits_from > { static VALUE from(const std::set& vec) { return traits_from_stdseq >::from(vec); } }; /** * Set Iterator class for an iterator with no end() boundaries. * */ template::value_type, typename FromOper = from_oper, typename AsvalOper = asval_oper > class SetIteratorOpen_T : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef ValueType value_type; typedef Iterator_T base; typedef SetIteratorOpen_T self_type; public: SetIteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) : Iterator_T(curr, seq) { } virtual VALUE value() const { return from(static_cast(*(base::current))); } // no setValue allowed Iterator *dup() const { return new self_type(*this); } }; /** * Set Iterator class for a iterator where begin() and end() boundaries are known. * */ template::value_type, typename FromOper = from_oper, typename AsvalOper = asval_oper > class SetIteratorClosed_T : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef ValueType value_type; typedef Iterator_T base; typedef SetIteratorClosed_T self_type; protected: virtual Iterator* advance(ptrdiff_t n) { std::advance( base::current, n ); if ( base::current == end ) throw stop_iteration(); return this; } public: SetIteratorClosed_T(nonconst_iter curr, nonconst_iter first, nonconst_iter last, VALUE seq = Qnil) : Iterator_T(curr, seq), begin(first), end(last) { } virtual VALUE value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } // no setValue allowed Iterator *dup() const { return new self_type(*this); } private: nonconst_iter begin; nonconst_iter end; }; // Template specialization to construct a closed iterator for sets // this turns a nonconst iterator into a const one for ruby to avoid // allowing the user to change the value template< typename InOutIter > inline Iterator* make_set_nonconst_iterator(const InOutIter& current, const InOutIter& begin, const InOutIter& end, VALUE seq = Qnil) { return new SetIteratorClosed_T< InOutIter >(current, begin, end, seq); } // Template specialization to construct an open iterator for sets // this turns a nonconst iterator into a const one for ruby to avoid // allowing the user to change the value template< typename InOutIter > inline Iterator* make_set_nonconst_iterator(const InOutIter& current, VALUE seq = Qnil) { return new SetIteratorOpen_T< InOutIter >(current, seq); } } %} %define %swig_sequence_methods_extra_set(Sequence...) %extend { %alias reject_bang "delete_if"; Sequence* reject_bang() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); for ( Sequence::iterator i = $self->begin(); i != $self->end(); ) { VALUE r = swig::from< Sequence::value_type >(*i); Sequence::iterator current = i++; if ( RTEST( rb_yield(r) ) ) $self->erase(current); } return self; } } %enddef %define %swig_set_methods(set...) %swig_sequence_methods_common(%arg(set)); %swig_sequence_methods_extra_set(%arg(set)); %fragment("RubyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="RubySequence_Cont") {} // Redefine std::set iterator/reverse_iterator typemap %typemap(out,noblock=1) iterator, reverse_iterator { $result = SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,const $type &), self), swig::Iterator::descriptor(),SWIG_POINTER_OWN); } // Redefine std::set std::pair typemap %typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator") std::pair { $result = rb_ary_new2(2); rb_ary_push($result, SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first), swig::Iterator::descriptor(),SWIG_POINTER_OWN)); rb_ary_push($result, SWIG_From(bool)(%static_cast($1,const $type &).second)); } %extend { %alias push "<<"; value_type push(const value_type& x) { self->insert(x); return x; } bool __contains__(const value_type& x) { return self->find(x) != self->end(); } value_type __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } }; %enddef %mixin std::set "Enumerable"; %rename("delete") std::set::__delete__; %rename("reject!") std::set::reject_bang; %rename("map!") std::set::map_bang; %rename("empty?") std::set::empty; %rename("include?" ) std::set::__contains__ const; %rename("has_key?" ) std::set::has_key const; %alias std::set::push "<<"; %include swig-3.0.8/Lib/ruby/attribute.i0000664000175000017500000000004212641054563016221 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/rubystrings.swg0000664000175000017500000000304112641054563017163 0ustar williamwilliam/* ------------------------------------------------------------ * utility methods for char strings * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) { if (TYPE(obj) == T_STRING) { char *cstr = StringValuePtr(obj); size_t size = RSTRING_LEN(obj) + 1; if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { *cptr = %new_copy_array(cstr, size, char); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } } if (psize) *psize = size; return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *)vptr; if (psize) *psize = vptr ? (strlen((char*)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE VALUE SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > LONG_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : Qnil; } else { return rb_str_new(carray, %numeric_cast(size,long)); } } else { return Qnil; } } } swig-3.0.8/Lib/ruby/rubykw.swg0000664000175000017500000000223112641054563016113 0ustar williamwilliam#ifndef RUBY_RUBYKW_SWG_ #define RUBY_RUBYKW_SWG_ /* Warnings for Ruby keywords */ #define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, renaming to 'C_" `x` "'",rename="C_%s",fullname=1) `x` /* from http://www.rubycentral.com/book/language.html */ RUBYKW(BEGIN); RUBYKW(END); RUBYKW(alias); RUBYKW(and); RUBYKW(begin); RUBYKW(break); RUBYKW(case); RUBYKW(class); RUBYKW(def); RUBYKW("defined"); RUBYKW(do); RUBYKW(else); RUBYKW(elsif); RUBYKW(end); RUBYKW(ensure); RUBYKW(false); RUBYKW(fatal); RUBYKW(for); RUBYKW(if); RUBYKW(in); RUBYKW(module); RUBYKW(next); RUBYKW(nil); RUBYKW(not); RUBYKW(or); RUBYKW(redo); RUBYKW(rescue); RUBYKW(retry); RUBYKW(return); RUBYKW(self); RUBYKW(super); RUBYKW(then); RUBYKW(true); RUBYKW(undef); RUBYKW(unless); RUBYKW(until); RUBYKW(when); RUBYKW(while); RUBYKW(yield); // RUBYKW(FalseClass); // RUBYKW(TrueClass); // RUBYKW(Numeric); // RUBYKW(Integer); // RUBYKW(Fixnum); // RUBYKW(Float); // RUBYKW(Range); // RUBYKW(Array); // RUBYKW(String); // RUBYKW(IO); // RUBYKW(File); // RUBYKW(FileUtils); // RUBYKW(Find); // RUBYKW(Struct); // RUBYKW(OpenStruct); // RUBYKW(Regexp); #undef RUBYKW #endif //RUBY_RUBYKW_SWG_ swig-3.0.8/Lib/ruby/rubyrun.swg0000664000175000017500000003276412641054563016314 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubyrun.swg * * This file contains the runtime support for Ruby modules * and includes code for managing global variables and pointer * type checking. * ----------------------------------------------------------------------------- */ /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 /* for raw pointers */ #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) #define swig_owntype swig_ruby_owntype /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) #define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg) #define SWIG_fail goto fail /* Ruby-specific SWIG API */ #define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() #define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) #define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) #define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) #define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) #include "assert.h" /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif typedef struct { VALUE klass; VALUE mImpl; void (*mark)(void *); void (*destroy)(void *); int trackObjects; } swig_class; /* Global pointer used to keep some internal SWIG stuff */ static VALUE _cSWIG_Pointer = Qnil; static VALUE swig_runtime_data_type_pointer = Qnil; /* Global IDs used to keep some internal SWIG stuff */ static ID swig_arity_id = 0; static ID swig_call_id = 0; /* If your swig extension is to be run within an embedded ruby and has director callbacks, you should set -DRUBY_EMBEDDED during compilation. This will reset ruby's stack frame on each entry point from the main program the first time a virtual director function is invoked (in a non-recursive way). If this is not done, you run the risk of Ruby trashing the stack. */ #ifdef RUBY_EMBEDDED # define SWIG_INIT_STACK \ if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \ ++swig_virtual_calls; # define SWIG_RELEASE_STACK --swig_virtual_calls; # define Ruby_DirectorTypeMismatchException(x) \ rb_raise( rb_eTypeError, "%s", x ); return c_result; static unsigned int swig_virtual_calls = 0; #else /* normal non-embedded extension */ # define SWIG_INIT_STACK # define SWIG_RELEASE_STACK # define Ruby_DirectorTypeMismatchException(x) \ throw Swig::DirectorTypeMismatchException( x ); #endif /* RUBY_EMBEDDED */ SWIGRUNTIME VALUE getExceptionClass(void) { static int init = 0; static VALUE rubyExceptionClass ; if (!init) { init = 1; rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); } return rubyExceptionClass; } /* This code checks to see if the Ruby object being raised as part of an exception inherits from the Ruby class Exception. If so, the object is simply returned. If not, then a new Ruby exception object is created and that will be returned to Ruby.*/ SWIGRUNTIME VALUE SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { VALUE exceptionClass = getExceptionClass(); if (rb_obj_is_kind_of(obj, exceptionClass)) { return obj; } else { return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); } } /* Initialize Ruby runtime support */ SWIGRUNTIME void SWIG_Ruby_InitRuntime(void) { if (_mSWIG == Qnil) { _mSWIG = rb_define_module("SWIG"); swig_call_id = rb_intern("call"); swig_arity_id = rb_intern("arity"); } } /* Define Ruby class for C type */ SWIGRUNTIME void SWIG_Ruby_define_class(swig_type_info *type) { char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); sprintf(klass_name, "TYPE%s", type->name); if (NIL_P(_cSWIG_Pointer)) { _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); } rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); free((void *) klass_name); } /* Create a new pointer object */ SWIGRUNTIME VALUE SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) { int own = flags & SWIG_POINTER_OWN; int track; char *klass_name; swig_class *sklass; VALUE klass; VALUE obj; if (!ptr) return Qnil; if (type->clientdata) { sklass = (swig_class *) type->clientdata; /* Are we tracking this class and have we already returned this Ruby object? */ track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ if (obj != Qnil) { VALUE value = rb_iv_get(obj, "@__swigtype__"); const char* type_name = RSTRING_PTR(value); if (strcmp(type->name, type_name) == 0) { return obj; } } } /* Create a new Ruby object */ obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), ( own ? VOIDFUNC(sklass->destroy) : (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 ) ), ptr); /* If tracking is on for this class then track this object. */ if (track) { SWIG_RubyAddTracking(ptr, obj); } } else { klass_name = (char *) malloc(4 + strlen(type->name) + 1); sprintf(klass_name, "TYPE%s", type->name); klass = rb_const_get(_mSWIG, rb_intern(klass_name)); free((void *) klass_name); obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); return obj; } /* Create a new class instance (always owned) */ SWIGRUNTIME VALUE SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) { VALUE obj; swig_class *sklass = (swig_class *) type->clientdata; obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); return obj; } /* Get type mangle from class name */ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); return StringValuePtr(stype); } /* Acquire a pointer value */ typedef struct { void (*datafree)(void *); int own; } swig_ruby_owntype; SWIGRUNTIME swig_ruby_owntype SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { swig_ruby_owntype oldown = {0, 0}; if (obj) { oldown.datafree = RDATA(obj)->dfree; RDATA(obj)->dfree = own.datafree; } return oldown; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; void *vptr = 0; /* Grab the pointer */ if (NIL_P(obj)) { if (ptr) *ptr = 0; return SWIG_OK; } else { if (TYPE(obj) != T_DATA) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } if (own) { own->datafree = RDATA(obj)->dfree; own->own = 0; } /* Check to see if the input object is giving up ownership of the underlying C struct or C++ object. If so then we need to reset the destructor since the Ruby object no longer owns the underlying C++ object.*/ if (flags & SWIG_POINTER_DISOWN) { /* Is tracking on for this class? */ int track = 0; if (ty && ty->clientdata) { swig_class *sklass = (swig_class *) ty->clientdata; track = sklass->trackObjects; } if (track) { /* We are tracking objects for this class. Thus we change the destructor * to SWIG_RubyRemoveTracking. This allows us to * remove the mapping from the C++ to Ruby object * when the Ruby object is garbage collected. If we don't * do this, then it is possible we will return a reference * to a Ruby object that no longer exists thereby crashing Ruby. */ RDATA(obj)->dfree = SWIG_RubyRemoveTracking; } else { RDATA(obj)->dfree = 0; } } /* Do type-checking if type info was provided */ if (ty) { if ((c = SWIG_MangleStr(obj)) == NULL) { return SWIG_ERROR; } tc = SWIG_TypeCheck(c, ty); if (!tc) { return SWIG_ERROR; } else { if (vptr == 0) { /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } if (ptr) { if (tc->type == ty) { *ptr = vptr; } else { int newmemory = 0; *ptr = SWIG_TypeCast(tc, vptr, &newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) own->own = own->own | SWIG_CAST_NEW_MEMORY; } } } } } else { if (ptr) *ptr = vptr; } return SWIG_OK; } /* Check convert */ SWIGRUNTIMEINLINE int SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) { char *c = SWIG_MangleStr(obj); if (!c) return 0; return SWIG_TypeCheck(c,ty) != 0; } SWIGRUNTIME VALUE SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; *(r++) = '_'; r = SWIG_PackData(r, ptr, sz); strcpy(r, type->name); return rb_str_new2(result); } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; const char *c; if (TYPE(obj) != T_STRING) goto type_error; c = StringValuePtr(obj); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; c = SWIG_UnpackData(c, ptr, sz); if (ty) { tc = SWIG_TypeCheck(c, ty); if (!tc) goto type_error; } return SWIG_OK; type_error: return SWIG_ERROR; } SWIGRUNTIME swig_module_info * SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata)) { VALUE pointer; swig_module_info *ret = 0; VALUE verbose = rb_gv_get("VERBOSE"); /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ rb_gv_set("VERBOSE", Qfalse); /* first check if pointer already created */ pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); if (pointer != Qnil) { Data_Get_Struct(pointer, swig_module_info, ret); } /* reinstate warnings */ rb_gv_set("VERBOSE", verbose); return ret; } SWIGRUNTIME void SWIG_Ruby_SetModule(swig_module_info *pointer) { /* register a new class */ VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); /* create and store the structure pointer to a global variable */ swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); } /* This function can be used to check whether a proc or method or similarly callable function has been passed. Usually used in a %typecheck, like: %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) { $result = SWIG_Ruby_isCallable( $input ); } */ SWIGINTERN int SWIG_Ruby_isCallable( VALUE proc ) { if ( rb_respond_to( proc, swig_call_id ) ) return 1; return 0; } /* This function can be used to check the arity (number of arguments) a proc or method can take. Usually used in a %typecheck. Valid arities will be that equal to minimal or those < 0 which indicate a variable number of parameters at the end. */ SWIGINTERN int SWIG_Ruby_arity( VALUE proc, int minimal ) { if ( rb_respond_to( proc, swig_arity_id ) ) { VALUE num = rb_funcall( proc, swig_arity_id, 0 ); int arity = NUM2INT(num); if ( arity < 0 && (arity+1) < -minimal ) return 1; if ( arity == minimal ) return 1; return 1; } return 0; } #ifdef __cplusplus } #endif swig-3.0.8/Lib/ruby/rubyprimtypes.swg0000664000175000017500000001215412641054563017533 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubyprimtypes.swg * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * Primitive Types * ------------------------------------------------------------ */ /* auxiliary ruby fail method */ %fragment("SWIG_ruby_failed","header") { SWIGINTERN VALUE SWIG_ruby_failed(void) { return Qnil; } } %define %ruby_aux_method(Type, Method, Action) SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE *args) { VALUE obj = args[0]; VALUE type = TYPE(obj); Type *res = (Type *)(args[1]); *res = Action; return obj; } %enddef /* boolean */ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE VALUE SWIG_From_dec(bool)(bool value) { return value ? Qtrue : Qfalse; } } %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(int)) { SWIGINTERN int SWIG_AsVal_dec(bool)(VALUE obj, bool *val) { if (obj == Qtrue) { if (val) *val = true; return SWIG_OK; } else if (obj == Qfalse) { if (val) *val = false; return SWIG_OK; } else { int res = 0; if (SWIG_AsVal(int)(obj, &res) == SWIG_OK) { if (val) *val = res ? true : false; return SWIG_OK; } } return SWIG_TypeError; } } /* long */ %fragment(SWIG_From_frag(long),"header", fragment="") { %define_as(SWIG_From_dec(long), LONG2NUM) } %fragment(SWIG_AsVal_frag(long),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(long, NUM2LONG, type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj)) SWIGINTERN int SWIG_AsVal_dec(long)(VALUE obj, long* val) { VALUE type = TYPE(obj); if ((type == T_FIXNUM) || (type == T_BIGNUM)) { long v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } /* unsigned long */ %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE VALUE SWIG_From_dec(unsigned long)(unsigned long value) { return ULONG2NUM(value); } } %fragment(SWIG_AsVal_frag(unsigned long),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(unsigned long, NUM2ULONG, type == T_FIXNUM ? NUM2ULONG(obj) : rb_big2ulong(obj)) SWIGINTERN int SWIG_AsVal_dec(unsigned long)(VALUE obj, unsigned long *val) { VALUE type = TYPE(obj); if ((type == T_FIXNUM) || (type == T_BIGNUM)) { unsigned long v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } /* long long */ %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), fragment="") { SWIGINTERNINLINE VALUE SWIG_From_dec(long long)(long long value) { return LL2NUM(value); } } %fragment(SWIG_AsVal_frag(long long),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(long long, NUM2LL, type == T_FIXNUM ? NUM2LL(obj) : rb_big2ll(obj)) SWIGINTERN int SWIG_AsVal_dec(long long)(VALUE obj, long long *val) { VALUE type = TYPE(obj); if ((type == T_FIXNUM) || (type == T_BIGNUM)) { long long v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), fragment="") { SWIGINTERNINLINE VALUE SWIG_From_dec(unsigned long long)(unsigned long long value) { return ULL2NUM(value); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(long long, NUM2ULL, type == T_FIXNUM ? NUM2ULL(obj) : rb_big2ull(obj)) SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val) { VALUE type = TYPE(obj); if ((type == T_FIXNUM) || (type == T_BIGNUM)) { unsigned long long v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } /* double */ %fragment(SWIG_From_frag(double),"header") { %define_as(SWIG_From_dec(double), rb_float_new) } %fragment(SWIG_AsVal_frag(double),"header",fragment="SWIG_ruby_failed") { %ruby_aux_method(double, NUM2DBL, NUM2DBL(obj); (void)type) SWIGINTERN int SWIG_AsVal_dec(double)(VALUE obj, double *val) { VALUE type = TYPE(obj); if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) { double v; VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } } swig-3.0.8/Lib/ruby/rubyhead.swg0000664000175000017500000001027112641054563016376 0ustar williamwilliam#include /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which * breaks using rb_intern as an lvalue, as SWIG does. We work around this * issue for now by disabling this. * https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645 */ #ifdef rb_intern # undef rb_intern #endif /* Remove global macros defined in Ruby's win32.h */ #ifdef write # undef write #endif #ifdef read # undef read #endif #ifdef bind # undef bind #endif #ifdef close # undef close #endif #ifdef connect # undef connect #endif /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ #ifndef NUM2LL #define NUM2LL(x) NUM2LONG((x)) #endif #ifndef LL2NUM #define LL2NUM(x) INT2NUM((long) (x)) #endif #ifndef ULL2NUM #define ULL2NUM(x) UINT2NUM((unsigned long) (x)) #endif /* Ruby 1.7 doesn't (yet) define NUM2ULL() */ #ifndef NUM2ULL #ifdef HAVE_LONG_LONG #define NUM2ULL(x) rb_num2ull((x)) #else #define NUM2ULL(x) NUM2ULONG(x) #endif #endif /* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */ /* Define these for older versions so we can just write code the new way */ #ifndef RSTRING_LEN # define RSTRING_LEN(x) RSTRING(x)->len #endif #ifndef RSTRING_PTR # define RSTRING_PTR(x) RSTRING(x)->ptr #endif #ifndef RSTRING_END # define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x)) #endif #ifndef RARRAY_LEN # define RARRAY_LEN(x) RARRAY(x)->len #endif #ifndef RARRAY_PTR # define RARRAY_PTR(x) RARRAY(x)->ptr #endif #ifndef RFLOAT_VALUE # define RFLOAT_VALUE(x) RFLOAT(x)->value #endif #ifndef DOUBLE2NUM # define DOUBLE2NUM(x) rb_float_new(x) #endif #ifndef RHASH_TBL # define RHASH_TBL(x) (RHASH(x)->tbl) #endif #ifndef RHASH_ITER_LEV # define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev) #endif #ifndef RHASH_IFNONE # define RHASH_IFNONE(x) (RHASH(x)->ifnone) #endif #ifndef RHASH_SIZE # define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries) #endif #ifndef RHASH_EMPTY_P # define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0) #endif #ifndef RSTRUCT_LEN # define RSTRUCT_LEN(x) RSTRUCT(x)->len #endif #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif /* * Need to be very careful about how these macros are defined, especially * when compiling C++ code or C code with an ANSI C compiler. * * VALUEFUNC(f) is a macro used to typecast a C function that implements * a Ruby method so that it can be passed as an argument to API functions * like rb_define_method() and rb_define_singleton_method(). * * VOIDFUNC(f) is a macro used to typecast a C function that implements * either the "mark" or "free" stuff for a Ruby Data object, so that it * can be passed as an argument to API functions like Data_Wrap_Struct() * and Data_Make_Struct(). */ #ifdef __cplusplus # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ # define PROTECTFUNC(f) ((VALUE (*)()) f) # define VALUEFUNC(f) ((VALUE (*)()) f) # define VOIDFUNC(f) ((void (*)()) f) # else # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ # define PROTECTFUNC(f) ((VALUE (*)()) f) # define VALUEFUNC(f) ((VALUE (*)()) f) # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) # else /* These definitions should work for Ruby 1.7+ */ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) # endif # endif #else # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) #endif /* Don't use for expressions have side effect */ #ifndef RB_STRING_VALUE #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) #endif #ifndef StringValue #define StringValue(s) RB_STRING_VALUE(s) #endif #ifndef StringValuePtr #define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s)) #endif #ifndef StringValueLen #define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s)) #endif #ifndef SafeStringValue #define SafeStringValue(v) do {\ StringValue(v);\ rb_check_safe_str(v);\ } while (0) #endif #ifndef HAVE_RB_DEFINE_ALLOC_FUNC #define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) #define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") #endif static VALUE _mSWIG = Qnil; swig-3.0.8/Lib/ruby/std_string.i0000664000175000017500000000027612641054563016407 0ustar williamwilliam %warnfilter(801) std::string; // wrong class name %warnfilter(378) std::basic_string::operator!=; AUTODOC(substr, "Return a portion of the String"); %include swig-3.0.8/Lib/ruby/timeval.i0000664000175000017500000000223412641054563015664 0ustar williamwilliam/* struct timeval * time_t Ruby has builtin class Time. INPUT/OUTPUT typemap for timeval and time_t is provided. */ %{ #ifdef __cplusplus extern "C" { #endif #ifdef HAVE_SYS_TIME_H # include struct timeval rb_time_timeval(VALUE); #endif #ifdef __cplusplus } #endif %} %typemap(in) struct timeval *INPUT (struct timeval temp) { if (NIL_P($input)) $1 = NULL; else { temp = rb_time_timeval($input); $1 = &temp; } } %typemap(in,numinputs=0) struct timeval *OUTPUT(struct timeval temp) { $1 = &temp; } %typemap(argout) struct timeval *OUTPUT { $result = rb_time_new($1->tv_sec, $1->tv_usec); } %typemap(out) struct timeval * { $result = rb_time_new($1->tv_sec, $1->tv_usec); } %typemap(out) struct timespec * { $result = rb_time_new($1->tv_sec, $1->tv_nsec / 1000); } // time_t %typemap(in) time_t { if (NIL_P($input)) $1 = (time_t)-1; else $1 = NUM2LONG(rb_funcall($input, rb_intern("tv_sec"), 0)); } %typemap(typecheck) time_t { $1 = (NIL_P($input) || TYPE(rb_funcall($input, rb_intern("respond_to?"), 1, ID2SYM(rb_intern("tv_sec")))) == T_TRUE); } %typemap(out) time_t { $result = rb_time_new($1, 0); } swig-3.0.8/Lib/ruby/std_stack.i0000664000175000017500000000152512641054563016204 0ustar williamwilliam/* Stacks */ %fragment("StdStackTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::stack **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::stack & vec) { return traits_from_stdseq >::from(vec); } }; } %} %rename("delete") std::stack::__delete__; %rename("reject!") std::stack::reject_bang; %rename("map!") std::stack::map_bang; %rename("empty?") std::stack::empty; %rename("include?" ) std::stack::__contains__ const; %rename("has_key?" ) std::stack::has_key const; %alias std::stack::push "<<"; %include swig-3.0.8/Lib/ruby/stl.i0000664000175000017500000000054512641054563015030 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/ruby/boost_shared_ptr.i0000664000175000017500000003764512641054563017602 0ustar williamwilliam%include // Set SHARED_PTR_DISOWN to $disown if required, for example // #define SHARED_PTR_DISOWN $disown #if !defined(SHARED_PTR_DISOWN) #define SHARED_PTR_DISOWN 0 #endif %fragment("SWIG_null_deleter_python", "header", fragment="SWIG_null_deleter") { %#define SWIG_NO_NULL_DELETER_SWIG_BUILTIN_INIT } // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE %{(void)arg1; delete reinterpret_cast< SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > * >(self);%} // Typemap customisations... // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(out) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE { void *argp = 0; swig_ruby_owntype newmem = {0, 0}; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(varout) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem.own & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE * { void *argp = 0; swig_ruby_owntype newmem = {0, 0}; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; if (newmem.own & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem.own & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE & { void *argp = 0; swig_ruby_owntype newmem = {0, 0}; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; if (!argp) { %variable_nullref("$type", "$name"); } if (newmem.own & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = *%const_cast(tempshared.get(), $1_ltype); } else { $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer by reference // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem.own & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); temp = %const_cast(tempshared.get(), $*1_ltype); } else { temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); } $1 = &temp; } %typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} %typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { swig_ruby_owntype newmem = {0, 0}; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem.own & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varout typemap not implemented" %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem.own & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); if ($owner) delete $1; } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varout typemap not implemented" %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); temp = &tempshared; $1 = &temp; } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varout typemap not implemented" %} // Typecheck typemaps // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); $1 = SWIG_CheckState(res); } // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/ruby/rubytracking.swg0000664000175000017500000001054012641054563017276 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubytracking.swg * * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif #if !defined(ST_DATA_T_DEFINED) /* Needs to be explicitly included for Ruby 1.8 and earlier */ #include #endif /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) # define NUM2SWIG(x) (unsigned long)NUM2LONG(x) #elif SIZEOF_VOIDP == SIZEOF_LONG_LONG # define SWIG2NUM(v) LL2NUM((unsigned long long)v) # define NUM2SWIG(x) (unsigned long long)NUM2LL(x) #else # error sizeof(void*) is not the same as long or long long #endif /* Global hash table to store Trackings from C/C++ structs to Ruby Objects. */ static st_table* swig_ruby_trackings = NULL; static VALUE swig_ruby_trackings_count(ANYARGS) { return SWIG2NUM(swig_ruby_trackings->num_entries); } /* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ VALUE trackings_value = Qnil; /* change the variable name so that we can mix modules compiled with older SWIG's - this used to be called "@__trackings__" */ ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); /* The trick here is that we have to store the hash table pointer in a Ruby variable. We do not want Ruby's GC to treat this pointer as a Ruby object, so we convert it to a Ruby numeric value. */ if (trackings_value == Qnil) { /* No, it hasn't. Create one ourselves */ swig_ruby_trackings = st_init_numtable(); rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); } else { swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); } rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", swig_ruby_trackings_count, NULL); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { /* Store the mapping to the global hash table. */ st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { /* Now lookup the value stored in the global hash table */ VALUE value; if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { return value; } else { return Qnil; } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It is very important to remove objects once they are destroyed since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { /* Delete the object from the hash table */ st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the Ruby object is longer than the C++ object */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { if (TYPE(object) != T_DATA) abort(); DATA_PTR(object) = 0; } } /* This is a helper method that iterates over all the trackings passing the C++ object pointer and its related Ruby object to the passed callback function. */ /* Proxy method to abstract the internal trackings datatype */ static int swig_ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) { (*meth)(ptr, obj); return ST_CONTINUE; } SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&swig_ruby_internal_iterate_callback, (st_data_t)meth); } #ifdef __cplusplus } #endif swig-3.0.8/Lib/ruby/std_functors.i0000664000175000017500000000140012641054563016732 0ustar williamwilliam/** * @file std_functors.i * @date Sun May 6 00:44:33 2007 * * @brief This file provides unary and binary functors for STL * containers, that will invoke a Ruby proc or method to do * their operation. * * You can use them in a swig file like: * * %include * %include * * %template< IntSet > std::set< int, swig::BinaryPredicate >; * * * which will then allow calling them from Ruby either like: * * # order of set is defined by C++ default * a = IntSet.new * * # sort order defined by Ruby proc * b = IntSet.new( proc { |a,b| a > b } ) * */ %include %fragment("StdFunctors"); swig-3.0.8/Lib/ruby/file.i0000664000175000017500000000120212641054563015134 0ustar williamwilliam// FILE * %{ #ifdef __cplusplus extern "C" { #endif /* Ruby 1.9 changed the file name of this header */ #ifdef HAVE_RUBY_IO_H #include "ruby/io.h" #else #include "rubyio.h" #endif #ifdef __cplusplus } #endif %} %typemap(in) FILE *READ { OpenFile *of; GetOpenFile($input, of); rb_io_check_readable(of); $1 = GetReadFile(of); rb_read_check($1); } %typemap(in) FILE *READ_NOCHECK { OpenFile *of; GetOpenFile($input, of); rb_io_check_readable(of); $1 = GetReadFile(of); } %typemap(in) FILE *WRITE { OpenFile *of; GetOpenFile($input, of); rb_io_check_writable(of); $1 = GetWriteFile(of); } swig-3.0.8/Lib/ruby/rubyerrors.swg0000664000175000017500000000720212641054563017011 0ustar williamwilliam/* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ /* Define some additional error types */ #define SWIG_ObjectPreviouslyDeletedError -100 /* Define custom exceptions for errors that do not map to existing Ruby exceptions. Note this only works for C++ since a global cannot be initialized by a function in C. For C, fallback to rb_eRuntimeError.*/ SWIGINTERN VALUE getNullReferenceError(void) { static int init = 0; static VALUE rb_eNullReferenceError ; if (!init) { init = 1; rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); } return rb_eNullReferenceError; } SWIGINTERN VALUE getObjectPreviouslyDeletedError(void) { static int init = 0; static VALUE rb_eObjectPreviouslyDeleted ; if (!init) { init = 1; rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); } return rb_eObjectPreviouslyDeleted; } SWIGINTERN VALUE SWIG_Ruby_ErrorType(int SWIG_code) { VALUE type; switch (SWIG_code) { case SWIG_MemoryError: type = rb_eNoMemError; break; case SWIG_IOError: type = rb_eIOError; break; case SWIG_RuntimeError: type = rb_eRuntimeError; break; case SWIG_IndexError: type = rb_eIndexError; break; case SWIG_TypeError: type = rb_eTypeError; break; case SWIG_DivisionByZero: type = rb_eZeroDivError; break; case SWIG_OverflowError: type = rb_eRangeError; break; case SWIG_SyntaxError: type = rb_eSyntaxError; break; case SWIG_ValueError: type = rb_eArgError; break; case SWIG_SystemError: type = rb_eFatal; break; case SWIG_AttributeError: type = rb_eRuntimeError; break; case SWIG_NullReferenceError: type = getNullReferenceError(); break; case SWIG_ObjectPreviouslyDeletedError: type = getObjectPreviouslyDeletedError(); break; case SWIG_UnknownError: type = rb_eRuntimeError; break; default: type = rb_eRuntimeError; } return type; } /* This function is called when a user inputs a wrong argument to a method. */ SWIGINTERN const char* Ruby_Format_TypeError( const char* msg, const char* type, const char* name, const int argn, VALUE input ) { char buf[128]; VALUE str; VALUE asStr; if ( msg && *msg ) { str = rb_str_new2(msg); } else { str = rb_str_new(NULL, 0); } str = rb_str_cat2( str, "Expected argument " ); sprintf( buf, "%d of type ", argn-1 ); str = rb_str_cat2( str, buf ); str = rb_str_cat2( str, type ); str = rb_str_cat2( str, ", but got " ); str = rb_str_cat2( str, rb_obj_classname(input) ); str = rb_str_cat2( str, " " ); asStr = rb_inspect(input); if ( RSTRING_LEN(asStr) > 30 ) { str = rb_str_cat( str, StringValuePtr(asStr), 30 ); str = rb_str_cat2( str, "..." ); } else { str = rb_str_append( str, asStr ); } if ( name ) { str = rb_str_cat2( str, "\n\tin SWIG method '" ); str = rb_str_cat2( str, name ); str = rb_str_cat2( str, "'" ); } return StringValuePtr( str ); } /* This function is called when an overloaded method fails */ SWIGINTERN void Ruby_Format_OverloadedError( const int argc, const int maxargs, const char* method, const char* prototypes ) { const char* msg = "Wrong # of arguments"; if ( argc <= maxargs ) msg = "Wrong arguments"; rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n" "Possible C/C++ prototypes are:\n%s", msg, method, prototypes); } swig-3.0.8/Lib/ruby/rubyiterators.swg0000664000175000017500000005444712641054563017526 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubyiterators.swg * * Implement a C++ 'output' iterator for Ruby. * * Users can derive form the Iterator to implemet their * own iterators. As an example (real one since we use it for STL/STD * containers), the template Iterator_T does the * implementation for generic C++ iterators. * ----------------------------------------------------------------------------- */ %include %fragment("ConstIterator","header",fragment="",fragment="GC_VALUE_definition") { namespace swig { struct stop_iteration { }; /** * Abstract base class used to represent all iterators of STL containers. */ struct ConstIterator { public: typedef ConstIterator self_type; protected: GC_VALUE _seq; protected: ConstIterator(VALUE seq) : _seq(seq) { } // Random access iterator methods, but not required in Ruby virtual ptrdiff_t distance(const ConstIterator &x) const { throw std::invalid_argument("distance not supported"); } virtual bool equal (const ConstIterator &x) const { throw std::invalid_argument("equal not supported"); } virtual self_type* advance(ptrdiff_t n) { throw std::invalid_argument("advance not supported"); } public: virtual ~ConstIterator() {} // Access iterator method, required by Ruby virtual VALUE value() const { throw std::invalid_argument("value not supported"); return Qnil; }; virtual VALUE setValue( const VALUE& v ) { throw std::invalid_argument("value= not supported"); return Qnil; } virtual self_type* next( size_t n = 1 ) { return this->advance( n ); } virtual self_type* previous( size_t n = 1 ) { ptrdiff_t nn = n; return this->advance( -nn ); } virtual VALUE to_s() const { throw std::invalid_argument("to_s not supported"); return Qnil; } virtual VALUE inspect() const { throw std::invalid_argument("inspect not supported"); return Qnil; } virtual ConstIterator *dup() const { throw std::invalid_argument("dup not supported"); return NULL; } // // C++ common/needed methods. We emulate a bidirectional // operator, to be compatible with all the STL. // The iterator traits will then tell the STL what type of // iterator we really are. // ConstIterator() : _seq( Qnil ) { } ConstIterator( const self_type& b ) : _seq( b._seq ) { } self_type& operator=( const self_type& b ) { _seq = b._seq; return *this; } bool operator == (const ConstIterator& x) const { return equal(x); } bool operator != (const ConstIterator& x) const { return ! operator==(x); } // Pre-decrement operator self_type& operator--() { return *previous(); } // Pre-increment operator self_type& operator++() { return *next(); } // Post-decrement operator self_type operator--(int) { self_type r = *this; previous(); return r; } // Post-increment operator self_type operator++(int) { self_type r = *this; next(); return r; } ConstIterator& operator += (ptrdiff_t n) { return *advance(n); } ConstIterator& operator -= (ptrdiff_t n) { return *advance(-n); } ConstIterator* operator + (ptrdiff_t n) const { return dup()->advance(n); } ConstIterator* operator - (ptrdiff_t n) const { return dup()->advance(-n); } ptrdiff_t operator - (const ConstIterator& x) const { return x.distance(*this); } static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::ConstIterator *"); init = 1; } return desc; } }; /** * Abstract base class used to represent all non-const iterators of STL containers. * */ struct Iterator : public ConstIterator { public: typedef Iterator self_type; protected: Iterator(VALUE seq) : ConstIterator(seq) { } virtual self_type* advance(ptrdiff_t n) { throw std::invalid_argument("operation not supported"); } public: static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::Iterator *"); init = 1; } return desc; } virtual Iterator *dup() const { throw std::invalid_argument("dup not supported"); return NULL; } virtual self_type* next( size_t n = 1 ) { return this->advance( n ); } virtual self_type* previous( size_t n = 1 ) { ptrdiff_t nn = n; return this->advance( -nn ); } bool operator == (const ConstIterator& x) const { return equal(x); } bool operator != (const Iterator& x) const { return ! operator==(x); } Iterator& operator += (ptrdiff_t n) { return *advance(n); } Iterator& operator -= (ptrdiff_t n) { return *advance(-n); } Iterator* operator + (ptrdiff_t n) const { return dup()->advance(n); } Iterator* operator - (ptrdiff_t n) const { return dup()->advance(-n); } ptrdiff_t operator - (const Iterator& x) const { return x.distance(*this); } }; } } %fragment("ConstIterator_T","header",fragment="",fragment="ConstIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { /** * Templated base classes for all custom const_iterators. * */ template class ConstIterator_T : public ConstIterator { public: typedef OutConstIterator const_iter; typedef typename std::iterator_traits::value_type value_type; typedef ConstIterator_T self_type; protected: virtual bool equal (const ConstIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } virtual ptrdiff_t distance(const ConstIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } virtual ConstIterator* advance(ptrdiff_t n) { std::advance( current, n ); return this; } public: ConstIterator_T() : ConstIterator(Qnil) { } ConstIterator_T(const_iter curr, VALUE seq = Qnil) : ConstIterator(seq), current(curr) { } const const_iter& get_current() const { return current; } const value_type& operator*() const { return *current; } virtual VALUE inspect() const { VALUE ret = rb_str_new2("#<"); ret = rb_str_cat2( ret, rb_obj_classname(_seq) ); ret = rb_str_cat2( ret, "::const_iterator " ); VALUE cur = value(); ret = rb_str_concat( ret, rb_inspect(cur) ); ret = rb_str_cat2( ret, ">" ); return ret; } virtual VALUE to_s() const { VALUE ret = rb_str_new2( rb_obj_classname(_seq) ); ret = rb_str_cat2( ret, "::const_iterator " ); VALUE cur = value(); ret = rb_str_concat( ret, rb_obj_as_string(cur) ); return ret; } protected: const_iter current; }; /** * Templated base classes for all custom non-const iterators. * */ template class Iterator_T : public Iterator { public: typedef InOutIterator nonconst_iter; // Make this class iterator STL compatible, by using iterator_traits typedef typename std::iterator_traits::iterator_category iterator_category; typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::pointer pointer; typedef typename std::iterator_traits::reference reference; typedef Iterator base; typedef Iterator_T< nonconst_iter > self_type; protected: virtual bool equal (const ConstIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } virtual ptrdiff_t distance(const ConstIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } virtual Iterator* advance(ptrdiff_t n) { std::advance( current, n ); return this; } public: Iterator_T(nonconst_iter curr, VALUE seq = Qnil) : Iterator(seq), current(curr) { } const nonconst_iter& get_current() const { return current; } self_type& operator=( const self_type& b ) { base::operator=( b ); return *this; } self_type& operator=( const value_type& b ) { *current = b; return *this; } const value_type& operator*() const { return *current; } value_type& operator*() { return *current; } virtual VALUE inspect() const { VALUE ret = rb_str_new2("#<"); ret = rb_str_cat2( ret, rb_obj_classname(_seq) ); ret = rb_str_cat2( ret, "::iterator " ); VALUE cur = value(); ret = rb_str_concat( ret, rb_inspect(cur) ); ret = rb_str_cat2( ret, ">" ); return ret; } virtual VALUE to_s() const { VALUE ret = rb_str_new2( rb_obj_classname(_seq) ); ret = rb_str_cat2( ret, "::iterator " ); VALUE cur = value(); ret = rb_str_concat( ret, rb_obj_as_string(cur) ); return ret; } protected: nonconst_iter current; }; /** * Auxiliary functor to store the value of a ruby object inside * a reference of a compatible C++ type. ie: Ruby -> C++ * */ template struct asval_oper { typedef ValueType value_type; typedef bool result_type; bool operator()(VALUE obj, value_type& v) const { return ( swig::asval< value_type >(obj, &v) == SWIG_OK ); } }; /** * Auxiliary functor to return a ruby object from a C++ type. * ie: C++ -> Ruby * */ template struct from_oper { typedef const ValueType& argument_type; typedef VALUE result_type; result_type operator()(argument_type v) const { return swig::from(v); } }; /** * ConstIterator class for a const_iterator with no end() boundaries. * */ template::value_type, typename FromOper = from_oper > class ConstIteratorOpen_T : public ConstIterator_T { public: FromOper from; typedef OutConstIterator const_iter; typedef ValueType value_type; typedef ConstIterator_T base; typedef ConstIteratorOpen_T self_type; ConstIteratorOpen_T(const_iter curr, VALUE seq = Qnil) : ConstIterator_T(curr, seq) { } virtual VALUE value() const { return from(static_cast(*(base::current))); } ConstIterator *dup() const { return new self_type(*this); } }; /** * Iterator class for an iterator with no end() boundaries. * */ template::value_type, typename FromOper = from_oper, typename AsvalOper = asval_oper > class IteratorOpen_T : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef ValueType value_type; typedef Iterator_T base; typedef IteratorOpen_T self_type; public: IteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) : Iterator_T(curr, seq) { } virtual VALUE value() const { return from(static_cast(*(base::current))); } virtual VALUE setValue( const VALUE& v ) { value_type& dst = *base::current; if ( asval(v, dst) ) return v; return Qnil; } Iterator *dup() const { return new self_type(*this); } }; /** * ConstIterator class for a const_iterator where begin() and end() boundaries are known. * */ template::value_type, typename FromOper = from_oper > class ConstIteratorClosed_T : public ConstIterator_T { public: FromOper from; typedef OutConstIterator const_iter; typedef ValueType value_type; typedef ConstIterator_T base; typedef ConstIteratorClosed_T self_type; protected: virtual ConstIterator* advance(ptrdiff_t n) { std::advance( base::current, n ); if ( base::current == end ) throw stop_iteration(); return this; } public: ConstIteratorClosed_T(const_iter curr, const_iter first, const_iter last, VALUE seq = Qnil) : ConstIterator_T(curr, seq), begin(first), end(last) { } virtual VALUE value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } ConstIterator *dup() const { return new self_type(*this); } private: const_iter begin; const_iter end; }; /** * Iterator class for a iterator where begin() and end() boundaries are known. * */ template::value_type, typename FromOper = from_oper, typename AsvalOper = asval_oper > class IteratorClosed_T : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef ValueType value_type; typedef Iterator_T base; typedef IteratorClosed_T self_type; protected: virtual Iterator* advance(ptrdiff_t n) { std::advance( base::current, n ); if ( base::current == end ) throw stop_iteration(); return this; } public: IteratorClosed_T(nonconst_iter curr, nonconst_iter first, nonconst_iter last, VALUE seq = Qnil) : Iterator_T(curr, seq), begin(first), end(last) { } virtual VALUE value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } // Iterator setter method, required by Ruby virtual VALUE setValue( const VALUE& v ) { if (base::current == end) throw stop_iteration(); value_type& dst = *base::current; if ( asval( v, dst ) ) return v; return Qnil; } Iterator *dup() const { return new self_type(*this); } private: nonconst_iter begin; nonconst_iter end; }; /* Partial specialization for bools which don't allow de-referencing */ template< typename InOutIterator, typename FromOper, typename AsvalOper > class IteratorOpen_T< InOutIterator, bool, FromOper, AsvalOper > : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef bool value_type; typedef Iterator_T base; typedef IteratorOpen_T self_type; IteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) : Iterator_T(curr, seq) { } virtual VALUE value() const { return from(static_cast(*(base::current))); } virtual VALUE setValue( const VALUE& v ) { bool tmp = *base::current; if ( asval( v, tmp ) ) { *base::current = tmp; return v; } return Qnil; } Iterator *dup() const { return new self_type(*this); } }; /* Partial specialization for bools which don't allow de-referencing */ template< typename InOutIterator, typename FromOper, typename AsvalOper > class IteratorClosed_T< InOutIterator, bool, FromOper, AsvalOper > : public Iterator_T { public: FromOper from; AsvalOper asval; typedef InOutIterator nonconst_iter; typedef bool value_type; typedef Iterator_T base; typedef IteratorClosed_T self_type; protected: virtual Iterator* advance(ptrdiff_t n) { std::advance( base::current, n ); if ( base::current == end ) throw stop_iteration(); return this; } public: IteratorClosed_T(nonconst_iter curr, nonconst_iter first, nonconst_iter last, VALUE seq = Qnil) : Iterator_T(curr, seq), begin(first), end(last) { } virtual VALUE value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } virtual VALUE setValue( const VALUE& v ) { if (base::current == end) throw stop_iteration(); bool tmp = *base::current; if ( asval( v, tmp ) ) { *base::current = tmp; return v; } return Qnil; } Iterator *dup() const { return new self_type(*this); } private: nonconst_iter begin; nonconst_iter end; }; /** * Helper function used to wrap a bounded const_iterator. This is to be used in * a %typemap(out), for example. * */ template inline Iterator* make_nonconst_iterator(const InOutIter& current, const InOutIter& begin, const InOutIter& end, VALUE seq = Qnil) { return new IteratorClosed_T(current, begin, end, seq); } /** * Helper function used to wrap an unbounded const_iterator. This is to be used in * a %typemap(out), for example. * */ template inline Iterator* make_nonconst_iterator(const InOutIter& current, VALUE seq = Qnil) { return new IteratorOpen_T(current, seq); } /** * Helper function used to wrap a bounded const_iterator. This is to be used in * a %typemap(out), for example. * */ template inline ConstIterator* make_const_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, VALUE seq = Qnil) { return new ConstIteratorClosed_T(current, begin, end, seq); } /** * Helper function used to wrap an unbounded const_iterator. This is to be used in * a %typemap(out), for example. * */ template inline ConstIterator* make_const_iterator(const OutIter& current, VALUE seq = Qnil) { return new ConstIteratorOpen_T(current, seq); } } } %fragment("ConstIterator"); // // This part is just so SWIG is aware of the base abstract iterator class. // namespace swig { /* Throw a StopIteration exception */ %ignore stop_iteration; struct stop_iteration {}; %typemap(throws) stop_iteration { (void)$1; SWIG_Ruby_ExceptionType(NULL, Qnil); SWIG_fail; } /* Mark methods that return new objects */ %newobject ConstIterator::dup; %newobject ConstIterator::operator + (ptrdiff_t n) const; %newobject ConstIterator::operator - (ptrdiff_t n) const; %nodirector ConstIterator; %catches(swig::stop_iteration) ConstIterator::value() const; %catches(swig::stop_iteration) ConstIterator::incr(size_t n = 1); %catches(swig::stop_iteration) ConstIterator::decr(size_t n = 1); %catches(std::invalid_argument) ConstIterator::distance(const ConstIterator &x) const; %catches(std::invalid_argument) ConstIterator::equal (const ConstIterator &x) const; %catches(swig::stop_iteration) ConstIterator::next(); %catches(swig::stop_iteration) ConstIterator::previous(); %catches(swig::stop_iteration) ConstIterator::advance(ptrdiff_t n); %catches(swig::stop_iteration) ConstIterator::operator += (ptrdiff_t n); %catches(swig::stop_iteration) ConstIterator::operator -= (ptrdiff_t n); %catches(swig::stop_iteration) ConstIterator::operator + (ptrdiff_t n) const; %catches(swig::stop_iteration) ConstIterator::operator - (ptrdiff_t n) const; struct ConstIterator { protected: ConstIterator(VALUE seq); public: virtual ~ConstIterator(); // Access iterator method, required by Ruby virtual VALUE value() const; // C++ common/needed methods virtual ConstIterator *dup() const; virtual VALUE inspect() const; virtual VALUE to_s() const; virtual ConstIterator* next(size_t n = 1); virtual ConstIterator* previous(size_t n = 1); bool operator == (const ConstIterator& x) const; ConstIterator* operator + (ptrdiff_t n) const; ConstIterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const ConstIterator& x) const; }; struct Iterator : public ConstIterator { %rename("value=") setValue( const VALUE& v ); virtual VALUE setValue( const VALUE& v ); virtual Iterator *dup() const; virtual Iterator* next(size_t n = 1); virtual Iterator* previous(size_t n = 1); virtual VALUE inspect() const; virtual VALUE to_s() const; bool operator == (const Iterator& x) const; Iterator* operator + (ptrdiff_t n) const; Iterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const Iterator& x) const; }; } swig-3.0.8/Lib/ruby/director.swg0000664000175000017500000002000612641054563016403 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Ruby proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ /* Use -DSWIG_DIRECTOR_NOUEH if you prefer to avoid the use of the Undefined Exception Handler provided by swig. */ #ifndef SWIG_DIRECTOR_NOUEH #ifndef SWIG_DIRECTOR_UEH #define SWIG_DIRECTOR_UEH #endif #endif #include #include #include #include # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) namespace Swig { /* memory handler */ struct GCItem { virtual ~GCItem() { } virtual swig_ruby_owntype get_own() const { swig_ruby_owntype own = {0, 0}; return own; } }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem *operator->() const { return _item; } private: GCItem *_item; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; struct GCItem_Object : GCItem { GCItem_Object(swig_ruby_owntype own) : _own(own) { } virtual ~GCItem_Object() { } swig_ruby_owntype get_own() const { return _own; } private: swig_ruby_owntype _own; }; template struct GCArray_T : GCItem { GCArray_T(Type *ptr) : _ptr(ptr) { } virtual ~GCArray_T() { delete[] _ptr; } private: Type *_ptr; }; /* body args */ struct body_args { VALUE recv; ID id; int argc; VALUE *argv; }; /* Base class for director exceptions */ class DirectorException : public std::exception { protected: VALUE swig_error; std::string swig_msg; protected: DirectorException(VALUE error) : swig_error(error) { } DirectorException(VALUE error, const char *hdr, const char *msg ="") : swig_error(error), swig_msg(hdr) { if (msg[0]) { swig_msg += " "; swig_msg += msg; } if (swig_msg.size()) { VALUE str = rb_str_new(swig_msg.data(), swig_msg.size()); swig_error = rb_exc_new3(error, str); } else { swig_error = error; } } public: virtual ~DirectorException() throw() { } VALUE getType() const { return CLASS_OF(swig_error); } VALUE getError() const { return swig_error; } /* Deprecated, use what() instead */ const std::string& getMessage() const { return swig_msg; } const char *what() const throw() { return swig_msg.c_str(); } }; /* unknown exception handler */ class UnknownExceptionHandler { #ifdef SWIG_DIRECTOR_UEH static void handler() { try { throw; } catch (DirectorException& e) { std::cerr << "SWIG Director exception caught:" << std::endl << e.what() << std::endl; } catch (std::exception& e) { std::cerr << "std::exception caught: "<< e.what() << std::endl; } catch (...) { std::cerr << "Unknown exception caught." << std::endl; } std::cerr << std::endl << "Ruby interpreter traceback:" << std::endl; std::cerr << std::endl; std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl << std::endl << "Exception is being re-thrown, program will like abort/terminate." << std::endl; throw; } public: std::unexpected_handler old; UnknownExceptionHandler(std::unexpected_handler nh = handler) { old = std::set_unexpected(nh); } ~UnknownExceptionHandler() { std::set_unexpected(old); } #endif }; /* Type mismatch in the return value from a Ruby method call */ class DirectorTypeMismatchException : public DirectorException { public: DirectorTypeMismatchException(VALUE error, const char *msg="") : DirectorException(error, "SWIG director type mismatch", msg) { } DirectorTypeMismatchException(const char *msg="") : DirectorException(rb_eTypeError, "SWIG director type mismatch", msg) { } static void raise(VALUE error, const char *msg) { throw DirectorTypeMismatchException(error, msg); } static void raise(const char *msg) { throw DirectorTypeMismatchException(msg); } }; /* Any Ruby exception that occurs during a director method call */ class DirectorMethodException : public DirectorException { public: DirectorMethodException(VALUE error) : DirectorException(error) { } DirectorMethodException(const char *msg = "") : DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) { } static void raise(VALUE error) { throw DirectorMethodException(error); } }; /* Attempted to call a pure virtual method via a director method */ class DirectorPureVirtualException : public DirectorException { public: DirectorPureVirtualException(const char *msg = "") : DirectorException(rb_eRuntimeError, "SWIG director pure virtual method called", msg) { } static void raise(const char *msg) { throw DirectorPureVirtualException(msg); } }; /* Simple thread abstraction for pthreads on win32 */ #ifdef __THREAD__ # define __PTHREAD__ # if defined(_WIN32) || defined(__WIN32__) # define pthread_mutex_lock EnterCriticalSection # define pthread_mutex_unlock LeaveCriticalSection # define pthread_mutex_t CRITICAL_SECTION # define SWIG_MUTEX_INIT(var) var # else # include # define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER # endif #endif #ifdef __PTHREAD__ struct Guard { pthread_mutex_t *_mutex; Guard(pthread_mutex_t &mutex) : _mutex(&mutex) { pthread_mutex_lock(_mutex); } ~Guard() { pthread_mutex_unlock(_mutex); } }; # define SWIG_GUARD(mutex) Guard _guard(mutex) #else # define SWIG_GUARD(mutex) #endif /* director base class */ class Director { private: /* pointer to the wrapped Ruby object */ VALUE swig_self; /* flag indicating whether the object is owned by Ruby or c++ */ mutable bool swig_disown_flag; public: /* wrap a Ruby object. */ Director(VALUE self) : swig_self(self), swig_disown_flag(false) { } /* discard our reference at destruction */ virtual ~Director() { } /* return a pointer to the wrapped Ruby object */ VALUE swig_get_self() const { return swig_self; } /* acquire ownership of the wrapped Ruby object (the sense of "disown" is from Ruby) */ void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag = true; } } /* ownership management */ private: typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; #ifdef __PTHREAD__ static pthread_mutex_t swig_mutex_own; #endif public: template void swig_acquire_ownership_array(Type *vptr) const { if (vptr) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCArray_T(vptr); } } template void swig_acquire_ownership(Type *vptr) const { if (vptr) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_T(vptr); } } void swig_acquire_ownership_obj(void *vptr, swig_ruby_owntype own) const { if (vptr && own.datafree) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_Object(own); } } swig_ruby_owntype swig_release_ownership(void *vptr) const { swig_ruby_owntype own = {0, 0}; if (vptr) { SWIG_GUARD(swig_mutex_own); swig_ownership_map::iterator iter = swig_owner.find(vptr); if (iter != swig_owner.end()) { own.datafree = iter->second->get_own().datafree; swig_owner.erase(iter); } } return own; } }; } swig-3.0.8/Lib/ruby/std_multiset.i0000664000175000017500000000257312641054563016751 0ustar williamwilliam/* Multisets */ %include %fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template inline void assign(const RubySeq& rubyseq, std::multiset* seq) { // seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } template struct traits_asptr > { static int asptr(VALUE obj, std::multiset **m) { return traits_asptr_stdseq >::asptr(obj, m); } }; template struct traits_from > { static VALUE from(const std::multiset& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_multiset_methods(Set...) %swig_set_methods(Set) %rename("delete") std::multiset::__delete__; %rename("reject!") std::multiset::reject_bang; %rename("map!") std::multiset::map_bang; %rename("empty?") std::multiset::empty; %rename("include?" ) std::multiset::__contains__ const; %rename("has_key?" ) std::multiset::has_key const; %alias std::multiset::push "<<"; %include swig-3.0.8/Lib/ruby/std_shared_ptr.i0000664000175000017500000000010412641054563017222 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.8/Lib/ruby/std_streambuf.i0000664000175000017500000000003712641054563017064 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/progargcargv.i0000664000175000017500000000140212641054563016703 0ustar williamwilliam/* int PROG_ARGC char **PROG_ARGV Some C function receive argc and argv from C main function. This typemap provides ignore typemap which pass Ruby ARGV contents as argc and argv to C function. */ // argc and argv %typemap(in,numinputs=0) int PROG_ARGC { $1 = RARRAY_LEN(rb_argv) + 1; } %typemap(in,numinputs=0) char **PROG_ARGV { int i, n; VALUE ary = rb_eval_string("[$0] + ARGV"); n = RARRAY_LEN(ary); $1 = (char **)malloc(n + 1); for (i = 0; i < n; i++) { VALUE v = rb_obj_as_string(RARRAY_PTR(ary)[i]); $1[i] = (char *)malloc(RSTRING_LEN(v) + 1); strcpy($1[i], RSTRING_PTR(v)); } } %typemap(freearg) char **PROG_ARGV { int i, n = RARRAY_LEN(rb_argv) + 1; for (i = 0; i < n; i++) free($1[i]); free($1); } swig-3.0.8/Lib/ruby/typemaps.i0000664000175000017500000002606212641054563016072 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer handling * * These mappings provide support for input/output arguments and * common uses for C/C++ pointers. INOUT mappings allow for C/C++ * pointer variables in addition to input/output arguments. * ----------------------------------------------------------------------------- */ #if !defined(SWIG_USE_OLD_TYPEMAPS) %include #else /* The SWIG typemap library provides a language independent mechanism for supporting output arguments, input values, and other C function calling mechanisms. The primary use of the library is to provide a better interface to certain C function--especially those involving pointers. */ // ------------------------------------------------------------------------ // Pointer handling // // These mappings provide support for input/output arguments and common // uses for C/C++ pointers. // ------------------------------------------------------------------------ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include typemaps.i double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include typemaps.i %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ %define INPUT_TYPEMAP(type, converter) %typemap(in) type *INPUT($*1_ltype temp), type &INPUT($*1_ltype temp) { temp = ($*1_ltype) converter($input); $1 = &temp; } %typemap(typecheck) type *INPUT = type; %typemap(typecheck) type &INPUT = type; %enddef INPUT_TYPEMAP(float, NUM2DBL); INPUT_TYPEMAP(double, NUM2DBL); INPUT_TYPEMAP(int, NUM2INT); INPUT_TYPEMAP(short, NUM2SHRT); INPUT_TYPEMAP(long, NUM2LONG); INPUT_TYPEMAP(long long, NUM2LL); INPUT_TYPEMAP(unsigned int, NUM2UINT); INPUT_TYPEMAP(unsigned short, NUM2USHRT); INPUT_TYPEMAP(unsigned long, NUM2ULONG); INPUT_TYPEMAP(unsigned long long, NUM2ULL); INPUT_TYPEMAP(unsigned char, NUM2UINT); INPUT_TYPEMAP(signed char, NUM2INT); INPUT_TYPEMAP(bool, RTEST); #undef INPUT_TYPEMAP // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a array element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Ruby Array. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include typemaps.i double modf(double x, double *OUTPUT); or you can use the %apply directive : %include typemaps.i %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Ruby output of the function would be a Array containing both output values. */ %define OUTPUT_TYPEMAP(type, converter, convtype) %typemap(in,numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;"; %typemap(argout, fragment="output_helper") type *OUTPUT, type &OUTPUT { VALUE o = converter(convtype (*$1)); $result = output_helper($result, o); } %enddef OUTPUT_TYPEMAP(int, INT2NUM, (int)); OUTPUT_TYPEMAP(short, INT2NUM, (int)); OUTPUT_TYPEMAP(long, INT2NUM, (long)); OUTPUT_TYPEMAP(long long, LL2NUM, (long long)); OUTPUT_TYPEMAP(unsigned int, UINT2NUM, (unsigned int)); OUTPUT_TYPEMAP(unsigned short, UINT2NUM, (unsigned int)); OUTPUT_TYPEMAP(unsigned long, UINT2NUM, (unsigned long)); OUTPUT_TYPEMAP(unsigned long long, ULL2NUM, (unsigned long long)); OUTPUT_TYPEMAP(unsigned char, UINT2NUM, (unsigned int)); OUTPUT_TYPEMAP(signed char, INT2NUM, (int)); OUTPUT_TYPEMAP(float, rb_float_new, (double)); OUTPUT_TYPEMAP(double, rb_float_new, (double)); #undef OUTPUT_TYPEMAP %typemap(in,numinputs=0) bool *OUTPUT(bool temp), bool &OUTPUT(bool temp) "$1 = &temp;"; %typemap(argout, fragment="output_helper") bool *OUTPUT, bool &OUTPUT { VALUE o = (*$1) ? Qtrue : Qfalse; $result = output_helper($result, o); } // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Ruby array. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include typemaps.i void neg(double *INOUT); or you can use the %apply directive : %include typemaps.i %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Ruby). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Ruby variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; %typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; %typemap(in) signed char *INOUT = signed char *INPUT; %typemap(in) bool *INOUT = bool *INPUT; %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) int &INOUT = int &INPUT; %typemap(in) short &INOUT = short &INPUT; %typemap(in) long &INOUT = long &INPUT; %typemap(in) long long &INOUT = long long &INPUT; %typemap(in) unsigned &INOUT = unsigned &INPUT; %typemap(in) unsigned short &INOUT = unsigned short &INPUT; %typemap(in) unsigned long &INOUT = unsigned long &INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; %typemap(in) unsigned char &INOUT = unsigned char &INPUT; %typemap(in) signed char &INOUT = signed char &INPUT; %typemap(in) bool &INOUT = bool &INPUT; %typemap(in) float &INOUT = float &INPUT; %typemap(in) double &INOUT = double &INPUT; %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT = long *OUTPUT; %typemap(argout) long long *INOUT = long long *OUTPUT; %typemap(argout) unsigned *INOUT = unsigned *OUTPUT; %typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; %typemap(argout) signed char *INOUT = signed char *OUTPUT; %typemap(argout) bool *INOUT = bool *OUTPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT = double *OUTPUT; %typemap(argout) int &INOUT = int &OUTPUT; %typemap(argout) short &INOUT = short &OUTPUT; %typemap(argout) long &INOUT = long &OUTPUT; %typemap(argout) long long &INOUT = long long &OUTPUT; %typemap(argout) unsigned &INOUT = unsigned &OUTPUT; %typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; %typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; %typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; %typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; %typemap(argout) signed char &INOUT = signed char &OUTPUT; %typemap(argout) bool &INOUT = bool &OUTPUT; %typemap(argout) float &INOUT = float &OUTPUT; %typemap(argout) double &INOUT = double &OUTPUT; /* Overloading information */ %typemap(typecheck) double *INOUT = double; %typemap(typecheck) signed char *INOUT = signed char; %typemap(typecheck) unsigned char *INOUT = unsigned char; %typemap(typecheck) unsigned long *INOUT = unsigned long; %typemap(typecheck) unsigned long long *INOUT = unsigned long long; %typemap(typecheck) unsigned short *INOUT = unsigned short; %typemap(typecheck) unsigned int *INOUT = unsigned int; %typemap(typecheck) long *INOUT = long; %typemap(typecheck) long long *INOUT = long long; %typemap(typecheck) short *INOUT = short; %typemap(typecheck) int *INOUT = int; %typemap(typecheck) float *INOUT = float; %typemap(typecheck) double &INOUT = double; %typemap(typecheck) signed char &INOUT = signed char; %typemap(typecheck) unsigned char &INOUT = unsigned char; %typemap(typecheck) unsigned long &INOUT = unsigned long; %typemap(typecheck) unsigned long long &INOUT = unsigned long long; %typemap(typecheck) unsigned short &INOUT = unsigned short; %typemap(typecheck) unsigned int &INOUT = unsigned int; %typemap(typecheck) long &INOUT = long; %typemap(typecheck) long long &INOUT = long long; %typemap(typecheck) short &INOUT = short; %typemap(typecheck) int &INOUT = int; %typemap(typecheck) float &INOUT = float; #endif // -------------------------------------------------------------------- // Special types // -------------------------------------------------------------------- %include %include %include swig-3.0.8/Lib/ruby/std_vector.i0000664000175000017500000000230212641054563016373 0ustar williamwilliam/* Vectors */ %fragment("StdVectorTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::vector **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::vector& vec) { return traits_from_stdseq >::from(vec); } }; } %} %define %swig_vector_methods(Type...) %swig_sequence_methods(Type) %swig_sequence_front_inserters(Type); %enddef %define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %swig_sequence_front_inserters(Type); %enddef %mixin std::vector "Enumerable"; %ignore std::vector::push_back; %ignore std::vector::pop_back; %rename("delete") std::vector::__delete__; %rename("reject!") std::vector::reject_bang; %rename("map!") std::vector::map_bang; %rename("empty?") std::vector::empty; %rename("include?" ) std::vector::__contains__ const; %rename("has_key?" ) std::vector::has_key const; %alias std::vector::push "<<"; %include swig-3.0.8/Lib/ruby/extconf.rb0000664000175000017500000000035212641054563016043 0ustar williamwilliamrequire 'mkmf' dir_config('yourlib') if have_header('yourlib.h') and have_library('yourlib', 'yourlib_init') # If you use swig -c option, you may have to link libswigrb. # have_library('swigrb') create_makefile('yourlib') end swig-3.0.8/Lib/ruby/rubystdfunctors.swg0000664000175000017500000001014312641054563020051 0ustar williamwilliam/** * @file rubystdfunctors.swg * @date Sun May 6 00:44:33 2007 * * @brief This file provides unary and binary functors for STL * containers, that will invoke a Ruby proc or method to do * their operation. * * You can use them in a swig file like: * * %include * %include * * %template< IntSet > std::set< int, swig::BinaryPredicate<> >; * * * which will then allow calling them from Ruby either like: * * # order of set is defined by C++ default * a = IntSet.new * * # sort order defined by Ruby proc * b = IntSet.new( proc { |a,b| a > b } ) * */ %include rubyclasses.swg namespace swig { %apply GC_VALUE { UnaryPredicate, BinaryPredicate, UnaryFunction, BinaryFunction }; %typecheck(SWIG_TYPECHECK_POINTER,noblock=1) UnaryPredicate, UnaryPredicate&, UnaryFunction, UnaryFunction& { $1 = SWIG_Ruby_isCallable($input) && SWIG_Ruby_arity($input, 1); } %typecheck(SWIG_TYPECHECK_POINTER,noblock=1) BinaryPredicate, BinaryPredicate&, BinaryFunction, BinaryFunction& { $1 = SWIG_Ruby_isCallable($input) && SWIG_Ruby_arity($input, 2); } %typemap(in,noblock=1) BinaryFunction&, BinaryFunction { $1 = new swig::BinaryFunction< >($input); } %typemap(in,noblock=1) UnaryFunction&, UnaryFunction { $1 = new swig::UnaryFunction< >($input); } %typemap(in,noblock=1) BinaryPredicate&, BinaryPredicate { $1 = new swig::BinaryPredicate<>($input); } %typemap(in,noblock=1) UnaryPredicate&, UnaryPredicate { $1 = new swig::UnaryPredicate< >($input); } %ignore BinaryFunction; template< class _T = GC_VALUE > struct BinaryFunction { }; %ignore UnaryFunction; template< class _T = GC_VALUE > struct UnaryFunction { }; %ignore BinaryPredicate; template< class _T = GC_VALUE > struct BinaryPredicate { }; %ignore UnaryPredicate; template< class _T = GC_VALUE > struct UnaryPredicate { }; } %fragment("StdFunctors","header",fragment="StdTraits",fragment="GC_VALUE_definition") { namespace swig { static ID call_id = rb_intern("call"); template > struct BinaryPredicate : GC_VALUE, std::binary_function< _T, _T, bool > { BinaryPredicate(VALUE obj = Qnil) : GC_VALUE(obj) { } bool operator()(_T a, _T b) const { if (_obj != Qnil) { SWIG_RUBY_THREAD_BEGIN_BLOCK; VALUE arg1 = swig::from(a); VALUE arg2 = swig::from(b); VALUE res = rb_funcall( _obj, swig::call_id, 2, arg1, arg2); SWIG_RUBY_THREAD_END_BLOCK; return RTEST(res); } else { return _DefaultFunc()(a, b); } } }; template > struct BinaryFunction : GC_VALUE, std::binary_function< _T, _T, _T > { BinaryFunction(VALUE obj = Qnil) : GC_VALUE(obj) { } _T operator()(_T a, _T b) const { if (_obj != Qnil) { SWIG_RUBY_THREAD_BEGIN_BLOCK; VALUE arg1 = swig::from(a); VALUE arg2 = swig::from(b); VALUE res = rb_funcall( _obj, swig::call_id, 2, arg1, arg2); SWIG_RUBY_THREAD_END_BLOCK; return swig::as<_T >(res); } else { return _DefaultFunc()(a, b); } } }; template< class _T = GC_VALUE > struct UnaryPredicate : GC_VALUE, std::unary_function< _T, bool > { UnaryPredicate(VALUE obj = Qnil) : GC_VALUE(obj) { } bool operator()(_T a) const { SWIG_RUBY_THREAD_BEGIN_BLOCK; VALUE arg1 = swig::from<_T >(a); VALUE res = rb_funcall( _obj, swig::call_id, 1, arg1); SWIG_RUBY_THREAD_END_BLOCK; return RTEST(res); } }; template< class _T = GC_VALUE > struct UnaryFunction : GC_VALUE, std::unary_function< _T, _T > { UnaryFunction(VALUE obj = Qnil) : GC_VALUE(obj) { } _T operator()(_T a) const { SWIG_RUBY_THREAD_BEGIN_BLOCK; VALUE arg1 = swig::from(a); VALUE res = rb_funcall( _obj, swig::call_id, 1, VALUE(arg1)); SWIG_RUBY_THREAD_END_BLOCK; return swig::as< _T >(res); } }; } // namespace swig } swig-3.0.8/Lib/ruby/rubyruntime.swg0000664000175000017500000000064712641054563017166 0ustar williamwilliam %runtime "swiglabels.swg" /* Common C API type-checking code */ %runtime "swigrun.swg" /* Common C API type-checking code */ %runtime "swigerrors.swg" /* SWIG errors */ %runtime "rubyhead.swg" /* Ruby includes and fixes */ %runtime "rubyerrors.swg" /* Ruby errors */ %runtime "rubytracking.swg" /* API for tracking C++ classes to Ruby objects */ %runtime "rubyapi.swg" %runtime "rubyrun.swg" swig-3.0.8/Lib/ruby/rubywstrings.swg0000664000175000017500000000473712641054563017367 0ustar williamwilliam/* ----------------------------------------------------------------------------- * rubywstrings.swg * * Currently, Ruby does not support Unicode or WChar properly, so these * are still treated as char arrays for now. * There are other libraries available that add support to this in * ruby including WString, FXString, etc. * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * utility methods for wchar_t strings * ------------------------------------------------------------ */ %fragment("SWIG_AsWCharPtrAndSize","header",fragment="",fragment="SWIG_pwchar_descriptor",fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc) { return SWIG_AsCharPtrAndSize( obj, (char**)cptr, psize, alloc); // VALUE tmp = 0; // bool ok = false; // if ( TYPE(obj) == T_STRING ) { // if (cptr) { // obj = tmp = SWIG_Unicode_FromObject(obj); // ok = true; // } // } // if (ok) { // Py_ssize_t len = PyUnicode_GetSize(obj); // rb_notimplement(); // if (cptr) { // *cptr = %new_array(len + 1, wchar_t); // SWIG_Unicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len); // (*cptr)[len] = 0; // } // if (psize) *psize = (size_t) len + 1; // if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; // return SWIG_OK; // } else { // swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); // if (pwchar_descriptor) { // void * vptr = 0; // if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) { // if (cptr) *cptr = (wchar_t *)vptr; // if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0; // return SWIG_OK; // } // } // } // return SWIG_TypeError; } } %fragment("SWIG_FromWCharPtrAndSize","header",fragment="",fragment="SWIG_pwchar_descriptor",fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE VALUE SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) { return SWIG_FromCharPtrAndSize( (const char*)carray, size); // if (carray) { // if (size > INT_MAX) { // swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); // return pwchar_descriptor ? // SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil; // } else { // return SWIG_Unicode_FromWideChar(carray, %numeric_cast(size,int)); // } // } else { // return Qnil; // } } } swig-3.0.8/Lib/ruby/std_sstream.i0000664000175000017500000000003612641054563016551 0ustar williamwilliam %include swig-3.0.8/Lib/ruby/ruby.swg0000664000175000017500000000513512641054563015557 0ustar williamwilliam/* ------------------------------------------------------------ * ruby.swg * * Ruby configuration module. * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * The Ruby auto rename rules * ------------------------------------------------------------ */ #if defined(SWIG_RUBY_AUTORENAME) /* Class names are CamelCase */ %rename("%(camelcase)s", %$isclass) ""; /* Constants created by %constant or #define are UPPER_CASE */ %rename("%(uppercase)s", %$isconstant) ""; /* SWIG only considers static class members with inline intializers to be constants. For examples of what is and isn't considered a constant by SWIG see naming.i in the Ruby test suite. */ %rename("%(uppercase)s", %$ismember, %$isvariable,%$isimmutable,%$isstatic,%$hasvalue,%$hasconsttype) ""; /* Enums are mapped to constants but all we do is make sure the first letter is uppercase */ %rename("%(firstuppercase)s", %$isenumitem) ""; /* Method names should be lower_case_with_underscores */ %rename("%(undercase)s", %$isfunction, %$not %$ismemberget, %$not %$ismemberset) ""; #endif /* ------------------------------------------------------------ * Inner macros * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The runtime part * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Special user directives * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Typemap specializations * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Overloaded operator support * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Warnings for Ruby keywords * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * Documentation for common Ruby methods * ------------------------------------------------------------ */ %include /* ------------------------------------------------------------ * The Ruby initialization function * ------------------------------------------------------------ */ %include swig-3.0.8/Lib/ruby/cmalloc.i0000664000175000017500000000004012641054563015626 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/rubycomplex.swg0000664000175000017500000000742412641054563017152 0ustar williamwilliam/* Defines the As/From conversors for double/float complex, you need to provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex accessor methods. See the std_complex.i and ccomplex.i for concrete examples. */ %fragment("rb_complex_new","header") { %#if !defined(T_COMPLEX) /* Ruby versions prior to 1.9 did not have native complex numbers. They were an extension in the STD library. */ SWIGINTERN VALUE rb_complex_new(VALUE x, VALUE y) { static ID new_id = rb_intern("new"); static VALUE cComplex = rb_const_get(rb_cObject, rb_intern("Complex")); return rb_funcall(cComplex, new_id, 2, x, y); } %#endif } %fragment("SWIG_Complex_Numbers","header") { %#if !defined(T_COMPLEX) SWIGINTERN int SWIG_Is_Complex( VALUE obj ) { static ID real_id = rb_intern("real"); static ID imag_id = rb_intern("imag"); return ( (rb_respond_to( obj, real_id ) ) && (rb_respond_to( obj, imag_id ) ) ); } %#else SWIGINTERN int SWIG_Is_Complex( VALUE obj ) { return TYPE(obj) == T_COMPLEX; } %#endif SWIGINTERN VALUE SWIG_Complex_Real(VALUE obj) { static ID real_id = rb_intern("real"); return rb_funcall(obj, real_id, 0); } SWIGINTERN VALUE SWIG_Complex_Imaginary(VALUE obj) { static ID imag_id = rb_intern("imag"); return rb_funcall(obj, imag_id, 0); } } %init { %#if !defined(T_COMPLEX) rb_require("complex"); %#endif } /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header",fragment="rb_complex_new") { SWIGINTERNINLINE VALUE SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) { VALUE re = rb_float_new(Real(c)); VALUE im = rb_float_new(Imag(c)); return rb_complex_new(re, im); } } %enddef /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(double), fragment="SWIG_Complex_Numbers") { SWIGINTERN int SWIG_AsVal(Type) (VALUE o, Type* val) { if ( SWIG_Is_Complex( o ) ) { if (val) { VALUE real = SWIG_Complex_Real(o); VALUE imag = SWIG_Complex_Imaginary(o); double re = 0; SWIG_AsVal_double( real, &re ); double im = 0; SWIG_AsVal_double( imag, &im ); *val = Constructor(re, im); } return SWIG_OK; } else { double d; int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(d, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef /* the float case */ %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float), fragment=SWIG_AsVal_frag(double), fragment="SWIG_Complex_Numbers") { SWIGINTERN int SWIG_AsVal(Type)(VALUE o, Type *val) { if ( SWIG_Is_Complex( o ) ) { VALUE real = SWIG_Complex_Real(o); VALUE imag = SWIG_Complex_Imaginary(o); double re = 0; SWIG_AsVal_double( real, &re ); double im = 0; SWIG_AsVal_double( imag, &im ); if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { if (val) *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float)); return SWIG_OK; } else { return SWIG_OverflowError; } } else { float re; int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); if (SWIG_IsOK(res)) { if (val) *val = Constructor(re, 0.0); return res; } } return SWIG_TypeError; } } %swig_fromcplx_conv(Type, Real, Imag); %enddef #define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ %swig_cplxflt_conv(Type, Constructor, Real, Imag) #define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ %swig_cplxdbl_conv(Type, Constructor, Real, Imag) swig-3.0.8/Lib/ruby/cstring.i0000664000175000017500000000004012641054563015665 0ustar williamwilliam%include swig-3.0.8/Lib/ruby/std_queue.i0000664000175000017500000000152312641054563016221 0ustar williamwilliam/* Queues */ %fragment("StdQueueTraits","header",fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(VALUE obj, std::queue **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static VALUE from(const std::queue & vec) { return traits_from_stdseq >::from(vec); } }; } %} %rename("delete") std::queue::__delete__; %rename("reject!") std::queue::reject_bang; %rename("map!") std::queue::map_bang; %rename("empty?") std::queue::empty; %rename("include?" ) std::queue::__contains__ const; %rename("has_key?" ) std::queue::has_key const; %alias std::queue::push "<<"; %include swig-3.0.8/Lib/ruby/std_complex.i0000664000175000017500000000072712641054563016551 0ustar williamwilliam/* * STD C++ complex typemaps */ %include %{ #include %} /* defining the complex as/from converters */ %swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag) %swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag) /* defining the typemaps */ %typemaps_primitive(%checkcode(CPLXDBL), std::complex); %typemaps_primitive(%checkcode(CPLXFLT), std::complex); swig-3.0.8/Lib/ruby/rubyapi.swg0000664000175000017500000000144112641054563016245 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Ruby API portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif SWIGINTERN VALUE SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { if (NIL_P(target)) { target = o; } else { if (TYPE(target) != T_ARRAY) { VALUE o2 = target; target = rb_ary_new(); rb_ary_push(target, o2); } rb_ary_push(target, o); } return target; } /* For ruby1.8.4 and earlier. */ #ifndef RUBY_INIT_STACK RUBY_EXTERN void Init_stack(VALUE* addr); # define RUBY_INIT_STACK \ VALUE variable_in_this_stack_frame; \ Init_stack(&variable_in_this_stack_frame); #endif #ifdef __cplusplus } #endif swig-3.0.8/Lib/ruby/argcargv.i0000664000175000017500000000231312641054563016015 0ustar williamwilliam/* ------------------------------------------------------------ * --- Argc & Argv --- * ------------------------------------------------------------ */ /* ------------------------------------------------------------ Use it as follow: %apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) } %inline %{ int mainApp(size_t argc, const char **argv) { return argc; } then in the ruby side: args = ["asdf", "asdf2"] mainApp(args); * ------------------------------------------------------------ */ %typemap(in) (int ARGC, char **ARGV) { if (rb_obj_is_kind_of($input,rb_cArray)) { int i; int size = RARRAY_LEN($input); $1 = ($1_ltype) size; $2 = (char **) malloc((size+1)*sizeof(char *)); VALUE *ptr = RARRAY_PTR($input); for (i=0; i < size; i++, ptr++) { $2[i]= StringValuePtr(*ptr); } $2[i]=NULL; } else { $1 = 0; $2 = 0; %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum); } } %typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { $1 = rb_obj_is_kind_of($input,rb_cArray); } %typemap(freearg) (int ARGC, char **ARGV) { free((char *) $2); } swig-3.0.8/Lib/ruby/cpointer.i0000664000175000017500000000004112641054563016040 0ustar williamwilliam%include swig-3.0.8/Lib/typemaps/0000775000175000017500000000000012641054563014731 5ustar williamwilliamswig-3.0.8/Lib/typemaps/fragments.swg0000664000175000017500000001757012641054563017453 0ustar williamwilliam/* Fragments ========= See the "Typemap fragments" section in the documentation for understanding fragments. Below is some info on how fragments and automatic type specialization is used. Macros that make the automatic generation of typemaps easier are provided. Consider the following code: %fragment(SWIG_From_frag(bool), "header") { static PyObject* SWIG_From_dec(bool)(bool value) { PyObject *obj = value ? Py_True : Py_False; Py_INCREF(obj); return obj; } } %typemap(out, fragment=SWIG_From_frag(bool)) bool { $result = SWIG_From(bool)($1)); } Here the macros SWIG_From_frag => fragment SWIG_From_dec => declaration SWIG_From => call allow you to define/include a fragment, and declare and call the 'from-bool' method as needed. In the simpler case, these macros just return something like SWIG_From_frag(bool) => "SWIG_From_bool" SWIG_From_dec(bool) => SWIG_From_bool SWIG_From(bool) => SWIG_From_bool But they are specialized for the different languages requirements, such as perl or tcl that requires passing the interpreter pointer, and also they can manage C++ ugly types, for example: SWIG_From_frag(std::complex) => "SWIG_From_std_complex_Sl_double_Sg_" SWIG_From_dec(std::complex) => SWIG_From_std_complex_Sl_double_Sg_ SWIG_From(std::complex) => SWIG_From_std_complex_Sl_double_Sg_ Hence, to declare methods to use with typemaps, always use the SWIG_From* macros. In the same way, the SWIG_AsVal* and SWIG_AsPtr* set of macros are provided. */ /* ----------------------------------------------------------------------------- * Define the basic macros to 'normalize' the type fragments * ----------------------------------------------------------------------------- */ #ifndef SWIG_AS_DECL_ARGS #define SWIG_AS_DECL_ARGS #endif #ifndef SWIG_FROM_DECL_ARGS #define SWIG_FROM_DECL_ARGS #endif #ifndef SWIG_AS_CALL_ARGS #define SWIG_AS_CALL_ARGS #endif #ifndef SWIG_FROM_CALL_ARGS #define SWIG_FROM_CALL_ARGS #endif #define %fragment_name(Name, Type...) %string_name(Name) "_" {Type} #define SWIG_Traits_frag(Type...) %fragment_name(Traits, Type) #define SWIG_AsPtr_frag(Type...) %fragment_name(AsPtr, Type) #define SWIG_AsVal_frag(Type...) %fragment_name(AsVal, Type) #define SWIG_From_frag(Type...) %fragment_name(From, Type) #define SWIG_AsVal_name(Type...) %symbol_name(AsVal, Type) #define SWIG_AsPtr_name(Type...) %symbol_name(AsPtr, Type) #define SWIG_From_name(Type...) %symbol_name(From, Type) #define SWIG_AsVal_dec(Type...) SWIG_AsVal_name(Type) SWIG_AS_DECL_ARGS #define SWIG_AsPtr_dec(Type...) SWIG_AsPtr_name(Type) SWIG_AS_DECL_ARGS #define SWIG_From_dec(Type...) SWIG_From_name(Type) SWIG_FROM_DECL_ARGS #define SWIG_AsVal(Type...) SWIG_AsVal_name(Type) SWIG_AS_CALL_ARGS #define SWIG_AsPtr(Type...) SWIG_AsPtr_name(Type) SWIG_AS_CALL_ARGS #define SWIG_From(Type...) SWIG_From_name(Type) SWIG_FROM_CALL_ARGS /* ------------------------------------------------------------ * common fragments * ------------------------------------------------------------ */ /* Default compiler options for gcc allow long_long but not LLONG_MAX. * Define SWIG_NO_LLONG_MAX if this added limits support is not wanted. */ %fragment("","header") %{ #include #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) # define LLONG_MAX __LONG_LONG_MAX__ # define LLONG_MIN (-LLONG_MAX - 1LL) # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) # endif #endif %} %fragment("","header") %{ #include %} %fragment("","header") %{ #include #include #ifndef WCHAR_MIN # define WCHAR_MIN 0 #endif #ifndef WCHAR_MAX # define WCHAR_MAX 65535 #endif %} %fragment("","header") %{ #include %} %fragment("","header") %{ #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf # define snprintf _snprintf # endif #endif %} %fragment("","header") %{ #include #ifdef _MSC_VER # ifndef strtoull # define strtoull _strtoui64 # endif # ifndef strtoll # define strtoll _strtoi64 # endif #endif %} %fragment("", "header") %{ #include %} %fragment("", "header") %{ #include %} %fragment("", "header") %{ #include %} %fragment("", "header") %{ #include %} %fragment("SWIG_isfinite","header",fragment=",") %{ /* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ #ifndef SWIG_isfinite # if defined(isfinite) # define SWIG_isfinite(X) (isfinite(X)) # elif defined(_MSC_VER) # define SWIG_isfinite(X) (_finite(X)) # elif defined(__sun) && defined(__SVR4) # include # define SWIG_isfinite(X) (finite(X)) # endif #endif %} %fragment("SWIG_Float_Overflow_Check","header",fragment=",SWIG_isfinite") %{ /* Accept infinite as a valid float value unless we are unable to check if a value is finite */ #ifdef SWIG_isfinite # define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X)) #else # define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX)) #endif %} /* ----------------------------------------------------------------------------- * special macros for fragments * ----------------------------------------------------------------------------- */ /* Macros to derive numeric types */ %define %numeric_type_from(Type, Base) %fragment(SWIG_From_frag(Type),"header", fragment=SWIG_From_frag(Base)) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(Type)(Type value) { return SWIG_From(Base)(value); } } %enddef %define %numeric_type_asval(Type, Base, Frag, OverflowCond) %fragment(SWIG_AsVal_frag(Type),"header", fragment=Frag, fragment=SWIG_AsVal_frag(Base)) { SWIGINTERN int SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val) { Base v; int res = SWIG_AsVal(Base)(obj, &v); if (SWIG_IsOK(res)) { if (OverflowCond) { return SWIG_OverflowError; } else { if (val) *val = %numeric_cast(v, Type); } } return res; } } %enddef #define %numeric_signed_type_asval(Type, Base, Frag, Min, Max) \ %numeric_type_asval(Type, Base, Frag, (v < Min || v > Max)) #define %numeric_unsigned_type_asval(Type, Base, Frag, Max) \ %numeric_type_asval(Type, Base, Frag, (v > Max)) /* Macro for 'signed long' derived types */ %define %numeric_slong(Type, Frag, Min, Max) %numeric_type_from(Type, long) %numeric_signed_type_asval(Type, long, Frag , Min, Max) %enddef /* Macro for 'unsigned long' derived types */ %define %numeric_ulong(Type, Frag, Max) %numeric_type_from(Type, unsigned long) %numeric_unsigned_type_asval(Type, unsigned long, Frag, Max) %enddef /* Macro for floating point derived types (original macro) */ %define %numeric_double(Type, Frag, Min, Max) %numeric_type_from(Type, double) %numeric_signed_type_asval(Type, double, Frag , Min, Max) %enddef /* Macro for floating point derived types */ %define %numeric_float(Type, Frag, OverflowCond) %numeric_type_from(Type, double) %numeric_type_asval(Type, double, Frag, OverflowCond) %enddef /* Macros for missing fragments */ %define %ensure_fragment(Fragment) %fragment(`Fragment`,"header") { %#error "SWIG language implementation must provide the Fragment fragment" } %enddef %define %ensure_type_fragments(Type) %fragment(SWIG_From_frag(Type),"header") { %#error "SWIG language implementation must provide a SWIG_From_frag(Type) fragment" } %fragment(SWIG_AsVal_frag(Type),"header") { %#error "SWIG language implementation must provide a SWIG_AsVal_frag(Type) fragment" } %enddef swig-3.0.8/Lib/typemaps/std_strings.swg0000664000175000017500000000366512641054563020030 0ustar williamwilliam /* defining the String asptr/from methods */ %define %std_string_asptr(String, Char, SWIG_AsCharPtrAndSize, Frag) %fragment(SWIG_AsPtr_frag(String),"header",fragment=Frag) { SWIGINTERN int SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val) { Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ; if (SWIG_IsOK((SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc)))) { if (buf) { if (val) *val = new String(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } else { if (val) *val = 0; return SWIG_OLDOBJ; } } else { static int init = 0; static swig_type_info* descriptor = 0; if (!init) { descriptor = SWIG_TypeQuery(#String " *"); init = 1; } if (descriptor) { String *vptr; int res = SWIG_ConvertPtr(obj, (void**)&vptr, descriptor, 0); if (SWIG_IsOK(res) && val) *val = vptr; return res; } } return SWIG_ERROR; } } %enddef %define %std_string_from(String, SWIG_FromCharPtrAndSize, Frag) %fragment(SWIG_From_frag(String),"header",fragment=Frag) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(String)(const String& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } %enddef %define %std_string_asval(String) %fragment(SWIG_AsVal_frag(String),"header", fragment=SWIG_AsPtr_frag(String)) { SWIGINTERN int SWIG_AsVal_dec(String)(SWIG_Object obj, String *val) { String* v = (String *) 0; int res = SWIG_AsPtr(String)(obj, &v); if (!SWIG_IsOK(res)) return res; if (v) { if (val) *val = *v; if (SWIG_IsNewObj(res)) { %delete(v); res = SWIG_DelNewMask(res); } return res; } return SWIG_ERROR; } } %enddef %define %typemaps_std_string(String, Char, AsPtrMethod, FromMethod, CheckCode) %std_string_asptr(String, Char, AsPtrMethod, #AsPtrMethod) %std_string_asval(String) %std_string_from(String, FromMethod, #FromMethod) %typemaps_asptrfromn(%arg(CheckCode), String); %enddef swig-3.0.8/Lib/typemaps/misctypes.swg0000664000175000017500000000072312641054563017475 0ustar williamwilliam /* ------------------------------------------------------------ * --- ANSI/Posix C/C++ types --- * ------------------------------------------------------------ */ #ifdef __cplusplus %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; %apply ptrdiff_t { std::ptrdiff_t }; %apply const ptrdiff_t& { const std::ptrdiff_t& }; #ifndef SWIG_INOUT_NODEF %apply size_t& { std::size_t& }; %apply ptrdiff_t& { std::ptrdiff_t& }; #endif #endif swig-3.0.8/Lib/typemaps/swigtype.swg0000664000175000017500000005420112641054563017330 0ustar williamwilliam/* ----------------------------------------------------------------------------- * --- Input arguments --- * ----------------------------------------------------------------------------- */ /* Pointers and arrays */ %typemap(in, noblock=1) SWIGTYPE *(void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg) SWIGTYPE * ""; %typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg) SWIGTYPE [] ""; %typemap(in, noblock=1) SWIGTYPE *const& (void *argp = 0, int res = 0, $*1_ltype temp) { res = SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$*ltype", $symname, $argnum); } temp = %reinterpret_cast(argp, $*ltype); $1 = %reinterpret_cast(&temp, $1_ltype); } %typemap(freearg) SWIGTYPE *const& ""; /* Reference */ %typemap(in, noblock=1) SWIGTYPE & (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg) SWIGTYPE & ""; #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(in,noblock=1,implicitconv=1) const SWIGTYPE & (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE & { if (SWIG_IsNewObj(res$argnum)) %delete($1); } #else %typemap(in,noblock=1) const SWIGTYPE & (void *argp, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } #endif /* Rvalue reference */ %typemap(in, noblock=1) SWIGTYPE && (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg) SWIGTYPE && ""; #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(in,noblock=1,implicitconv=1) const SWIGTYPE && (void *argp = 0, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE && { if (SWIG_IsNewObj(res$argnum)) %delete($1); } #else %typemap(in,noblock=1) const SWIGTYPE && (void *argp, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } $1 = %reinterpret_cast(argp, $ltype); } #endif /* By value */ #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(in,implicitconv=1) SWIGTYPE (void *argp, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $<ype temp = %reinterpret_cast(argp, $<ype); $1 = *temp; if (SWIG_IsNewObj(res)) %delete(temp); } } #else %typemap(in) SWIGTYPE (void *argp, int res = 0) { res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, $<ype)); } } #endif /* ----------------------------------------------------------------------------- * --- Output arguments --- * ----------------------------------------------------------------------------- */ /* Pointers, references */ %typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[] { %set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags)); } %typemap(out, noblock=1) SWIGTYPE *const& { %set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags)); } /* Return by value */ %typemap(out, noblock=1) SWIGTYPE { %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags)); } /* ----------------------------------------------------------------------------- * --- Variable input --- * ----------------------------------------------------------------------------- */ /* memberin/globalin/varin, for fix arrays. */ %typemap(memberin) SWIGTYPE [ANY] { if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)$input + ii); } else { %variable_nullref("$type","$name"); } } %typemap(globalin) SWIGTYPE [ANY] { if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)$input + ii); } else { %variable_nullref("$type","$name"); } } %typemap(varin) SWIGTYPE [ANY] { $basetype *inp = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } else if (inp) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)inp + ii); } else { %variable_nullref("$type", "$name"); } } /* memberin/globalin/varin, for fix double arrays. */ %typemap(memberin) SWIGTYPE [ANY][ANY] { if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { if ($input[ii]) { size_t jj = 0; for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } else { %variable_nullref("$type","$name"); } } } else { %variable_nullref("$type","$name"); } } %typemap(globalin) SWIGTYPE [ANY][ANY] { if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { if ($input[ii]) { size_t jj = 0; for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } else { %variable_nullref("$type","$name"); } } } else { %variable_nullref("$type","$name"); } } %typemap(varin) SWIGTYPE [ANY][ANY] { $basetype (*inp)[$1_dim1] = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } else if (inp) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { if (inp[ii]) { size_t jj = 0; for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = inp[ii][jj]; } else { %variable_nullref("$type", "$name"); } } } else { %variable_nullref("$type", "$name"); } } /* Pointers, references, and variable size arrays */ %typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE * { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = %reinterpret_cast(argp, $ltype); } %typemap(varin,noblock=1,warning="462:Unable to set dimensionless array variable") SWIGTYPE [] { %variable_fail(SWIG_AttributeError, "$type", "read-only $name"); } %typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE & { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } $1 = *(%reinterpret_cast(argp, $ltype)); } %typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE && { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } $1 = *(%reinterpret_cast(argp, $ltype)); } #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(varin,implicitconv=1) SWIGTYPE { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $&type temp; temp = %reinterpret_cast(argp, $&type); $1 = *temp; if (SWIG_IsNewObj(res)) %delete(temp); } } #else %typemap(varin) SWIGTYPE { void *argp = 0; int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, $&type)); } } #endif /* ----------------------------------------------------------------------------- * --- Variable output --- * ----------------------------------------------------------------------------- */ /* Pointers and arrays */ %typemap(varout, noblock=1) SWIGTYPE * { %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags)); } %typemap(varout, noblock=1) SWIGTYPE [] { %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags)); } /* References */ %typemap(varout, noblock=1) SWIGTYPE & { %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags)); } %typemap(varout, noblock=1) SWIGTYPE && { %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags)); } /* Value */ %typemap(varout, noblock=1) SWIGTYPE { %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags)); } /* ------------------------------------------------------------ * --- Typechecking rules --- * ------------------------------------------------------------ */ %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE * { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE *const& { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $*descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE && { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE & { int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE && { int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) SWIGTYPE { int res = SWIG_ConvertPtr($input, 0, $&descriptor, %implicitconv_flag); $1 = SWIG_CheckState(res); } #else %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE & { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE && { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE { void *vptr = 0; int res = SWIG_ConvertPtr($input, &vptr, $&descriptor, 0); $1 = SWIG_CheckState(res); } #endif /* ----------------------------------------------------------------------------- * --- Director typemaps --- * * ----------------------------------------------------------------------------- */ #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE *, SWIGTYPE *const& { $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags); } %typemap(directorin,noblock=1) SWIGTYPE { $input = SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags); } %typemap(directorin,noblock=1) SWIGTYPE & { $input = SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags); } %typemap(directorin,noblock=1) SWIGTYPE && { $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags); } /* directorout */ #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * swig_argp, int swig_res = 0) { swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags | %implicitconv_flag); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } $result = *(%reinterpret_cast(swig_argp, $<ype)); if (SWIG_IsNewObj(swig_res)) %delete(%reinterpret_cast(swig_argp, $<ype)); } #else %typemap(directorout,noblock=1) SWIGTYPE (void * swig_argp, int swig_res = 0) { swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } $result = *(%reinterpret_cast(swig_argp, $<ype)); } #endif %typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *(void *swig_argp, int swig_res, swig_owntype own) { swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } $result = %reinterpret_cast(swig_argp, $ltype); swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */); } %typemap(directorfree,noblock=1,match="directorout") SWIGTYPE * { if (director) { SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input))); } } %typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &(void *swig_argp, int swig_res, swig_owntype own) { swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } if (!swig_argp) { %dirout_nullref("$type"); } $result = %reinterpret_cast(swig_argp, $ltype); swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */); } %typemap(directorfree,noblock=1,match="directorout") SWIGTYPE & { if (director) { SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input))); } } %typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&(void *swig_argp, int swig_res, swig_owntype own) { swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } if (!swig_argp) { %dirout_nullref("$type"); } $result = %reinterpret_cast(swig_argp, $ltype); swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */); } %typemap(directorfree,noblock=1,match="directorout") SWIGTYPE && { if (director) { SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input))); } } #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* ------------------------------------------------------------ * --- Constants --- * ------------------------------------------------------------ */ %typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags)); } %typemap(constcode,noblock=1) SWIGTYPE { %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr(&$value),$&descriptor,%newpointer_flags)); } /* ------------------------------------------------------------ * --- Exception handling --- * ------------------------------------------------------------ */ %typemap(throws,noblock=1) SWIGTYPE { %raise(SWIG_NewPointerObj(%new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor); } %typemap(throws,noblock=1) SWIGTYPE * { %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor); } %typemap(throws,noblock=1) SWIGTYPE [ANY] { %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor); } %typemap(throws,noblock=1) SWIGTYPE & { %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor); } %typemap(throws,noblock=1) SWIGTYPE && { %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor); } %typemap(throws,noblock=1) (...) { SWIG_exception_fail(SWIG_RuntimeError,"unknown exception"); } /* ------------------------------------------------------------ * --- CLASS::* typemaps --- * ------------------------------------------------------------ */ %typemap(in) SWIGTYPE (CLASS::*) { int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } } %typemap(out,noblock=1) SWIGTYPE (CLASS::*) { %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); } %typemap(varin) SWIGTYPE (CLASS::*) { int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } } %typemap(varout,noblock=1) SWIGTYPE (CLASS::*) { %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); } %typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) { %set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($type), $descriptor)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE (CLASS::*) { $input = SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor); } /* directorout */ %typemap(directorout) SWIGTYPE (CLASS::*) { int swig_res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($type), $descriptor); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } } #endif /* ------------------------------------------------------------ * --- function ptr typemaps --- * ------------------------------------------------------------ */ /* ISO C++ doesn't allow direct casting of a function ptr to a object ptr. So, maybe the ptr sizes are not the same, and we need to take some providences. */ %typemap(in) SWIGTYPE ((*)(ANY)) { int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } } %typecheck(SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE ((*)(ANY)) { void *ptr = 0; int res = SWIG_ConvertFunctionPtr($input, &ptr, $descriptor); $1 = SWIG_CheckState(res); } %typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) { %set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor)); } %typemap(varin) SWIGTYPE ((*)(ANY)) { int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } } %typemap(varout,noblock=1) SWIGTYPE ((*)(ANY)) { %set_varoutput(SWIG_NewFunctionPtrObj((void *)($1), $descriptor)); } %typemap(constcode, noblock=1) SWIGTYPE ((*)(ANY)){ %set_constant("$symname", SWIG_NewFunctionPtrObj((void *)$value, $descriptor)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE ((*)(ANY)) { $input = SWIG_NewFunctionPtrObj((void*)($1), $descriptor); } /* directorout */ %typemap(directorout) SWIGTYPE ((*)(ANY)) { int swig_res = SWIG_ConvertFunctionPtr($input,(void**)(&$result),$descriptor); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } } #endif %apply SWIGTYPE * { SWIGTYPE *const } /* ------------------------------------------------------------ * --- Special typemaps --- * ------------------------------------------------------------ */ /* DISOWN typemap */ %typemap(in, noblock=1) SWIGTYPE *DISOWN (int res = 0) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type", $symname, $argnum); } } %typemap(varin) SWIGTYPE *DISOWN { void *temp = 0; int res = SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = ($ltype) temp; } /* DYNAMIC typemap */ %typemap(out,noblock=1) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { %set_output(SWIG_NewPointerObj(%as_voidptr($1), SWIG_TypeDynamicCast($descriptor, %as_voidptrptr(&$1)), $owner | %newpointer_flags)); } /* INSTANCE typemap */ %typemap(out,noblock=1) SWIGTYPE INSTANCE { %set_output(SWIG_NewInstanceObj(%new_copy($1, $1_ltype), $&1_descriptor, SWIG_POINTER_OWN | %newinstance_flags)); } %typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] { %set_output(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, $owner | %newinstance_flags)); } %typemap(varout,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[] { %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags)); } %typemap(varout,noblock=1) SWIGTYPE &INSTANCE { %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags)); } %typemap(varout,noblock=1) SWIGTYPE INSTANCE { %set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags)); } swig-3.0.8/Lib/typemaps/inoutlist.swg0000664000175000017500000002241112641054563017505 0ustar williamwilliam/* ------------------------------------------------------------ * * Define the IN/OUTPUT typemaps assuming the output parameters are * returned in a list, i.e., they are not directly modified. * * The user should provide the %append_output(result, obj) method, * via a macro, which append a particular object to the result. * * * In Tcl, for example, the file is used as: * * #define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj); * %include * * while in Python it is used as: * * #define %append_output(obj) $result = SWIG_Python_AppendResult($result, obj) * %include * * where the method SWIG_Python_AppendResult is defined inside the * %append_output fragment. * * If you forget to define %append_output, this file will generate * an error. * * ------------------------------------------------------------ */ // // Uncomment the following definition if you don't want the in/out // typemaps by default, ie, you prefer to use typemaps.i. // //#define SWIG_INOUT_NODEF // // Use the following definition to enable the INPUT parameters to // accept both 'by value' and 'pointer' objects. // #define SWIG_INPUT_ACCEPT_PTRS // ------------------------------------------------------------------------ // Pointer handling // // These mappings provide support for input/output arguments and common // uses for C/C++ pointers. // ------------------------------------------------------------------------ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ #if defined(SWIG_INPUT_ACCEPT_PTRS) #define %check_input_ptr(input,arg,desc,disown) (SWIG_IsOK((res = SWIG_ConvertPtr(input,%as_voidptrptr(arg),desc,disown)))) #else #define %check_input_ptr(input,arg,desc,disown) (SWIG_IsOK((res = SWIG_ERROR))) #endif %define %_value_input_typemap(code, asval_meth, asval_frag, Type) %typemap(in,noblock=1,fragment=asval_frag) Type *INPUT ($*ltype temp, int res = 0) { if (!%check_input_ptr($input,&$1,$descriptor,$disown)) { Type val; int ecode = asval_meth($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$*ltype",$symname, $argnum); } temp = %static_cast(val, $*ltype); $1 = &temp; res = SWIG_AddTmpMask(ecode); } } %typemap(in,noblock=1,fragment=asval_frag) Type &INPUT($*ltype temp, int res = 0) { if (!%check_input_ptr($input,&$1,$descriptor,$disown)) { Type val; int ecode = asval_meth($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$*ltype",$symname, $argnum); } temp = %static_cast(val, $*ltype); $1 = &temp; res = SWIG_AddTmpMask(ecode); } } %typemap(freearg,noblock=1,match="in") Type *INPUT, Type &INPUT { if (SWIG_IsNewObj(res$argnum)) %delete($1); } %typemap(typecheck,noblock=1,precedence=code,fragment=asval_frag) Type *INPUT, Type &INPUT { void *ptr = 0; int res = asval_meth($input, 0); $1 = SWIG_CheckState(res); if (!$1) { $1 = %check_input_ptr($input,&ptr,$1_descriptor,0); } } %enddef %define %_ptr_input_typemap(code,asptr_meth,asptr_frag,Type) %typemap(in,noblock=1,fragment=asptr_frag) Type *INPUT(int res = 0) { res = asptr_meth($input, &$1); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } res = SWIG_AddTmpMask(res); } %typemap(in,noblock=1,fragment=asptr_frag) Type &INPUT(int res = 0) { res = asptr_meth($input, &$1); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } if (!$1) { %argument_nullref("$type",$symname, $argnum); } res = SWIG_AddTmpMask(res); } %typemap(freearg,noblock=1,match="in") Type *INPUT, Type &INPUT { if (SWIG_IsNewObj(res$argnum)) %delete($1); } %typemap(typecheck,noblock=1,precedence=code,fragment=asptr_frag) Type *INPUT, Type &INPUT { int res = asptr_meth($input, (Type**)0); $1 = SWIG_CheckState(res); } %enddef // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a list. For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters): double modf(double x, double *ip); You could wrap it with SWIG as follows : double modf(double x, double *OUTPUT); or you can use the %apply directive : %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The output of the function would be a list containing both output values. */ %define %_value_output_typemap(from_meth, from_frag, Type) %typemap(in,numinputs=0,noblock=1) Type *OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ), Type &OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ) { $1 = &temp; } %typemap(argout,noblock=1,fragment=from_frag) Type *OUTPUT, Type &OUTPUT { if (SWIG_IsTmpObj(res$argnum)) { %append_output(from_meth((*$1))); } else { int new_flags = SWIG_IsNewObj(res$argnum) ? (SWIG_POINTER_OWN | %newpointer_flags) : %newpointer_flags; %append_output(SWIG_NewPointerObj((void*)($1), $1_descriptor, new_flags)); } } %enddef // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a list. For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : void neg(double *INOUT); or you can use the %apply directive : %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value. Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ %define %_value_inout_typemap(Type) %typemap(in) Type *INOUT = Type *INPUT; %typemap(in) Type &INOUT = Type &INPUT; %typemap(typecheck) Type *INOUT = Type *INPUT; %typemap(typecheck) Type &INOUT = Type &INPUT; %typemap(argout) Type *INOUT = Type *OUTPUT; %typemap(argout) Type &INOUT = Type &OUTPUT; %enddef %define %_ptr_inout_typemap(Type) %_value_inout_typemap(%arg(Type)) %typemap(typecheck) Type *INOUT = Type *INPUT; %typemap(typecheck) Type &INOUT = Type &INPUT; %typemap(freearg) Type *INOUT = Type *INPUT; %typemap(freearg) Type &INOUT = Type &INPUT; %enddef #ifndef SWIG_INOUT_NODEF %define %value_input_typemap(code,asval_meth, asval_frag, Type...) %_value_input_typemap(%arg(code),%arg(asval_meth),%arg(asval_frag),%arg(Type)) %enddef %define %ptr_input_typemap(code,asval_meth,asval_frag,Type...) %_ptr_input_typemap(%arg(code),%arg(asval_meth),%arg(asval_frag),%arg(Type)) %enddef %define %value_output_typemap(from_meth,from_frag,Type...) %_value_output_typemap(%arg(from_meth),%arg(from_frag),%arg(Type)) %enddef #define %value_inout_typemap(Type...) %_value_inout_typemap(%arg(Type)) #define %ptr_inout_typemap(Type...) %_ptr_inout_typemap(%arg(Type)) #else /* You need to include typemaps.i */ #define %value_output_typemap(Type...) #define %value_input_typemap(Type...) #define %value_inout_typemap(Type...) #define %ptr_input_typemap(Type...) #define %ptr_inout_typemap(Type...) #endif /* SWIG_INOUT_DEFAULT */ /*---------------------------------------------------------------------- Front ends. use the following macros to define your own IN/OUTPUT/INOUT typemaps ------------------------------------------------------------------------*/ %define %typemaps_inout(Code, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...) %_value_input_typemap(%arg(Code), %arg(AsValMeth), %arg(AsValFrag), %arg(Type)); %_value_output_typemap(%arg(FromMeth), %arg(FromFrag), %arg(Type)); %_value_inout_typemap(%arg(Type)); %enddef %define %typemaps_inoutn(Code,Type...) %typemaps_inout(%arg(Code), %arg(SWIG_AsVal(Type)), %arg(SWIG_From(Type)), %arg(SWIG_AsVal_frag(Type)), %arg(SWIG_From_frag(Type)), %arg(Type)); %enddef swig-3.0.8/Lib/typemaps/std_except.swg0000664000175000017500000000224212641054563017615 0ustar williamwilliam%include /* Mark all of std exception classes as "exception classes" via the "exceptionclass" feature. If needed, you can disable it by using %noexceptionclass. */ %define %std_exception_map(Exception, Code) %exceptionclass Exception; #if !defined(SWIG_STD_EXCEPTIONS_AS_CLASSES) %typemap(throws,noblock=1) Exception { SWIG_exception_fail(Code, $1.what()); } %ignore Exception; struct Exception { }; #endif %enddef namespace std { %std_exception_map(bad_exception, SWIG_SystemError); %std_exception_map(domain_error, SWIG_ValueError); %std_exception_map(exception, SWIG_SystemError); %std_exception_map(invalid_argument, SWIG_ValueError); %std_exception_map(length_error, SWIG_IndexError); %std_exception_map(logic_error, SWIG_RuntimeError); %std_exception_map(out_of_range, SWIG_IndexError); %std_exception_map(overflow_error, SWIG_OverflowError); %std_exception_map(range_error, SWIG_OverflowError); %std_exception_map(runtime_error, SWIG_RuntimeError); %std_exception_map(underflow_error, SWIG_OverflowError); } %include swig-3.0.8/Lib/typemaps/swigobject.swg0000664000175000017500000000157612641054563017624 0ustar williamwilliam/* ------------------------------------------------------------ * Language Object * - Just pass straight through unmodified * ------------------------------------------------------------ */ %typemap(in) SWIG_Object "$1 = $input;"; %typemap(in,noblock=1) SWIG_Object const & ($*ltype temp) { temp = %static_cast($input, $*ltype); $1 = &temp; } %typemap(out,noblock=1) SWIG_Object { %set_output($1); } %typemap(out,noblock=1) SWIG_Object const & { %set_output(*$1); } %typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = ($input != 0);"; %typemap(throws,noblock=1) SWIG_Object { %raise($1, "$type", 0); } %typemap(constcode,noblock=1) SWIG_Object { %set_constant("$symname", $value); } #if defined(SWIG_DIRECTOR_TYPEMAPS) %typemap(directorin) SWIG_Object "$input = $1;"; %typemap(directorout) SWIG_Object "$result = $input;"; #endif /* SWIG_DIRECTOR_TYPEMAPS */ swig-3.0.8/Lib/typemaps/cwstring.swg0000664000175000017500000000031712641054563017314 0ustar williamwilliam%include %include %typemaps_cstring(%cwstring, wchar_t, SWIG_AsWCharPtr, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtr, SWIG_FromWCharPtrAndSize); swig-3.0.8/Lib/typemaps/cmalloc.swg0000664000175000017500000000460612641054563017073 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cmalloc.swg * * This library file contains macros that can be used to create objects using * the C malloc function. * ----------------------------------------------------------------------------- */ %{ #include %} /* %malloc(TYPE [, NAME = TYPE]) %calloc(TYPE [, NAME = TYPE]) %realloc(TYPE [, NAME = TYPE]) %free(TYPE [, NAME = TYPE]) %allocators(TYPE [,NAME = TYPE]) Creates functions for allocating/reallocating memory. TYPE *malloc_NAME(size_t nbytes = sizeof(TYPE); TYPE *calloc_NAME(size_t nobj=1, size_t size=sizeof(TYPE)); TYPE *realloc_NAME(TYPE *ptr, size_t nbytes); void free_NAME(TYPE *ptr); */ %define %malloc(TYPE,NAME...) #if #NAME != "" %rename(malloc_##NAME) ::malloc(size_t nbytes); #else %rename(malloc_##TYPE) ::malloc(size_t nbytes); #endif #if #TYPE != "void" %typemap(default) size_t nbytes "$1 = (size_t) sizeof(TYPE);" #endif TYPE *malloc(size_t nbytes); %typemap(default) size_t nbytes; %enddef %define %calloc(TYPE,NAME...) #if #NAME != "" %rename(calloc_##NAME) ::calloc(size_t nobj, size_t sz); #else %rename(calloc_##TYPE) ::calloc(size_t nobj, size_t sz); #endif #if #TYPE != "void" %typemap(default) size_t sz "$1 = (size_t) sizeof(TYPE);" #else %typemap(default) size_t sz "$1 = 1;" #endif %typemap(default) size_t nobj "$1 = 1;" TYPE *calloc(size_t nobj, size_t sz); %typemap(default) size_t sz; %typemap(default) size_t nobj; %enddef %define %realloc(TYPE,NAME...) %insert("header") { #if #NAME != "" TYPE *realloc_##NAME(TYPE *ptr, size_t nitems) #else TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems) #endif { #if #TYPE != "void" return (TYPE *) realloc(ptr, nitems*sizeof(TYPE)); #else return (TYPE *) realloc(ptr, nitems); #endif } } #if #NAME != "" TYPE *realloc_##NAME(TYPE *ptr, size_t nitems); #else TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems); #endif %enddef %define %free(TYPE,NAME...) #if #NAME != "" %rename(free_##NAME) ::free(TYPE *ptr); #else %rename(free_##TYPE) ::free(TYPE *ptr); #endif void free(TYPE *ptr); %enddef %define %sizeof(TYPE,NAME...) #if #NAME != "" %constant size_t sizeof_##NAME = sizeof(TYPE); #else %constant size_t sizeof_##TYPE = sizeof(TYPE); #endif %enddef %define %allocators(TYPE,NAME...) %malloc(TYPE,NAME) %calloc(TYPE,NAME) %realloc(TYPE,NAME) %free(TYPE,NAME) #if #TYPE != "void" %sizeof(TYPE,NAME) #endif %enddef swig-3.0.8/Lib/typemaps/cstring.swg0000664000175000017500000000024712641054563017127 0ustar williamwilliam%include %typemaps_cstring(%cstring, char, SWIG_AsCharPtr, SWIG_AsCharPtrAndSize, SWIG_FromCharPtr, SWIG_FromCharPtrAndSize); swig-3.0.8/Lib/typemaps/string.swg0000664000175000017500000000137612641054563016770 0ustar williamwilliam%ensure_fragment(SWIG_AsCharPtrAndSize) %ensure_fragment(SWIG_FromCharPtrAndSize) %types(char *); %fragment("SWIG_pchar_descriptor","header") { SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { static int init = 0; static swig_type_info* info = 0; if (!init) { info = SWIG_TypeQuery("_p_char"); init = 1; } return info; } } %fragment("SWIG_strnlen","header",fragment="SWIG_FromCharPtrAndSize") { size_t SWIG_strnlen(const char* s, size_t maxlen) { const char *p; for (p = s; maxlen-- && *p; p++) ; return p - s; } } %include %typemaps_string(%checkcode(STRING), %checkcode(CHAR), char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen, SWIG_strnlen, "", CHAR_MIN, CHAR_MAX) swig-3.0.8/Lib/typemaps/enumint.swg0000664000175000017500000000236412641054563017137 0ustar williamwilliam/* ------------------------------------------------------------ * Enums mapped as integer values * ------------------------------------------------------------ */ %apply int { enum SWIGTYPE }; %apply const int& { const enum SWIGTYPE & }; %apply const int& { const enum SWIGTYPE && }; %typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE & (int val, int ecode, $basetype temp) { ecode = SWIG_AsVal(int)($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$type", $symname, $argnum); } else { temp = %static_cast(val,$basetype); $1 = &temp; } } %typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE && (int val, int ecode, $basetype temp) { ecode = SWIG_AsVal(int)($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$type", $symname, $argnum); } else { temp = %static_cast(val,$basetype); $1 = &temp; } } %typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE { if (sizeof(int) != sizeof($1)) { %variable_fail(SWIG_AttributeError,"$type", "arch, read-only $name"); } else { int ecode = SWIG_AsVal(int)($input, %reinterpret_cast(&$1,int*)); if (!SWIG_IsOK(ecode)) { %variable_fail(ecode, "$type", "$name"); } } } swig-3.0.8/Lib/typemaps/std_wstring.swg0000664000175000017500000000062012641054563020020 0ustar williamwilliam%include #ifndef SWIG_STD_BASIC_STRING #define SWIG_STD_WSTRING %include %{ #include %} %fragment(""); namespace std { %naturalvar wstring; class wstring; } %typemaps_std_string(std::wstring, wchar_t, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, %checkcode(STDUNISTRING)); #else %include #endif swig-3.0.8/Lib/typemaps/swigmacros.swg0000664000175000017500000001755312641054563017644 0ustar williamwilliam/* ----------------------------------------------------------------------------- * SWIG API. Portion only visible from SWIG * ----------------------------------------------------------------------------- */ /* This file implements the internal macros of the 'SWIG API', which are useful to implement all the SWIG target languages. Basic preprocessor macros: -------------------------- %arg(Arg) Safe argument wrap %str(Arg) Stringify the argument %begin_block Begin an execution block %end_block End an execution block %block(Block) Execute Block as an execution block %define_as(Def, Val) Define 'Def' as 'Val', expanding Def and Val first %ifcplusplus(V1, V2) if C++ Mode; then V1; else V2; fi Casting Operations: ------------------- SWIG provides the following casting macros, which implement the corresponding C++ casting operations: %const_cast(a, Type) const_cast(a) %static_cast(a, Type) static_cast(a) %reinterpret_cast(a, Type) reinterpret_cast(a) %numeric_cast(a, Type) static_cast(a) %as_voidptr(a) const_cast(static_cast(a)) %as_voidptrptr(a) reinterpret_cast(a) or their C unsafe versions. In C++ we use the safe version unless SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). Memory allocation: ------------------ These allocation/freeing macros are safe to use in C or C++ and dispatch the proper new/delete/delete[] or free/malloc calls as needed. %new_instance(Type) Allocate a new instance of given Type %new_copy(value,Type) Allocate and initialize a new instance with 'value' %new_array(size,Type) Allocate a new array with given size and Type %new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr' %delete(cptr) Delete an instance %delete_array(cptr) Delete an array Auxiliary loop macros: ---------------------- %formacro(Macro, Args...) or %formacro_1(Macro, Args...) for i in Args do Macro($i) done %formacro_2(Macro2, Args...) for i,j in Args do Macro2($i, $j) done Flags and conditional macros: ----------------------------- %mark_flag(flag) flag := True %evalif(flag,expr) if flag; then expr fi %evalif_2(flag1 flag2,expr) if flag1 and flag2; then expr fi */ /* ----------------------------------------------------------------------------- * Basic preprocessor macros * ----------------------------------------------------------------------------- */ #define %arg(Arg...) Arg #define %str(Arg) `Arg` #ifndef %begin_block # define %begin_block do { #endif #ifndef %end_block # define %end_block } while(0) #endif #define %block(Block...) %begin_block Block; %end_block /* define a new macro */ %define %define_as(Def, Val...)%#define Def Val %enddef /* include C++ or else value */ %define %ifcplusplus(cppval, nocppval) #ifdef __cplusplus cppval #else nocppval #endif %enddef /* insert the SWIGVERSION in the interface and the wrapper code */ #if SWIG_VERSION %insert("header") { %define_as(SWIGVERSION, SWIG_VERSION) %#define SWIG_VERSION SWIGVERSION } #endif /* ----------------------------------------------------------------------------- * Casting operators * ----------------------------------------------------------------------------- */ #if defined(SWIG_NO_CPLUSPLUS_CAST) /* Disable 'modern' cplusplus casting operators */ # if defined(SWIG_CPLUSPLUS_CAST) # undef SWIG_CPLUSPLUS_CAST # endif #endif #if defined(__cplusplus) && defined(SWIG_CPLUSPLUS_CAST) # define %const_cast(a,Type...) const_cast< Type >(a) # define %static_cast(a,Type...) static_cast< Type >(a) # define %reinterpret_cast(a,Type...) reinterpret_cast< Type >(a) # define %numeric_cast(a,Type...) static_cast< Type >(a) #else /* C case */ # define %const_cast(a,Type...) (Type)(a) # define %static_cast(a,Type...) (Type)(a) # define %reinterpret_cast(a,Type...) (Type)(a) # define %numeric_cast(a,Type...) (Type)(a) #endif /* __cplusplus */ #define %as_voidptr(a) SWIG_as_voidptr(a) #define %as_voidptrptr(a) SWIG_as_voidptrptr(a) %insert("header") { %define_as(SWIG_as_voidptr(a), %const_cast(%static_cast(a,const void *), void *)) %define_as(SWIG_as_voidptrptr(a), ((void)%as_voidptr(*a),%reinterpret_cast(a, void**))) } /* ----------------------------------------------------------------------------- * Allocating/freeing elements * ----------------------------------------------------------------------------- */ #if defined(__cplusplus) # define %new_instance(Type...) (new Type) # define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&))) # define %new_array(size,Type...) (new Type[size]) # define %new_copy_array(ptr,size,Type...) %reinterpret_cast(memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size)), Type*) # define %delete(cptr) delete cptr # define %delete_array(cptr) delete[] cptr #else /* C case */ # define %new_instance(Type...) (Type *)malloc(sizeof(Type)) # define %new_copy(val,Type...) (Type *)memcpy(%new_instance(Type),&val,sizeof(Type)) # define %new_array(size,Type...) (Type *)malloc((size)*sizeof(Type)) # define %new_copy_array(ptr,size,Type...) (Type *)memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size)) # define %delete(cptr) free((char*)cptr) # define %delete_array(cptr) free((char*)cptr) #endif /* __cplusplus */ /* ----------------------------------------------------------------------------- * SWIG names and mangling * ----------------------------------------------------------------------------- */ #define %mangle(Type...) #@Type #define %descriptor(Type...) SWIGTYPE_ ## #@Type #define %string_name(Name) "SWIG_" %str(Name) #define %symbol_name(Name, Type...) SWIG_ ## Name ## _ #@Type #define %checkcode(Code) SWIG_TYPECHECK_ ## Code /* ----------------------------------------------------------------------------- * Auxiliary loop macros * ----------------------------------------------------------------------------- */ /* for loop for macro with one argument */ %define %_formacro_1(macro, arg1,...)macro(arg1) #if #__VA_ARGS__ != "__fordone__" %_formacro_1(macro, __VA_ARGS__) #endif %enddef /* for loop for macro with one argument */ %define %formacro_1(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef %define %formacro(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef /* for loop for macro with two arguments */ %define %_formacro_2(macro, arg1, arg2, ...)macro(arg1, arg2) #if #__VA_ARGS__ != "__fordone__" %_formacro_2(macro, __VA_ARGS__) #endif %enddef /* for loop for macro with two arguments */ %define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef /* ----------------------------------------------------------------------------- * SWIG flags * ----------------------------------------------------------------------------- */ /* mark a flag, ie, define a macro name but ignore it in the interface. the flag can be later used with %evalif */ %define %mark_flag(x) %define x 1 %enddef %enddef /* %evalif and %evalif_2 are use to evaluate or process an expression if the given predicate is 'true' (1). */ %define %_evalif(_x,_expr) #if _x == 1 _expr #endif %enddef %define %_evalif_2(_x,_y,_expr) #if _x == 1 && _y == 1 _expr #endif %enddef %define %evalif(_x,_expr...) %_evalif(%arg(_x),%arg(_expr)) %enddef %define %evalif_2(_x,_y,_expr...) %_evalif_2(%arg(_x),%arg(_y),%arg(_expr)) %enddef swig-3.0.8/Lib/typemaps/void.swg0000664000175000017500000000403012641054563016411 0ustar williamwilliam/* ------------------------------------------------------------ * Void * - Accepts any kind of pointer * ------------------------------------------------------------ */ /* in */ %typemap(in,noblock=1) void * (int res) { res = SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } } %typemap(freearg) void * ""; %typemap(in,noblock=1) void * const& ($*ltype temp = 0, int res) { res = SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown); if (!SWIG_IsOK(res)) { %argument_fail(res, "Stype", $symname, $argnum); } $1 = &temp; } %typemap(freearg) void * const& ""; /* out */ #if defined(VOID_Object) %typemap(out,noblock=1) void { $result = VOID_Object; } #else %typemap(out,noblock=1) void {} #endif /* varin */ %typemap(varin) void * { void *temp = 0; int res = SWIG_ConvertPtr($input, &temp, 0, SWIG_POINTER_DISOWN); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = ($1_ltype) temp; } /* typecheck */ %typecheck(SWIG_TYPECHECK_VOIDPTR, noblock=1) void * { void *ptr = 0; int res = SWIG_ConvertPtr($input, &ptr, 0, 0); $1 = SWIG_CheckState(res); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1) void *, void const*, void *const, void const *const, void const *&, void *const &, void const *const & { $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags); } /* directorout */ %typemap(directorout,noblock=1) void * (void *argp, int res) { res = SWIG_ConvertPtr($input, &argp, 0, 0); if (!SWIG_IsOK(res)) { %dirout_fail(res,"$type"); } $result = %reinterpret_cast(argp, $ltype); } %typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) void * const& (void *argp, int res) { res = SWIG_ConvertPtr($input, &argp, 0, $disown); if (!SWIG_IsOK(res)) { %dirout_fail(res,"$type"); } static $*ltype temp = %reinterpret_cast(argp, $*ltype); $result = &temp; } #endif /* SWIG_DIRECTOR_TYPEMAPS */ swig-3.0.8/Lib/typemaps/primtypes.swg0000664000175000017500000002064012641054563017511 0ustar williamwilliam/* ------------------------------------------------------------ * Primitive type fragments and macros * ------------------------------------------------------------ */ /* This file provide fragments and macros for the C/C++ primitive types. The file defines default fragments for the following types: bool signed char unsigned char signed wchar_t // in C++ unsigned wchar_t // in C++ short unsigned short int unsigned int float size_t ptrdiff_t which can always be redefined in the swig target language if needed. The fragments for the following types, however, always need to be defined in the target language: long unsigned long long long unsigned long long double If they are not provided, an #error directive will appear in the wrapped code. -------------------------------------------------------------------- This file provides the macro %typemaps_primitive(CheckCode, Type) which generates the typemaps for a primitive type with a given checkcode. It is assumed that the primitive type is 'normalized' and the corresponding SWIG_AsVal(Type) and SWIG_From(Type) methods are provided via fragments. The following auxiliary macros (explained with bash pseudo code) are also defined: %apply_ctypes(Macro) for i in C Type do Macro($i) done %apply_cpptypes(Macro) for i in C++ Type do Macro($i) done %apply_ctypes_2(Macro2) for i in C Type do for j in C Type do Macro_2($i, $j) done done %apply_cpptypes_2(Macro2) for i in C++ Type do for j in C++ Type do Macro_2($i, $j) done done %apply_checkctypes(Macro2) for i in Check Type do Macro2(%checkcode($i), $i) done */ /* ------------------------------------------------------------ * Primitive type fragments * ------------------------------------------------------------ */ /* boolean */ %fragment(SWIG_From_frag(bool),"header",fragment=SWIG_From_frag(long)) { SWIGINTERN SWIG_Object SWIG_From_dec(bool)(bool value) { return SWIG_From(long)(value ? 1 : 0); } } %fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val) { long v; int res = SWIG_AsVal(long)(obj, val ? &v : 0); if (SWIG_IsOK(res)) { if (val) *val = v ? true : false; return res; } return SWIG_TypeError; } } /* signed/unsigned char */ %numeric_slong(signed char, "", SCHAR_MIN, SCHAR_MAX) %numeric_ulong(unsigned char, "", UCHAR_MAX) /* short/unsigned short */ %numeric_slong(short, "", SHRT_MIN, SHRT_MAX) %numeric_ulong(unsigned short, "", USHRT_MAX) /* int/unsigned int */ %numeric_slong(int, "", INT_MIN, INT_MAX) %numeric_ulong(unsigned int, "", UINT_MAX) /* signed/unsigned wchar_t */ #ifdef __cplusplus %numeric_slong(signed wchar_t, "", WCHAR_MIN, WCHAR_MAX) %numeric_ulong(unsigned wchar_t, "", UWCHAR_MAX) #endif /* float */ %numeric_float(float, "SWIG_Float_Overflow_Check", SWIG_Float_Overflow_Check(v)) /* long/unsigned long */ %ensure_type_fragments(long) %ensure_type_fragments(unsigned long) /* long long/unsigned long long */ %ensure_type_fragments(long long) %ensure_type_fragments(unsigned long long) /* double */ %ensure_type_fragments(double) /* size_t */ %fragment(SWIG_From_frag(size_t),"header",fragment=SWIG_From_frag(unsigned long)) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(size_t)(size_t value) { return SWIG_From(unsigned long)(%numeric_cast(value, unsigned long)); } } %fragment(SWIG_AsVal_frag(size_t),"header",fragment=SWIG_AsVal_frag(unsigned long)) { SWIGINTERNINLINE int SWIG_AsVal_dec(size_t)(SWIG_Object obj, size_t *val) { unsigned long v; int res = SWIG_AsVal(unsigned long)(obj, val ? &v : 0); if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, size_t); return res; } } /* ptrdiff_t */ %fragment(SWIG_From_frag(ptrdiff_t),"header",fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(ptrdiff_t)(ptrdiff_t value) { return SWIG_From(long)(%numeric_cast(value,long)); } } %fragment(SWIG_AsVal_frag(ptrdiff_t),"header",fragment=SWIG_AsVal_frag(long)) { SWIGINTERNINLINE int SWIG_AsVal_dec(ptrdiff_t)(SWIG_Object obj, ptrdiff_t *val) { long v; int res = SWIG_AsVal(long)(obj, val ? &v : 0); if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, ptrdiff_t); return res; } } %fragment("SWIG_CanCastAsInteger","header", fragment=SWIG_AsVal_frag(double), fragment="", fragment="") { SWIGINTERNINLINE int SWIG_CanCastAsInteger(double *d, double min, double max) { double x = *d; if ((min <= x && x <= max)) { double fx = floor(x); double cx = ceil(x); double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ if ((errno == EDOM) || (errno == ERANGE)) { errno = 0; } else { double summ, reps, diff; if (rd < x) { diff = x - rd; } else if (rd > x) { diff = rd - x; } else { return 1; } summ = rd + x; reps = diff/summ; if (reps < 8*DBL_EPSILON) { *d = rd; return 1; } } } return 0; } } /* ------------------------------------------------------------ * Generate the typemaps for primitive type * ------------------------------------------------------------ */ #define %typemaps_primitive(Code, Type) %typemaps_asvalfromn(%arg(Code), Type) /* ------------------------------------------------------------ * Primitive Type Macros * ------------------------------------------------------------ */ /* useful macros to derive typemap declarations from primitive types */ %define _apply_macro(macro, arg2, arg1...) #if #arg1 != "" macro(%arg(arg1),arg2); #else macro(arg2); #endif %enddef /* Apply macro to the C-types */ %define %apply_ctypes(Macro, Arg2...) _apply_macro(Macro, bool , Arg2); _apply_macro(Macro, signed char , Arg2); _apply_macro(Macro, unsigned char , Arg2); _apply_macro(Macro, short , Arg2); _apply_macro(Macro, unsigned short , Arg2); _apply_macro(Macro, int , Arg2); _apply_macro(Macro, unsigned int , Arg2); _apply_macro(Macro, long , Arg2); _apply_macro(Macro, unsigned long , Arg2); _apply_macro(Macro, long long , Arg2); _apply_macro(Macro, unsigned long long , Arg2); _apply_macro(Macro, float , Arg2); _apply_macro(Macro, double , Arg2); _apply_macro(Macro, char , Arg2); _apply_macro(Macro, wchar_t , Arg2); _apply_macro(Macro, size_t , Arg2); _apply_macro(Macro, ptrdiff_t , Arg2); %enddef /* apply the Macro2(Type1, Type2) to all C types */ #define %apply_ctypes_2(Macro2) %apply_ctypes(%apply_ctypes, Macro2) /* apply the Macro(Type) to all C++ types */ %define %apply_cpptypes(Macro, Arg2...) %apply_ctypes(Macro, Arg2) _apply_macro(Macro, std::size_t, Arg2); _apply_macro(Macro, std::ptrdiff_t, Arg2); _apply_macro(Macro, std::string, Arg2); _apply_macro(Macro, std::wstring, Arg2); _apply_macro(Macro, std::complex, Arg2); _apply_macro(Macro, std::complex, Arg2); %enddef /* apply the Macro2(Type1, Type2) to all C++ types */ #define %apply_cpptypes_2(Macro2) %apply_cpptypes(%apply_cpptypes, Macro2) /* apply the Macro2(CheckCode,Type) to all Checked Types */ %define %apply_checkctypes(Macro2) Macro2(%checkcode(BOOL), bool); Macro2(%checkcode(INT8), signed char); Macro2(%checkcode(UINT8), unsigned char); Macro2(%checkcode(INT16), short); Macro2(%checkcode(UINT16), unsigned short); Macro2(%checkcode(INT32), int); Macro2(%checkcode(UINT32), unsigned int); Macro2(%checkcode(INT64), long); Macro2(%checkcode(UINT64), unsigned long); Macro2(%checkcode(INT128), long long); Macro2(%checkcode(UINT128), unsigned long long); Macro2(%checkcode(FLOAT), float); Macro2(%checkcode(DOUBLE), double); Macro2(%checkcode(CHAR), char); Macro2(%checkcode(UNICHAR), wchar_t); Macro2(%checkcode(SIZE), size_t); Macro2(%checkcode(PTRDIFF), ptrdiff_t); %enddef /* ------------------------------------------------------------ * Generate the typemaps for all the primitive types with checkcode * ------------------------------------------------------------ */ %apply_checkctypes(%typemaps_primitive); swig-3.0.8/Lib/typemaps/cstrings.swg0000664000175000017500000002003612641054563017310 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cstrings.swg * * This file provides typemaps and macros for dealing with various forms * of C character string handling. The primary use of this module * is in returning character data that has been allocated or changed in * some way. * ----------------------------------------------------------------------------- */ %define %typemaps_cstring(Name, Char, SWIG_AsCharPtr, SWIG_AsCharPtrAndSize, SWIG_FromCharPtr, SWIG_FromCharPtrAndSize) /* %cstring_input_binary(TYPEMAP, SIZE) * * Macro makes a function accept binary string data along with * a size. For example: * * %cstring_input_binary(Char *buff, int size); * void foo(Char *buff, int size) { * } * */ %define Name ## _input_binary(TYPEMAP, SIZE) %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } $1 = ($1_ltype) buf; $2 = ($2_ltype) size - 1; } %typemap(freearg,noblock=1,match="in") (TYPEMAP, SIZE) { if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); } %enddef /* * %cstring_bounded_output(TYPEMAP, MAX) * * This macro is used to return a NULL-terminated output string of * some maximum length. For example: * * %cstring_bounded_output(Char *outx, 512); * void foo(Char *outx) { * sprintf(outx,"blah blah\n"); * } * */ %define Name ## _bounded_output(TYPEMAP,MAX) %typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) { $1 = ($1_ltype) temp; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP { $1[MAX] = 0; %append_output(SWIG_FromCharPtr($1)); } %enddef /* * %cstring_chunk_output(TYPEMAP, SIZE) * * This macro is used to return a chunk of binary string data. * Embedded NULLs are okay. For example: * * %cstring_chunk_output(Char *outx, 512); * void foo(Char *outx) { * memmove(outx, somedata, 512); * } * */ %define Name ## _chunk_output(TYPEMAP,SIZE) %typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) { $1 = ($1_ltype) temp; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP { %append_output(SWIG_FromCharPtrAndSize($1,SIZE)); } %enddef /* * %cstring_bounded_mutable(TYPEMAP, SIZE) * * This macro is used to wrap a string that's going to mutate. * * %cstring_bounded_mutable(Char *in, 512); * void foo(in *x) { * while (*x) { * *x = toupper(*x); * x++; * } * } * */ %define Name ## _bounded_mutable(TYPEMAP,MAX) %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP (int res,Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &t, &n, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res, "TYPEMAP", $symname, $argnum); } if ( n > (size_t) MAX ) n = (size_t) MAX; memcpy(temp, t, sizeof(Char)*n); if (alloc == SWIG_NEWOBJ) %delete_array(t); temp[n - 1] = 0; $1 = ($1_ltype) temp; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { $1[MAX] = 0; %append_output(SWIG_FromCharPtr($1)); } %enddef /* * %cstring_mutable(TYPEMAP [, expansion]) * * This macro is used to wrap a string that will mutate in place. * It may change size up to a user-defined expansion. * * %cstring_mutable(Char *in); * void foo(in *x) { * while (*x) { * *x = toupper(*x); * x++; * } * } * */ %define Name ## _mutable(TYPEMAP,EXP...) %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP (int res, Char *t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) { #if #EXP != "" expansion += EXP; #endif res = SWIG_AsCharPtrAndSize($input, &t, &n, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res, "TYPEMAP", $symname, $argnum); } $1 = %new_array(n+expansion, $*1_ltype); memcpy($1,t,sizeof(Char)*n); if (alloc == SWIG_NEWOBJ) %delete_array(t); $1[n-1] = 0; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { %append_output(SWIG_FromCharPtr($1)); %delete_array($1); } %enddef /* * %cstring_output_maxsize(TYPEMAP, SIZE) * * This macro returns data in a string of some user-defined size. * * %cstring_output_maxsize(Char *outx, int max) { * void foo(Char *outx, int max) { * sprintf(outx,"blah blah\n"); * } */ %define Name ## _output_maxsize(TYPEMAP, SIZE) %typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (int res, size_t size, Char *buff = 0) { res = SWIG_AsVal(size_t)($input, &size); if (!SWIG_IsOK(res)) { %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } buff= %new_array(size+1, Char); $2 = %numeric_cast(size, $2_ltype); $1 = %static_cast(buff, $1_ltype); } %typemap(freearg,noblock=1,match="in") (TYPEMAP,SIZE) { if (buff$argnum) %delete_array(buff$argnum); } %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) { %append_output(SWIG_FromCharPtr($1)); } %enddef /* * %cstring_output_withsize(TYPEMAP, SIZE) * * This macro is used to return Character data along with a size * parameter. * * %cstring_output_maxsize(Char *outx, int *max) { * void foo(Char *outx, int *max) { * sprintf(outx,"blah blah\n"); * *max = strlen(outx); * } */ %define Name ## _output_withsize(TYPEMAP, SIZE) %typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (int res, size_t n, Char *buff = 0, $*2_ltype size) { res = SWIG_AsVal(size_t)($input, &n); if (!SWIG_IsOK(res)) { %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } buff= %new_array(n+1, Char); $1 = %static_cast(buff, $1_ltype); size = %numeric_cast(n,$*2_ltype); $2 = &size; } %typemap(freearg,noblock=1,match="in")(TYPEMAP,SIZE) { if (buff$argnum) %delete_array(buff$argnum); } %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) { %append_output(SWIG_FromCharPtrAndSize($1,*$2)); } %enddef /* * %cstring_output_allocate(TYPEMAP, RELEASE) * * This macro is used to return Character data that was * allocated with new or malloc. * * %cstring_output_allocated(Char **outx, free($1)); * void foo(Char **outx) { * *outx = (Char *) malloc(512); * sprintf(outx,"blah blah\n"); * } */ %define Name ## _output_allocate(TYPEMAP, RELEASE) %typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) { $1 = &temp; } %typemap(freearg,match="in") TYPEMAP ""; %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { if (*$1) { %append_output(SWIG_FromCharPtr(*$1)); RELEASE; } } %enddef /* * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) * * This macro is used to return Character data that was * allocated with new or malloc. * * %cstring_output_allocated(Char **outx, int *sz, free($1)); * void foo(Char **outx, int *sz) { * *outx = (Char *) malloc(512); * sprintf(outx,"blah blah\n"); * *sz = strlen(outx); * } */ %define Name ## _output_allocate_size(TYPEMAP, SIZE, RELEASE) %typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { $1 = &temp; $2 = &tempn; } %typemap(freearg,match="in") (TYPEMAP,SIZE) ""; %typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) { if (*$1) { %append_output(SWIG_FromCharPtrAndSize(*$1,*$2)); RELEASE; } } %enddef %enddef swig-3.0.8/Lib/typemaps/strings.swg0000664000175000017500000004456612641054563017163 0ustar williamwilliam// // Use the macro SWIG_PRESERVE_CARRAY_SIZE if you prefer to preserve // the size of char arrays, ie // ------------------------------------------ // C Side => Language Side // ------------------------------------------ // char name[5] = "hola" => 'hola\0' // // the default behaviour is // // char name[5] = "hola" => 'hola' // // //#define SWIG_PRESERVE_CARRAY_SIZE /* ------------------------------------------------------------ * String typemaps for type Char (char or wchar_t) * ------------------------------------------------------------ */ %define %_typemap_string(StringCode, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_AsCharPtr, SWIG_FromCharPtr, SWIG_AsCharArray, SWIG_NewCopyCharArray, SWIG_DeleteCharArray) /* in */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char * (int res, Char *buf = 0, int alloc = 0), const Char * (int res, Char *buf = 0, int alloc = 0) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = %reinterpret_cast(buf, $1_ltype); } %typemap(freearg,noblock=1,match="in") Char *, const Char * { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } %typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (int res, Char *buf = 0, int alloc = 0) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = &buf; } %typemap(freearg, noblock=1,match="in") Char const*& { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* out */ %typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * { %set_output(SWIG_FromCharPtr((const Char *)$1)); } %typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char const*& { %set_output(SWIG_FromCharPtr(*$1)); } %typemap(newfree,noblock=1) Char * { SWIG_DeleteCharArray($1); } /* varin */ %typemap(varin,fragment=#SWIG_AsCharPtrAndSize) Char * { Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ; int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc); if (!SWIG_IsOK(res)) { %variable_fail(res,"$type","$name"); } if ($1) SWIG_DeleteCharArray($1); if (alloc == SWIG_NEWOBJ) { $1 = cptr; } else { $1 = csize ? ($1_type)SWIG_NewCopyCharArray(cptr, csize, Char) : 0; } } %typemap(varin,fragment=#SWIG_AsCharPtrAndSize,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ; int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (alloc == SWIG_NEWOBJ) { $1 = cptr; } else { $1 = csize ? ($1_type)SWIG_NewCopyCharArray(cptr, csize, Char) : 0; } } /* varout */ %typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * { %set_varoutput(SWIG_FromCharPtr($1)); } /* memberin */ %typemap(memberin,noblock=1) Char * { if ($1) SWIG_DeleteCharArray($1); if ($input) { size_t size = SWIG_CharPtrLen(%reinterpret_cast($input, const Char *)) + 1; $1 = ($1_type)SWIG_NewCopyCharArray(%reinterpret_cast($input, const Char *), size, Char); } else { $1 = 0; } } %typemap(memberin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { if ($input) { size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1; $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char); } else { $1 = 0; } } /* globalin */ %typemap(globalin,noblock=1) Char * { if ($1) SWIG_DeleteCharArray($1); if ($input) { size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1; $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char); } else { $1 = 0; } } %typemap(globalin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { if ($input) { size_t size = SWIG_CharPtrLen($input) + 1; $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char); } else { $1 = 0; } } /* constant */ %typemap(constcode,noblock=1,fragment=#SWIG_FromCharPtr) Char *, Char const*, Char * const, Char const* const { %set_constant("$symname", SWIG_FromCharPtr($value)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtr) Char *, Char const*, Char *const, Char const *const, Char const *&, Char *const &, Char const *const & { $input = SWIG_FromCharPtr((const Char *)$1); } /* directorout */ %typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char * (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %dirout_fail(res, "$type"); } if (alloc == SWIG_NEWOBJ) { swig_acquire_ownership_array(buf); } $result = %reinterpret_cast(buf, $1_ltype); } %typemap(directorfree,noblock=1) Char * { if (director) { director->swig_release_ownership(%as_voidptr($input)); } } %typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char *const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ), Char const*const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) { res = SWIG_AsCharPtr($input, &buf, &alloc); if (!SWIG_IsOK(res)) { %dirout_fail(res, "$type"); } static $*1_ltype tmp = buf; $result = &tmp; if (alloc == SWIG_NEWOBJ) { swig_acquire_ownership_array(buf); } } %typemap(directorfree,noblock=1) Char * const&, Char const* const& { if (director) { director->swig_release_ownership(%as_voidptr(*$input)); } } #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* typecheck */ %typemap(typecheck,noblock=1,precedence=StringCode, fragment=#SWIG_AsCharPtr) Char *, const Char *, Char const*& { int res = SWIG_AsCharPtr($input, 0, 0); $1 = SWIG_CheckState(res); } /* throws */ %typemap(throws,noblock=1,fragment=#SWIG_FromCharPtr) Char * { %raise(SWIG_FromCharPtr($1), "$type", 0); } /* ------------------------------------------------------------ * Unknown size const Character array Char[ANY] handling * ------------------------------------------------------------ */ %apply Char * { Char [] }; %apply const Char * { const Char [] }; %typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char [] { %variable_fail(SWIG_AttributeError, "$type", "read-only $name"); } /* ------------------------------------------------------------ * Fixed size Character array Char[ANY] handling * ------------------------------------------------------------ */ /* memberin and globalin typemaps */ %typemap(memberin,noblock=1) Char [ANY] { if ($input) memcpy($1,$input,$1_dim0*sizeof(Char)); else memset($1,0,$1_dim0*sizeof(Char)); } %typemap(globalin,noblock=1) Char [ANY] { if ($input) memcpy($1,$input,$1_dim0*sizeof(Char)); else memset($1,0,$1_dim0*sizeof(Char)); } /* in */ %typemap(in,noblock=1,fragment=#SWIG_AsCharArray) Char [ANY] (Char temp[$1_dim0], int res), const Char [ANY](Char temp[$1_dim0], int res) { res = SWIG_AsCharArray($input, temp, $1_dim0); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = %reinterpret_cast(temp, $1_ltype); } %typemap(freearg) Char [ANY], const Char [ANY] ""; %typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0], int res) { res = SWIG_AsCharArray($input, temp, $1_dim0); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = &temp; } %typemap(freearg) const Char (&)[ANY] ""; %typemap(out,fragment=#SWIG_FromCharPtrAndSize,fragment=#SWIG_CharBufLen) Char [ANY], const Char[ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $1_dim0; %#endif %set_output(SWIG_FromCharPtrAndSize($1, size)); } /* varin */ %typemap(varin,fragment=#SWIG_AsCharArray) Char [ANY] { int res = SWIG_AsCharArray($input, $1, $1_dim0); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } } /* varout */ %typemap(varout,fragment=#SWIG_CharBufLen) Char [ANY], const Char [ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $1_dim0; %#endif %set_varoutput(SWIG_FromCharPtrAndSize($1, size)); } /* constant */ %typemap(constcode,fragment=#SWIG_CharBufLen) Char [ANY], const Char [ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $value_dim0; %#endif %set_constant("$symname", SWIG_FromCharPtrAndSize($value,size)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,fragment=#SWIG_CharBufLen) Char [ANY], const Char [ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $1_dim0; %#endif $input = SWIG_FromCharPtrAndSize($1, size); } /* directorout */ %typemap(directorout,noblock=1,fragment=#SWIG_AsCharArray) Char [ANY] (Char temp[$result_dim0]), const Char [ANY] (Char temp[$result_dim0], int res) { res = SWIG_AsCharArray($input, temp, $result_dim0); if (!SWIG_IsOK(res)) { %dirout_fail(res, "$type"); } $result = temp; } #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* typecheck */ %typemap(typecheck,noblock=1,precedence=StringCode, fragment=#SWIG_AsCharArray) Char [ANY], const Char[ANY] { int res = SWIG_AsCharArray($input, (Char *)0, $1_dim0); $1 = SWIG_CheckState(res); } /* throws */ %typemap(throws,fragment=#SWIG_CharBufLen) Char [ANY], const Char[ANY] { %#ifndef SWIG_PRESERVE_CARRAY_SIZE size_t size = SWIG_CharBufLen($1, $1_dim0); %#else size_t size = $1_dim0; %#endif %raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0); } /* ------------------------------------------------------------------- * --- Really fix size Char arrays, including '\0'chars at the end --- * ------------------------------------------------------------------- */ %typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { %set_varoutput(SWIG_FromCharPtrAndSize($1, $1_dim0)); } %typemap(out,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { %set_output(SWIG_FromCharPtrAndSize($1, $1_dim0)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) %typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { $input = SWIG_FromCharPtrAndSize($1, $1_dim0); } #endif /* SWIG_DIRECTOR_TYPEMAPS */ %typemap(throws,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { %raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0); } /* ------------------------------------------------------------ * --- String & length --- * ------------------------------------------------------------ */ /* Here len doesn't include the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), (const Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = %reinterpret_cast(buf, $1_ltype); $2 = %numeric_cast(size - 1, $2_ltype); } %typemap(freearg,noblock=1,match="in") (Char *STRING, size_t LENGTH) { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* old 'int' form */ %typemap(in) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH); %typemap(freearg) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH); /* Here size includes the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), (const Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $1 = %reinterpret_cast(buf, $1_ltype); $2 = %numeric_cast(size, $2_ltype); } %typemap(freearg,noblock=1,match="in") (Char *STRING, size_t SIZE) { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* old 'int' form */ %typemap(in) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE); %typemap(freearg) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE); /* reverse order versions */ /* Here len doesn't include the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (size_t LENGTH, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), (size_t LENGTH, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } $2 = %reinterpret_cast(buf, $2_ltype) ; $1 = %numeric_cast(size - 1, $1_ltype) ; } %typemap(freearg, noblock=1, match="in") (size_t LENGTH, Char *STRING) { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* old 'int' form */ %typemap(in) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING); %typemap(freearg) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING); /* Here size includes the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (size_t SIZE, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), (size_t SIZE, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type",$symname, $argnum); } $2 = %reinterpret_cast(buf, $2_ltype) ; $1 = %numeric_cast(size, $1_ltype) ; } %typemap(freearg, noblock=1, match="in") (size_t SIZE, Char *STRING) { if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum); } /* old 'int' form */ %typemap(in) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING); %typemap(freearg) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING); %enddef /* ------------------------------------------------------------ * --- String fragment methods --- * ------------------------------------------------------------ */ #ifndef %_typemap2_string %define %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_NewCopyCharArray, SWIG_DeleteCharArray, FragLimits, CHAR_MIN, CHAR_MAX) %fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) { SWIGINTERNINLINE SWIG_Object SWIG_From##CharName##Ptr(const Char *cptr) { return SWIG_FromCharPtrAndSize(cptr, (cptr ? SWIG_CharPtrLen(cptr) : 0)); } } %fragment("SWIG_From"#CharName"Array","header",fragment=#SWIG_FromCharPtrAndSize) { SWIGINTERNINLINE SWIG_Object SWIG_From##CharName##Array(const Char *cptr, size_t size) { return SWIG_FromCharPtrAndSize(cptr, size); } } %fragment("SWIG_As" #CharName "Ptr","header",fragment=#SWIG_AsCharPtrAndSize) { %define_as(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_AsCharPtrAndSize(obj, val, NULL, alloc)) } %fragment("SWIG_As" #CharName "Array","header",fragment=#SWIG_AsCharPtrAndSize) { SWIGINTERN int SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size) { Char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc); if (SWIG_IsOK(res)) { /* special case of single char conversion when we don't need space for NUL */ if (size == 1 && csize == 2 && cptr && !cptr[1]) --csize; if (csize <= size) { if (val) { if (csize) memcpy(val, cptr, csize*sizeof(Char)); if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char)); } if (alloc == SWIG_NEWOBJ) { SWIG_DeleteCharArray(cptr); res = SWIG_DelNewMask(res); } return res; } if (alloc == SWIG_NEWOBJ) SWIG_DeleteCharArray(cptr); } return SWIG_TypeError; } } /* Char */ %fragment(SWIG_From_frag(Char),"header",fragment=#SWIG_FromCharPtrAndSize) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(Char)(Char c) { return SWIG_FromCharPtrAndSize(&c,1); } } %fragment(SWIG_AsVal_frag(Char),"header", fragment="SWIG_As"#CharName"Array", fragment=FragLimits, fragment=SWIG_AsVal_frag(long)) { SWIGINTERN int SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val) { int res = SWIG_As##CharName##Array(obj, val, 1); if (!SWIG_IsOK(res)) { long v; res = SWIG_AddCast(SWIG_AsVal(long)(obj, &v)); if (SWIG_IsOK(res)) { if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) { if (val) *val = %numeric_cast(v, Char); } else { res = SWIG_OverflowError; } } } return res; } } %_typemap_string(StringCode, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_As##CharName##Ptr, SWIG_From##CharName##Ptr, SWIG_As##CharName##Array, SWIG_NewCopyCharArray, SWIG_DeleteCharArray) %enddef #endif /* ------------------------------------------------------------ * String typemaps and fragments, with default allocators * ------------------------------------------------------------ */ %define %typemaps_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, FragLimits, CHAR_MIN, CHAR_MAX) %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, %new_copy_array, %delete_array, FragLimits, CHAR_MIN, CHAR_MAX) %enddef /* ------------------------------------------------------------ * String typemaps and fragments, with custom allocators * ------------------------------------------------------------ */ %define %typemaps_string_alloc(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_NewCopyCharArray, SWIG_DeleteCharArray, FragLimits, CHAR_MIN, CHAR_MAX) %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_CharBufLen, SWIG_NewCopyCharArray, SWIG_DeleteCharArray, FragLimits, CHAR_MIN, CHAR_MAX) %enddef swig-3.0.8/Lib/typemaps/cpointer.swg0000664000175000017500000000627512641054563017310 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cpointer.swg * * This library file contains macros that can be used to manipulate simple * pointer objects. * * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %pointer_class(type,name) * * Places a simple proxy around a simple type like 'int', 'float', or whatever. * The proxy provides this interface: * * class type { * public: * type(); * ~type(); * type value(); * void assign(type value); * }; * * Example: * * %pointer_class(int, intp); * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = intp() * >>> a.assign(10) * >>> a.value() * 10 * >>> b = intp() * >>> b.assign(20) * >>> print add(a,b) * 30 * * As a general rule, this macro should not be used on class/structures that * are already defined in the interface. * ----------------------------------------------------------------------------- */ %define %pointer_class(TYPE, NAME) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { NAME() { return %new_instance(TYPE); } ~NAME() { if ($self) %delete($self); } } %extend NAME { void assign(TYPE value) { *$self = value; } TYPE value() { return *$self; } TYPE * cast() { return $self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; } } %types(NAME = TYPE); %enddef /* ----------------------------------------------------------------------------- * %pointer_functions(type,name) * * Create functions for allocating/deallocating pointers. This can be used * if you don't want to create a proxy class or if the pointer is complex. * * %pointer_functions(int, intp) * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = copy_intp(10) * >>> intp_value(a) * 10 * >>> b = new_intp() * >>> intp_assign(b,20) * >>> print add(a,b) * 30 * >>> delete_intp(a) * >>> delete_intp(b) * * ----------------------------------------------------------------------------- */ %define %pointer_functions(TYPE,NAME) %{ static TYPE *new_##NAME() { return %new_instance(TYPE); } static TYPE *copy_##NAME(TYPE value) { return %new_copy(value, TYPE); } static void delete_##NAME(TYPE *obj) { if (obj) %delete(obj); } static void NAME ##_assign(TYPE *obj, TYPE value) { *obj = value; } static TYPE NAME ##_value(TYPE *obj) { return *obj; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); void delete_##NAME(TYPE *obj); void NAME##_assign(TYPE *obj, TYPE value); TYPE NAME##_value(TYPE *obj); %enddef /* ----------------------------------------------------------------------------- * %pointer_cast(type1,type2,name) * * Generates a pointer casting function. * ----------------------------------------------------------------------------- */ %define %pointer_cast(TYPE1,TYPE2,NAME) %inline %{ TYPE2 NAME(TYPE1 x) { return %static_cast(x, TYPE2); } %} %enddef swig-3.0.8/Lib/typemaps/exception.swg0000664000175000017500000000522712641054563017457 0ustar williamwilliam/* ----------------------------------------------------------------------------- * exceptions.swg * * This SWIG library file provides language independent exception handling * ----------------------------------------------------------------------------- */ %include /* macros for error manipulation */ #define %nullref_fmt() "invalid null reference " #define %varfail_fmt(_type,_name) "in variable '"`_name`"' of type '"`_type`"'" #ifndef %argfail_fmt #define %argfail_fmt(_type,_name,_argn) "in method '" `_name` "', argument " `_argn`" of type '" `_type`"'" #endif #define %outfail_fmt(_type) "in output value of type '"_type"'" #ifndef %argnullref_fmt #define %argnullref_fmt(_type,_name,_argn) %nullref_fmt() %argfail_fmt(_type, _name, _argn) #endif #define %varnullref_fmt(_type,_name) %nullref_fmt() %varfail_fmt(_type, _name) #define %outnullref_fmt(_type) %nullref_fmt() %outfail_fmt(_type) /* setting an error */ #define %error(code,msg...) SWIG_Error(code, msg) #define %type_error(msg...) SWIG_Error(SWIG_TypeError, msg) %insert("runtime") { %define_as(SWIG_exception_fail(code, msg), %block(%error(code, msg); SWIG_fail)) %define_as(SWIG_contract_assert(expr, msg), if (!(expr)) { %error(SWIG_RuntimeError, msg); SWIG_fail; } else) } #ifdef __cplusplus /* You can use the SWIG_CATCH_STDEXCEPT macro with the %exception directive as follows: %exception { try { $action } catch (my_except& e) { ... } SWIG_CATCH_STDEXCEPT // catch std::exception catch (...) { SWIG_exception_fail(SWIG_UnknownError, "Unknown exception"); } } */ %fragment(""); %define SWIG_CATCH_STDEXCEPT /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); } catch (std::domain_error& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); } catch (std::overflow_error& e) { SWIG_exception_fail(SWIG_OverflowError, e.what() ); } catch (std::out_of_range& e) { SWIG_exception_fail(SWIG_IndexError, e.what() ); } catch (std::length_error& e) { SWIG_exception_fail(SWIG_IndexError, e.what() ); } catch (std::runtime_error& e) { SWIG_exception_fail(SWIG_RuntimeError, e.what() ); } catch (std::exception& e) { SWIG_exception_fail(SWIG_SystemError, e.what() ); } %enddef %define SWIG_CATCH_UNKNOWN catch (std::exception& e) { SWIG_exception_fail(SWIG_SystemError, e.what() ); } catch (...) { SWIG_exception_fail(SWIG_UnknownError, "unknown exception"); } %enddef #endif /* __cplusplus */ swig-3.0.8/Lib/typemaps/carrays.swg0000664000175000017500000000517612641054563017130 0ustar williamwilliam/* ----------------------------------------------------------------------------- * carrays.swg * * This library file contains macros that can be used to manipulate simple * pointers as arrays. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %array_functions(TYPE,NAME) * * Generates functions for creating and accessing elements of a C array * (as pointers). Creates the following functions: * * TYPE *new_NAME(int nelements) * void delete_NAME(TYPE *); * TYPE NAME_getitem(TYPE *, int index); * void NAME_setitem(TYPE *, int index, TYPE value); * * ----------------------------------------------------------------------------- */ %define %array_functions(TYPE,NAME) %{ static TYPE *new_##NAME(size_t nelements) { return %new_array(nelements, TYPE); } static void delete_##NAME(TYPE *ary) { %delete_array(ary); } static TYPE NAME##_getitem(TYPE *ary, size_t index) { return ary[index]; } static void NAME##_setitem(TYPE *ary, size_t index, TYPE value) { ary[index] = value; } %} TYPE *new_##NAME(size_t nelements); void delete_##NAME(TYPE *ary); TYPE NAME##_getitem(TYPE *ary, size_t index); void NAME##_setitem(TYPE *ary, size_t index, TYPE value); %enddef /* ----------------------------------------------------------------------------- * %array_class(TYPE,NAME) * * Generates a class wrapper around a C array. The class has the following * interface: * * struct NAME { * NAME(int nelements); * ~NAME(); * TYPE getitem(int index); * void setitem(int index, TYPE value); * TYPE * cast(); * static NAME *frompointer(TYPE *t); * } * * Use * * %array_class_wrap(TYPE,NAME,GET,SET) * * if you want different names for the get/set methods. * ----------------------------------------------------------------------------- */ %define %array_class_wrap(TYPE,NAME,getitem,setitem) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { NAME(size_t nelements) { return %new_array(nelements, TYPE); } ~NAME() { %delete_array(self); } TYPE getitem(size_t index) { return self[index]; } void setitem(size_t index, TYPE value) { self[index] = value; } TYPE * cast() { return self; } static NAME *frompointer(TYPE *t) { return %static_cast(t, NAME *); } }; %types(NAME = TYPE); %enddef #ifndef %array_class %define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,getitem,setitem) %enddef #endif swig-3.0.8/Lib/typemaps/traits.swg0000664000175000017500000001662412641054563016772 0ustar williamwilliam// // Use the following macro with modern STL implementations // //#define SWIG_STD_MODERN_STL // // Use this to deactive the previous definition, when using gcc-2.95 // or similar old compilers. // //#define SWIG_STD_NOMODERN_STL // Here, we identify compilers we now have problems with STL. %{ #if defined(__GNUC__) # if __GNUC__ == 2 && __GNUC_MINOR <= 96 # define SWIG_STD_NOMODERN_STL # endif #endif %} // // Common code for supporting the STD C++ namespace // %fragment(""); %fragment(""); %fragment("Traits","header",fragment="") { namespace swig { /* type categories */ struct pointer_category { }; struct value_category { }; /* General traits that provides type_name and type_info */ template struct traits { }; template inline const char* type_name() { return traits::type_name(); } template struct traits_info { static swig_type_info *type_query(std::string name) { name += " *"; return SWIG_TypeQuery(name.c_str()); } static swig_type_info *type_info() { static swig_type_info *info = type_query(type_name()); return info; } }; template inline swig_type_info *type_info() { return traits_info::type_info(); } /* Partial specialization for pointers */ template struct traits { typedef pointer_category category; static std::string make_ptr_name(const char* name) { std::string ptrname = name; ptrname += " *"; return ptrname; } static const char* type_name() { static std::string name = make_ptr_name(swig::type_name()); return name.c_str(); } }; template ::category > struct traits_check { }; /* Traits that provides the from method for an unknown type */ template struct traits_from_ptr { static SWIG_Object from SWIG_FROM_DECL_ARGS(Type *val) { return SWIG_NewPointerObj(val, type_info(), flags); } }; template struct traits_from { static SWIG_Object from SWIG_FROM_DECL_ARGS(const Type& val) { return traits_from_ptr::from(new Type(val)); } }; template struct traits_from { static SWIG_Object from SWIG_FROM_DECL_ARGS(Type* val) { return traits_from_ptr<0, Type>::from(val); } }; template inline SWIG_Object from SWIG_FROM_DECL_ARGS(const Type& val) { return traits_from::from(val); } /* Traits that provides the asptr/asval method for an unknown type */ template struct traits_asptr { static int asptr SWIG_AS_DECL_ARGS (SWIG_Object obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, %as_voidptrptr(&p), type_info(), 0); if (SWIG_IsOK(res) && val) *val = p; return res; } }; template inline int asptr SWIG_AS_DECL_ARGS(SWIG_Object obj, Type **vptr) { return traits_asptr::asptr SWIG_AS_CALL_ARGS(obj, vptr); } template struct traits_asval { static int asval SWIG_AS_DECL_ARGS(SWIG_Object obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr SWIG_AS_CALL_ARGS(obj, &p); if (SWIG_IsOK(res) && p) { *val = *p; if (SWIG_IsNewObj(res)) { %delete(p); res = SWIG_DelNewMask(res); } } return res; } else { return traits_asptr::asptr SWIG_AS_CALL_ARGS(obj, (Type **)(0)); } } }; template inline int asval SWIG_AS_DECL_ARGS (SWIG_Object obj, Type *val) { return traits_asval::asval SWIG_AS_CALL_ARGS(obj, val); } /* Traits that provides the check method for an unknown type */ #define SWIG_CHECK_DECL_ARGS(obj) SWIG_AS_DECL_ARGS(obj, void * = 0) #define SWIG_CHECK_CALL_ARGS(obj) SWIG_AS_CALL_ARGS(obj, 0) template struct traits_checkval { static int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { if (obj) { int res = asval SWIG_AS_CALL_ARGS(obj, (Type *)(0)); return SWIG_CheckState(res); } else { return 0; } } }; template struct traits_checkptr { static int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { if (obj) { int res = asptr SWIG_AS_CALL_ARGS(obj, (Type **)(0)); return SWIG_CheckState(res); } else { return 0; } } }; template struct traits_check : traits_checkval { }; template struct traits_check : traits_checkptr { }; template inline int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { return traits_check::check SWIG_CHECK_CALL_ARGS(obj); } } } /* Generate the traits for an unknown SWIGTYPE */ %define %traits_swigtype(Type...) %fragment(SWIG_Traits_frag(Type),"header",fragment="Traits") { namespace swig { template <> struct traits { typedef pointer_category category; static const char* type_name() { return #Type; } }; } } %enddef /* Generate the traits for a 'value' type, such as 'double', for which the SWIG_AsVal and SWIG_From methods are already defined. */ %define %traits_value(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="Traits") { namespace swig { template <> struct traits { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval { typedef Type value_type; static int asval SWIG_AS_DECL_ARGS (SWIG_Object obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from { typedef Type value_type; static SWIG_Object from SWIG_FROM_DECL_ARGS (const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Generate the traits for a 'pointer' type, such as 'std::string', for which the SWIG_AsPtr and SWIG_From methods are already defined. */ %define %traits_pointer(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="Traits") { namespace swig { template <> struct traits { typedef pointer_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asptr { typedef Type value_type; static int asptr SWIG_AS_DECL_ARGS (SWIG_Object obj, value_type **val) { return SWIG_AsPtr(Type)(obj, val); } }; template <> struct traits_from { typedef Type value_type; static SWIG_Object from SWIG_FROM_DECL_ARGS (const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Generate the typemaps for a class that has 'value' traits */ %define %typemap_traits_value(Code,Type...) %typemaps_asvalfrom(%arg(Code), %arg(swig::asval), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), Type); %enddef /* Generate the typemaps for a class that has 'pointer' traits */ %define %typemap_traits_pointer(Code,Type...) %typemaps_asptrfrom(%arg(Code), %arg(swig::asptr), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), Type); %enddef swig-3.0.8/Lib/typemaps/factory.swg0000664000175000017500000000461112641054563017124 0ustar williamwilliam/* Implement a more natural wrap for factory methods, for example, if you have: ---- geometry.h -------- struct Geometry { enum GeomType{ POINT, CIRCLE }; virtual ~Geometry() {} virtual int draw() = 0; // // Factory method for all the Geometry objects // static Geometry *create(GeomType i); }; struct Point : Geometry { int draw() { return 1; } double width() { return 1.0; } }; struct Circle : Geometry { int draw() { return 2; } double radius() { return 1.5; } }; // // Factory method for all the Geometry objects // Geometry *Geometry::create(GeomType type) { switch (type) { case POINT: return new Point(); case CIRCLE: return new Circle(); default: return 0; } } ---- geometry.h -------- You can use the %factory with the Geometry::create method as follows: %newobject Geometry::create; %factory(Geometry *Geometry::create, Point, Circle); %include "geometry.h" and Geometry::create will return a 'Point' or 'Circle' instance instead of the plain 'Geometry' type. For example, in python: circle = Geometry.create(Geometry.CIRCLE) r = circle.radius() where circle is a Circle proxy instance. NOTES: remember to fully qualify all the type names and don't use %factory inside a namespace declaration, ie, instead of namespace Foo { %factory(Geometry *Geometry::create, Point, Circle); } use %factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle); */ %define %_factory_dispatch(Type) if (!dcast) { Type *dobj = dynamic_cast($1); if (dobj) { dcast = 1; %set_output(SWIG_NewPointerObj(%as_voidptr(dobj),$descriptor(Type *), $owner | %newpointer_flags)); } }%enddef %define %factory(Method,Types...) %typemap(out) Method { int dcast = 0; %formacro(%_factory_dispatch, Types) if (!dcast) { %set_output(SWIG_NewPointerObj(%as_voidptr($1),$descriptor, $owner | %newpointer_flags)); } }%enddef swig-3.0.8/Lib/typemaps/swigtypemaps.swg0000664000175000017500000001157412641054563020217 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigtypemaps.swg * * Unified Typemap Library frontend * ----------------------------------------------------------------------------- */ /* This file provides the frontend to the Unified Typemap Library. When using this library in a SWIG target language, you need to define a minimum set of fragments, specialize a couple of macros, and then include this file. Typically you will create a 'mytypemaps.swg' file in each target language, where you will have the following sections: === mytypemaps.swg === // Fragment section %include // Unified typemap section %include // Local typemap section === mytypemaps.swg === While we add more docs, please take a look at the following cases to see how you specialized the unified typemap library for a new target language: Lib/python/pytypemaps.swg Lib/tcl/tcltypemaps.swg Lib/ruby/rubytypemaps.swg Lib/perl5/perltypemaps.swg */ #define SWIGUTL SWIGUTL /* ----------------------------------------------------------------------------- * Language specialization section. * * Tune these macros for each language as needed. * ----------------------------------------------------------------------------- */ /* The SWIG target language object must be provided. For example in python you define: #define SWIG_Object PyObject * */ #if !defined(SWIG_Object) #error "SWIG_Object must be defined as the SWIG target language object" #endif /*==== flags for new/convert methods ====*/ #ifndef %convertptr_flags %define %convertptr_flags 0 %enddef #endif #ifndef %newpointer_flags %define %newpointer_flags 0 %enddef #endif #ifndef %newinstance_flags %define %newinstance_flags 0 %enddef #endif /*==== set output ====*/ #ifndef %set_output /* simple set output operation */ #define %set_output(obj) $result = obj #endif /*==== set variable output ====*/ #ifndef %set_varoutput /* simple set varoutput operation */ #define %set_varoutput(obj) $result = obj #endif /*==== append output ====*/ #ifndef %append_output #if defined(SWIG_AppendOutput) /* simple append operation */ #define %append_output(obj) $result = SWIG_AppendOutput($result,obj) #else #error "Language must define SWIG_AppendOutput or %append_output" #endif #endif /*==== set constant ====*/ #ifndef %set_constant #if defined(SWIG_SetConstant) /* simple set constant operation */ #define %set_constant(name,value) SWIG_SetConstant(name,value) #else #error "Language must define SWIG_SetConstant or %set_constant" #endif #endif /*==== raise an exception ====*/ #ifndef %raise #if defined(SWIG_Raise) /* simple raise operation */ #define %raise(obj, type, desc) SWIG_Raise(obj, type, desc); SWIG_fail #else #error "Language must define SWIG_Raise or %raise" #endif #endif /*==== director output exception ====*/ #if defined(SWIG_DIRECTOR_TYPEMAPS) #ifndef SWIG_DirOutFail #define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg) #endif #endif /* ----------------------------------------------------------------------------- * Language independent definitions * ----------------------------------------------------------------------------- */ #define %error_block(Block...) %block(Block) #define %default_code(code) SWIG_ArgError(code) #define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn)) #define %argument_nullref(type, name, argn) SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn)) #define %variable_fail(code, type, name) SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name)) #define %variable_nullref(type, name) SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name)) #if defined(SWIG_DIRECTOR_TYPEMAPS) #define %dirout_fail(code, type) SWIG_DirOutFail(%default_code(code), %outfail_fmt(type)) #define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type)) #endif /* ----------------------------------------------------------------------------- * All the typemaps * ----------------------------------------------------------------------------- */ %include %include %include %include %include %include %include %include %include %include %include %include swig-3.0.8/Lib/typemaps/std_string.swg0000664000175000017500000000053312641054563017634 0ustar williamwilliam// // String // #ifndef SWIG_STD_BASIC_STRING #define SWIG_STD_STRING %include %fragment(""); namespace std { %naturalvar string; class string; } %typemaps_std_string(std::string, char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, %checkcode(STDSTRING)); #else %include #endif swig-3.0.8/Lib/typemaps/cdata.swg0000664000175000017500000000352012641054563016527 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cdata.swg * * This library file contains macros for manipulating raw C data as strings. * ----------------------------------------------------------------------------- */ %{ typedef struct SWIGCDATA { char *data; size_t len; } SWIGCDATA; %} /* ----------------------------------------------------------------------------- * Typemaps for returning binary data * ----------------------------------------------------------------------------- */ %typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA { %set_output(SWIG_FromCharPtrAndSize($1.data,$1.len)); } %typemap(in) (const void *indata, size_t inlen) = (char *STRING, size_t SIZE); /* ----------------------------------------------------------------------------- * %cdata(TYPE [, NAME]) * * Convert raw C data to a binary string. * ----------------------------------------------------------------------------- */ %define %cdata(TYPE,NAME...) %insert("header") { #ifdef __cplusplus extern "C" { #endif #if #NAME == "" static SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements) #else static SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements) #endif { SWIGCDATA d; d.data = (char *) ptr; #if #TYPE != "void" d.len = nelements*sizeof(TYPE); #else d.len = nelements; #endif return d; } #ifdef __cplusplus } #endif } #ifdef __cplusplus extern "C" #endif #if #NAME == "" SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements = 1); #else SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements = 1); #endif %enddef %rename(cdata) ::cdata_void(void *ptr, size_t nelements = 1); %cdata(void); /* Memory move function. Due to multi-argument typemaps this appears to be wrapped as void memmove(void *data, const char *s); */ void memmove(void *data, const void *indata, size_t inlen); swig-3.0.8/Lib/typemaps/attribute.swg0000664000175000017500000002301612641054563017460 0ustar williamwilliam/* ----------------------------------------------------------------------------- * attribute.swg * * Attribute implementation * ----------------------------------------------------------------------------- */ /* The following macros convert a pair of set/get methods into a "native" attribute. Use %attribute when you have a pair of get/set methods to a primitive type like in: %attribute(A, int, a, get_a, set_a); struct A { int get_a() const; void set_a(int aa); }; If you don't provide a 'set' method, a 'read-only' attribute is generated, ie, like in: %attribute(A, int, c, get_c); Use %attributeref when you have const/non-const reference access methods for primitive types or class/structs, like in: %attributeref(A, int, b); struct A { const int& b() const; int& b(); }; %attributeref(B, int, c); struct B { int& c(); }; You can also use %attributeref(Class, AttributeType, AttributeName, AccessorMethod) if the internal C++ reference methods have a different name from the attribute you want, so %attributeref(B, int, d, c); is the same as the last example, but instead of the attribute 'c' being called 'c', it is called 'd'. Now you can use the attributes like so: x = A() x.a = 3 # calls A::set_a print x.a # calls A::get_a x.b = 3 # calls A::b() print x.b # calls A::b() const Use %attribute2 instead of %attribute to indicate that reference-pointer translation is required. You use %attribute2 instead of %attribute in cases like this: %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo); %inline %{ struct MyFoo { int x; }; class MyClass { MyFoo foo; public: MyFoo& GetFoo() { return foo; } void SetFoo(const MyFoo& other) { foo = other; } }; %} Here, the data type of the property is a wrapped type (MyFoo) and on the C++ side it is passed by reference. The problem is that the SWIG wrapper will pass around a pointer (MyFoo *) which is not compatible with the reference type of the accessors (MyFoo &). Therefore, if you use %attribute, you'll get an error from your C/C++ compiler. %attribute2 translates between a pointer and a reference to eliminate the error. In case you're confused, let's make it simple: just use %attribute at first, but if the C/C++ compiler gives an error while compiling the wrapper, try %attribute2 instead. NOTE: remember that if the type contains commas, such as 'std::pair', you need to use the macro like: %attributeref(A, %arg(std::pair), pval); where %arg() 'normalizes' the type to be understood as a single argument, otherwise the macro will get confused by the comma. The %attributeval is the same as %attribute, but should be used when the type is a class/struct (ie a non-primitive type) and when the get and set methods return/pass by value. The following is very similar to the above example, but note that the access is by value rather than reference. %attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo); %attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo); %inline %{ class MyClassVal { MyFoo foo; public: MyFoo GetFoo() { return foo; } void SetFoo(MyFoo other) { foo = other; } }; %} The %attributestring is the same as %attributeval, but should be used for string class types, which are unusual as they are a class on the C++ side, but normally an immutable/primitive type in the target language. Example usage for std::string: %include %attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString); %attributestring(MyStringyClass, std::string, ReadOnlyString, GetString); %inline %{ class MyStringyClass { std::string str; public: MyStringyClass(const std::string &val) : str(val) {} std::string GetString() { return str; } void SetString(std::string other) { str = other; } }; %} The %attributestring also works for class types that have %naturalvar turned on and so is also useful for shared_ptr which has %naturalvar turned on in %shared_ptr. */ // // Define SWIG_ATTRIBUTE_TEMPLATE if you want to use templates instead of macros for the C++ get and set wrapper methods // Does not always generate compilable code, use at your peril! // //#define SWIG_ATTRIBUTE_TEMPLATE %define %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, GetMethodCall, SetMethodCall) %ignore Class::GetMethod(); %ignore Class::GetMethod() const; #if #SetMethod != #AttributeName %ignore Class::SetMethod; #endif %extend Class { AttributeType AttributeName; } #if defined(__cplusplus) && defined(SWIG_ATTRIBUTE_TEMPLATE) %{ template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(const C* self_) { return GetMethodCall; } template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(C* self_) { return GetMethodCall; } template < class C > inline void %mangle(Class) ##_## AttributeName ## _set(C* self_, AttributeType val_) { SetMethodCall; } %} #else %{ #define %mangle(Class) ##_## AttributeName ## _get(self_) GetMethodCall #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) SetMethodCall %} #endif %enddef %define %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, GetMethodCall) %ignore Class::GetMethod(); %ignore Class::GetMethod() const; %immutable Class::AttributeName; %extend Class { AttributeType AttributeName; } #if defined(__cplusplus) && defined(SWIG_ATTRIBUTE_TEMPLATE) %{ template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(const C* self_) { return GetMethodCall; } template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(C* self_) { return GetMethodCall; } %} #else %{ #define %mangle(Class) ##_## AttributeName ## _get(self_) GetMethodCall %} #endif %enddef // User macros %define %attribute(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) #else %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, self_->GetMethod()) #endif %enddef %define %attribute2(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) #else %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, &self_->GetMethod()) #endif %enddef %define %attributeref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) #endif %enddef %define %attribute2ref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) #else %attribute_custom(%arg(Class), %arg(AttributeType), AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) #endif %enddef // deprecated (same as %attributeref, but there is an argument order inconsistency) %define %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName...) #if #AttributeName != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else %attribute_custom(%arg(Class), %arg(AttributeType), AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #endif %enddef %define %attributeval(Class, AttributeType, AttributeName, GetMethod, SetMethod...) %{ #define %mangle(Class) ##_## AttributeName ## _get(self_) new AttributeType(self_->GetMethod()) %} #if #SetMethod != "" %{ #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(*val_) %} #if #SetMethod != #AttributeName %ignore Class::SetMethod; #endif #else %immutable Class::AttributeName; #endif %ignore Class::GetMethod(); %ignore Class::GetMethod() const; %newobject Class::AttributeName; %extend Class { AttributeType AttributeName; } %enddef %define %attributestring(Class, AttributeType, AttributeName, GetMethod, SetMethod...) %{ #define %mangle(Class) ##_## AttributeName ## _get(self_) *new AttributeType(self_->GetMethod()) %} #if #SetMethod != "" %{ #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(val_) %} #if #SetMethod != #AttributeName %ignore Class::SetMethod; #endif #else %immutable Class::AttributeName; #endif %ignore Class::GetMethod(); %ignore Class::GetMethod() const; %newobject Class::AttributeName; %typemap(newfree) const AttributeType &AttributeName "delete $1;" %extend Class { AttributeType AttributeName; } %enddef swig-3.0.8/Lib/typemaps/implicit.swg0000664000175000017500000001133212641054563017265 0ustar williamwilliam/* The %implicit macro allows a SwigType (Class) to be accepted as an input parameter and use its implicit constructors when needed. For example: %implicit(A, int, double, B); %inline { struct B { }; struct A { int ii; A(int i) { ii = 1; } A(double d) { ii = 2; } A(const B& b) { ii = 3; } }; int get(A a) { return a.ii; } } Here, you can call 'get' as get(1) ==> get(A(1)) get(2.0) ==> get(A(2.0)) get(B()) ==> get(A(B())) and swig will construct an 'A' temporal variable using the corresponding implicit constructor. The plain implicit macro takes care of simple type list. If it doesn't work because you are passing template types with commas, then use the %implicit_{1,2,3} versions and/or the %arg macro. */ %define %implicit_type(Type...) %traits_swigtype(Type); %enddef %define %implicit_frag(Type...) ,fragment=SWIG_Traits_frag(Type) %enddef %define %implicit_code(Type...) { Type _v; int res = swig::asval(obj, &_v); if (SWIG_IsOK(res)) { if (val) *val = new value_type(static_cast(_v)); return SWIG_AddNewMask(res); } } %enddef /* implicit */ %define %implicit(Type, ...) %formacro_1(%implicit_type,__VA_ARGS__); %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits" %formacro_1(%implicit_frag,__VA_ARGS__)) %{ namespace swig { template <> struct traits { typedef pointer_category category; static const char* type_name() { return "Type"; } }; template <> struct traits_asptr< Type > { typedef Type value_type; static int asptr(SWIG_Object obj, value_type **val) { Type *vptr; static swig_type_info* desc = SWIG_TypeQuery("Type *"); int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); if (SWIG_IsOK(res)) { if (val) *val = vptr; return res; } else { %formacro_1(%implicit_code,__VA_ARGS__) } return SWIG_TypeError; } }; } %} %typemap_traits_ptr(%checkcode(POINTER),Type); %enddef /* implicit_1 */ %define %implicit_1(Type, Imp1) %traits_swigtype(Imp1); %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits", fragment=SWIG_Traits_frag(Imp1)) %{ namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return "Type"; } }; template <> struct traits_asptr< Type > { typedef Type value_type; static int asptr(SWIG_Object obj, value_type **val) { Type *vptr; static swig_type_info* desc = SWIG_TypeQuery("Type *"); int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); if (SWIG_IsOK(res)) { if (val) *val = vptr; return res; } else { %implicit_code(Imp1); } return SWIG_TypeError; } }; } %} %typemap_traits_ptr(%checkcode(POINTER),Type); %enddef /* implicit_2 */ %define %implicit_2(Type, Imp1, Imp2) %traits_swigtype(Imp1); %traits_swigtype(Imp2); %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits", fragment=SWIG_Traits_frag(Imp1), fragment=SWIG_Traits_frag(Imp2)) %{ namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return "Type"; } }; template <> struct traits_asptr< Type > { typedef Type value_type; static int asptr(SWIG_Object obj, value_type **val) { Type *vptr; static swig_type_info* desc = SWIG_TypeQuery("Type *"); int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); if (SWIG_IsOK(res)) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { %implicit_code(Imp1); %implicit_code(Imp2); } return SWIG_TypeError; } }; } %} %typemap_traits_ptr(%checkcode(POINTER),Type); %enddef /* implicit_3 */ %define %implicit_3(Type, Imp1, Imp2, Imp3) %traits_swigtype(Imp1); %traits_swigtype(Imp2); %traits_swigtype(Imp3); %fragment(SWIG_Traits_frag(Type),"header", fragment="StdTraits", fragment=SWIG_Traits_frag(Imp1), fragment=SWIG_Traits_frag(Imp2), fragment=SWIG_Traits_frag(Imp3)) %{ namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return "Type"; } }; template <> struct traits_asptr< Type > { typedef Type value_type; static int asptr(SWIG_Object obj, value_type **val) { Type *vptr; static swig_type_info* desc = SWIG_TypeQuery("Type *"); int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); if (SWIG_IsOK(res)) { if (val) *val = vptr; return res; } else { %implicit_code(Imp1); %implicit_code(Imp2); %implicit_code(Imp3); } return SWIG_TypeError; } }; } %} %typemap_traits_ptr(%checkcode(POINTER),Type); %enddef swig-3.0.8/Lib/typemaps/typemaps.swg0000664000175000017500000001072412641054563017321 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.swg * * Tcl Pointer handling * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers. * ----------------------------------------------------------------------------- */ // INPUT typemaps. // These remap a C pointer to be an "INPUT" value which is passed by value // instead of reference. /* The following methods can be applied to turn a pointer into a simple "input" value. That is, instead of passing a pointer to an object, you would use a real value instead. int *INPUT short *INPUT long *INPUT long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT unsigned long long *INPUT unsigned char *INPUT bool *INPUT float *INPUT double *INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); */ // OUTPUT typemaps. These typemaps are used for parameters that // are output only. The output value is appended to the result as // a list element. /* The following methods can be applied to turn a pointer into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. In the case of multiple output values, they are returned in the form of a Tcl tuple. int *OUTPUT short *OUTPUT long *OUTPUT long long *OUTPUT unsigned int *OUTPUT unsigned short *OUTPUT unsigned long *OUTPUT unsigned long long *OUTPUT unsigned char *OUTPUT bool *OUTPUT float *OUTPUT double *OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters).K: double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Tcl output of the function would be a tuple containing both output values. */ // INOUT // Mappings for an argument that is both an input and output // parameter /* The following methods can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" methods described earlier. Output values are returned in the form of a Tcl tuple. int *INOUT short *INOUT long *INOUT long long *INOUT unsigned int *INOUT unsigned short *INOUT unsigned long *INOUT unsigned long long *INOUT unsigned char *INOUT bool *INOUT float *INOUT double *INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); Unlike C, this mapping does not directly modify the input value (since this makes no sense in Tcl). Rather, the modified input value shows up as the return value of the function. Thus, to apply this function to a Tcl variable you might do this : x = neg(x) Note : previous versions of SWIG used the symbol 'BOTH' to mark input/output arguments. This is still supported, but will be slowly phased out in future releases. */ #if defined(SWIG_INOUT_NODEF) %apply_checkctypes(%typemaps_inoutn) %apply size_t& { std::size_t& }; %apply ptrdiff_t& { std::ptrdiff_t& }; #endif swig-3.0.8/Lib/typemaps/valtypes.swg0000664000175000017500000001574312641054563017334 0ustar williamwilliam/*--------------------------------------------------------------------- * Value typemaps (Type, const Type&) for value types, such as * fundamental types (int, double), that define the AsVal/From * methods. * * To apply them, just use one of the following macros: * * %typemaps_from(FromMeth, FromFrag, Type) * %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type) * %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, AsValFrag, FromFrag, Type) * * or the simpler and normalize form: * * %typemaps_asvalfromn(CheckCode, Type) * * Also, you can use the individual typemap definitions: * * %value_in_typemap(asval_meth,frag,Type) * %value_varin_typemap(asval_meth,frag,Type) * %value_typecheck_typemap(checkcode,asval_meth,frag,Type) * %value_directorout_typemap(asval_meth,frag,Type) * * %value_out_typemap(from_meth,frag,Type) * %value_varout_typemap(from_meth,frag,Type) * %value_constcode_typemap(from_meth,frag,Type) * %value_directorin_typemap(from_meth,frag,Type) * %value_throws_typemap(from_meth,frag,Type) * *---------------------------------------------------------------------*/ /* in */ %define %value_in_typemap(asval_meth,frag,Type...) %typemap(in,noblock=1,fragment=frag) Type (Type val, int ecode = 0) { ecode = asval_meth($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$ltype", $symname, $argnum); } $1 = %static_cast(val,$ltype); } %typemap(freearg) Type ""; %typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) { ecode = asval_meth($input, &val); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$*ltype", $symname, $argnum); } temp = %static_cast(val, $*ltype); $1 = &temp; } %typemap(freearg) const Type& ""; %enddef /* out */ %define %value_out_typemap(from_meth,frag,Type...) %typemap(out,noblock=1,fragment=frag) Type, const Type { %set_output(from_meth(%static_cast($1,Type))); } %typemap(out,noblock=1,fragment=frag) const Type& { %set_output(from_meth(%static_cast(*$1,Type))); } %enddef /* varin */ %define %value_varin_typemap(asval_meth,frag,Type...) %typemap(varin,fragment=frag) Type { Type val; int res = asval_meth($input, &val); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = %static_cast(val,$ltype); } %enddef /* varout */ %define %value_varout_typemap(from_meth,frag,Type...) %typemap(varout,noblock=1,fragment=frag) Type, const Type& { %set_varoutput(from_meth(%static_cast($1,Type))); } %enddef /* constant installation code */ %define %value_constcode_typemap(from_meth,frag,Type...) %typemap(constcode,noblock=1,fragment=frag) Type { %set_constant("$symname", from_meth(%static_cast($value,Type))); } %enddef #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %define %value_directorin_typemap(from_meth,frag,Type...) %typemap(directorin,noblock=1,fragment=frag) Type *DIRECTORIN { $input = from_meth(%static_cast(*$1,Type)); } %typemap(directorin,noblock=1,fragment=frag) Type, const Type& { $input = from_meth(%static_cast($1,Type)); } %enddef /* directorout */ %define %value_directorout_typemap(asval_meth,frag,Type...) %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT(Type swig_val, int swig_res) { swig_res = asval_meth($result, &swig_val); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res, "$type"); } *$1 = swig_val; } %typemap(directorout,noblock=1,fragment=frag) Type { Type swig_val; int swig_res = asval_meth($input, &swig_val); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res, "$type"); } $result = %static_cast(swig_val,$type); } %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const Type& { Type swig_val; int swig_res = asval_meth($input, &swig_val); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res, "$type"); } $basetype *temp = new $basetype(($basetype)swig_val); swig_acquire_ownership(temp); $result = temp; } %typemap(directorfree,noblock=1) const Type & { if (director) { director->swig_release_ownership(%as_voidptr($input)); } } %typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type %enddef #else #define %value_directorin_typemap(from_meth,frag,Type...) #define %value_directorout_typemap(asval_meth,frag,Type...) #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* throws */ %define %value_throws_typemap(from_meth,frag,Type...) %typemap(throws,noblock=1,fragment=frag) Type { %raise(from_meth(%static_cast($1,Type)), "$type", 0); } %enddef /* typecheck */ %define %value_typecheck_typemap(check,asval_meth,frag,Type...) %typemap(typecheck,precedence=check,fragment=frag) Type, const Type& { int res = asval_meth($input, NULL); $1 = SWIG_CheckState(res); } %enddef /*--------------------------------------------------------------------- * typemap definition for types with AsVal methods *---------------------------------------------------------------------*/ %define %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type...) %value_in_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); %value_varin_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); %value_directorout_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); %value_typecheck_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); %value_input_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with from method *---------------------------------------------------------------------*/ %define %typemaps_from(FromMeth, FromFrag, Type...) %value_out_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_varout_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_constcode_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_directorin_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_throws_typemap(%arg(FromMeth), %arg(FromFrag), Type); %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with alval/from method *---------------------------------------------------------------------*/ %define %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...) %typemaps_asval(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type); %value_inout_typemap(Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with for 'normalized' asval/from methods *---------------------------------------------------------------------*/ %define %typemaps_asvalfromn(CheckCode, Type...) %typemaps_asvalfrom(%arg(CheckCode), SWIG_AsVal(Type), SWIG_From(Type), %arg(SWIG_AsVal_frag(Type)), %arg(SWIG_From_frag(Type)), Type); %enddef swig-3.0.8/Lib/typemaps/README0000664000175000017500000000372512641054563015620 0ustar williamwilliamStill in development, but if you are interested into looking around, start with swigtypemaps.swg which is the head file. Also read the docs for %fragments in fragments.swg and follow the definitions in one of the supported languages: python, perl, ruby, tcl /* ----------------------------------------------------------------------------- * Internal typemap specializations * ----------------------------------------------------------------------------- */ carrays.swg Implement the carrays.i library cdata.swg Implement the cdata.i library cmalloc.swg Implement the cmalloc.i library cpointer.swg Implement the cpointer.i library cstring.swg Implement the cstring.i library typemaps for char * cwstring.swg Implement the cstring.i library typemaps for wchar_t * exception.swg Implement the exception.i library implicit.swg Allow the use of implicit C++ constructors string.swg Typemaps for char * string wstring.swg Typemaps for wchar_t * string std_string.swg Typemaps for std::string std_wstring.swg Typemaps for std::wstring swigtype.swg Typemaps for the SWIGTYPE type void.swg Typemaps for the 'void' type enumint.swg Typemaps for enums treated as 'int' swigobject.swg Typemaps for the SWIG_Object as in PyObject, Tcl_Obj, etc. misctypes.swg Typemaps for miscellaneos types (size_t, ptrdiff_t, etc) ptrtypes.swg Typemaps for types with a 'ptr' behavior valtypes.swg Typemaps for 'by value' types inoutlist.swg IN/OUTPUT/INOUT typemaps, where the OUTPUT values are returned in a list primtypes.swg Common macros to manage primitive types (short,int,double,etc) cstrings.swg Common macros to implemented the cstring/cwstring libraries std_strings.swg Common macros to implemented the std::string/std::wstring typemaps strings.swg Common macros and typemaps for string and wstring (char *, wchar_t *) swigmacros.swg Basic macros fragments.swg Macros for fragment manipulations typemaps.swg The old typemaps.i library, not needed anymore swig-3.0.8/Lib/typemaps/wstring.swg0000664000175000017500000000143212641054563017150 0ustar williamwilliam%ensure_fragment(SWIG_AsWCharPtrAndSize) %ensure_fragment(SWIG_FromWCharPtrAndSize) %types(wchar_t *); %fragment("SWIG_pwchar_descriptor","header") { SWIGINTERN swig_type_info* SWIG_pwchar_descriptor() { static int init = 0; static swig_type_info* info = 0; if (!init) { info = SWIG_TypeQuery("_p_wchar_t"); init = 1; } return info; } } %fragment("SWIG_wcsnlen","header",fragment="SWIG_FromWCharPtrAndSize") { size_t SWIG_wcsnlen(const wchar_t* s, size_t maxlen) { const wchar_t *p; for (p = s; maxlen-- && *p; p++) ; return p - s; } } %include %typemaps_string(%checkcode(UNISTRING), %checkcode(UNICHAR), wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen, SWIG_wcsnlen, "", WCHAR_MIN, WCHAR_MAX) swig-3.0.8/Lib/typemaps/ptrtypes.swg0000664000175000017500000001470012641054563017347 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ptrtypes.swg * * Value typemaps (Type, const Type&) for "Ptr" types, such as swig * wrapped classes, that define the AsPtr/From methods * * To apply them, just use one of the following macros: * * %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type) * %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type) * * or the simpler and normalize form: * * %typemaps_asptrfromn(CheckCode, Type) * * Also, you can use the individual typemap definitions: * * %ptr_in_typemap(asptr_meth,frag,Type) * %ptr_varin_typemap(asptr_meth,frag,Type) * %ptr_typecheck_typemap(check,asptr_meth,frag,Type) * %ptr_directorout_typemap(asptr_meth,frag,Type) * ----------------------------------------------------------------------------- */ %include /* in */ %define %ptr_in_typemap(asptr_meth,frag,Type...) %typemap(in,fragment=frag) Type { Type *ptr = (Type *)0; int res = asptr_meth($input, &ptr); if (!SWIG_IsOK(res) || !ptr) { %argument_fail((ptr ? res : SWIG_TypeError), "$type", $symname, $argnum); } $1 = *ptr; if (SWIG_IsNewObj(res)) %delete(ptr); } %typemap(freearg) Type ""; %typemap(in,fragment=frag) const Type & (int res = SWIG_OLDOBJ) { Type *ptr = (Type *)0; res = asptr_meth($input, &ptr); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } if (!ptr) { %argument_nullref("$type",$symname, $argnum); } $1 = ptr; } %typemap(freearg,noblock=1) const Type & { if (SWIG_IsNewObj(res$argnum)) %delete($1); } %enddef /* varin */ %define %ptr_varin_typemap(asptr_meth,frag,Type...) %typemap(varin,fragment=frag) Type { Type *ptr = (Type *)0; int res = asptr_meth($input, &ptr); if (!SWIG_IsOK(res) || !ptr) { %variable_fail((ptr ? res : SWIG_TypeError), "$type", "$name"); } $1 = *ptr; if (SWIG_IsNewObj(res)) %delete(ptr); } %enddef #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorout */ %define %ptr_directorout_typemap(asptr_meth,frag,Type...) %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp, int swig_ores) { Type *swig_optr = 0; swig_ores = $result ? asptr_meth($result, &swig_optr) : 0; if (!SWIG_IsOK(swig_ores) || !swig_optr) { %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type"); } temp = *swig_optr; $1 = &temp; if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr); } %typemap(directorout,noblock=1,fragment=frag) Type { Type *swig_optr = 0; int swig_ores = asptr_meth($input, &swig_optr); if (!SWIG_IsOK(swig_ores) || !swig_optr) { %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type"); } $result = *swig_optr; if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr); } %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Type* { Type *swig_optr = 0; int swig_ores = asptr_meth($input, &swig_optr); if (!SWIG_IsOK(swig_ores)) { %dirout_fail(swig_ores,"$type"); } $result = swig_optr; if (SWIG_IsNewObj(swig_ores)) { swig_acquire_ownership(swig_optr); } } %typemap(directorfree,noblock=1) Type* { if (director) { director->swig_release_ownership(%as_voidptr($input)); } } %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Type& { Type *swig_optr = 0; int swig_ores = asptr_meth($input, &swig_optr); if (!SWIG_IsOK(swig_ores)) { %dirout_fail(swig_ores,"$type"); } else { if (!swig_optr) { %dirout_nullref("$type"); } } $result = swig_optr; if (SWIG_IsNewObj(swig_ores)) { swig_acquire_ownership(swig_optr); } } %typemap(directorfree,noblock=1) Type& { if (director) { director->swig_release_ownership(%as_voidptr($input)); } } %typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type %enddef #else #define %ptr_directorout_typemap(asptr_meth,frag,Type...) #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* typecheck */ %define %ptr_typecheck_typemap(check,asptr_meth,frag,Type...) %typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type * { int res = asptr_meth($input, (Type**)(0)); $1 = SWIG_CheckState(res); } %typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type, const Type& { int res = asptr_meth($input, (Type**)(0)); $1 = SWIG_CheckState(res); } %enddef /*--------------------------------------------------------------------- * typemap definition for types with asptr method *---------------------------------------------------------------------*/ %define %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type...) %fragment(SWIG_AsVal_frag(Type),"header",fragment=SWIG_AsPtr_frag(Type)) { SWIGINTERNINLINE int SWIG_AsVal(Type)(SWIG_Object obj, Type *val) { Type *v = (Type *)0; int res = SWIG_AsPtr(Type)(obj, &v); if (!SWIG_IsOK(res)) return res; if (v) { if (val) *val = *v; if (SWIG_IsNewObj(res)) { %delete(v); res = SWIG_DelNewMask(res); } return res; } return SWIG_ERROR; } } %ptr_in_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); %ptr_varin_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); %ptr_directorout_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); %ptr_typecheck_typemap(%arg(CheckCode), %arg(AsPtrMeth),%arg(AsPtrFrag), Type); %ptr_input_typemap(%arg(CheckCode),%arg(AsPtrMeth),%arg(AsPtrFrag),Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with asptr/from methods *---------------------------------------------------------------------*/ %define %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...) %typemaps_asptr(%arg(CheckCode), %arg(AsPtrMeth), %arg(AsPtrFrag), Type) %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type); %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type); %ptr_inout_typemap(Type); %enddef /*--------------------------------------------------------------------- * typemap definition for types with for 'normalized' asptr/from methods *---------------------------------------------------------------------*/ %define %typemaps_asptrfromn(CheckCode, Type...) %typemaps_asptrfrom(%arg(CheckCode), %arg(SWIG_AsPtr(Type)), %arg(SWIG_From(Type)), %arg(SWIG_AsPtr_frag(Type)), %arg(SWIG_From_frag(Type)), Type); %enddef swig-3.0.8/Lib/swigrun.swg0000664000175000017500000004033212641054563015311 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigrun.swg * * This file contains generic C API SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE # define SWIG_QUOTE_STRING(x) #x # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else # define SWIG_TYPE_TABLE_NAME #endif /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ #ifndef SWIGRUNTIME # define SWIGRUNTIME SWIGINTERN #endif #ifndef SWIGRUNTIMEINLINE # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE #endif /* Generic buffer size */ #ifndef SWIG_BUFFER_SIZE # define SWIG_BUFFER_SIZE 1024 #endif /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 /* Flags/methods for returning states. The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code } else { //fail code } Now you can be more explicit: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { // success code } else { // fail code } which is the same really, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); if (SWIG_IsOK(res)) { // success code if (SWIG_IsNewObj(res) { ... delete *ptr; } else { ... } } else { // fail code } I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as int SWIG_ConvertPtr(obj, ptr,...) { if () { if () { *ptr = ; return SWIG_NEWOBJ; } else { *ptr = ; return SWIG_OLDOBJ; } } else { return SWIG_BADOBJ; } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the SWIG errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this int food(double) int fooi(int); and you call food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) /* The NewMask denotes the object was created (using new/malloc) */ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) /* The TmpMask is for in/out typemaps that use temporal objects */ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) /* Simple returning values */ #define SWIG_BADOBJ (SWIG_ERROR) #define SWIG_OLDOBJ (SWIG_OK) #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) /* Check, add and del mask methods */ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank # define SWIG_TypeRank unsigned long # endif # ifndef SWIG_MAXCASTRANK /* Default cast allowed */ # define SWIG_MAXCASTRANK (2) # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif #include #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ struct swig_cast_info *cast; /* linked list of types that can cast into this type */ void *clientdata; /* language specific type data */ int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { swig_type_info *type; /* pointer to type that is equivalent to this type */ swig_converter_func converter; /* function to cast the void pointers */ struct swig_cast_info *next; /* pointer to next cast in linked list */ struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ size_t size; /* Number of types in this module */ struct swig_module_info *next; /* Pointer to next element in circularly linked list */ swig_type_info **type_initial; /* Array of initially generated type structures */ swig_cast_info **cast_initial; /* Array of initially generated casting structures */ void *clientdata; /* Language specific module data */ } swig_module_info; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } return (int)((l1 - f1) - (l2 - f2)); } /* Check type equivalence in a name list like ||... Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int SWIG_TypeCmp(const char *nb, const char *tb) { int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; } /* Check type equivalence in a name list like ||... Return 0 if not equal, 1 if equal */ SWIGRUNTIME int SWIG_TypeEquiv(const char *nb, const char *tb) { return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (strcmp(iter->type->name, c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (iter->type == from) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ SWIGRUNTIMEINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ SWIGRUNTIME const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (!type) return NULL; if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Set the clientdata field for a type */ SWIGRUNTIME void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } } cast = cast->next; } } SWIGRUNTIME void SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { size_t l = 0; size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { int compare = strcmp(name, iname); if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { r = i - 1; } else { break; } } else if (compare > 0) { l = i + 1; } } else { break; /* should never happen */ } } while (l <= r); } iter = iter->next; } while (iter != end); return 0; } /* Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); if (ret) { return ret; } else { /* STEP 2: If the type hasn't been found, do a complete search of the str field (the human readable name) */ swig_module_info *iter = start; do { size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; } iter = iter->next; } while (iter != end); } /* neither found a match */ return 0; } /* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } /* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } SWIGRUNTIME const char * SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { *ptr = (void *) 0; return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sizeof(void *)); } SWIGRUNTIME char * SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { char *r = buff; size_t lname = (name ? strlen(name) : 0); if ((2*sz + 2 + lname) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); if (lname) { strncpy(r,name,lname+1); } else { *r = 0; } return buff; } SWIGRUNTIME const char * SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { memset(ptr,0,sz); return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sz); } #ifdef __cplusplus } #endif swig-3.0.8/Lib/swigarch.i0000664000175000017500000000305412641054563015052 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigarch.i * * SWIG library file for 32bit/64bit code specialization and checking. * * Use only in extreme cases, when no arch. independent code can be * generated * * To activate architecture specific code, use * * swig -DSWIGWORDSIZE32 * * or * * swig -DSWIGWORDSIZE64 * * Note that extra checking code will be added to the wrapped code, * which will prevent the compilation in a different architecture. * * If you don't specify the SWIGWORDSIZE (the default case), swig will * generate architecture independent and/or 32bits code, with no extra * checking code added. * ----------------------------------------------------------------------------- */ #if !defined(SWIGWORDSIZE32) && !defined(SWIGWORDSIZE64) # if (__WORDSIZE == 32) # define SWIGWORDSIZE32 # endif #endif #if !defined(SWIGWORDSIZE64) && !defined(SWIGWORDSIZE32) # if defined(__x86_64) || defined(__x86_64__) || (__WORDSIZE == 64) # define SWIGWORDSIZE64 # endif #endif #ifdef SWIGWORDSIZE32 %{ #define SWIGWORDSIZE32 #ifndef LONG_MAX #include #endif #if (__WORDSIZE == 64) || (LONG_MAX != INT_MAX) # error "SWIG wrapped code invalid in 64 bit architecture, regenerate code using -DSWIGWORDSIZE64" #endif %} #endif #ifdef SWIGWORDSIZE64 %{ #define SWIGWORDSIZE64 #ifndef LONG_MAX #include #endif #if (__WORDSIZE == 32) || (LONG_MAX == INT_MAX) # error "SWIG wrapped code invalid in 32 bit architecture, regenerate code using -DSWIGWORDSIZE32" #endif %} #endif swig-3.0.8/Lib/swigwarnings.swg0000664000175000017500000001566612641054563016351 0ustar williamwilliam/* Include the internal swig macro codes. These macros correspond to the one found in Source/Include/swigwarn.h plus the 'SWIG' prefix. For example, in the include file 'swigwarn.h' you will find #define WARN_TYPEMAP_CHARLEAK ... and in the 'swigwarn.swg' interface, you will see %define SWIGWARN_TYPEMAP_CHARLEAK ... This code can be used in warning filters as follows: %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK); Warnings messages used in typemaps. Message names will be the same as those in Lib/swigwarn.swg but with the suffix _MSG. For example, for the code SWIGWARN_TYPEMAP_CHARLEAK, once you use %typemapmsg(CHARLEAK,); you use the message in your typemap as %typemap(varin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) char * while you suppress the warning using %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK); as described above. */ /* ----------------------------------------------------------------------------- * SWIG warning codes * ----------------------------------------------------------------------------- */ %include /* ----------------------------------------------------------------------------- * Auxiliary macros * ----------------------------------------------------------------------------- */ /* Macro to define warning messages */ #define %_warningmsg(Val, Msg...) `Val`":"Msg #define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg) /* ----------------------------------------------------------------------------- * Typemap related warning messages * ----------------------------------------------------------------------------- */ %define SWIGWARN_TYPEMAP_CHARLEAK_MSG "451:Setting a const char * variable may leak memory." %enddef %define SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG "454:Setting a pointer/reference variable may leak memory." %enddef %define SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG "470:Thread/reentrant unsafe wrapping, consider returning by value instead." %enddef %define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG "473:Returning a pointer or reference in a director method is not recommended." %enddef %define SWIGWARN_TYPEMAP_INITIALIZER_LIST_MSG "476:Initialization using std::initializer_list." %enddef /* ----------------------------------------------------------------------------- * Operator related warning messages * ----------------------------------------------------------------------------- */ %define SWIGWARN_IGNORE_OPERATOR_NEW_MSG "350:operator new ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_DELETE_MSG "351:operator delete ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_PLUS_MSG "352:operator+ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MINUS_MSG "353:operator- ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MUL_MSG "354:operator* ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_DIV_MSG "355:operator/ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MOD_MSG "356:operator% ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_XOR_MSG "357:operator^ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_AND_MSG "358:operator& ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_OR_MSG "359:operator| ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_NOT_MSG "360:operator~ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LNOT_MSG "361:operator! ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_EQ_MSG "362:operator= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LT_MSG "363:operator< ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_GT_MSG "364:operator> ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_PLUSEQ_MSG "365:operator+= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MINUSEQ_MSG "366:operator-= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MULEQ_MSG "367:operator*= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_DIVEQ_MSG "368:operator/= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MODEQ_MSG "369:operator%= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_XOREQ_MSG "370:operator^= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_ANDEQ_MSG "371:operator&= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_OREQ_MSG "372:operator|= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LSHIFT_MSG "373:operator<< ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_RSHIFT_MSG "374:operator>> ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LSHIFTEQ_MSG "375:operator<<= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_RSHIFTEQ_MSG "376:operator>>= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_EQUALTO_MSG "377:operator== ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_NOTEQUAL_MSG "378:operator!= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LTEQUAL_MSG "379:operator<= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_GTEQUAL_MSG "380:operator>= ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LAND_MSG "381:operator&& ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_LOR_MSG "382:operator|| ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_PLUSPLUS_MSG "383:operator++ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_MINUSMINUS_MSG "384:operator-- ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_COMMA_MSG "385:operator-- ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_ARROWSTAR_MSG "386:operator->* ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_ARROW_MSG "387:operator-> ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_CALL_MSG "388:operator() ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_INDEX_MSG "389:operator[] ignored (consider using %%extend)" %enddef %define SWIGWARN_IGNORE_OPERATOR_UPLUS_MSG "390:operator+ ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_UMINUS_MSG "391:operator- ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_UMUL_MSG "392:operator* ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_UAND_MSG "393:operator& ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_NEWARR_MSG "394:operator new[] ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_DELARR_MSG "395:operator delete[] ignored" %enddef %define SWIGWARN_IGNORE_OPERATOR_REF_MSG "396:operator*() ignored" %enddef #define %ignoreoperator(Oper) %ignorewarn(SWIGWARN_IGNORE_OPERATOR_##Oper##_MSG) /* ----------------------------------------------------------------------------- * Macros for keyword and built-in names * ----------------------------------------------------------------------------- */ #define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg)) #define %builtinwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, msg), %$isfunction) /* ----------------------------------------------------------------------------- * Warning filter feature * ----------------------------------------------------------------------------- */ #define %_warnfilter(filter...) %feature("warnfilter",`filter`) #define %warnfilter(filter...) %_warnfilter(filter) swig-3.0.8/Lib/guile/0000775000175000017500000000000012641054563014174 5ustar williamwilliamswig-3.0.8/Lib/guile/interpreter.i0000664000175000017500000000261512641054563016715 0ustar williamwilliam/* ----------------------------------------------------------------------------- * interpreter.i * * SWIG file for a simple Guile interpreter * ----------------------------------------------------------------------------- */ %{ #include GSCM_status guile_init(); int main(int argc, char **argv) { GSCM_status status; GSCM_top_level toplev; char *eval_answer; char input_str[16384]; int done; /* start a scheme interpreter */ status = gscm_run_scm(argc, argv, 0, stdout, stderr, guile_init, 0, "#t"); if (status != GSCM_OK) { fputs(gscm_error_msg(status), stderr); fputc('\n', stderr); printf("Error in startup.\n"); exit(1); } /* create the top level environment */ status = gscm_create_top_level(&toplev); if (status != GSCM_OK) { fputs(gscm_error_msg(status), stderr); fputc('\n', stderr); exit(1); } /* now sit in a scheme eval loop: I input the expressions, have guile * evaluate them, and then get another expression. */ done = 0; fprintf(stdout,"Guile > "); while (!done) { if (fgets(input_str,16384,stdin) == NULL) { exit(1); } else { if (strncmp(input_str,"quit",4) == 0) exit(1); status = gscm_eval_str(&eval_answer, toplev, input_str); fprintf(stdout,"%s\n", eval_answer); fprintf(stdout,"Guile > "); } } /* now clean up and quit */ gscm_destroy_top_level(toplev); } %} swig-3.0.8/Lib/guile/std_pair.i0000664000175000017500000011753112641054563016163 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // // See std_vector.i for the rationale of typemap application // ------------------------------------------------------------------------ %{ #include %} // exported class namespace std { template struct pair { %typemap(in) pair %{ if (scm_is_pair($input)) { T* x; U* y; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(*x,*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } %} %typemap(in) const pair& (std::pair *temp = 0), const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { T* x; U* y; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = new std::pair< T, U >(*x,*y); $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); U* y = new U($1.second); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); $result = scm_cons(first,second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (scm_is_pair($input)) { T* x; U* y; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (scm_is_pair($input)) { T* x; U* y; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // specializations for built-ins %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair %{ if (scm_is_pair($input)) { U* y; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(CONVERT_FROM(first),*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } %} %typemap(in) const pair& (std::pair *temp = 0), const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { U* y; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = new std::pair< T, U >(CONVERT_FROM(first),*y); $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { U* y = new U($1.second); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); $result = scm_cons(CONVERT_TO($1.first),second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (scm_is_pair($input)) { U* y; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (scm_is_pair($input)) { U* y; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair %{ if (scm_is_pair($input)) { T* x; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); $1 = std::make_pair(*x,CONVERT_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } %} %typemap(in) const pair& (std::pair *temp = 0), const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { T* x; SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); temp = new std::pair< T, U >(*x,CONVERT_FROM(second)); $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); $result = scm_cons(first,CONVERT_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (scm_is_pair($input)) { T* x; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && CHECK(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (scm_is_pair($input)) { T* x; SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && CHECK(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) template<> struct pair { %typemap(in) pair %{ if (scm_is_pair($input)) { SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); $1 = std::make_pair(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } %} %typemap(in) const pair& (std::pair *temp = 0), const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "pair<" #T "," #U "> expected"); temp = new std::pair< T, U >(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { $result = scm_cons(CONVERT_T_TO($1.first), CONVERT_U_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ if (scm_is_pair($input)) { SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ if (scm_is_pair($input)) { SCM first = SCM_CAR($input); SCM second = SCM_CDR($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { $1 = 0; } } else { /* wrapped pair? */ std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; %enddef specialize_std_pair_on_first(bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_first(int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_first(short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_first(long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_first(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_first(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_first(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_first(double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_first(float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_first(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_second(bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_second(int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_second(short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_second(long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_second(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_second(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_second(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_second(double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_second(float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_second(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(int,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(short,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(long,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(double,scm_is_number, scm_to_double,scm_from_double, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(float,scm_is_number, scm_to_double,scm_from_double, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); } swig-3.0.8/Lib/guile/list-vector.i0000664000175000017500000004350212641054563016625 0ustar williamwilliam/* ----------------------------------------------------------------------------- * list_vector.i * * Guile typemaps for converting between arrays and Scheme lists or vectors * ----------------------------------------------------------------------------- */ /* Here is a macro that will define typemaps for converting between C arrays and Scheme lists or vectors when passing arguments to the C function. TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) Supported calling conventions: func(int VECTORLENINPUT, [const] C_TYPE *VECTORINPUT) Scheme wrapper will take one argument, a vector. A temporary C array of elements of type C_TYPE will be allocated and filled with the elements of the vectors, converted to C with the SCM_TO_C function. Length and address of the array are passed to the C function. SCM_TYPE is used to describe the Scheme type of the elements in the Guile procedure documentation. func(int LISTLENINPUT, [const] C_TYPE *LISTINPUT) Likewise, but the Scheme wrapper will take one argument, a list. func(int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) Scheme wrapper will take no arguments. Addresses of an integer and a C_TYPE * variable will be passed to the C function. The C function is expected to return address and length of a freshly allocated array of elements of type C_TYPE through these pointers. The elements of this array are converted to Scheme with the C_TO_SCM function and returned as a Scheme vector. If the function has a void return value, the vector constructed by this typemap becomes the return value of the Scheme wrapper. Otherwise, the function returns multiple values. (See the documentation on how to deal with multiple values.) func(int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) Likewise, but the Scheme wrapper will return a list instead of a vector. It is also allowed to use "size_t LISTLENINPUT" rather than "int LISTLENINPUT". */ %define TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) /* input */ /* We make use of the new multi-dispatch typemaps here. */ %typemap(in, doc="$NAME is a vector of " #SCM_TYPE " values") (int VECTORLENINPUT, C_TYPE *VECTORINPUT), (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT) { SCM_VALIDATE_VECTOR($argnum, $input); $1 = scm_c_vector_length($input); if ($1 > 0) { $1_ltype i; $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); for (i = 0; i<$1; i++) { SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i)); $2[i] = SCM_TO_C_EXPR; } } else $2 = NULL; } %typemap(in, doc="$NAME is a list of " #SCM_TYPE " values") (int LISTLENINPUT, C_TYPE *LISTINPUT), (size_t LISTLENINPUT, C_TYPE *LISTINPUT) { SCM_VALIDATE_LIST($argnum, $input); $1 = scm_to_ulong(scm_length($input)); if ($1 > 0) { $1_ltype i; SCM rest; $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); for (i = 0, rest = $input; i<$1; i++, rest = SCM_CDR(rest)) { SCM swig_scm_value = SCM_CAR(rest); $2[i] = SCM_TO_C_EXPR; } } else $2 = NULL; } /* Do not check for NULL pointers (override checks). */ %typemap(check) (int VECTORLENINPUT, C_TYPE *VECTORINPUT), (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT), (int LISTLENINPUT, C_TYPE *LISTINPUT), (size_t LISTLENINPUT, C_TYPE *LISTINPUT) "/* no check for NULL pointer */"; /* Discard the temporary array after the call. */ %typemap(freearg) (int VECTORLENINPUT, C_TYPE *VECTORINPUT), (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT), (int LISTLENINPUT, C_TYPE *LISTINPUT), (size_t LISTLENINPUT, C_TYPE *LISTINPUT) {if ($2!=NULL) SWIG_free($2);} %enddef /* output */ %define TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) /* First we make temporary variables ARRAYLENTEMP and ARRAYTEMP, whose addresses we pass to the C function. We ignore both arguments for Scheme. */ %typemap(in,numinputs=0) (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) (int arraylentemp, C_TYPE *arraytemp), (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) (int arraylentemp, C_TYPE *arraytemp), (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) (size_t arraylentemp, C_TYPE *arraytemp), (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) (size_t arraylentemp, C_TYPE *arraytemp) %{ $1 = &arraylentemp; $2 = &arraytemp; %} /* In the ARGOUT typemaps, we convert the array into a vector or a list and append it to the results. */ %typemap(argout, doc="$NAME (a vector of " #SCM_TYPE " values)") (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) { $*1_ltype i; SCM res = scm_make_vector(scm_from_long(*$1), SCM_BOOL_F); for (i = 0; i<*$1; i++) { C_TYPE swig_c_value = (*$2)[i]; SCM elt = C_TO_SCM_EXPR; scm_vector_set_x(res, scm_from_long(i), elt); } SWIG_APPEND_VALUE(res); } %typemap(argout, doc="$NAME (a list of " #SCM_TYPE " values)") (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT), (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) { int i; SCM res = SCM_EOL; for (i = ((int)(*$1)) - 1; i>=0; i--) { C_TYPE swig_c_value = (*$2)[i]; SCM elt = C_TO_SCM_EXPR; res = scm_cons(elt, res); } SWIG_APPEND_VALUE(res); } /* In the FREEARG typemaps, get rid of the C vector. (This can be overridden if you want to keep the C vector.) */ %typemap(freearg) (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT), (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) { if ((*$2)!=NULL) free(*$2); } %enddef %define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_TYPE) TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) %enddef %define TYPEMAP_LIST_VECTOR_INPUT(C_TYPE, SCM_TO_C, SCM_TYPE) TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR (C_TYPE, SCM_TO_C(swig_scm_value), SCM_TYPE) %enddef %define TYPEMAP_LIST_VECTOR_OUTPUT(C_TYPE, C_TO_SCM, SCM_TYPE) TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR (C_TYPE, C_TO_SCM(swig_c_value), SCM_TYPE) %enddef %define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) TYPEMAP_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR (C_TYPE, SCM_TO_C(swig_scm_value), C_TO_SCM(swig_c_value), SCM_TYPE) %enddef /* We use the macro to define typemaps for some standard types. */ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); /* For the char *, free all strings after converting */ %typemap(freearg) (int *VECTORLENOUTPUT, char ***VECTOROUTPUT), (size_t *VECTORLENOUTPUT, char ***VECTOROUTPUT), (int *LISTLENOUTPUT, char ***LISTOUTPUT), (size_t *LISTLENOUTPUT, char ***LISTOUTPUT), (int *VECTORLENOUTPUT, const char ***VECTOROUTPUT), (size_t *VECTORLENOUTPUT, const char ***VECTOROUTPUT), (int *LISTLENOUTPUT, const char ***LISTOUTPUT), (size_t *LISTLENOUTPUT, const char ***LISTOUTPUT) { if ((*$2)!=NULL) { int i; for (i = 0; i < *$1; i++) { if ((*$2)[i] != NULL) free((*$2)[i]); } free(*$2); } } %typemap(freearg) (int VECTORLENINPUT, char **VECTORINPUT), (size_t VECTORLENINPUT, char **VECTORINPUT), (int LISTLENINPUT, char **LISTINPUT), (size_t LISTLENINPUT, char **LISTINPUT), (int VECTORLENINPUT, const char **VECTORINPUT), (size_t VECTORLENINPUT, const char **VECTORINPUT), (int LISTLENINPUT, const char **LISTINPUT), (size_t LISTLENINPUT, const char **LISTINPUT) { if (($2)!=NULL) { int i; for (i = 0; i< $1; i++) if (($2)[i] != NULL) free(($2)[i]); free($2); } } /* Following is a macro that emits typemaps that are much more flexible. (They are also messier.) It supports multiple parallel lists and vectors (sharing one length argument each). TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) Supported calling conventions: func(int PARALLEL_VECTORLENINPUT, [const] C_TYPE *PARALLEL_VECTORINPUT, ...) or func([const] C_TYPE *PARALLEL_VECTORINPUT, ..., int PARALLEL_VECTORLENINPUT) func(int PARALLEL_LISTLENINPUT, [const] C_TYPE *PARALLEL_LISTINPUT, ...) or func([const] C_TYPE *PARALLEL_LISTINPUT, ..., int PARALLEL_LISTLENINPUT) func(int *PARALLEL_VECTORLENOUTPUT, C_TYPE **PARALLEL_VECTOROUTPUT, ...) or func(C_TYPE **PARALLEL_VECTOROUTPUT, int *PARALLEL_VECTORLENOUTPUT, ...) func(int *PARALLEL_LISTLENOUTPUT, C_TYPE **PARALLEL_LISTOUTPUT) or func(C_TYPE **PARALLEL_LISTOUTPUT, int *PARALLEL_LISTLENOUTPUT) It is also allowed to use "size_t PARALLEL_LISTLENINPUT" rather than "int PARALLEL_LISTLENINPUT". */ %define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) /* input */ /* Passing data is a little complicated here; just remember: IGNORE typemaps come first, then IN, then CHECK. But if IGNORE is given, IN won't be used for this type. We need to "ignore" one of the parameters because there shall be only one argument on the Scheme side. Here we only initialize the array length to 0 but save its address for a later change. */ %typemap(in,numinputs=0) int PARALLEL_VECTORLENINPUT (int *_global_vector_length), size_t PARALLEL_VECTORLENINPUT (size_t *_global_vector_length) { $1 = 0; _global_vector_length = &$1; } %typemap(in,numinputs=0) int PARALLEL_LISTLENINPUT (int *_global_list_length), size_t PARALLEL_LISTLENINPUT (size_t *_global_list_length) { $1 = 0; _global_list_length = &$1; } /* All the work is done in IN. */ %typemap(in, doc="$NAME is a vector of " #SCM_TYPE " values") C_TYPE *PARALLEL_VECTORINPUT, const C_TYPE *PARALLEL_VECTORINPUT { SCM_VALIDATE_VECTOR($argnum, $input); *_global_vector_length = scm_c_vector_length($input); if (*_global_vector_length > 0) { int i; $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * (*_global_vector_length)); for (i = 0; i<*_global_vector_length; i++) { SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i)); $1[i] = SCM_TO_C_EXPR; } } else $1 = NULL; } %typemap(in, doc="$NAME is a list of " #SCM_TYPE " values") C_TYPE *PARALLEL_LISTINPUT, const C_TYPE *PARALLEL_LISTINPUT { SCM_VALIDATE_LIST($argnum, $input); *_global_list_length = scm_to_ulong(scm_length($input)); if (*_global_list_length > 0) { int i; SCM rest; $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * (*_global_list_length)); for (i = 0, rest = $input; i<*_global_list_length; i++, rest = SCM_CDR(rest)) { SCM swig_scm_value = SCM_CAR(rest); $1[i] = SCM_TO_C_EXPR; } } else $1 = NULL; } /* Don't check for NULL pointers (override checks). */ %typemap(check) C_TYPE *PARALLEL_VECTORINPUT, const C_TYPE *PARALLEL_VECTORINPUT, C_TYPE *PARALLEL_LISTINPUT, const C_TYPE *PARALLEL_LISTINPUT "/* no check for NULL pointer */"; /* Discard the temporary array after the call. */ %typemap(freearg) C_TYPE *PARALLEL_VECTORINPUT, const C_TYPE *PARALLEL_VECTORINPUT, C_TYPE *PARALLEL_LISTINPUT, const C_TYPE *PARALLEL_LISTINPUT {if ($1!=NULL) SWIG_free($1);} %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) /* output */ /* First we make a temporary variable ARRAYLENTEMP, use its address as the ...LENOUTPUT argument for the C function and "ignore" the ...LENOUTPUT argument for Scheme. */ %typemap(in,numinputs=0) int *PARALLEL_VECTORLENOUTPUT (int _global_arraylentemp), size_t *PARALLEL_VECTORLENOUTPUT (size_t _global_arraylentemp), int *PARALLEL_LISTLENOUTPUT (int _global_arraylentemp), size_t *PARALLEL_LISTLENOUTPUT (size_t _global_arraylentemp) "$1 = &_global_arraylentemp;"; /* We also need to ignore the ...OUTPUT argument. */ %typemap(in,numinputs=0) C_TYPE **PARALLEL_VECTOROUTPUT (C_TYPE *arraytemp), C_TYPE **PARALLEL_LISTOUTPUT (C_TYPE *arraytemp) "$1 = &arraytemp;"; /* In the ARGOUT typemaps, we convert the array into a vector or a list and append it to the results. */ %typemap(argout, doc="$NAME (a vector of " #SCM_TYPE " values)") C_TYPE **PARALLEL_VECTOROUTPUT { int i; SCM res = scm_make_vector(scm_from_long(_global_arraylentemp), SCM_BOOL_F); for (i = 0; i<_global_arraylentemp; i++) { C_TYPE swig_c_value = (*$1)[i]; SCM elt = C_TO_SCM_EXPR; scm_vector_set_x(res, scm_from_long(i), elt); } SWIG_APPEND_VALUE(res); } %typemap(argout, doc="$NAME (a list of " #SCM_TYPE " values)") C_TYPE **PARALLEL_LISTOUTPUT { int i; SCM res = SCM_EOL; if (_global_arraylentemp > 0) { for (i = _global_arraylentemp - 1; i>=0; i--) { C_TYPE swig_c_value = (*$1)[i]; SCM elt = C_TO_SCM_EXPR; res = scm_cons(elt, res); } } SWIG_APPEND_VALUE(res); } /* In the FREEARG typemaps, get rid of the C vector. (This can be overridden if you want to keep the C vector.) */ %typemap(freearg) C_TYPE **PARALLEL_VECTOROUTPUT, C_TYPE **PARALLEL_LISTOUTPUT { if ((*$1)!=NULL) free(*$1); } %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT(C_TYPE, SCM_TO_C, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR (C_TYPE, SCM_TO_C(swig_scm_value), SCM_TYPE) %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT(C_TYPE, C_TO_SCM, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR (C_TYPE, C_TO_SCM(swig_c_value), SCM_TYPE) %enddef %define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR (C_TYPE, SCM_TO_C(swig_scm_value), C_TO_SCM(swig_c_value), SCM_TYPE) %enddef /* We use the macro to define typemaps for some standard types. */ TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); %typemap(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT, const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT { if (($1)!=NULL) { int i; for (i = 0; i<*_global_list_length; i++) if (($1)[i] != NULL) SWIG_free(($1)[i]); SWIG_free($1); } } %typemap(freearg) char ***PARALLEL_LISTOUTPUT, char ***PARALLEL_VECTOROUTPUT, const char ***PARALLEL_LISTOUTPUT, const char ***PARALLEL_VECTOROUTPUT { if ((*$1)!=NULL) { int i; for (i = 0; i<_global_arraylentemp; i++) if ((*$1)[i] != NULL) free((*$1)[i]); free(*$1); } } swig-3.0.8/Lib/guile/std_except.i0000664000175000017500000000026612641054563016514 0ustar williamwilliam// TODO: STL exception handling // Note that the generic std_except.i file did not work %{ #include %} namespace std { %ignore exception; struct exception { }; } swig-3.0.8/Lib/guile/ports.i0000664000175000017500000000247012641054563015520 0ustar williamwilliam/* ----------------------------------------------------------------------------- * ports.i * * Guile typemaps for handling ports * ----------------------------------------------------------------------------- */ %{ #ifndef _POSIX_SOURCE /* This is needed on Solaris for fdopen(). */ # define _POSIX_SOURCE 199506L #endif #include #include #include %} /* This typemap for FILE * accepts (1) FILE * pointer objects, (2) Scheme file ports. In this case, it creates a temporary C stream which reads or writes from a dup'ed file descriptor. */ %typemap(in, doc="$NAME is a file port or a FILE * pointer") FILE * { if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) != 0) { if (!(SCM_FPORTP($input))) { scm_wrong_type_arg("$symname", $argnum, $input); } else { int fd; if (SCM_OUTPUT_PORT_P($input)) { scm_force_output($input); } fd=dup(SCM_FPORT_FDES($input)); if (fd==-1) { scm_misc_error("$symname", strerror(errno), SCM_EOL); } $1=fdopen(fd, SCM_OUTPUT_PORT_P($input) ? (SCM_INPUT_PORT_P($input) ? "r+" : "w") : "r"); if ($1==NULL) { scm_misc_error("$symname", strerror(errno), SCM_EOL); } } } } %typemap(freearg) FILE* { if ($1) { fclose($1); } } swig-3.0.8/Lib/guile/std_deque.i0000664000175000017500000000003412641054563016320 0ustar williamwilliam%include swig-3.0.8/Lib/guile/std_common.i0000664000175000017500000000110212641054563016502 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; #define SWIG_bool2scm(b) scm_from_bool(b ? 1 : 0) #define SWIG_string2scm(s) SWIG_str02scm(s.c_str()) %{ #include inline std::string SWIG_scm2string(SCM x) { char* temp; temp = SWIG_scm2str(x); std::string s(temp); if (temp) SWIG_free(temp); return s; } %} swig-3.0.8/Lib/guile/extra-install.list0000664000175000017500000000004712641054563017661 0ustar williamwilliam# see top-level Makefile.in common.scm swig-3.0.8/Lib/guile/cplusplus.i0000664000175000017500000000136312641054563016403 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cplusplus.i * * SWIG typemaps for C++ * ----------------------------------------------------------------------------- */ %typemap(guile,out) string, std::string { $result = SWIG_str02scm(const_cast($1.c_str())); } %typemap(guile,in) string, std::string { $1 = SWIG_scm2str($input); } %typemap(guile,out) complex, complex, std::complex { $result = scm_make_rectangular( scm_from_double ($1.real ()), scm_from_double ($1.imag ()) ); } %typemap(guile,in) complex, complex, std::complex { $1 = std::complex( scm_to_double (scm_real_part ($input)), scm_to_double (scm_imag_part ($input)) ); } swig-3.0.8/Lib/guile/guile_scm.swg0000664000175000017500000000230612641054563016666 0ustar williamwilliam/* ----------------------------------------------------------------------------- * guile_scm.swg * * This SWIG interface file is processed if the Guile module is run * with SCM_ flavor. * ----------------------------------------------------------------------------- */ #define SWIGGUILE_SCM %runtime "swigrun.swg" // Common C API type-checking code %runtime "guile_scm_run.swg" %include %runtime %{ #define GUILE_MAYBE_VALUES \ if (gswig_list_p) gswig_result = scm_values(gswig_result); #define GUILE_MAYBE_VECTOR \ if (gswig_list_p) gswig_result = scm_vector(gswig_result); #define SWIG_APPEND_VALUE(object) \ if (gswig_result == SCM_UNSPECIFIED) \ gswig_result = object; \ else { \ if (!gswig_list_p) { \ gswig_list_p = 1; \ gswig_result = scm_listify(gswig_result, object, SCM_UNDEFINED); \ } \ else \ gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \ } %} %insert(init) "swiginit.swg" %init %{ SWIG_GUILE_INIT_STATIC void SWIG_init(void) { SWIG_InitializeModule(0); SWIG_PropagateClientData(); %} swig-3.0.8/Lib/guile/common.scm0000664000175000017500000000452012641054563016171 0ustar williamwilliam;;;************************************************************************ ;;;*common.scm ;;;* ;;;* This file contains generic SWIG GOOPS classes for generated ;;;* GOOPS file support ;;;************************************************************************ (define-module (Swig swigrun)) (define-module (Swig common) #:use-module (oop goops) #:use-module (Swig swigrun)) (define-class () (new-function #:init-value #f)) (define-method (initialize (class ) initargs) (slot-set! class 'new-function (get-keyword #:new-function initargs #f)) (next-method)) (define-class () (swig-smob #:init-value #f) #:metaclass ) (define-method (initialize (obj ) initargs) (next-method) (slot-set! obj 'swig-smob (let ((arg (get-keyword #:init-smob initargs #f))) (if arg arg (let ((ret (apply (slot-ref (class-of obj) 'new-function) (get-keyword #:args initargs '())))) ;; if the class is registered with runtime environment, ;; new-Function will return a goops class. In that case, extract the smob ;; from that goops class and set it as the current smob. (if (slot-exists? ret 'swig-smob) (slot-ref ret 'swig-smob) ret)))))) (define (display-address o file) (display (number->string (object-address o) 16) file)) (define (display-pointer-address o file) ;; Don't fail if the function SWIG-PointerAddress is not present. (let ((address (false-if-exception (SWIG-PointerAddress o)))) (if address (begin (display " @ " file) (display (number->string address 16) file))))) (define-method (write (o ) file) ;; We display _two_ addresses to show the object's identity: ;; * first the address of the GOOPS proxy object, ;; * second the pointer address. ;; The reason is that proxy objects are created and discarded on the ;; fly, so different proxy objects for the same C object will appear. (let ((class (class-of o))) (if (slot-bound? class 'name) (begin (display "#<" file) (display (class-name class) file) (display #\space file) (display-address o file) (display-pointer-address o file) (display ">" file)) (next-method)))) (export ) ;;; common.scm ends here swig-3.0.8/Lib/guile/pointer-in-out.i0000664000175000017500000000637512641054563017252 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pointer-in-out.i * * Guile typemaps for passing pointers indirectly * ----------------------------------------------------------------------------- */ /* Here is a macro that will define typemaps for passing C pointers indirectly. TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE) Supported calling conventions (in this example, PTRTYPE is int *): func(int **INPUT) Scheme wrapper will take one argument, a wrapped C pointer. The address of a variable containing this pointer will be passed to the function. func(int **INPUT_CONSUMED) Likewise, but mark the pointer object as not garbage collectable. func(int **INPUT_DESTROYED) Likewise, but mark the pointer object as destroyed. func(int **OUTPUT) Scheme wrapper will take no arguments. The address of an int * variable will be passed to the function. The function is expected to modify the variable; its value is wrapped and becomes an extra return value. (See the documentation on how to deal with multiple values.) func(int **OUTPUT_NONCOLLECTABLE) Likewise, but make the pointer object not garbage collectable. func(int **BOTH) func(int **INOUT) This annotation combines INPUT and OUTPUT. */ %define TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE) %typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE *INPUT(PTRTYPE temp) { if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { scm_wrong_type_arg(FUNC_NAME, $argnum, $input); } $1 = &temp; } %typemap(in, doc="$NAME is of type <" #SCM_TYPE "> and is consumed by the function") PTRTYPE *INPUT_CONSUMED(PTRTYPE temp) { if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { scm_wrong_type_arg(FUNC_NAME, $argnum, $input); } SWIG_Guile_MarkPointerNoncollectable($input); $1 = &temp; } %typemap(in, doc="$NAME is of type <" #SCM_TYPE "> and is consumed by the function") PTRTYPE *INPUT_DESTROYED(PTRTYPE temp) { if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { scm_wrong_type_arg(FUNC_NAME, $argnum, $input); } SWIG_Guile_MarkPointerDestroyed($input); $1 = &temp; } %typemap(in, numinputs=0) PTRTYPE *OUTPUT(PTRTYPE temp), PTRTYPE *OUTPUT_NONCOLLECTABLE(PTRTYPE temp) "$1 = &temp;"; %typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT "SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 1));"; %typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT_NONCOLLECTABLE "SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 0));"; %typemap(in) PTRTYPE *BOTH = PTRTYPE *INPUT; %typemap(argout) PTRTYPE *BOTH = PTRTYPE *OUTPUT; %typemap(in) PTRTYPE *INOUT = PTRTYPE *INPUT; %typemap(argout) PTRTYPE *INOUT = PTRTYPE *OUTPUT; /* As a special convenience measure, also attach docs involving SCM_TYPE to the standard pointer typemaps */ %typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE { if (SWIG_ConvertPtr($input, (void **) &$1, $descriptor, 0)) scm_wrong_type_arg(FUNC_NAME, $argnum, $input); } %typemap(out, doc="<" #SCM_TYPE ">") PTRTYPE { $result = SWIG_NewPointerObj ($1, $descriptor, $owner); } %enddef swig-3.0.8/Lib/guile/std_map.i0000664000175000017500000016665312641054563016016 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // // The aim of all that follows would be to integrate std::map with // Guile as much as possible, namely, to allow the user to pass and // be returned Scheme association lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::map), f(const std::map&), f(const std::map*): // the parameter being read-only, either a Scheme alist or a // previously wrapped std::map can be passed. // -- f(std::map&), f(std::map*): // the parameter must be modified; therefore, only a wrapped std::map // can be passed. // -- std::map f(): // the map is returned by copy; therefore, a Scheme alist // is returned which is most easily used in other Scheme functions // -- std::map& f(), std::map* f(), const std::map& f(), // const std::map* f(): // the map is returned by reference; therefore, a wrapped std::map // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { $1 = std::map< K, T >(); } else if (scm_is_pair($input)) { $1 = std::map< K, T >(); SCM alist = $input; while (!scm_is_null(alist)) { K* k; T* x; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[*k] = *x; alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { temp = std::map< K, T >(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::map< K, T >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { K* k; T* x; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[*k] = *x; alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { SCM alist = SCM_EOL; for (std::map< K, T >::reverse_iterator i=$i.rbegin(); i!=$i.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); SCM entry = scm_cons(k,x); alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { /* native sequence? */ if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ K* k; T* x; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { /* wrapped map? */ std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { /* native sequence? */ if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ K* k; T* x; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { /* wrapped map? */ std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map< K, T> &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& __getitem__(const K& key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(const K& key, const T& x) { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map< K, T >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scm_cons(k,result); } return result; } } }; // specializations for built-ins %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { $1 = std::map< K, T >(); } else if (scm_is_pair($input)) { $1 = std::map< K, T >(); SCM alist = $input; while (!scm_is_null(alist)) { T* x; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[CONVERT_FROM(key)] = *x; alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { temp = std::map< K, T >(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::map< K, T >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { T* x; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[CONVERT_FROM(key)] = *x; alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { SCM alist = SCM_EOL; for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { T* val = new T(i->second); SCM k = CONVERT_TO(i->first); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); SCM entry = scm_cons(k,x); alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only T* x; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only T* x; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map< K, T > &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(K key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(K key, const T& x) { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { std::map< K, T >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { SCM k = CONVERT_TO(i->first); result = scm_cons(k,result); } return result; } } }; %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { $1 = std::map< K, T >(); } else if (scm_is_pair($input)) { $1 = std::map< K, T >(); SCM alist = $input; while (!scm_is_null(alist)) { K* k; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[*k] = CONVERT_FROM(val); alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { temp = std::map< K, T >(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::map< K, T >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { K* k; SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[*k] = CONVERT_FROM(val); alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { SCM alist = SCM_EOL; for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = CONVERT_TO(i->second); SCM entry = scm_cons(k,x); alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only K* k; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (CHECK(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only K* k; SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (CHECK(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map< K, T > &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(const K& key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(const K& key, T x) { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map< K, T >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scm_cons(k,result); } return result; } } }; %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) template<> class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { $1 = std::map< K, T >(); } else if (scm_is_pair($input)) { $1 = std::map< K, T >(); SCM alist = $input; while (!scm_is_null(alist)) { SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const map& (std::map temp, std::map* m), const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { temp = std::map< K, T >(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::map< K, T >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { SCM entry, key, val; entry = SCM_CAR(alist); if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); key = SCM_CAR(entry); val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) map { SCM alist = SCM_EOL; for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { SCM k = CONVERT_K_TO(i->first); SCM x = CONVERT_T_TO(i->second); SCM entry = scm_cons(k,x); alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (CHECK_T(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { // check the first element only SCM head = SCM_CAR($input); if (scm_is_pair(head)) { SCM key = SCM_CAR(head); SCM val = SCM_CDR(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; } else if (scm_is_pair(val)) { val = SCM_CAR(val); if (CHECK_T(val)) $1 = 1; else $1 = 0; } else { $1 = 0; } } } else { $1 = 0; } } else { // wrapped map? std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; else $1 = 0; } } %rename("length") size; %rename("null?") empty; %rename("clear!") clear; %rename("ref") __getitem__; %rename("set!") __setitem__; %rename("delete!") __delitem__; %rename("has-key?") has_key; public: map(); map(const map< K, T> &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(K key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void __setitem__(K key, T x) { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { std::map< K, T >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { SCM k = CONVERT_K_TO(i->first); result = scm_cons(k,result); } return result; } } }; %enddef specialize_std_map_on_key(bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_key(int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_key(short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_key(long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_key(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_key(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_key(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_key(double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_key(float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_key(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_value(bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_value(int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_value(short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_value(long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_value(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_value(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_value(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_value(double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_value(float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_value(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(bool,scm_is_bool, scm_is_true,SWIG_bool2scm, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(int,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(short,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(long,scm_is_number, scm_to_long,scm_from_long, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(double,scm_is_number, scm_to_double,scm_from_double, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(float,scm_is_number, scm_to_double,scm_from_double, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, bool,scm_is_bool, scm_is_true,SWIG_bool2scm); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, int,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, short,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, long,scm_is_number, scm_to_long,scm_from_long); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned int,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned short,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, unsigned long,scm_is_number, scm_to_ulong,scm_from_ulong); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, double,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, float,scm_is_number, scm_to_double,scm_from_double); specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); } swig-3.0.8/Lib/guile/std_string.i0000664000175000017500000000444112641054563016531 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * SWIG typemaps for std::string * ----------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ // std::string is typemapped by value // This can prevent exporting methods which return a string // in order for the user to modify it. // However, I think I'll wait until someone asks for it... // ------------------------------------------------------------------------ %include %{ #include %} namespace std { %naturalvar string; class string; %typemap(typecheck) string = char *; %typemap(typecheck) const string & = char *; %typemap(in) string (char * tempptr) { if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(in) const string & ($*1_ltype temp, char *tempptr) { if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); temp.assign(tempptr); if (tempptr) SWIG_free(tempptr); $1 = &temp; } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(in) string * (char *tempptr) { if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); $1 = new $*1_ltype(tempptr); if (tempptr) SWIG_free(tempptr); } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(out) string { $result = SWIG_str02scm($1.c_str()); } %typemap(out) const string & { $result = SWIG_str02scm($1->c_str()); } %typemap(out) string * { $result = SWIG_str02scm($1->c_str()); } %typemap(varin) string { if (scm_is_string($input)) { char *tempptr = SWIG_scm2str($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } else { SWIG_exception(SWIG_TypeError, "string expected"); } } %typemap(varout) string { $result = SWIG_str02scm($1.c_str()); } } swig-3.0.8/Lib/guile/guilemain.i0000664000175000017500000000203412641054563016317 0ustar williamwilliam/* ----------------------------------------------------------------------------- * guilemain.i * * The main functions for a user augmented guile * version that can handle wrapped calls as generated by SWIG * ----------------------------------------------------------------------------- */ %{ #include #ifdef __cplusplus extern "C" { #endif /* Debugger interface (don't change the order of the following lines) */ #define GDB_TYPE SCM #include GDB_INTERFACE; static void inner_main(void *closure, int argc, char **argv) { #ifdef SWIGINIT SWIGINIT #else SWIG_init(); /* SWIG init function */ #endif scm_shell(argc, argv); /* scheme interpreter */ /* never reached: scm_shell will perform an exit */ } #ifdef __cplusplus } #endif int main(int argc, char **argv) { /* put any default initialisation code here: e.g. exit handlers */ scm_boot_guile(argc, argv, inner_main, 0); /* make a stack entry for the garbage collector */ return 0; /* never reached, but avoids a warning */ } %} swig-3.0.8/Lib/guile/stl.i0000664000175000017500000000054512641054563015154 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/guile/Makefile0000664000175000017500000000003512641054563015632 0ustar williamwilliam co: co RCS/*.i* RCS/*.swg* swig-3.0.8/Lib/guile/guile_scm_run.swg0000664000175000017500000003373412641054563017563 0ustar williamwilliam/* ----------------------------------------------------------------------------- * guile_scm_run.swg * ----------------------------------------------------------------------------- */ #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* In the code below, use guile 2.0 compatible functions where possible. Functions that don't exist in older versions will be mapped to a deprecated equivalent for those versions only */ #if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) static SCM scm_module_variable (SCM module, SCM sym) { return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); } #endif #if SCM_MAJOR_VERSION >= 2 /* scm_c_define_gsubr takes a different parameter type depending on the guile version */ typedef scm_t_subr swig_guile_proc; #else typedef SCM (*swig_guile_proc)(); #endif typedef SCM (*guile_destructor)(SCM); typedef struct swig_guile_clientdata { guile_destructor destroy; SCM goops_class; } swig_guile_clientdata; #if SCM_MAJOR_VERSION <= 2 #define scm_to_utf8_string scm_to_locale_string #define scm_from_utf8_string scm_from_locale_string #endif #define SWIG_scm2str(s) \ SWIG_Guile_scm2newstr(s, NULL) #define SWIG_str02scm(str) \ str ? scm_from_utf8_string(str) : SCM_BOOL_F # define SWIG_malloc(size) \ scm_malloc(size) # define SWIG_free(mem) \ free(mem) #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Guile_ConvertPtr(s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ SWIG_Guile_MustGetPtr(s, type, argnum, flags, FUNC_NAME) #define SWIG_NewPointerObj(ptr, type, owner) \ SWIG_Guile_NewPointerObj((void*)ptr, type, owner) #define SWIG_PointerAddress(object) \ SWIG_Guile_PointerAddress(object) #define SWIG_PointerType(object) \ SWIG_Guile_PointerType(object) #define SWIG_IsPointerOfType(object, type) \ SWIG_Guile_IsPointerOfType(object, type) #define SWIG_IsPointer(object) \ SWIG_Guile_IsPointer(object) #define SWIG_contract_assert(expr, msg) \ if (!(expr)) \ scm_error(scm_from_locale_symbol("swig-contract-assertion-failed"), \ (char *) FUNC_NAME, (char *) msg, \ SCM_EOL, SCM_BOOL_F); else /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) \ SWIG_Guile_ConvertMember(obj, ptr, sz, ty, FUNC_NAME) #define SWIG_NewMemberObj(ptr, sz, type) \ SWIG_Guile_NewMemberObj(ptr, sz, type, FUNC_NAME) /* Runtime API */ static swig_module_info *SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)); #define SWIG_GetModule(clientdata) SWIG_Guile_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) SWIGINTERN char * SWIG_Guile_scm2newstr(SCM str, size_t *len) { #define FUNC_NAME "SWIG_Guile_scm2newstr" char *ret; SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME); ret = scm_to_utf8_string(str); if (!ret) return NULL; if (len) *len = strlen(ret) - 1; return ret; #undef FUNC_NAME } static int swig_initialized = 0; static scm_t_bits swig_tag = 0; static scm_t_bits swig_collectable_tag = 0; static scm_t_bits swig_destroyed_tag = 0; static scm_t_bits swig_member_function_tag = 0; static SCM swig_make_func = SCM_EOL; static SCM swig_keyword = SCM_EOL; static SCM swig_symbol = SCM_EOL; #define SWIG_Guile_GetSmob(x) \ ( !scm_is_null(x) && SCM_INSTANCEP(x) && scm_is_true(scm_slot_exists_p(x, swig_symbol)) \ ? scm_slot_ref(x, swig_symbol) : (x) ) SWIGINTERN SCM SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner) { if (ptr == NULL) return SCM_EOL; else { SCM smob; swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata; if (owner) SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type); else SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type); if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) { return smob; } else { /* the scm_make() C function only handles the creation of gf, methods and classes (no instances) the (make ...) function is later redefined in goops.scm. So we need to call that Scheme function. */ return scm_apply(swig_make_func, scm_list_3(cdata->goops_class, swig_keyword, smob), SCM_EOL); } } } SWIGINTERN unsigned long SWIG_Guile_PointerAddress(SCM object) { SCM smob = SWIG_Guile_GetSmob(object); if (SCM_NULLP(smob)) return 0; else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) { return (unsigned long) (void *) SCM_CELL_WORD_1(smob); } else scm_wrong_type_arg("SWIG-Guile-PointerAddress", 1, object); } SWIGINTERN swig_type_info * SWIG_Guile_PointerType(SCM object) { SCM smob = SWIG_Guile_GetSmob(object); if (SCM_NULLP(smob)) return NULL; else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) { return (swig_type_info *) SCM_CELL_WORD_2(smob); } else scm_wrong_type_arg("SWIG-Guile-PointerType", 1, object); } SWIGINTERN int SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags) { swig_cast_info *cast; swig_type_info *from; SCM smob = SWIG_Guile_GetSmob(s); if (SCM_NULLP(smob)) { *result = NULL; return SWIG_OK; } else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { /* we do not accept smobs representing destroyed pointers */ from = (swig_type_info *) SCM_CELL_WORD_2(smob); if (!from) return SWIG_ERROR; if (type) { cast = SWIG_TypeCheckStruct(from, type); if (cast) { int newmemory = 0; *result = SWIG_TypeCast(cast, (void *) SCM_CELL_WORD_1(smob), &newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ return SWIG_OK; } else { return SWIG_ERROR; } } else { *result = (void *) SCM_CELL_WORD_1(smob); return SWIG_OK; } } return SWIG_ERROR; } SWIGINTERNINLINE void * SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type, int argnum, int flags, const char *func_name) { void *result; int res = SWIG_Guile_ConvertPtr(s, &result, type, flags); if (!SWIG_IsOK(res)) { /* type mismatch */ scm_wrong_type_arg((char *) func_name, argnum, s); } return result; } SWIGINTERNINLINE int SWIG_Guile_IsPointerOfType (SCM s, swig_type_info *type) { void *result; if (SWIG_Guile_ConvertPtr(s, &result, type, 0)) { /* type mismatch */ return 0; } else return 1; } SWIGINTERNINLINE int SWIG_Guile_IsPointer (SCM s) { /* module might not be initialized yet, so initialize it */ SWIG_GetModule(0); return SWIG_Guile_IsPointerOfType (s, NULL); } /* Mark a pointer object non-collectable */ SWIGINTERN void SWIG_Guile_MarkPointerNoncollectable(SCM s) { SCM smob = SWIG_Guile_GetSmob(s); if (!SCM_NULLP(smob)) { if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { SCM_SET_CELL_TYPE(smob, swig_tag); } else scm_wrong_type_arg(NULL, 0, s); } } /* Mark a pointer object destroyed */ SWIGINTERN void SWIG_Guile_MarkPointerDestroyed(SCM s) { SCM smob = SWIG_Guile_GetSmob(s); if (!SCM_NULLP(smob)) { if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { SCM_SET_CELL_TYPE(smob, swig_destroyed_tag); } else scm_wrong_type_arg(NULL, 0, s); } } /* Member functions */ SWIGINTERN SCM SWIG_Guile_NewMemberObj(void *ptr, size_t sz, swig_type_info *type, const char *func_name) { SCM smob; void *copy = malloc(sz); memcpy(copy, ptr, sz); SCM_NEWSMOB2(smob, swig_member_function_tag, copy, (void *) type); return smob; } SWIGINTERN int SWIG_Guile_ConvertMember(SCM smob, void *ptr, size_t sz, swig_type_info *type, const char *func_name) { swig_cast_info *cast; swig_type_info *from; if (SCM_SMOB_PREDICATE(swig_member_function_tag, smob)) { from = (swig_type_info *) SCM_CELL_WORD_2(smob); if (!from) return SWIG_ERROR; if (type) { cast = SWIG_TypeCheckStruct(from, type); if (!cast) return SWIG_ERROR; } memcpy(ptr, (void *) SCM_CELL_WORD_1(smob), sz); return SWIG_OK; } return SWIG_ERROR; } /* Init */ SWIGINTERN int print_swig_aux (SCM swig_smob, SCM port, scm_print_state *pstate, const char *attribute) { swig_type_info *type; type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob); if (type) { scm_puts((char *) "#<", port); scm_puts((char *) attribute, port); scm_puts((char *) "swig-pointer ", port); scm_puts((char *) SWIG_TypePrettyName(type), port); scm_puts((char *) " ", port); scm_intprint((long) SCM_CELL_WORD_1(swig_smob), 16, port); scm_puts((char *) ">", port); /* non-zero means success */ return 1; } else { return 0; } } SWIGINTERN int print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { return print_swig_aux(swig_smob, port, pstate, ""); } SWIGINTERN int print_collectable_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { return print_swig_aux(swig_smob, port, pstate, "collectable-"); } SWIGINTERN int print_destroyed_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { return print_swig_aux(swig_smob, port, pstate, "destroyed-"); } SWIGINTERN int print_member_function_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { swig_type_info *type; type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob); if (type) { scm_puts((char *) "#<", port); scm_puts((char *) "swig-member-function-pointer ", port); scm_puts((char *) SWIG_TypePrettyName(type), port); scm_puts((char *) " >", port); /* non-zero means success */ return 1; } else { return 0; } } SWIGINTERN SCM equalp_swig (SCM A, SCM B) { if (SCM_CELL_WORD_0(A) == SCM_CELL_WORD_0(B) && SCM_CELL_WORD_1(A) == SCM_CELL_WORD_1(B) && SCM_CELL_WORD_2(A) == SCM_CELL_WORD_2(B)) return SCM_BOOL_T; else return SCM_BOOL_F; } SWIGINTERN size_t free_swig(SCM A) { swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(A); if (type) { if (type->clientdata && ((swig_guile_clientdata *)type->clientdata)->destroy) ((swig_guile_clientdata *)type->clientdata)->destroy(A); } return 0; } SWIGINTERN size_t free_swig_member_function(SCM A) { free((swig_type_info *) SCM_CELL_WORD_1(A)); return 0; } SWIGINTERN int ensure_smob_tag(SCM swig_module, scm_t_bits *tag_variable, const char *smob_name, const char *scheme_variable_name) { SCM variable = scm_module_variable(swig_module, scm_from_locale_symbol(scheme_variable_name)); if (scm_is_false(variable)) { *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0); scm_c_module_define(swig_module, scheme_variable_name, scm_from_ulong(*tag_variable)); return 1; } else { *tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable)); return 0; } } SWIGINTERN SCM SWIG_Guile_Init () { static SCM swig_module; if (swig_initialized) return swig_module; swig_initialized = 1; swig_module = scm_c_resolve_module("Swig swigrun"); if (ensure_smob_tag(swig_module, &swig_tag, "swig-pointer", "swig-pointer-tag")) { scm_set_smob_print(swig_tag, print_swig); scm_set_smob_equalp(swig_tag, equalp_swig); } if (ensure_smob_tag(swig_module, &swig_collectable_tag, "collectable-swig-pointer", "collectable-swig-pointer-tag")) { scm_set_smob_print(swig_collectable_tag, print_collectable_swig); scm_set_smob_equalp(swig_collectable_tag, equalp_swig); scm_set_smob_free(swig_collectable_tag, free_swig); } if (ensure_smob_tag(swig_module, &swig_destroyed_tag, "destroyed-swig-pointer", "destroyed-swig-pointer-tag")) { scm_set_smob_print(swig_destroyed_tag, print_destroyed_swig); scm_set_smob_equalp(swig_destroyed_tag, equalp_swig); } if (ensure_smob_tag(swig_module, &swig_member_function_tag, "swig-member-function-pointer", "swig-member-function-pointer-tag")) { scm_set_smob_print(swig_member_function_tag, print_member_function_swig); scm_set_smob_free(swig_member_function_tag, free_swig_member_function); } swig_make_func = scm_permanent_object( scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make"))); swig_keyword = scm_permanent_object(scm_from_locale_keyword((char*) "init-smob")); swig_symbol = scm_permanent_object(scm_from_locale_symbol("swig-smob")); #ifdef SWIG_INIT_RUNTIME_MODULE SWIG_INIT_RUNTIME_MODULE #endif return swig_module; } SWIGINTERN swig_module_info * SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) { SCM module = SWIG_Guile_Init(); SCM variable = scm_module_variable(module, scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME)); if (scm_is_false(variable)) { return NULL; } else { return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable)); } } SWIGINTERN void SWIG_Guile_SetModule(swig_module_info *swig_module) { SCM module = SWIG_Guile_Init(); scm_module_define(module, scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), scm_from_ulong((unsigned long) swig_module)); } SWIGINTERN int SWIG_Guile_GetArgs (SCM *dest, SCM rest, int reqargs, int optargs, const char *procname) { int i; int num_args_passed = 0; for (i = 0; i") C_NAME { SCM swig_scm_value = $input; $1 = SCM_TO_C_EXPR; } %typemap (varin, doc="NEW-VALUE is of type <" #SCM_NAME ">") C_NAME { SCM swig_scm_value = $input; $1 = SCM_TO_C_EXPR; } %typemap (out, doc="<" #SCM_NAME ">") C_NAME { C_NAME swig_c_value = $1; $result = C_TO_SCM_EXPR; } %typemap (varout, doc="<" #SCM_NAME ">") C_NAME { C_NAME swig_c_value = $1; $result = C_TO_SCM_EXPR; } /* INPUT and OUTPUT */ %typemap (in, doc="$NAME is of type <" #SCM_NAME ">)") C_NAME *INPUT(C_NAME temp) { SCM swig_scm_value = $input; temp = (C_NAME) SCM_TO_C_EXPR; $1 = &temp; } %typemap (in,numinputs=0) C_NAME *OUTPUT (C_NAME temp) {$1 = &temp;} %typemap (argout,doc="$name (of type <" #SCM_NAME ">)") C_NAME *OUTPUT { C_NAME swig_c_value = *$1; SWIG_APPEND_VALUE(C_TO_SCM_EXPR); } %typemap (in) C_NAME *BOTH = C_NAME *INPUT; %typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT; %typemap (in) C_NAME *INOUT = C_NAME *INPUT; %typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT; /* Const primitive references. Passed by value */ %typemap(in, doc="$NAME is of type <" #SCM_NAME ">") const C_NAME & (C_NAME temp) { SCM swig_scm_value = $input; temp = SCM_TO_C_EXPR; $1 = &temp; } %typemap(out, doc="<" #SCM_NAME ">") const C_NAME & { C_NAME swig_c_value = *$1; $result = C_TO_SCM_EXPR; } /* Throw typemap */ %typemap(throws) C_NAME { C_NAME swig_c_value = $1; scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(C_TO_SCM_EXPR, SCM_UNDEFINED)); } %enddef /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. It generates slightly simpler code than the macro above, but it is only suitable for very simple conversion expressions. */ %define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME) %typemap (in, doc="$NAME is of type <" #SCM_NAME ">") C_NAME {$1 = ($1_ltype) SCM_TO_C($input);} %typemap (varin, doc="NEW-VALUE is of type <" #SCM_NAME ">") C_NAME {$1 = ($1_ltype) SCM_TO_C($input);} %typemap (out, doc="<" #SCM_NAME ">") C_NAME {$result = C_TO_SCM($1);} %typemap (varout, doc="<" #SCM_NAME ">") C_NAME {$result = C_TO_SCM($1);} /* INPUT and OUTPUT */ %typemap (in, doc="$NAME is of type <" #SCM_NAME ">)") C_NAME *INPUT(C_NAME temp), C_NAME &INPUT(C_NAME temp) { temp = (C_NAME) SCM_TO_C($input); $1 = &temp; } %typemap (in,numinputs=0) C_NAME *OUTPUT (C_NAME temp), C_NAME &OUTPUT(C_NAME temp) {$1 = &temp;} %typemap (argout,doc="$name (of type <" #SCM_NAME ">)") C_NAME *OUTPUT, C_NAME &OUTPUT {SWIG_APPEND_VALUE(C_TO_SCM(*$1));} %typemap (in) C_NAME *BOTH = C_NAME *INPUT; %typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT; %typemap (in) C_NAME *INOUT = C_NAME *INPUT; %typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT; %typemap (in) C_NAME &INOUT = C_NAME &INPUT; %typemap (argout) C_NAME &INOUT = C_NAME &OUTPUT; /* Const primitive references. Passed by value */ %typemap(in, doc="$NAME is of type <" #SCM_NAME ">") const C_NAME & (C_NAME temp) { temp = SCM_TO_C($input); $1 = ($1_ltype) &temp; } %typemap(out, doc="<" #SCM_NAME ">") const C_NAME & { $result = C_TO_SCM(*$1); } /* Throw typemap */ %typemap(throws) C_NAME { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(C_TO_SCM($1), SCM_UNDEFINED)); } %enddef SIMPLE_MAP(bool, scm_is_true, scm_from_bool, boolean); SIMPLE_MAP(char, SCM_CHAR, SCM_MAKE_CHAR, char); SIMPLE_MAP(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); SIMPLE_MAP(signed char, SCM_CHAR, SCM_MAKE_CHAR, char); SIMPLE_MAP(int, scm_to_int, scm_from_long, integer); SIMPLE_MAP(short, scm_to_short, scm_from_long, integer); SIMPLE_MAP(long, scm_to_long, scm_from_long, integer); SIMPLE_MAP(ptrdiff_t, scm_to_long, scm_from_long, integer); SIMPLE_MAP(unsigned int, scm_to_uint, scm_from_ulong, integer); SIMPLE_MAP(unsigned short, scm_to_ushort, scm_from_ulong, integer); SIMPLE_MAP(unsigned long, scm_to_ulong, scm_from_ulong, integer); SIMPLE_MAP(size_t, scm_to_ulong, scm_from_ulong, integer); SIMPLE_MAP(float, scm_to_double, scm_from_double, real); SIMPLE_MAP(double, scm_to_double, scm_from_double, real); // SIMPLE_MAP(char *, SWIG_scm2str, SWIG_str02scm, string); // SIMPLE_MAP(const char *, SWIG_scm2str, SWIG_str02scm, string); /* Define long long typemaps -- uses functions that are only defined in recent versions of Guile, availability also depends on Guile's configuration. */ SIMPLE_MAP(long long, scm_to_long_long, scm_from_long_long, integer); SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, integer); /* Strings */ %typemap (in, doc="$NAME is a string") char *(int must_free = 0) { $1 = ($1_ltype)SWIG_scm2str($input); must_free = 1; } %typemap (varin, doc="NEW-VALUE is a string") char * {$1 = ($1_ltype)SWIG_scm2str($input);} %typemap (out, doc="") char * {$result = SWIG_str02scm((const char *)$1);} %typemap (varout, doc="") char * {$result = SWIG_str02scm($1);} %typemap (in, doc="$NAME is a string") char **INPUT(char * temp, int must_free = 0) { temp = (char *) SWIG_scm2str($input); $1 = &temp; must_free = 1; } %typemap (in,numinputs=0) char **OUTPUT (char * temp) {$1 = &temp;} %typemap (argout,doc="$NAME (a string)") char **OUTPUT {SWIG_APPEND_VALUE(SWIG_str02scm(*$1));} %typemap (in) char **BOTH = char **INPUT; %typemap (argout) char **BOTH = char **OUTPUT; %typemap (in) char **INOUT = char **INPUT; %typemap (argout) char **INOUT = char **OUTPUT; /* SWIG_scm2str makes a malloc'ed copy of the string, so get rid of it after the function call. */ %typemap (freearg) char * "if (must_free$argnum && $1) SWIG_free($1);"; %typemap (freearg) char **INPUT, char **BOTH "if (must_free$argnum && (*$1)) SWIG_free(*$1);" %typemap (freearg) char **OUTPUT "SWIG_free(*$1);" /* But this shall not apply if we try to pass a single char by reference. */ %typemap (freearg) char *OUTPUT, char *BOTH ""; /* If we set a string variable, delete the old result first, unless const. */ %typemap (varin) char * { if ($1) free($1); $1 = ($1_ltype) SWIG_scm2str($input); } %typemap (varin) const char * { $1 = ($1_ltype) SWIG_scm2str($input); } %typemap(throws) char * { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_str02scm($1), SCM_UNDEFINED)); } /* Void */ %typemap (out,doc="") void "gswig_result = SCM_UNSPECIFIED;"; /* SCM is passed through */ typedef unsigned long SCM; %typemap (in) SCM "$1=$input;"; %typemap (out) SCM "$result=$1;"; %typecheck(SWIG_TYPECHECK_POINTER) SCM "$1=1;"; /* ------------------------------------------------------------ * String & length * ------------------------------------------------------------ */ %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { size_t temp; $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp); $2 = ($2_ltype) temp; } /* ------------------------------------------------------------ * CLASS::* (member function pointer) typemaps * taken from typemaps/swigtype.swg * ------------------------------------------------------------ */ #define %set_output(obj) $result = obj #define %set_varoutput(obj) $result = obj #define %argument_fail(code, type, name, argn) scm_wrong_type_arg((char *) FUNC_NAME, argn, $input); #define %as_voidptr(ptr) (void*)(ptr) %typemap(in) SWIGTYPE (CLASS::*) { int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor); if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } } %typemap(out,noblock=1) SWIGTYPE (CLASS::*) { %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); } %typemap(varin) SWIGTYPE (CLASS::*) { int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor); if (!SWIG_IsOK(res)) { scm_wrong_type_arg((char *) FUNC_NAME, 1, $input); } } %typemap(varout,noblock=1) SWIGTYPE (CLASS::*) { %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); } /* ------------------------------------------------------------ * Typechecking rules * ------------------------------------------------------------ */ /* adapted from python.swg */ %typecheck(SWIG_TYPECHECK_INTEGER) int, short, long, unsigned int, unsigned short, unsigned long, signed char, unsigned char, long long, unsigned long long, size_t, ptrdiff_t, std::size_t, std::ptrdiff_t, const int &, const short &, const long &, const unsigned int &, const unsigned short &, const unsigned long &, const long long &, const unsigned long long &, const size_t &, const ptrdiff_t &, const std::size_t &, const std::ptrdiff_t &, enum SWIGTYPE { $1 = scm_is_true(scm_integer_p($input)) && scm_is_true(scm_exact_p($input))? 1 : 0; } %typecheck(SWIG_TYPECHECK_BOOL) bool, bool&, const bool& { $1 = SCM_BOOLP($input) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) float, double, const float &, const double & { $1 = scm_is_true(scm_real_p($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = SCM_CHARP($input) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = scm_is_string($input) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { void *ptr; int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); $1 = SWIG_CheckState(res); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, 0); $1 = SWIG_CheckState(res); } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; int res = SWIG_ConvertPtr($input, &ptr, 0, 0); $1 = SWIG_CheckState(res); } /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* typemaps.i ends here */ swig-3.0.8/Lib/guile/std_vector.i0000664000175000017500000004066412641054563016534 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * * SWIG typemaps for std::vector * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // Guile as much as possible, namely, to allow the user to pass and // be returned Guile vectors or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&), f(const std::vector*): // the parameter being read-only, either a Guile sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(): // the vector is returned by copy; therefore, a Guile vector of T:s // is returned which is most easily used in other Guile functions // -- std::vector& f(), std::vector* f(), const std::vector& f(), // const std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class vector { %typemap(in) vector { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); $1 = std::vector< T >(size); for (unsigned long i=0; i(); } else if (scm_is_pair($input)) { SCM head, tail; $1 = std::vector< T >(); tail = $input; while (!scm_is_null(tail)) { head = SCM_CAR(tail); tail = SCM_CDR(tail); $1.push_back(*((T*)SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); } } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } %typemap(in) const vector& (std::vector temp), const vector* (std::vector temp) { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); temp = std::vector< T >(size); $1 = &temp; for (unsigned long i=0; i(); $1 = &temp; } else if (scm_is_pair($input)) { temp = std::vector< T >(); $1 = &temp; SCM head, tail; tail = $input; while (!scm_is_null(tail)) { head = SCM_CAR(tail); tail = SCM_CDR(tail); temp.push_back(*((T*) SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } %typemap(out) vector { $result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); for (unsigned int i=0; i<$1.size(); i++) { T* x = new T((($1_type &)$1)[i]); scm_vector_set_x($result,scm_from_long(i), SWIG_NewPointerObj(x, $descriptor(T *), 1)); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ if (scm_is_vector($input)) { unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SCM o = scm_vector_ref($input,scm_from_ulong(0)); T* x; if (SWIG_ConvertPtr(o,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ T* x; SCM head = SCM_CAR($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { /* wrapped vector? */ std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ if (scm_is_vector($input)) { unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; SCM o = scm_vector_ref($input,scm_from_ulong(0)); if (SWIG_ConvertPtr(o,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ T* x; SCM head = SCM_CAR($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } else { /* wrapped vector? */ std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) $1 = 1; else $1 = 0; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); %rename(length) size; unsigned int size() const; %rename("empty?") empty; bool empty() const; %rename("clear!") clear; void clear(); %rename("set!") set; %rename("pop!") pop; %rename("push!") push_back; void push_back(const T& x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } const T& ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { %typemap(in) vector { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); $1 = std::vector< T >(size); for (unsigned long i=0; i(); } else if (scm_is_pair($input)) { SCM v = scm_vector($input); unsigned long size = scm_c_vector_length(v); $1 = std::vector< T >(size); for (unsigned long i=0; i& (std::vector temp), const vector* (std::vector temp) { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); temp = std::vector< T >(size); $1 = &temp; for (unsigned long i=0; i(); $1 = &temp; } else if (scm_is_pair($input)) { SCM v = scm_vector($input); unsigned long size = scm_c_vector_length(v); temp = std::vector< T >(size); $1 = &temp; for (unsigned long i=0; i { $result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); for (unsigned int i=0; i<$1.size(); i++) { SCM x = CONVERT_TO((($1_type &)$1)[i]); scm_vector_set_x($result,scm_from_long(i),x); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ if (scm_is_vector($input)) { unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SCM o = scm_vector_ref($input,scm_from_ulong(0)); $1 = CHECK(o) ? 1 : 0; } } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ SCM head = SCM_CAR($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ std::vector< T >* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) ? 1 : 0; } } %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ if (scm_is_vector($input)) { unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ SCM o = scm_vector_ref($input,scm_from_ulong(0)); $1 = CHECK(o) ? 1 : 0; } } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; } else if (scm_is_pair($input)) { /* check the first element only */ SCM head = SCM_CAR($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ std::vector< T >* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) ? 1 : 0; } } public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector&); %rename(length) size; unsigned int size() const; %rename("empty?") empty; bool empty() const; %rename("clear!") clear; void clear(); %rename("set!") set; %rename("pop!") pop; %rename("push!") push_back; void push_back(T x); %extend { T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); T x = self->back(); self->pop_back(); return x; } T ref(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i swig-3.0.8/Lib/guile/swigrun.i0000664000175000017500000000170512641054563016047 0ustar williamwilliam/* -*- mode: c -*- */ %module swigrun #ifdef SWIGGUILE_SCM /* Hook the runtime module initialization into the shared initialization function SWIG_Guile_Init. */ %runtime %{ /* Hook the runtime module initialization into the shared initialization function SWIG_Guile_Init. */ #include #ifdef __cplusplus extern "C" #endif SCM scm_init_Swig_swigrun_module (void); #define SWIG_INIT_RUNTIME_MODULE scm_init_Swig_swigrun_module(); %} /* The runtime type system from common.swg */ typedef struct swig_type_info swig_type_info; const char * SWIG_TypeName(const swig_type_info *type); const char * SWIG_TypePrettyName(const swig_type_info *type); swig_type_info * SWIG_TypeQuery(const char *); /* Language-specific stuff */ %apply bool { int }; int SWIG_IsPointer(SCM object); int SWIG_IsPointerOfType(SCM object, swig_type_info *type); unsigned long SWIG_PointerAddress(SCM object); swig_type_info * SWIG_PointerType(SCM object); #endif swig-3.0.8/Lib/r/0000775000175000017500000000000012641054563013330 5ustar williamwilliamswig-3.0.8/Lib/r/rtype.swg0000664000175000017500000002003612641054563015216 0ustar williamwilliam /* These map the primitive C types to the appropriate R type for use in class representations. */ %typemap("rtype") int, int *, int & "integer"; %typemap("rtype") long, long *, long & "integer"; %typemap("rtype") float, float*, float & "numeric"; %typemap("rtype") double, double*, double & "numeric"; %typemap("rtype") char *, char ** "character"; %typemap("rtype") char "character"; %typemap("rtype") string, string *, string & "character"; %typemap("rtype") std::string, std::string *, std::string & "character"; %typemap("rtype") bool, bool * "logical"; %typemap("rtype") enum SWIGTYPE "character"; %typemap("rtype") enum SWIGTYPE * "character"; %typemap("rtype") enum SWIGTYPE *const "character"; %typemap("rtype") enum SWIGTYPE & "character"; %typemap("rtype") enum SWIGTYPE && "character"; %typemap("rtype") SWIGTYPE * "$R_class"; %typemap("rtype") SWIGTYPE *const "$R_class"; %typemap("rtype") SWIGTYPE & "$R_class"; %typemap("rtype") SWIGTYPE && "$R_class"; %typemap("rtype") SWIGTYPE "$&R_class"; %typemap("rtypecheck") int, int &, long, long & %{ (is.integer($arg) || is.numeric($arg)) && length($arg) == 1 %} %typemap("rtypecheck") int *, long * %{ is.integer($arg) || is.numeric($arg) %} %typemap("rtypecheck") float, double %{ is.numeric($arg) && length($arg) == 1 %} %typemap("rtypecheck") float *, double * %{ is.numeric($arg) %} %typemap("rtypecheck") bool, bool & %{ is.logical($arg) && length($arg) == 1 %} %typemap("rtypecheck") bool * %{ is.logical($arg) %} /* Set up type checks to insure overloading precedence. We would like non pointer items to shadow pointer items, so that they get called if length = 1 */ %typecheck(SWIG_TYPECHECK_BOOL) bool {} %typecheck(SWIG_TYPECHECK_UINT32) unsigned int {} %typecheck(SWIG_TYPECHECK_INTEGER) int {} %typecheck(SWIG_TYPECHECK_FLOAT) float {} %typecheck(SWIG_TYPECHECK_DOUBLE) double {} %typecheck(SWIG_TYPECHECK_BOOL_PTR) bool * {} %typecheck(SWIG_TYPECHECK_INT32_PTR) int * {} %typecheck(SWIG_TYPECHECK_FLOAT_PTR) float * {} %typecheck(SWIG_TYPECHECK_DOUBLE_PTR) double * {} %typecheck(SWIG_TYPECHECK_CHAR_PTR) char * {} %typecheck(SWIG_TYPECHECK_INT32_ARRAY) int[ANY] {} %typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) float[ANY] {} %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) double [ANY] {} /* Have to be careful that as(x, "numeric") is different from as.numeric(x). The latter makes a REALSXP, whereas the former leaves an INTSXP as an INTSXP. */ /* Force coercion of integer, since by default R sets all constants to numeric, which means that you can't directly call a function with an integer using an R numercal literal */ %typemap(scoercein) int, int *, int & %{ $input = as.integer($input); %} %typemap(scoercein) long, long *, long & %{ $input = as.integer($input); %} %typemap(scoercein) float, float*, float &, double, double *, double & %{ %} %typemap(scoercein) char, char *, char & %{ $input = as($input, "character"); %} %typemap(scoercein) string, string *, string & %{ $input = as($input, "character"); %} %typemap(scoercein) std::string, std::string *, std::string & %{ $input = as($input, "character"); %} %typemap(scoercein) enum SWIGTYPE %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE & %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE && %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE * %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE *const %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE && %{ if (inherits($input, "ExternalReference")) $input = slot($input,"ref") %} /* %typemap(scoercein) SWIGTYPE *, SWIGTYPE *const %{ $input = coerceIfNotSubclass($input, "$R_class") %} %typemap(scoercein) SWIGTYPE & %{ $input = coerceIfNotSubclass($input, "$R_class") %} %typemap(scoercein) SWIGTYPE && %{ $input = coerceIfNotSubclass($input, "$R_class") %} %typemap(scoercein) SWIGTYPE %{ $input = coerceIfNotSubclass($input, "$&R_class") %} */ %typemap(scoercein) SWIGTYPE[ANY] %{ if(is.list($input)) assert(all(sapply($input, class) == "$R_class")); %} /* **************************************************************** */ %typemap(scoercein) bool, bool *, bool & "$input = as.logical($input);"; %typemap(scoercein) int, int *, int &, long, long *, long & "$input = as.integer($input);"; %typemap(scoercein) char *, string, std::string, string &, std::string & %{ $input = as($input, "character"); %} %typemap(scoerceout) enum SWIGTYPE %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE & %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE && %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE * %{ $result = enumToInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE *const %{ $result = enumToInteger($result, "$R_class"); %} %typemap(scoerceout) SEXP %{ %} %typemap(scoerceout) SWIGTYPE %{ $result <- new("$&R_class", ref=$result); %} %typemap(scoerceout) SWIGTYPE & %{ $result <- new("$R_class", ref=$result) ; %} %typemap(scoerceout) SWIGTYPE && %{ $result <- new("$R_class", ref=$result) ; %} %typemap(scoerceout) SWIGTYPE * %{ $result <- new("$R_class", ref=$result) ; %} %typemap(scoerceout) SWIGTYPE *const %{ $result <- new("$R_class", ref=$result) ; %} /* Override the SWIGTYPE * above. */ %typemap(scoerceout) char, char *, char &, float, double, float*, double*, float &, double &, int, int &, long, long &, bool, bool &, string, std::string, string &, std::string &, void, signed int, signed int &, unsigned int, unsigned int &, short, short &, unsigned short, unsigned short &, long long, signed long long, signed long long &, unsigned long long, unsigned long long &, signed long, signed long &, unsigned long, unsigned long &, signed char, signed char &, unsigned char, unsigned char & %{ %} %apply int {size_t, std::size_t, ptrdiff_t, std::ptrdiff_t, signed int, unsigned int, short, unsigned short, signed char, unsigned char} %apply int* {size_t[], std::size_t[], ptrdiff_t[], std::ptrdiff_t[], signed int[], unsigned int[], short[], unsigned short[], signed char[], unsigned char[]} %apply int* {size_t[ANY], std::size_t[ANY], ptrdiff_t[ANY], std::ptrdiff_t[ANY], signed int[ANY], unsigned int[ANY], short[ANY], unsigned short[ANY], signed char[ANY], unsigned char[ANY]} %apply int* {size_t*, std::size_t*, ptrdiff_t*, std::ptrdiff_t*, signed int*, unsigned int*, short*, unsigned short*, signed char*, unsigned char*} %apply long { long long, signed long long, unsigned long long, signed long, unsigned long} %apply long* { long long*, signed long long*, unsigned long long*, signed long*, unsigned long*, long long[], signed long long[], unsigned long long[], signed long[], unsigned long[], long long[ANY], signed long long[ANY], unsigned long long[ANY], signed long[ANY], unsigned long[ANY]} %apply float* { float[], float[ANY] } %apply double * { double[], double[ANY] } %apply bool* { bool[], bool[ANY] } #if 0 Just examining the values for a SWIGTYPE. %typemap(scoerceout) SWIGTYPE %{ name = $1_name type = $1_type ltype = $1_ltype mangle = $1_mangle descriptor = $1_descriptor pointer type = $*1_type pointer ltype = $*1_ltype pointer descriptor = $*1_descriptor basetype = $*_basetype %} #endif swig-3.0.8/Lib/r/std_pair.i0000664000175000017500000000010412641054563015302 0ustar williamwilliam%fragment("StdPairTraits","header") %{ %} %include swig-3.0.8/Lib/r/std_container.i0000664000175000017500000000007112641054563016334 0ustar williamwilliam%include %include swig-3.0.8/Lib/r/std_except.i0000664000175000017500000000004312641054563015641 0ustar williamwilliam%include swig-3.0.8/Lib/r/cdata.i0000664000175000017500000000003612641054563014555 0ustar williamwilliam%include swig-3.0.8/Lib/r/exception.i0000664000175000017500000000034112641054563015476 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(switch (code) {case SWIG_IndexError: return Rf_ScalarLogical(NA_LOGICAL); default: %error(code, msg); SWIG_fail;} )) } swig-3.0.8/Lib/r/std_alloc.i0000664000175000017500000000003212641054563015441 0ustar williamwilliam%include swig-3.0.8/Lib/r/std_deque.i0000664000175000017500000000003112641054563015451 0ustar williamwilliam%includeswig-3.0.8/Lib/r/std_common.i0000664000175000017500000000433612641054563015652 0ustar williamwilliam%include /* Generate the traits for a 'primitive' type, such as 'double', for which the SWIG_AsVal and SWIG_From methods are already defined. */ %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval< Type > { typedef Type value_type; static int asval(SEXP obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from< Type > { typedef Type value_type; static SEXP from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval< Type > { typedef Type value_type; static int asval(SEXP obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from< Type > { typedef Type value_type; static SEXP from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.8/Lib/r/r.swg0000664000175000017500000001407712641054563014324 0ustar williamwilliam/* */ %insert("header") "swiglabels.swg" %insert("header") "swigerrors.swg" %insert("init") "swiginit.swg" %insert("runtime") "swigrun.swg" %insert("runtime") "rrun.swg" %init %{ SWIGEXPORT void SWIG_init(void) { %} %include #define %Rruntime %insert("s") #define SWIG_Object SEXP #define VOID_Object R_NilValue #define %append_output(obj) SET_VECTOR_ELT($result, $n, obj) %define %set_constant(name, obj) %begin_block SEXP _obj = obj; assign(name, _obj); %end_block %enddef %define %raise(obj,type,desc) return R_NilValue; %enddef %insert("sinit") "srun.swg" %insert("sinitroutine") %{ SWIG_init(); SWIG_InitializeModule(0); %} %include %typemap(in) (double *x, int len) %{ $1 = REAL(x); $2 = Rf_length(x); %} /* XXX Need to worry about inheritance, e.g. if B extends A and we are looking for an A[], then B elements are okay. */ %typemap(scheck) SWIGTYPE[ANY] %{ # assert(length($input) > $1_dim0) assert(all(sapply($input, class) == "$R_class")); %} %typemap(out) void ""; %typemap(in) int *, int[ANY], signed int *, signed int[ANY], unsigned int *, unsigned int[ANY], short *, short[ANY], signed short *, signed short[ANY], unsigned short *, unsigned short[ANY], long *, long[ANY], signed long *, signed long[ANY], unsigned long *, unsigned long[ANY], long long *, long long[ANY], signed long long *, signed long long[ANY], unsigned long long *, unsigned long long[ANY] { { int _rswigi; int _rswiglen = LENGTH($input); $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype); for (_rswigi=0; _rswigi< _rswiglen; _rswigi++) { $1[_rswigi] = INTEGER($input)[_rswigi]; } } } %typemap(in) float *, float[ANY], double *, double[ANY] { { int _rswigi; int _rswiglen = LENGTH($input); $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype); for (_rswigi=0; _rswigi<_rswiglen; _rswigi++) { $1[_rswigi] = REAL($input)[_rswigi]; } } } %typemap(freearg,noblock=1) int *, int[ANY], signed int *, signed int[ANY], unsigned int *, unsigned int[ANY], short *, short[ANY], signed short *, signed short[ANY], unsigned short *, unsigned short[ANY], long *, long[ANY], signed long *, signed long[ANY], unsigned long *, unsigned long[ANY], long long *, long long[ANY], signed long long *, signed long long[ANY], unsigned long long *, unsigned long long[ANY], float *, float[ANY], double *, double[ANY] %{ free($1); %} %typemap(freearg, noblock=1) int *OUTPUT, signed int *OUTPUT, unsigned int *OUTPUT, short *OUTPUT, signed short *OUTPUT, unsigned short *OUTPUT, long *OUTPUT, signed long *OUTPUT, unsigned long *OUTPUT, long long *OUTPUT, signed long long *OUTPUT, unsigned long long *OUTPUT, float *OUTPUT, double *OUTPUT, char *OUTPUT, signed char *OUTPUT, unsigned char *OUTPUT {} /* Should we recycle to make the length correct. And warn if length() > the dimension. */ %typemap(scheck) SWIGTYPE [ANY] %{ # assert(length($input) >= $1_dim0) %} /* Handling vector case to avoid warnings, although we just use the first one. */ %typemap(scheck) unsigned int %{ assert(length($input) == 1 && $input >= 0, "All values must be non-negative"); %} %typemap(scheck) int, long %{ if(length($input) > 1) { warning("using only the first element of $input"); }; %} %include %include %include %include %include %typemap(in,noblock=1) enum SWIGTYPE[ANY] { $1 = %reinterpret_cast(INTEGER($input), $1_ltype); } %typemap(in,noblock=1,fragment="SWIG_strdup") char * { $1 = %reinterpret_cast(SWIG_strdup(CHAR(STRING_ELT($input, 0))), $1_ltype); } %typemap(freearg,noblock=1) char * { free($1); } %typemap(in,noblock=1,fragment="SWIG_strdup") char *[ANY] { $1 = %reinterpret_cast(SWIG_strdup(CHAR(STRING_ELT($input, 0))), $1_ltype); } %typemap(freearg,noblock=1) char *[ANY] { free($1); } %typemap(in,noblock=1,fragment="SWIG_strdup") char[ANY] { $1 = SWIG_strdup(CHAR(STRING_ELT($input, 0))); } %typemap(freearg,noblock=1) char[ANY] { free($1); } %typemap(in,noblock=1,fragment="SWIG_strdup") char[] { $1 = SWIG_strdup(CHAR(STRING_ELT($input, 0))); } %typemap(freearg,noblock=1) char[] { free($1); } %typemap(memberin) char[] %{ if ($input) strcpy($1, $input); else strcpy($1, ""); %} %typemap(globalin) char[] %{ if ($input) strcpy($1, $input); else strcpy($1, ""); %} %typemap(out,noblock=1) char * { $result = $1 ? Rf_mkString(%reinterpret_cast($1,char *)) : R_NilValue; } %typemap(in,noblock=1) char { $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype); } %typemap(out) char { char tmp[2] = "x"; tmp[0] = $1; $result = Rf_mkString(tmp); } %typemap(in,noblock=1) int, long { $1 = %static_cast(INTEGER($input)[0], $1_ltype); } %typemap(out,noblock=1) int, long "$result = Rf_ScalarInteger($1);"; %typemap(in,noblock=1) bool "$1 = LOGICAL($input)[0] ? true : false;"; %typemap(out,noblock=1) bool "$result = Rf_ScalarLogical($1);"; %typemap(in,noblock=1) float, double { $1 = %static_cast(REAL($input)[0], $1_ltype); } /* Why is this here ? */ /* %typemap(out,noblock=1) unsigned int * "$result = ScalarReal(*($1));"; */ %Rruntime %{ setMethod('[', "ExternalReference", function(x,i,j, ..., drop=TRUE) if (!is.null(x$"__getitem__")) sapply(i, function(n) x$"__getitem__"(i=as.integer(n-1)))) setMethod('[<-' , "ExternalReference", function(x,i,j, ..., value) if (!is.null(x$"__setitem__")) { sapply(1:length(i), function(n) x$"__setitem__"(i=as.integer(i[n]-1), x=value[n])) x }) setAs('ExternalReference', 'character', function(from) {if (!is.null(from$"__str__")) from$"__str__"()}) suppressWarnings(setMethod('print', 'ExternalReference', function(x) {print(as(x, "character"))})) %} swig-3.0.8/Lib/r/std_list.i0000664000175000017500000000024712641054563015332 0ustar williamwilliam#define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/r/rstdcommon.swg0000664000175000017500000001220712641054563016241 0ustar williamwilliam%fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { /* Traits that provides the from method */ template struct traits_from_ptr { static SWIG_Object from(Type *val, int owner = 0) { return SWIG_NewPointerObj(val, type_info(), owner); } }; template struct traits_from { static SWIG_Object from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static SWIG_Object from(Type* val) { return traits_from_ptr::from(val, 0); } }; template inline SWIG_Object from(const Type& val) { return traits_from::from(val); } template inline SWIG_Object from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } /* Traits that provides the asval/as/check method */ template struct traits_asptr { static int asptr(SWIG_Object obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(SWIG_Object obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(SWIG_Object obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(SWIG_Object obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(SWIG_Object obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(SWIG_Object obj, bool throw_error) { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { if (throw_error) throw std::invalid_argument("bad type"); } return v; } }; template struct traits_as { static Type as(SWIG_Object obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); if (throw_error) throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(SWIG_Object obj, bool throw_error) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res)) { return v; } else { if (throw_error) throw std::invalid_argument("bad type"); return 0; } } }; template inline Type as(SWIG_Object obj, bool te = false) { return traits_as::category>::as(obj, te); } template struct traits_check { static bool check(SWIG_Object obj) { int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(SWIG_Object obj) { int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; return SWIG_IsOK(res) ? true : false; } }; template inline bool check(SWIG_Object obj) { return traits_check::category>::check(obj); } } } %define %specialize_std_container(Type,Check,As,From) %{ namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(SWIG_Object obj, value_type *val) { if (Check(obj)) { if (val) *val = As(obj); return SWIG_OK; } return SWIG_ERROR; } }; template <> struct traits_from { typedef Type value_type; static SWIG_Object from(const value_type& val) { return From(val); } }; template <> struct traits_check { static int check(SWIG_Object obj) { int res = Check(obj); return obj && res ? res : 0; } }; } %} %enddef swig-3.0.8/Lib/r/std_map.i0000664000175000017500000000010312641054563015123 0ustar williamwilliam%fragment("StdMapTraits","header") %{ %} %include swig-3.0.8/Lib/r/ropers.swg0000664000175000017500000000422412641054563015366 0ustar williamwilliam#ifdef __cplusplus // These are auto-supported by the Perl-module %rename(__plusplus__) *::operator++; %rename(__minmin__) *::operator--; %rename(__add__) *::operator+; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-(); %rename(__neg__) *::operator-() const; %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__mod__) *::operator%; %rename(__gt__) *::operator>; %rename(__lt__) *::operator<; %rename(__not__) *::operator!; // These are renamed, but no 'use overload...' is added %rename(__lshift__) *::operator<<; %rename(__rshift__) *::operator>>; %rename(__and__) *::operator&; %rename(__or__) *::operator|; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; %rename(__le__) *::operator<=; %rename(__ge__) *::operator>=; %rename(__call__) *::operator(); %rename(__getitem__) *::operator[]; %rename(__seteq__) *::operator=; %rename(__land__) operator&&; %rename(__lor__) operator||; %rename(__plusplus__) *::operator++; %rename(__minusminus__) *::operator--; %rename(__arrowstar__) *::operator->*; %rename(__index__) *::operator[]; %rename(Equal) operator =; %rename(PlusEqual) operator +=; %rename(MinusEqual) operator -=; %rename(MultiplyEqual) operator *=; %rename(DivideEqual) operator /=; %rename(PercentEqual) operator %=; %rename(Plus) operator +; %rename(Minus) operator -; %rename(Multiply) operator *; %rename(Divide) operator /; %rename(Percent) operator %; %rename(Not) operator !; %rename(IndexIntoConst) operator[](unsigned idx) const; %rename(IndexInto) operator[](unsigned idx); %rename(Functor) operator (); %rename(EqualEqual) operator ==; %rename(NotEqual) operator !=; %rename(LessThan) operator <; %rename(LessThanEqual) operator <=; %rename(GreaterThan) operator >; %rename(GreaterThanEqual) operator >=; %rename(And) operator &&; %rename(Or) operator ||; %rename(PlusPlusPrefix) operator++(); %rename(PlusPlusPostfix) operator++(int); %rename(MinusMinusPrefix) operator--(); %rename(MinusMinusPostfix) operator--(int); #endif swig-3.0.8/Lib/r/srun.swg0000664000175000017500000000747512641054563015056 0ustar williamwilliam# srun.swg # # # This is the basic code that is needed at run time within R to # provide and define the relevant classes. It is included # automatically in the generated code by copying the contents of # srun.swg into the newly created binding code. # This could be provided as a separate run-time library but this # approach allows the code to to be included directly into the # generated bindings and so removes the need to have and install an # additional library. We may however end up with multiple copies of # this and some confusion at run-time as to which class to use. This # is an issue when we use NAMESPACES as we may need to export certain # classes. ###################################################################### if(length(getClassDef("RSWIGStruct")) == 0) setClass("RSWIGStruct", representation("VIRTUAL")) if(length(getClassDef("ExternalReference")) == 0) # Should be virtual but this means it loses its slots currently #representation("VIRTUAL") setClass("ExternalReference", representation( ref = "externalptr")) if(length(getClassDef("NativeRoutinePointer")) == 0) setClass("NativeRoutinePointer", representation(parameterTypes = "character", returnType = "character", "VIRTUAL"), contains = "ExternalReference") if(length(getClassDef("CRoutinePointer")) == 0) setClass("CRoutinePointer", contains = "NativeRoutinePointer") if(length(getClassDef("EnumerationValue")) == 0) setClass("EnumerationValue", contains = "integer") if(!isGeneric("copyToR")) setGeneric("copyToR", function(value, obj = new(gsub("Ref$", "", class(value)))) standardGeneric("copyToR" )) setGeneric("delete", function(obj) standardGeneric("delete")) SWIG_createNewRef = function(className, ..., append = TRUE) { f = get(paste("new", className, sep = "_"), mode = "function") f(...) } if(!isGeneric("copyToC")) setGeneric("copyToC", function(value, obj = SWIG_createNewRef(class(value))) standardGeneric("copyToC" )) # defineEnumeration = function(name, .values, where = topenv(parent.frame()), suffix = "Value") { # Mirror the class definitions via the E analogous to .__C__ defName = paste(".__E__", name, sep = "") assign(defName, .values, envir = where) if(nchar(suffix)) name = paste(name, suffix, sep = "") setClass(name, contains = "EnumerationValue", where = where) } enumToInteger <- function(name,type) { if (is.character(name)) { ans <- as.integer(get(paste(".__E__", type, sep = ""))[name]) if (is.na(ans)) {warning("enum not found ", name, " ", type)} ans } } enumFromInteger = function(i,type) { itemlist <- get(paste(".__E__", type, sep="")) names(itemlist)[match(i, itemlist)] } coerceIfNotSubclass = function(obj, type) { if(!is(obj, type)) {as(obj, type)} else obj } setClass("SWIGArray", representation(dims = "integer"), contains = "ExternalReference") setMethod("length", "SWIGArray", function(x) x@dims[1]) defineEnumeration("SCopyReferences", .values = c( "FALSE" = 0, "TRUE" = 1, "DEEP" = 2)) assert = function(condition, message = "") { if(!condition) stop(message) TRUE } if(FALSE) { print.SWIGFunction = function(x, ...) { } } ####################################################################### R_SWIG_getCallbackFunctionStack = function() { # No PACKAGE argument as we don't know what the DLL is. .Call("R_SWIG_debug_getCallbackFunctionData") } R_SWIG_addCallbackFunctionStack = function(fun, userData = NULL) { # No PACKAGE argument as we don't know what the DLL is. .Call("R_SWIG_R_pushCallbackFunctionData", fun, userData) } ####################################################################### swig-3.0.8/Lib/r/rkw.swg0000664000175000017500000000125212641054563014655 0ustar williamwilliam/* Warnings for R keywords, built-in names and bad names. */ #define RKW(x) %keywordwarn("'" `x` "' is a R keyword, renaming to '_" `x`"'", rename="_%s") `x` #define RSWIGKW(x) %keywordwarn("'" `x` "' is a SWIG R reserved parameter name, renaming to '_" `x`"'", rename="_%s") `x` /* Warnings for R reserved words taken from http://cran.r-project.org/doc/manuals/R-lang.html#Reserved-words */ RKW(if); RKW(else); RKW(repeat); RKW(while); RKW(function); RKW(for); RKW(in); RKW(next); RKW(break); RKW(TRUE); RKW(FALSE); RKW(NULL); RKW(Inf); RKW(NaN); RKW(NA); RKW(NA_integer_); RKW(NA_real_); RKW(NA_complex_); RKW(NA_character_); RSWIGKW(self); #undef RKW #undef RSWIGKW swig-3.0.8/Lib/r/rcontainer.swg0000664000175000017500000001260012641054563016215 0ustar williamwilliam // // Common fragments // /**** The python container methods ****/ %fragment("StdSequenceTraits","header",fragment="") { %#include namespace swig { inline size_t check_index(ptrdiff_t i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); } else if ( (size_t) i < size ) { return (size_t) i; } else if (insert && ((size_t) i == size)) { return size; } throw std::out_of_range("index out of range"); } inline size_t slice_index(ptrdiff_t i, size_t size) { if ( i < 0 ) { if ((size_t) (-i) <= size) { return (size_t) (i + size); } else { throw std::out_of_range("index out of range"); } } else { return ( (size_t) i < size ) ? ((size_t) i) : size; } } template inline typename Sequence::iterator getpos(Sequence* self, Difference i) { typename Sequence::iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline typename Sequence::const_iterator cgetpos(const Sequence* self, Difference i) { typename Sequence::const_iterator pos = self->begin(); std::advance(pos, check_index(i,self->size())); return pos; } template inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::const_iterator vb = self->begin(); typename Sequence::const_iterator ve = self->begin(); std::advance(vb,ii); std::advance(ve,jj); return new Sequence(vb, ve); } else { return new Sequence(); } } template inline void setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj < ii) jj = ii; size_t ssize = jj - ii; if (ssize <= v.size()) { typename Sequence::iterator sb = self->begin(); typename InputSeq::const_iterator vmid = v.begin(); std::advance(sb,ii); std::advance(vmid, jj - ii); self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); } else { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); self->insert(sb, v.begin(), v.end()); } } template inline void delslice(Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { typename Sequence::iterator sb = self->begin(); typename Sequence::iterator se = self->begin(); std::advance(sb,ii); std::advance(se,jj); self->erase(sb,se); } } } } %define %swig_container_methods(Container...) %newobject __getslice__; %extend { bool __nonzero__() const { return !(self->empty()); } size_type __len__() const { return self->size(); } } %enddef %define %swig_sequence_methods_common(Sequence...) // %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) %fragment("StdSequenceTraits"); %extend { value_type pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty container"); Sequence::value_type x = self->back(); self->pop_back(); return x; } Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) { return swig::getslice(self, i, j); } void __setslice__(difference_type i, difference_type j, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { swig::setslice(self, i, j, v); } void __delslice__(difference_type i, difference_type j) throw (std::out_of_range) { swig::delslice(self, i, j); } void __delitem__(difference_type i) throw (std::out_of_range) { self->erase(swig::getpos(self,i)); } } %enddef %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } void append(const value_type& x) { self->push_back(x); } } %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { value_type __getitem__(difference_type i) throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } void __setitem__(difference_type i, value_type x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } void append(value_type x) { self->push_back(x); } } %enddef swig-3.0.8/Lib/r/rrun.swg0000664000175000017500000002164712641054563015052 0ustar williamwilliam #ifdef __cplusplus #include extern "C" { #endif /* for raw pointer */ #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags) /* Remove global namespace pollution */ #if !defined(SWIG_NO_R_NO_REMAP) # define R_NO_REMAP #endif #if !defined(SWIG_NO_STRICT_R_HEADERS) # define STRICT_R_HEADERS #endif #include #include #include #include #if R_VERSION >= R_Version(2,6,0) #define VMAXTYPE void * #else #define VMAXTYPE char * #endif /* This is mainly a way to avoid having lots of local variables that may conflict with those in the routine. Change name to R_SWIG_Callb.... */ typedef struct RCallbackFunctionData { SEXP fun; SEXP userData; SEXP expr; SEXP retValue; int errorOccurred; SEXP el; /* Temporary pointer used in the construction of the expression to call the R function. */ struct RCallbackFunctionData *previous; /* Stack */ } RCallbackFunctionData; static RCallbackFunctionData *callbackFunctionDataStack; SWIGRUNTIME SEXP R_SWIG_debug_getCallbackFunctionData() { int n, i; SEXP ans; RCallbackFunctionData *p = callbackFunctionDataStack; n = 0; while(p) { n++; p = p->previous; } Rf_protect(ans = Rf_allocVector(VECSXP, n)); for(p = callbackFunctionDataStack, i = 0; i < n; p = p->previous, i++) SET_VECTOR_ELT(ans, i, p->fun); Rf_unprotect(1); return(ans); } SWIGRUNTIME RCallbackFunctionData * R_SWIG_pushCallbackFunctionData(SEXP fun, SEXP userData) { RCallbackFunctionData *el; el = (RCallbackFunctionData *) calloc(1, sizeof(RCallbackFunctionData)); el->fun = fun; el->userData = userData; el->previous = callbackFunctionDataStack; callbackFunctionDataStack = el; return(el); } SWIGRUNTIME SEXP R_SWIG_R_pushCallbackFunctionData(SEXP fun, SEXP userData) { R_SWIG_pushCallbackFunctionData(fun, userData); return R_NilValue; } SWIGRUNTIME RCallbackFunctionData * R_SWIG_getCallbackFunctionData() { if(!callbackFunctionDataStack) { Rf_error("Supposedly impossible error occurred in the SWIG callback mechanism." " No callback function data set."); } return callbackFunctionDataStack; } SWIGRUNTIME void R_SWIG_popCallbackFunctionData(int doFree) { RCallbackFunctionData *el = NULL; if(!callbackFunctionDataStack) return ; /* Error !!! */ el = callbackFunctionDataStack ; callbackFunctionDataStack = callbackFunctionDataStack->previous; if(doFree) free(el); } /* Interface to S function is(obj, type) which is to be used to determine if an external pointer inherits from the right class. Ideally, we would like to be able to do this without an explicit call to the is() function. When the S4 class system uses its own SEXP types, then we will hopefully be able to do this in the C code. Should we make the expression static and preserve it to avoid the overhead of allocating each time. */ SWIGRUNTIME int R_SWIG_checkInherits(SEXP obj, SEXP tag, const char *type) { SEXP e, val; int check_err = 0; Rf_protect(e = Rf_allocVector(LANGSXP, 3)); SETCAR(e, Rf_install("extends")); SETCAR(CDR(e), Rf_mkString(CHAR(PRINTNAME(tag)))); SETCAR(CDR(CDR(e)), Rf_mkString(type)); val = R_tryEval(e, R_GlobalEnv, &check_err); Rf_unprotect(1); if(check_err) return(0); return(LOGICAL(val)[0]); } SWIGRUNTIME void * R_SWIG_resolveExternalRef(SEXP arg, const char * const type, const char * const argName, Rboolean nullOk) { void *ptr; SEXP orig = arg; if(TYPEOF(arg) != EXTPTRSXP) arg = GET_SLOT(arg, Rf_mkString("ref")); if(TYPEOF(arg) != EXTPTRSXP) { Rf_error("argument %s must be an external pointer (from an ExternalReference)", argName); } ptr = R_ExternalPtrAddr(arg); if(ptr == NULL && nullOk == (Rboolean) FALSE) { Rf_error("the external pointer (of type %s) for argument %s has value NULL", argName, type); } if(type[0] && R_ExternalPtrTag(arg) != Rf_install(type) && strcmp(type, "voidRef") && !R_SWIG_checkInherits(orig, R_ExternalPtrTag(arg), type)) { Rf_error("the external pointer for argument %s has tag %s, not the expected value %s", argName, CHAR(PRINTNAME(R_ExternalPtrTag(arg))), type); } return(ptr); } SWIGRUNTIME void R_SWIG_ReferenceFinalizer(SEXP el) { void *ptr = R_SWIG_resolveExternalRef(el, "", "", (Rboolean) 1); fprintf(stderr, "In R_SWIG_ReferenceFinalizer for %p\n", ptr); Rf_PrintValue(el); if(ptr) { if(TYPEOF(el) != EXTPTRSXP) el = GET_SLOT(el, Rf_mkString("ref")); if(TYPEOF(el) == EXTPTRSXP) R_ClearExternalPtr(el); free(ptr); } return; } typedef enum {R_SWIG_EXTERNAL, R_SWIG_OWNER } R_SWIG_Owner; SWIGRUNTIME SEXP SWIG_MakePtr(void *ptr, const char *typeName, R_SWIG_Owner owner) { SEXP external, r_obj; const char *p = typeName; if(typeName[0] == '_') p = typeName + 1; Rf_protect(external = R_MakeExternalPtr(ptr, Rf_install(typeName), R_NilValue)); Rf_protect(r_obj = NEW_OBJECT(MAKE_CLASS((char *) typeName))); if(owner) R_RegisterCFinalizer(external, R_SWIG_ReferenceFinalizer); r_obj = SET_SLOT(r_obj, Rf_mkString((char *) "ref"), external); SET_S4_OBJECT(r_obj); Rf_unprotect(2); return(r_obj); } SWIGRUNTIME SEXP R_SWIG_create_SWIG_R_Array(const char *typeName, SEXP ref, int len) { SEXP arr; /*XXX remove the char * cast when we can. MAKE_CLASS should be declared appropriately. */ Rf_protect(arr = NEW_OBJECT(MAKE_CLASS((char *) typeName))); Rf_protect(arr = R_do_slot_assign(arr, Rf_mkString("ref"), ref)); Rf_protect(arr = R_do_slot_assign(arr, Rf_mkString("dims"), Rf_ScalarInteger(len))); Rf_unprotect(3); SET_S4_OBJECT(arr); return arr; } #define ADD_OUTPUT_ARG(result, pos, value, name) r_ans = AddOutputArgToReturn(pos, value, name, OutputValues); SWIGRUNTIME SEXP AddOutputArgToReturn(int pos, SEXP value, const char *name, SEXP output) { SET_VECTOR_ELT(output, pos, value); return(output); } /* Create a new pointer object */ SWIGRUNTIMEINLINE SEXP SWIG_R_NewPointerObj(void *ptr, swig_type_info *type, int flags) { SEXP rptr = R_MakeExternalPtr(ptr, R_MakeExternalPtr(type, R_NilValue, R_NilValue), R_NilValue); SET_S4_OBJECT(rptr); return rptr; } /* Convert a pointer value */ SWIGRUNTIMEINLINE int SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) { void *vptr; if (!obj) return SWIG_ERROR; if (obj == R_NilValue) { if (ptr) *ptr = NULL; return SWIG_OK; } vptr = R_ExternalPtrAddr(obj); if (ty) { swig_type_info *to = (swig_type_info*) R_ExternalPtrAddr(R_ExternalPtrTag(obj)); if (to == ty) { if (ptr) *ptr = vptr; } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); int newmemory = 0; if (ptr) *ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } } else { if (ptr) *ptr = vptr; } return SWIG_OK; } SWIGRUNTIME swig_module_info * SWIG_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; return (swig_module_info *) type_pointer; } SWIGRUNTIME void SWIG_SetModule(void *v, swig_module_info *swig_module) { } typedef struct { void *pack; swig_type_info *ty; size_t size; } RSwigPacked; /* Create a new packed object */ SWIGRUNTIMEINLINE SEXP RSwigPacked_New(void *ptr, size_t sz, swig_type_info *ty) { SEXP rptr; RSwigPacked *sobj = (RSwigPacked*) malloc(sizeof(RSwigPacked)); if (sobj) { void *pack = malloc(sz); if (pack) { memcpy(pack, ptr, sz); sobj->pack = pack; sobj->ty = ty; sobj->size = sz; } else { sobj = 0; } } rptr = R_MakeExternalPtr(sobj, R_NilValue, R_NilValue); return rptr; } SWIGRUNTIME swig_type_info * RSwigPacked_UnpackData(SEXP obj, void *ptr, size_t size) { RSwigPacked *sobj = (RSwigPacked *)R_ExternalPtrAddr(obj); if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; } SWIGRUNTIMEINLINE SEXP SWIG_R_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? RSwigPacked_New((void *) ptr, sz, type) : R_NilValue; } /* Convert a packed value value */ SWIGRUNTIME int SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = RSwigPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } #ifdef __cplusplus #define SWIG_exception_noreturn(code, msg) do { throw std::runtime_error(msg); } while(0) #else #define SWIG_exception_noreturn(code, msg) do { return result; } while(0) #endif #ifdef __cplusplus } #endif swig-3.0.8/Lib/r/std_string.i0000664000175000017500000000004312641054563015657 0ustar williamwilliam%include swig-3.0.8/Lib/r/stl.i0000664000175000017500000000023512641054563014304 0ustar williamwilliam/* initial STL definition. extended as needed in each language */ %include std_common.i %include std_vector.i %include std_pair.i %include std_string.i swig-3.0.8/Lib/r/boost_shared_ptr.i0000664000175000017500000003647612641054563017063 0ustar williamwilliam%include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(out) CONST TYPE { %set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(varout) CONST TYPE { %set_varoutput(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE * { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE & { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; if (!argp) { %variable_nullref("$type", "$name"); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = *%const_cast(tempshared.get(), $1_ltype); } else { $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer by reference // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); temp = %const_cast(tempshared.get(), $*1_ltype); } else { temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); } $1 = &temp; } %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} %typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { int newmem = 0; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varout typemap not implemented" %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); if ($owner) delete $1; } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varout typemap not implemented" %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); temp = &tempshared; $1 = &temp; } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varout typemap not implemented" %} // Typecheck typemaps // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); $1 = SWIG_CheckState(res); } // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/r/typemaps.i0000664000175000017500000000004112641054563015337 0ustar williamwilliam%include swig-3.0.8/Lib/r/std_vector.i0000664000175000017500000005333412641054563015666 0ustar williamwilliam// R specific swig components /* Vectors */ %fragment("StdVectorTraits","header",fragment="StdSequenceTraits") %{ namespace swig { // vectors of doubles template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(REALSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { NUMERIC_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); } }; // vectors of floats template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(REALSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { NUMERIC_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); } }; // vectors of unsigned int template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(INTSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { INTEGER_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); } }; // vectors of int template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(INTSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { INTEGER_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); } }; // vectors of bool template <> struct traits_from_ptr > { static SEXP from (std::vector *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(LGLSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { LOGICAL_POINTER(result)[pos] = ((*val)[pos]); } UNPROTECT(1); return(result); //return SWIG_R_NewPointerObj(val, type_info< std::vector >(), owner); } }; // vectors of strings template <> struct traits_from_ptr > > { static SEXP from (std::vector > *val, int owner = 0) { SEXP result; PROTECT(result = Rf_allocVector(STRSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { CHARACTER_POINTER(result)[pos] = Rf_mkChar(((*val)[pos]).c_str()); } UNPROTECT(1); return(result); //return SWIG_R_NewPointerObj(val, type_info< std::vector >(), owner); } }; // catch all that does everything with vectors template struct traits_from_ptr< std::vector< T > > { static SEXP from (std::vector< T > *val, int owner = 0) { return SWIG_R_NewPointerObj(val, type_info< std::vector< T > >(), owner); } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; // not sure how to check the size of the SEXP obj is correct unsigned int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); double *S = NUMERIC_POINTER(obj); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; // not sure how to check the size of the SEXP obj is correct unsigned int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); double *S = NUMERIC_POINTER(obj); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; unsigned int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); SEXP coerced; PROTECT(coerced = Rf_coerceVector(obj, INTSXP)); int *S = INTEGER_POINTER(coerced); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } UNPROTECT(1); return res; } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; // not sure how to check the size of the SEXP obj is correct int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); SEXP coerced; PROTECT(coerced = Rf_coerceVector(obj, INTSXP)); int *S = INTEGER_POINTER(coerced); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } UNPROTECT(1); return res; } }; template <> struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; // not sure how to check the size of the SEXP obj is correct int sexpsz = Rf_length(obj); p = new std::vector(sexpsz); SEXP coerced; PROTECT(coerced = Rf_coerceVector(obj, LGLSXP)); int *S = LOGICAL_POINTER(coerced); for (unsigned pos = 0; pos < p->size(); pos++) { (*p)[pos] = static_cast(S[pos]); } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } UNPROTECT(1); return res; } }; // catchall for R to vector conversion template struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; Rprintf("my asptr\n"); int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector >(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; // now for vectors of vectors. These will be represented as lists of vectors on the // catch all that does everything with vectors template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(INTSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { INTEGER_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast(val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(INTSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { INTEGER_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast(val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(REALSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { NUMERIC_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast(val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(REALSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { NUMERIC_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast(val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template <> struct traits_from_ptr > > { static SEXP from (std::vector< std::vector > *val, int owner = 0) { SEXP result; // allocate the R list PROTECT(result = Rf_allocVector(VECSXP, val->size())); for (unsigned pos = 0; pos < val->size(); pos++) { // allocate the R vector SET_VECTOR_ELT(result, pos, Rf_allocVector(LGLSXP, val->at(pos).size())); // Fill the R vector for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos) { LOGICAL_POINTER(VECTOR_ELT(result, pos))[vpos] = (val->at(pos).at(vpos)); } } UNPROTECT(1); return(result); } }; template struct traits_from_ptr< std::vector < std::vector< T > > > { static SEXP from (std::vector < std::vector< T > > *val, int owner = 0) { return SWIG_R_NewPointerObj(val, type_info< std::vector < std::vector< T > > >(), owner); } }; // R side template <> struct traits_asptr < std::vector< std::vector > > { static int asptr(SEXP obj, std::vector< std::vector > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(INTEGER_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector< std::vector< int> > > { static int asptr(SEXP obj, std::vector< std::vector< int> > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector< int> > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(INTEGER_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector< std::vector< float> > > { static int asptr(SEXP obj, std::vector< std::vector< float> > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector< float> > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(NUMERIC_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector< std::vector< double> > > { static int asptr(SEXP obj, std::vector< std::vector< double> > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector< double> > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(NUMERIC_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template <> struct traits_asptr < std::vector< std::vector< bool > > > { static int asptr(SEXP obj, std::vector< std::vector< bool> > **val) { std::vector > *p; // this is the length of the list unsigned int sexpsz = Rf_length(obj); p = new std::vector< std::vector< bool > > (sexpsz); for (unsigned listpos = 0; listpos < sexpsz; ++listpos) { unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos)); for (unsigned vpos = 0; vpos < vecsize; ++vpos) { (*p)[listpos].push_back(static_cast(LOGICAL_POINTER(VECTOR_ELT(obj, listpos))[vpos])); } } int res = SWIG_OK; if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; // catchall template struct traits_asptr < std::vector< std::vector > > { static int asptr(SEXP obj, std::vector< std::vector > **val) { std::vector< std::vector > *p; Rprintf("vector of vectors - unsupported content\n"); int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector< std::vector > > (), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %define %traits_type_name(Type...) %fragment(SWIG_Traits_frag(Type), "header", fragment="StdTraits",fragment="StdVectorTraits") { namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return #Type; } }; } } %enddef %include %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector) %traits_type_name(std::vector) %typemap("rtypecheck") std::vector, std::vector const, std::vector const& %{ is.numeric($arg) %} %typemap("rtype") std::vector "numeric" %typemap("scoercein") std::vector, std::vector const, std::vector const& ""; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector) %traits_type_name(std::vector) %typemap("rtypecheck") std::vector, std::vector const, std::vector const& %{ is.numeric($arg) %} %typemap("rtype") std::vector "numeric" %typemap("scoercein") std::vector, std::vector const, std::vector const& ""; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); %traits_type_name(std::vector); %typemap("rtypecheck") std::vector , std::vector const, std::vector const& %{ is.logical($arg) %} %typemap("rtype") std::vector "logical" %typemap("scoercein") std::vector , std::vector const, std::vector const& "$input = as.logical($input);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); %traits_type_name(std::vector); %typemap("rtypecheck") std::vector , std::vector const, std::vector const& %{ is.integer($arg) || is.numeric($arg) %} %typemap("rtype") std::vector "integer" %typemap("scoercein") std::vector , std::vector const, std::vector const& "$input = as.integer($input);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); %traits_type_name(std::vector); %typemap("rtypecheck") std::vector, std::vector const, std::vector const& %{ is.integer($arg) || is.numeric($arg) %} %typemap("rtype") std::vector "integer" %typemap("scoercein") std::vector, std::vector const, std::vector const& "$input = as.integer($input);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.integer);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.integer);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.numeric);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.numeric);"; %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector >); %traits_type_name(std::vector< std::vector >); %typemap("rtypecheck") std::vector >, std::vector > const, std::vector >const& %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %} %typemap("rtype") std::vector > "list" %typemap("scoercein") std::vector< std::vector >, std::vector > const, std::vector >const& "$input = lapply($input, as.logical);"; // we don't want these to be given R classes as they // have already been turned into R vectors. %typemap(scoerceout) std::vector, std::vector *, std::vector &, std::vector, std::vector *, std::vector &, std::vector, std::vector *, std::vector &, // vectors of vectors std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >&, std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >&, std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >&, std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >&, std::vector< std::vector >, std::vector< std::vector >*, std::vector< std::vector >& %{ %} swig-3.0.8/Lib/r/rfragments.swg0000664000175000017500000001110712641054563016222 0ustar williamwilliam#define SWIG_Error(code, msg) Rf_warning(msg); return Rf_ScalarLogical(NA_LOGICAL) #define SWIG_fail return Rf_ScalarLogical(NA_LOGICAL) /* for raw pointers */ #define SWIG_ConvertPtr(oc, ptr, ty, flags) SWIG_R_ConvertPtr(oc, ptr, ty, flags) #define SWIG_ConvertFunctionPtr(oc, ptr, ty) SWIG_R_ConvertPtr(oc, ptr, ty, 0) #define SWIG_NewPointerObj(ptr, ty, flags) SWIG_R_NewPointerObj(ptr, ty, flags) #define SWIG_NewFunctionPtrObj(ptr, ty) SWIG_R_NewPointerObj(ptr, ty, 0) /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_R_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, ty) SWIG_R_NewPackedObj(ptr, sz, ty) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, ty, flags) SWIG_ConvertPtr(obj, pptr, ty, flags) #define SWIG_NewInstanceObj(ptr, ty, flags) SWIG_NewPointerObj(ptr, ty, flags) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_R_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, ty) SWIG_R_NewPackedObj(ptr, sz, ty) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_R_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_R_SetModule(pointer) %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(long)(long value) { return Rf_ScalarInteger((int)value); } } %fragment(SWIG_AsVal_frag(long),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(long)(SEXP obj, long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } } %fragment(SWIG_From_frag(long long),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(long long)(long long value) { return Rf_ScalarInteger((int)value); } } %fragment(SWIG_AsVal_frag(long long),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(long long)(SEXP obj, long long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned long),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(unsigned long)(unsigned long value) { return Rf_ScalarInteger((int)value); } } %fragment(SWIG_AsVal_frag(unsigned long),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(unsigned long)(SEXP obj, unsigned long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned long long),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(unsigned long long)(unsigned long long value) { return Rf_ScalarInteger((int)value); } } %fragment(SWIG_AsVal_frag(unsigned long long),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(unsigned long long)(SEXP obj, unsigned long long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } } %fragment(SWIG_From_frag(double),"header") { SWIGINTERNINLINE SEXP SWIG_From_dec(double)(double value) { return Rf_ScalarReal(value); } } %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERNINLINE int SWIG_AsVal_dec(double)(SEXP obj, double *val) { if (val) *val = Rf_asReal(obj); return SWIG_OK; } } %fragment("SWIG_AsCharPtrAndSize", "header") { SWIGINTERN int SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc) { if (cptr && Rf_isString(obj)) { char *cstr = %const_cast(CHAR(STRING_ELT(obj, 0)), char *); int len = strlen(cstr); if (alloc) { if (*alloc == SWIG_NEWOBJ) { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; } } else { *cptr = %reinterpret_cast(malloc(len + 1), char *); *cptr = strcpy(*cptr, cstr); } if (psize) *psize = len + 1; return SWIG_OK; } return SWIG_TypeError; } } %fragment("SWIG_strdup","header") { SWIGINTERN char * SWIG_strdup(const char *str) { char *newstr = %reinterpret_cast(malloc(strlen(str) + 1), char *); return strcpy(newstr, str); } } //# This is modified from the R header files %fragment("SWIG_FromCharPtrAndSize","header") { SWIGINTERN SEXP SWIG_FromCharPtrAndSize(const char* carray, size_t size) { SEXP t, c; if (!carray) return R_NilValue; /* See R internals document 1.10. MkCharLen was introduced in 2.7.0. Use that instead of hand creating vector. Starting in 2.8.0 creating strings via vectors was deprecated in order to allow for use of CHARSXP caches. */ Rf_protect(t = Rf_allocVector(STRSXP, 1)); %#if R_VERSION >= R_Version(2,7,0) c = Rf_mkCharLen(carray, size); %#else c = Rf_allocVector(CHARSXP, size); strncpy((char *)CHAR(c), carray, size); %#endif SET_STRING_ELT(t, 0, c); Rf_unprotect(1); return t; } } swig-3.0.8/Lib/shared_ptr.i0000664000175000017500000000414412641054563015377 0ustar williamwilliam// This is a helper file for shared_ptr and should not be included directly. // The main implementation detail in using this smart pointer of a type is to customise the code generated // to use a pointer to the smart pointer of the type, rather than the usual pointer to the underlying type. // So for some type T, shared_ptr * is used rather than T *. // shared_ptr namespaces could be boost or std or std::tr1 // For example for std::tr1, use: // #define SWIG_SHARED_PTR_NAMESPACE std // #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 #if !defined(SWIG_SHARED_PTR_NAMESPACE) # define SWIG_SHARED_PTR_NAMESPACE boost #endif #if defined(SWIG_SHARED_PTR_SUBNAMESPACE) # define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE::SWIG_SHARED_PTR_SUBNAMESPACE #else # define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE #endif namespace SWIG_SHARED_PTR_NAMESPACE { #if defined(SWIG_SHARED_PTR_SUBNAMESPACE) namespace SWIG_SHARED_PTR_SUBNAMESPACE { #endif template class shared_ptr { }; #if defined(SWIG_SHARED_PTR_SUBNAMESPACE) } #endif } %fragment("SWIG_null_deleter", "header") { struct SWIG_null_deleter { void operator() (void const *) const { } }; %#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() %#define SWIG_NO_NULL_DELETER_1 %#define SWIG_NO_NULL_DELETER_SWIG_POINTER_NEW %#define SWIG_NO_NULL_DELETER_SWIG_POINTER_OWN } // Workaround empty first macro argument bug #define SWIGEMPTYHACK // Main user macro for defining shared_ptr typemaps for both const and non-const pointer types %define %shared_ptr(TYPE...) %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } SWIG_SHARED_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE) SWIG_SHARED_PTR_TYPEMAPS(const, TYPE) %enddef // Legacy macros %define SWIG_SHARED_PTR(PROXYCLASS, TYPE...) #warning "SWIG_SHARED_PTR(PROXYCLASS, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead." %shared_ptr(TYPE) %enddef %define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) #warning "SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead." %shared_ptr(TYPE) %enddef swig-3.0.8/Lib/std/0000775000175000017500000000000012641054563013661 5ustar williamwilliamswig-3.0.8/Lib/std/std_unordered_set.i0000664000175000017500000000743512641054563017560 0ustar williamwilliam// // std::unordered_set // Work in progress - the code is not compilable yet: // operator--() and constructor(compare function) not available for unordered_ // types // %include %include // Unordered Set %define %std_unordered_set_methods_common(unordered_set...) unordered_set(); unordered_set( const unordered_set& ); bool empty() const; size_type size() const; void clear(); void swap(unordered_set& v); size_type erase(const key_type& x); size_type count(const key_type& x) const; #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; iterator begin(); iterator end(); %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 void erase(iterator pos) { $self->erase(pos); } void erase(iterator first, iterator last) { $self->erase(first, last); } } iterator find(const key_type& x); std::pair equal_range(const key_type& x); #endif %enddef %define %std_unordered_set_methods(unordered_set...) %std_unordered_set_methods_common(unordered_set); #ifdef SWIG_EXPORT_ITERATOR_METHODS std::pair insert(const value_type& __x); #endif %enddef // ------------------------------------------------------------------------ // std::unordered_set // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::unordered_set), f(const std::unordered_set&): // the parameter being read-only, either a sequence or a // previously wrapped std::unordered_set can be passed. // -- f(std::unordered_set&), f(std::unordered_set*): // the parameter may be modified; therefore, only a wrapped std::unordered_set // can be passed. // -- std::unordered_set f(), const std::unordered_set& f(): // the unordered_set is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::unordered_set& f(), std::unordered_set* f(): // the unordered_set is returned by reference; therefore, a wrapped std::unordered_set // is returned // -- const std::unordered_set* f(), f(const std::unordered_set*): // for consistency, they expect and return a plain unordered_set pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template , class _Compare = std::equal_to< _Key >, class _Alloc = allocator< _Key > > class unordered_set { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Hash hasher; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %fragment(SWIG_Traits_frag(std::unordered_set< _Key, _Hash, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdUnorderedSetTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_set<" #_Key "," #_Hash "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::unordered_set< _Key, _Hash, _Compare, _Alloc >); unordered_set( const _Compare& ); #ifdef %swig_unordered_set_methods // Add swig/language extra methods %swig_unordered_set_methods(std::unordered_set< _Key, _Hash, _Compare, _Alloc >); #endif %std_unordered_set_methods(unordered_set); }; } swig-3.0.8/Lib/std/std_pair.i0000664000175000017500000000720012641054563015637 0ustar williamwilliam%include %{ #include %} namespace std { template struct pair { typedef T first_type; typedef U second_type; %traits_swigtype(T); %traits_swigtype(U); %fragment(SWIG_Traits_frag(std::pair< T, U >), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T "," #U " >"; } }; } } #ifndef SWIG_STD_PAIR_ASVAL %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair< T, U >); #else %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair< T, U >); #endif pair(); pair(T first, U second); pair(const pair& p); template pair(const pair< U1, U2 > &p); T first; U second; #ifdef %swig_pair_methods // Add swig/language extra methods %swig_pair_methods(std::pair< T, U >) #endif }; // *** // The following specializations should disappear or get // simplified when a 'const SWIGTYPE*&' can be defined // *** template struct pair< T, U* > { typedef T first_type; typedef U* second_type; %traits_swigtype(T); %traits_swigtype(U); %fragment(SWIG_Traits_frag(std::pair< T, U* >), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T "," #U " * >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair< T, U* >); pair(); pair(T __a, U* __b); pair(const pair& __p); T first; U* second; #ifdef %swig_pair_methods // Add swig/language extra methods %swig_pair_methods(std::pair< T, U* >) #endif }; template struct pair< T*, U > { typedef T* first_type; typedef U second_type; %traits_swigtype(T); %traits_swigtype(U); %fragment(SWIG_Traits_frag(std::pair< T*, U >), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T " *," #U " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair< T*, U >); pair(); pair(T* __a, U __b); pair(const pair& __p); T* first; U second; #ifdef %swig_pair_methods // Add swig/language extra methods %swig_pair_methods(std::pair< T*, U >) #endif }; template struct pair< T*, U* > { typedef T* first_type; typedef U* second_type; %traits_swigtype(T); %traits_swigtype(U); %fragment(SWIG_Traits_frag(std::pair< T*, U* >), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T " *," #U " * >"; } }; } } %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair< T*, U* >); pair(); pair(T* __a, U* __b); pair(const pair& __p); T* first; U* second; #ifdef %swig_pair_methods // Add swig/language extra methods %swig_pair_methods(std::pair< T*, U* >) #endif }; } swig-3.0.8/Lib/std/std_unordered_multiset.i0000664000175000017500000000570412641054563020630 0ustar williamwilliam// // std::unordered_multiset // Work in progress - the code is not compilable yet: // operator--() and constructor(compare function) not available for unordered_ // types // %include // Unordered Multiset %define %std_unordered_multiset_methods(unordered_multiset...) %std_unordered_set_methods_common(unordered_multiset); %enddef // ------------------------------------------------------------------------ // std::unordered_multiset // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::unordered_multiset), f(const std::unordered_multiset&): // the parameter being read-only, either a sequence or a // previously wrapped std::unordered_multiset can be passed. // -- f(std::unordered_multiset&), f(std::unordered_multiset*): // the parameter may be modified; therefore, only a wrapped std::unordered_multiset // can be passed. // -- std::unordered_multiset f(), const std::unordered_multiset& f(): // the set is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::unordered_multiset& f(), std::unordered_multiset* f(): // the set is returned by reference; therefore, a wrapped std::unordered_multiset // is returned // -- const std::unordered_multiset* f(), f(const std::unordered_multiset*): // for consistency, they expect and return a plain set pointer. // ------------------------------------------------------------------------ // exported classes namespace std { //unordered_multiset template , class _Alloc = allocator< _Key > > class unordered_multiset { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %fragment(SWIG_Traits_frag(std::unordered_multiset< _Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdMultisetTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_multiset<" #_Key "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset< _Key, _Compare, _Alloc >); unordered_multiset( const _Compare& ); #ifdef %swig_unordered_multiset_methods // Add swig/language extra methods %swig_unordered_multiset_methods(std::unordered_multiset< _Key, _Compare, _Alloc >); #endif %std_unordered_multiset_methods(unordered_multiset); }; } swig-3.0.8/Lib/std/std_container.i0000664000175000017500000000664012641054563016675 0ustar williamwilliam%include %include %include %{ #include %} // Common non-resizable container methods %define %std_container_methods_non_resizable(container...) container(); container(const container&); bool empty() const; size_type size() const; void swap(container& v); #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; iterator begin(); iterator end(); reverse_iterator rbegin(); reverse_iterator rend(); #endif %enddef // Common container methods %define %std_container_methods(container...) %std_container_methods_non_resizable(%arg(container)) void clear(); allocator_type get_allocator() const; %enddef // Common sequence %define %std_sequence_methods_common(sequence) %std_container_methods(%arg(sequence)); sequence(size_type size); void pop_back(); void resize(size_type new_size); #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 iterator erase(iterator pos) { return $self->erase(pos); } iterator erase(iterator first, iterator last) { return $self->erase(first, last); } } #endif %enddef %define %std_sequence_methods_non_resizable(sequence) %std_container_methods_non_resizable(%arg(sequence)) const value_type& front() const; const value_type& back() const; %enddef %define %std_sequence_methods(sequence) %std_sequence_methods_common(%arg(sequence)); sequence(size_type size, const value_type& value); void push_back(const value_type& x); const value_type& front() const; const value_type& back() const; void assign(size_type n, const value_type& x); void resize(size_type new_size, const value_type& x); #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 iterator insert(iterator pos, const value_type& x) { return $self->insert(pos, x); } void insert(iterator pos, size_type n, const value_type& x) { $self->insert(pos, n, x); } } #endif %enddef %define %std_sequence_methods_non_resizable_val(sequence...) %std_container_methods_non_resizable(%arg(sequence)) value_type front() const; value_type back() const; #endif %enddef %define %std_sequence_methods_val(sequence...) %std_sequence_methods_common(%arg(sequence)); sequence(size_type size, value_type value); void push_back(value_type x); value_type front() const; value_type back() const; void assign(size_type n, value_type x); void resize(size_type new_size, value_type x); #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 iterator insert(iterator pos, value_type x) { return $self->insert(pos, x); } void insert(iterator pos, size_type n, value_type x) { $self->insert(pos, n, x); } } #endif %enddef // // Ignore member methods for Type with no default constructor // %define %std_nodefconst_type(Type...) %feature("ignore") std::vector< Type >::vector(size_type size); %feature("ignore") std::vector< Type >::resize(size_type size); %feature("ignore") std::deque< Type >::deque(size_type size); %feature("ignore") std::deque< Type >::resize(size_type size); %feature("ignore") std::list< Type >::list(size_type size); %feature("ignore") std::list< Type >::resize(size_type size); %enddef swig-3.0.8/Lib/std/std_except.i0000664000175000017500000000215212641054563016175 0ustar williamwilliam#if defined(SWIGJAVA) || defined(SWIGCSHARP) #error "do not use this version of std_except.i" #endif %{ #include %} #if defined(SWIG_STD_EXCEPTIONS_AS_CLASSES) namespace std { struct exception { virtual ~exception() throw(); virtual const char* what() const throw(); }; struct bad_exception : exception { }; struct logic_error : exception { logic_error(const string& msg); }; struct domain_error : logic_error { domain_error(const string& msg); }; struct invalid_argument : logic_error { invalid_argument(const string& msg); }; struct length_error : logic_error { length_error(const string& msg); }; struct out_of_range : logic_error { out_of_range(const string& msg); }; struct runtime_error : exception { runtime_error(const string& msg); }; struct range_error : runtime_error { range_error(const string& msg); }; struct overflow_error : runtime_error { overflow_error(const string& msg); }; struct underflow_error : runtime_error { underflow_error(const string& msg); }; } #endif swig-3.0.8/Lib/std/std_unordered_multimap.i0000664000175000017500000000631612641054563020612 0ustar williamwilliam// // std::unordered_multimap // Work in progress - the code is not compilable yet: // operator--() and constructor(compare function) not available for unordered_ // types // %include %define %std_unordered_multimap_methods(mmap...) %std_map_methods_common(mmap); #ifdef SWIG_EXPORT_ITERATOR_METHODS std::pair equal_range(const key_type& x); std::pair equal_range(const key_type& x) const; #endif %enddef // ------------------------------------------------------------------------ // std::unordered_multimap // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::unordered_multimap), f(const std::unordered_multimap&): // the parameter being read-only, either a sequence or a // previously wrapped std::unordered_multimap can be passed. // -- f(std::unordered_multimap&), f(std::unordered_multimap*): // the parameter may be modified; therefore, only a wrapped std::unordered_multimap // can be passed. // -- std::unordered_multimap f(), const std::unordered_multimap& f(): // the map is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::unordered_multimap& f(), std::unordered_multimap* f(): // the map is returned by reference; therefore, a wrapped std::unordered_multimap // is returned // -- const std::unordered_multimap* f(), f(const std::unordered_multimap*): // for consistency, they expect and return a plain map pointer. // ------------------------------------------------------------------------ // exported class namespace std { template, class _Alloc = allocator > > class unordered_multimap { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair< const _Key, _Tp > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >), fragment="StdMultimapTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >); unordered_multimap( const _Compare& ); #ifdef %swig_unordered_multimap_methods // Add swig/language extra methods %swig_unordered_multimap_methods(std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >); #endif %std_unordered_multimap_methods(unordered_multimap); }; } swig-3.0.8/Lib/std/std_iostream.i0000664000175000017500000002122512641054563016532 0ustar williamwilliam/* For wchar support, you need to include the wchar.i file before this file, ie: %include %include or equivalently, just include %include */ %include %include %include #if defined(SWIG_WCHAR) %include #endif %{ #include %} namespace std { // 27.6.2.1 Template class basic_ostream template > class basic_ostream : virtual public basic_ios<_CharT, _Traits> { public: // Types (inherited from basic_ios (27.4.4)): typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; // 27.6.2.2 Constructor/destructor: explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __sb); virtual ~basic_ostream(); // 27.6.2.5 Formatted output: // 27.6.2.5.3 basic_ostream::operator<< basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& (*__pf)(basic_ostream<_CharT, _Traits>&)); basic_ostream<_CharT, _Traits>& operator<<(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&)); basic_ostream<_CharT, _Traits>& operator<<(ios_base& (*__pf) (ios_base&)); // 27.6.2.5.2 Arithmetic Inserters basic_ostream<_CharT, _Traits>& operator<<(long __n); basic_ostream<_CharT, _Traits>& operator<<(unsigned long __n); basic_ostream<_CharT, _Traits>& operator<<(bool __n); basic_ostream<_CharT, _Traits>& operator<<(short __n); basic_ostream<_CharT, _Traits>& operator<<(unsigned short __n); basic_ostream<_CharT, _Traits>& operator<<(int __n); basic_ostream<_CharT, _Traits>& operator<<(unsigned int __n); basic_ostream<_CharT, _Traits>& operator<<(long long __n); basic_ostream<_CharT, _Traits>& operator<<(unsigned long long __n); basic_ostream<_CharT, _Traits>& operator<<(double __f); basic_ostream<_CharT, _Traits>& operator<<(float __f); basic_ostream<_CharT, _Traits>& operator<<(long double __f); basic_ostream<_CharT, _Traits>& operator<<(const void* __p); basic_ostream<_CharT, _Traits>& operator<<(basic_streambuf<_CharT, _Traits>* __sb); %extend { std::basic_ostream<_CharT, _Traits >& operator<<(const std::basic_string<_CharT,_Traits, std::allocator<_CharT> >& s) { *self << s; return *self; } } // Unformatted output: basic_ostream<_CharT, _Traits>& put(char_type __c); basic_ostream<_CharT, _Traits>& write(const char_type* __s, streamsize __n); basic_ostream<_CharT, _Traits>& flush(); // Seeks: pos_type tellp(); basic_ostream<_CharT, _Traits>& seekp(pos_type); basic_ostream<_CharT, _Traits>& seekp(off_type, ios_base::seekdir); }; // 27.6.1.1 Template class basic_istream template > class basic_istream : virtual public basic_ios<_CharT, _Traits> { public: // Types (inherited from basic_ios (27.4.4)): typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; public: // 27.6.1.1.1 Constructor/destructor: explicit basic_istream(basic_streambuf<_CharT, _Traits>* __sb); virtual ~basic_istream(); // 27.6.1.2.3 basic_istream::operator>> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& (*__pf)(basic_istream<_CharT, _Traits>&)); basic_istream<_CharT, _Traits>& operator>>(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&)); basic_istream<_CharT, _Traits>& operator>>(ios_base& (*__pf)(ios_base&)); // 27.6.1.2.2 Arithmetic Extractors basic_istream<_CharT, _Traits>& operator>>(bool& __n); basic_istream<_CharT, _Traits>& operator>>(short& __n); basic_istream<_CharT, _Traits>& operator>>(unsigned short& __n); basic_istream<_CharT, _Traits>& operator>>(int& __n); basic_istream<_CharT, _Traits>& operator>>(unsigned int& __n); basic_istream<_CharT, _Traits>& operator>>(long& __n); basic_istream<_CharT, _Traits>& operator>>(unsigned long& __n); basic_istream<_CharT, _Traits>& operator>>(long long& __n); basic_istream<_CharT, _Traits>& operator>>(unsigned long long& __n); basic_istream<_CharT, _Traits>& operator>>(float& __f); basic_istream<_CharT, _Traits>& operator>>(double& __f); basic_istream<_CharT, _Traits>& operator>>(long double& __f); basic_istream<_CharT, _Traits>& operator>>(void*& __p); basic_istream<_CharT, _Traits>& operator>>(basic_streambuf<_CharT, _Traits>* __sb); // 27.6.1.3 Unformatted input: inline streamsize gcount(void) const; int_type get(void); basic_istream<_CharT, _Traits>& get(char_type& __c); basic_istream<_CharT, _Traits>& get(char_type* __s, streamsize __n, char_type __delim); inline basic_istream<_CharT, _Traits>& get(char_type* __s, streamsize __n); basic_istream<_CharT, _Traits>& get(basic_streambuf<_CharT, _Traits>& __sb, char_type __delim); inline basic_istream<_CharT, _Traits>& get(basic_streambuf<_CharT, _Traits>& __sb); basic_istream<_CharT, _Traits>& getline(char_type* __s, streamsize __n, char_type __delim); inline basic_istream<_CharT, _Traits>& getline(char_type* __s, streamsize __n); basic_istream<_CharT, _Traits>& ignore(streamsize __n = 1, int_type __delim = _Traits::eof()); int_type peek(void); basic_istream<_CharT, _Traits>& read(char_type* __s, streamsize __n); streamsize readsome(char_type* __s, streamsize __n); basic_istream<_CharT, _Traits>& putback(char_type __c); basic_istream<_CharT, _Traits>& unget(void); int sync(void); pos_type tellg(void); basic_istream<_CharT, _Traits>& seekg(pos_type); basic_istream<_CharT, _Traits>& seekg(off_type, ios_base::seekdir); }; // 27.6.1.5 Template class basic_iostream template > class basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> { public: typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __sb); virtual ~basic_iostream(); }; typedef basic_ostream ostream ; typedef basic_istream istream; typedef basic_iostream iostream; extern istream cin; extern ostream cout; extern ostream cerr; extern ostream clog; #if defined(SWIG_WCHAR) typedef basic_ostream wostream; typedef basic_istream wistream; typedef basic_iostream wiostream; extern wistream wcin; extern wostream wcout; extern wostream wcerr; extern wostream wclog; #endif template > std::basic_ostream<_CharT, _Traits>& endl(std::basic_ostream<_CharT, _Traits>&); template > std::basic_ostream<_CharT, _Traits>& ends(std::basic_ostream<_CharT, _Traits>&); template > std::basic_ostream<_CharT, _Traits>& flush(std::basic_ostream<_CharT, _Traits>&); } namespace std { %template(ostream) basic_ostream; %template(istream) basic_istream; %template(iostream) basic_iostream; %template(endl) endl >; %template(ends) ends >; %template(flush) flush >; #if defined(SWIG_WCHAR) %template(wostream) basic_ostream; %template(wistream) basic_istream; %template(wiostream) basic_iostream; %template(wendl) endl >; %template(wends) ends >; %template(wflush) flush >; #endif } swig-3.0.8/Lib/std/std_alloc.i0000664000175000017500000000373712641054563016011 0ustar williamwilliamnamespace std { /** * @brief The "standard" allocator, as per [20.4]. * * The private _Alloc is "SGI" style. (See comments at the top * of stl_alloc.h.) * * The underlying allocator behaves as follows. * - __default_alloc_template is used via two typedefs * - "__single_client_alloc" typedef does no locking for threads * - "__alloc" typedef is threadsafe via the locks * - __new_alloc is used for memory requests * * (See @link Allocators allocators info @endlink for more.) */ template class allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef const _Tp* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Tp value_type; template struct rebind; allocator() throw(); allocator(const allocator&) throw(); template allocator(const allocator<_Tp1>&) throw(); ~allocator() throw(); pointer address(reference __x) const; const_pointer address(const_reference __x) const; // NB: __n is permitted to be 0. The C++ standard says nothing // about what the return value is when __n == 0. _Tp* allocate(size_type __n, const void* = 0); // __p is not permitted to be a null pointer. void deallocate(pointer __p, size_type __n); size_type max_size() const throw(); void construct(pointer __p, const _Tp& __val); void destroy(pointer __p); }; template<> class allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind; }; } // namespace std swig-3.0.8/Lib/std/std_deque.i0000664000175000017500000000667312641054563016024 0ustar williamwilliam// // std::deque %include // Deque %define %std_deque_methods(deque...) %std_sequence_methods(deque) void pop_front(); void push_front(const value_type& x); %enddef %define %std_deque_methods_val(deque...) %std_sequence_methods_val(deque) void pop_front(); void push_front(value_type x); %enddef // ------------------------------------------------------------------------ // std::deque // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::deque), f(const std::deque&): // the parameter being read-only, either a sequence or a // previously wrapped std::deque can be passed. // -- f(std::deque&), f(std::deque*): // the parameter may be modified; therefore, only a wrapped std::deque // can be passed. // -- std::deque f(), const std::deque& f(): // the deque is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::deque& f(), std::deque* f(): // the deque is returned by reference; therefore, a wrapped std::deque // is returned // -- const std::deque* f(), f(const std::deque*): // for consistency, they expect and return a plain deque pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class deque { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::deque< _Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdDequeTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::deque<" #_Tp " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque< _Tp, _Alloc >); #ifdef %swig_deque_methods // Add swig/language extra methods %swig_deque_methods(std::deque< _Tp, _Alloc >); #endif %std_deque_methods(deque); }; template class deque< _Tp*, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::deque< _Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdDequeTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::deque<" #_Tp " * >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque< _Tp*, _Alloc >); #ifdef %swig_deque_methods_val // Add swig/language extra methods %swig_deque_methods_val(std::deque< _Tp*, _Alloc >); #endif %std_deque_methods_val(std::deque< _Tp*, _Alloc >); }; } swig-3.0.8/Lib/std/std_ios.i0000664000175000017500000001213612641054563015502 0ustar williamwilliam%include %include %include %{ #ifndef SWIG_STD_NOMODERN_STL # include #else # include #endif %} namespace std { template > class basic_streambuf; template > class basic_istream; template > class basic_ostream; // 27.4.2 Class ios_base typedef size_t streamsize; class locale; class ios_base { public: #ifdef SWIG_NESTED_CLASSES // 27.4.2.1.1 Class ios_base::failure class failure : public exception { public: explicit failure(const string& __str) throw(); }; #endif // 27.4.2.1.2 Type ios_base::fmtflags typedef int fmtflags; // 27.4.2.1.2 Type fmtflags static const fmtflags boolalpha ; static const fmtflags dec ; static const fmtflags fixed ; static const fmtflags hex ; static const fmtflags internal ; static const fmtflags left ; static const fmtflags oct ; static const fmtflags right ; static const fmtflags scientific ; static const fmtflags showbase ; static const fmtflags showpoint ; static const fmtflags showpos ; static const fmtflags skipws ; static const fmtflags unitbuf ; static const fmtflags uppercase ; static const fmtflags adjustfield ; static const fmtflags basefield ; static const fmtflags floatfield ; // 27.4.2.1.3 Type ios_base::iostate typedef int iostate; static const iostate badbit ; static const iostate eofbit ; static const iostate failbit ; static const iostate goodbit ; // 27.4.2.1.4 Type openmode typedef int openmode; static const openmode app ; static const openmode ate ; static const openmode binary ; static const openmode in ; static const openmode out ; static const openmode trunc ; // 27.4.2.1.5 Type seekdir typedef int seekdir; static const seekdir beg ; static const seekdir cur ; static const seekdir end ; // Callbacks; enum event { erase_event, imbue_event, copyfmt_event }; typedef void (*event_callback) (event, ios_base&, int); void register_callback(event_callback __fn, int __index); // Fmtflags state: inline fmtflags flags() const ; inline fmtflags flags(fmtflags __fmtfl); inline fmtflags setf(fmtflags __fmtfl); inline fmtflags setf(fmtflags __fmtfl, fmtflags __mask); inline void unsetf(fmtflags __mask) ; inline streamsize precision() const ; inline streamsize precision(streamsize __prec); inline streamsize width() const ; inline streamsize width(streamsize __wide); static bool sync_with_stdio(bool __sync = true); // Locales: locale imbue(const locale& __loc); inline locale getloc() const { return _M_ios_locale; } // Storage: static int xalloc() throw(); inline long& iword(int __ix); inline void*& pword(int __ix); // Destructor ~ios_base(); protected: ios_base(); //50. Copy constructor and assignment operator of ios_base private: ios_base(const ios_base&); ios_base& operator=(const ios_base&); }; template > class basic_ios : public ios_base { public: // Types: typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; public: iostate rdstate() const; void clear(iostate __state = goodbit); void setstate(iostate __state); bool good() const; bool eof() const; bool fail() const; bool bad() const; iostate exceptions() const; void exceptions(iostate __except); // Constructor/destructor: explicit basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base(); virtual ~basic_ios() ; // Members: basic_ostream<_CharT, _Traits>* tie() const; basic_ostream<_CharT, _Traits>* tie(basic_ostream<_CharT, _Traits>* __tiestr); basic_streambuf<_CharT, _Traits>* rdbuf() const; basic_streambuf<_CharT, _Traits>* rdbuf(basic_streambuf<_CharT, _Traits>* __sb); basic_ios& copyfmt(const basic_ios& __rhs); char_type fill() const; char_type fill(char_type __ch); // Locales: locale imbue(const locale& __loc); char narrow(char_type __c, char __dfault) const; char_type widen(char __c) const; protected: // 27.4.5.1 basic_ios constructors basic_ios(); private: basic_ios(const basic_ios&); basic_ios& operator=(const basic_ios&); }; } namespace std { typedef basic_ios ios; %template(ios) basic_ios; #if defined(SWIG_WCHAR) typedef basic_ios wios; %template(wios) basic_ios; #endif } swig-3.0.8/Lib/std/std_common.i0000664000175000017500000001161112641054563016175 0ustar williamwilliam%include // // Use the following macro with modern STL implementations // //#define SWIG_STD_MODERN_STL // // Use this to deactive the previous definition, when using gcc-2.95 // or similar old compilers. // //#define SWIG_STD_NOMODERN_STL // Here, we identify compilers we know have problems with STL. %{ #if defined(__GNUC__) # if __GNUC__ == 2 && __GNUC_MINOR <= 96 # define SWIG_STD_NOMODERN_STL # endif #endif %} // // Common code for supporting the C++ std namespace // %fragment(""); %fragment(""); %fragment(""); %fragment("StdIteratorTraits","header",fragment="") %{ #if defined(__SUNPRO_CC) && defined(_RWSTD_VER) # if !defined(SWIG_NO_STD_NOITERATOR_TRAITS_STL) # define SWIG_STD_NOITERATOR_TRAITS_STL # endif #endif #if !defined(SWIG_STD_NOITERATOR_TRAITS_STL) #include #else namespace std { template struct iterator_traits { typedef ptrdiff_t difference_type; typedef typename Iterator::value_type value_type; }; template struct iterator_traits<__reverse_bi_iterator > { typedef Distance difference_type; typedef T value_type; }; template struct iterator_traits { typedef T value_type; typedef ptrdiff_t difference_type; }; template inline typename iterator_traits<_InputIterator>::difference_type distance(_InputIterator __first, _InputIterator __last) { typename iterator_traits<_InputIterator>::difference_type __n = 0; while (__first != __last) { ++__first; ++__n; } return __n; } } #endif %} %fragment("StdTraitsCommon","header",fragment="") %{ namespace swig { template struct noconst_traits { typedef Type noconst_type; }; template struct noconst_traits { typedef Type noconst_type; }; /* type categories */ struct pointer_category { }; struct value_category { }; /* General traits that provides type_name and type_info */ template struct traits { }; template inline const char* type_name() { return traits::noconst_type >::type_name(); } template struct traits_info { static swig_type_info *type_query(std::string name) { name += " *"; return SWIG_TypeQuery(name.c_str()); } static swig_type_info *type_info() { static swig_type_info *info = type_query(type_name()); return info; } }; template inline swig_type_info *type_info() { return traits_info::type_info(); } /* Partial specialization for pointers */ template struct traits { typedef pointer_category category; static std::string make_ptr_name(const char* name) { std::string ptrname = name; ptrname += " *"; return ptrname; } static const char* type_name() { static std::string name = make_ptr_name(swig::type_name()); return name.c_str(); } }; template struct traits_as { }; template struct traits_check { }; } %} /* Generate the traits for a swigtype */ %define %traits_swigtype(Type...) %fragment(SWIG_Traits_frag(Type),"header",fragment="StdTraits") { namespace swig { template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return #Type; } }; } } %enddef /* Generate the typemaps for a class that has 'value' traits */ %define %typemap_traits(Code,Type...) %typemaps_asvalfrom(%arg(Code), %arg(swig::asval< Type >), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), Type); %enddef /* Generate the typemaps for a class that behaves more like a 'pointer' or plain wrapped Swigtype. */ %define %typemap_traits_ptr(Code,Type...) %typemaps_asptrfrom(%arg(Code), %arg(swig::asptr), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), Type); %enddef /* Equality methods */ %define %std_equal_methods(Type...) %extend Type { bool operator == (const Type& v) { return *self == v; } bool operator != (const Type& v) { return *self != v; } } %enddef /* Order methods */ %define %std_order_methods(Type...) %extend Type { bool operator > (const Type& v) { return *self > v; } bool operator < (const Type& v) { return *self < v; } bool operator >= (const Type& v) { return *self >= v; } bool operator <= (const Type& v) { return *self <= v; } } %enddef /* Comparison methods */ %define %std_comp_methods(Type...) %std_equal_methods(Type ) %std_order_methods(Type ) %enddef swig-3.0.8/Lib/std/std_vectora.i0000664000175000017500000000022312641054563016345 0ustar williamwilliam// // We keep this file only for backward compatibility, since std_vector.i // now uses the std::allocator parameter. // %include swig-3.0.8/Lib/std/std_multimap.i0000664000175000017500000000627212641054563016544 0ustar williamwilliam// // std::multimap // %include %define %std_multimap_methods(mmap...) %std_map_methods_common(mmap); #ifdef SWIG_EXPORT_ITERATOR_METHODS std::pair equal_range(const key_type& x); std::pair equal_range(const key_type& x) const; #endif %enddef // ------------------------------------------------------------------------ // std::multimap // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::multimap), f(const std::multimap&): // the parameter being read-only, either a sequence or a // previously wrapped std::multimap can be passed. // -- f(std::multimap&), f(std::multimap*): // the parameter may be modified; therefore, only a wrapped std::multimap // can be passed. // -- std::multimap f(), const std::multimap& f(): // the map is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::multimap& f(), std::multimap* f(): // the map is returned by reference; therefore, a wrapped std::multimap // is returned // -- const std::multimap* f(), f(const std::multimap*): // for consistency, they expect and return a plain map pointer. // ------------------------------------------------------------------------ // exported class namespace std { template, class _Alloc = allocator > > class multimap { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair< const _Key, _Tp > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", fragment=SWIG_Traits_frag(_Key), fragment=SWIG_Traits_frag(_Tp), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #_Key "," #_Tp " >"; } }; } } %fragment(SWIG_Traits_frag(std::multimap< _Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >), fragment="StdMultimapTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap< _Key, _Tp, _Compare, _Alloc >); multimap( const _Compare& ); #ifdef %swig_multimap_methods // Add swig/language extra methods %swig_multimap_methods(std::multimap< _Key, _Tp, _Compare, _Alloc >); #endif %std_multimap_methods(multimap); }; } swig-3.0.8/Lib/std/_std_deque.i0000664000175000017500000001051412641054563016150 0ustar williamwilliam/* ----------------------------------------------------------------------------- * _std_deque.i * * This file contains a generic definition of std::deque along with * some helper functions. Specific language modules should include * this file to generate wrappers. * ----------------------------------------------------------------------------- */ %include %{ #include #include %} /* This macro defines all of the standard methods for a deque. This is defined as a macro to simplify the task of specialization. For example, template<> class deque { public: %std_deque_methods(int); }; */ %define %std_deque_methods_noempty(T) typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; deque(); deque(unsigned int size, const T& value=T()); deque(const deque< T > &); ~deque(); void assign(unsigned int n, const T& value); void swap(deque< T > &x); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, T c = T()); const_reference front(); const_reference back(); void push_front(const T& x); void push_back(const T& x); void pop_front(); void pop_back(); void clear(); /* Some useful extensions */ %extend { const_reference getitem(int i) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i += size; if (i>=0 && isize()); if (i<0) i+= size; if (i>=0 && isize()); if (i<0) i+= size; if (i>=0 && ierase(self->begin()+i); } else { throw std::out_of_range("deque index out of range"); } } std::deque< T > getslice(int i, int j) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; if (i<0) i = 0; if (j>size) j = size; std::deque< T > tmp(j-i); std::copy(self->begin()+i,self->begin()+j,tmp.begin()); return tmp; } void setslice(int i, int j, const std::deque< T >& v) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; if (i<0) i = 0; if (j>size) j = size; if (int(v.size()) == j-i) { std::copy(v.begin(),v.end(),self->begin()+i); } else { self->erase(self->begin()+i,self->begin()+j); if (i+1 <= size) self->insert(self->begin()+i+1,v.begin(),v.end()); else self->insert(self->end(),v.begin(),v.end()); } } void delslice(int i, int j) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; if (i<0) i = 0; if (j>size) j = size; self->erase(self->begin()+i,self->begin()+j); } }; %enddef #ifdef SWIGPHP %define %std_deque_methods(T) %extend { bool is_empty() const { return self->empty(); } }; %std_deque_methods_noempty(T) %enddef #else %define %std_deque_methods(T) bool empty() const; %std_deque_methods_noempty(T) %enddef #endif namespace std { template class deque { public: %std_deque_methods(T); }; } swig-3.0.8/Lib/std/std_list.i0000664000175000017500000000744012641054563015665 0ustar williamwilliam// // std::list // %include // List %define %std_list_methods(list) %std_sequence_methods(list) void pop_front(); void push_front(const value_type& x); void reverse(); %enddef %define %std_list_methods_val(list) %std_sequence_methods_val(list) void pop_front(); void push_front(value_type x); void remove(value_type x); void unique(); void reverse(); void sort(); void merge(list& x); %enddef // ------------------------------------------------------------------------ // std::list // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::list), f(const std::list&): // the parameter being read-only, either a sequence or a // previously wrapped std::list can be passed. // -- f(std::list&), f(std::list*): // the parameter may be modified; therefore, only a wrapped std::list // can be passed. // -- std::list f(), const std::list& f(): // the list is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::list& f(), std::list* f(): // the list is returned by reference; therefore, a wrapped std::list // is returned // -- const std::list* f(), f(const std::list*): // for consistency, they expect and return a plain list pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class list { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::list< _Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdListTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::list<" #_Tp ", " #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list< _Tp, _Alloc >); #ifdef %swig_list_methods // Add swig/language extra methods %swig_list_methods(std::list< _Tp, _Alloc >); #endif %std_list_methods(list); }; template class list< _Tp*, _Alloc> { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::list< _Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdListTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::list<" #_Tp " *," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list< _Tp*, _Alloc >); #ifdef %swig_list_methods_val // Add swig/language extra methods %swig_list_methods_val(std::list< _Tp*, _Alloc >); #endif %std_list_methods_val(list); }; } %define %std_extequal_list(...) %extend std::list< __VA_ARGS__ > { void remove(const value_type& x) { self->remove(x); } void merge(std::list< __VA_ARGS__ >& x){ self->merge(x); } void unique() { self->unique(); } void sort() { self->sort(); } } %enddef swig-3.0.8/Lib/std/std_basic_string.i0000664000175000017500000001454412641054563017364 0ustar williamwilliam%include %include %include %include %fragment(""); namespace std { %naturalvar basic_string; } namespace std { template , typename _Alloc = allocator<_CharT> > class basic_string { #if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL) %ignore push_back; %ignore clear; %ignore compare; %ignore append; #endif public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _CharT value_type; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; static const size_type npos; #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; #endif %traits_swigtype(_CharT); %fragment(SWIG_Traits_frag(_CharT)); basic_string(const _CharT* __s, size_type __n); // Capacity: size_type length() const; size_type max_size() const; size_type capacity() const; void reserve(size_type __res_arg = 0); // Modifiers: basic_string& append(const basic_string& __str); basic_string& append(const basic_string& __str, size_type __pos, size_type __n); basic_string& append(const _CharT* __s, size_type __n); basic_string& append(size_type __n, _CharT __c); basic_string& assign(const basic_string& __str); basic_string& assign(const basic_string& __str, size_type __pos, size_type __n); basic_string& assign(const _CharT* __s, size_type __n); basic_string& insert(size_type __pos1, const basic_string& __str); basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n); basic_string& insert(size_type __pos, const _CharT* __s, size_type __n); basic_string& insert(size_type __pos, size_type __n, _CharT __c); basic_string& erase(size_type __pos = 0, size_type __n = npos); basic_string& replace(size_type __pos, size_type __n, const basic_string& __str); basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c); size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const; // String operations: const _CharT* c_str() const; size_type find(const _CharT* __s, size_type __pos, size_type __n) const; size_type find(const basic_string& __str, size_type __pos = 0) const; size_type find(_CharT __c, size_type __pos = 0) const; size_type rfind(const basic_string& __str, size_type __pos = npos) const; size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const; size_type rfind(_CharT __c, size_type __pos = npos) const; size_type find_first_of(const basic_string& __str, size_type __pos = 0) const; size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_first_of(_CharT __c, size_type __pos = 0) const; size_type find_last_of(const basic_string& __str, size_type __pos = npos) const; size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_last_of(_CharT __c, size_type __pos = npos) const; size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const; size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_first_not_of(_CharT __c, size_type __pos = 0) const; size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const; size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const; size_type find_last_not_of(_CharT __c, size_type __pos = npos) const; basic_string substr(size_type __pos = 0, size_type __n = npos) const; int compare(const basic_string& __str) const; int compare(size_type __pos, size_type __n, const basic_string& __str) const; int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const; %ignore pop_back(); %ignore front() const; %ignore back() const; %ignore basic_string(size_type n); %std_sequence_methods_val(basic_string); %ignore pop(); #ifdef %swig_basic_string // Add swig/language extra methods %swig_basic_string(std::basic_string< _CharT, _Traits, _Alloc >); #endif #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; void insert(iterator __p, size_type __n, _CharT __c); basic_string& replace(iterator __i1, iterator __i2, const basic_string& __str); basic_string& replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n); basic_string& replace(iterator __i1, iterator __i2, size_type __n, _CharT __c); basic_string& replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2); basic_string& replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2); #endif basic_string& operator +=(const basic_string& v); %newobject __add__; %newobject __radd__; %extend { std::basic_string< _CharT,_Traits,_Alloc >* __add__(const basic_string& v) { std::basic_string< _CharT,_Traits,_Alloc >* res = new std::basic_string< _CharT,_Traits,_Alloc >(*self); *res += v; return res; } std::basic_string< _CharT,_Traits,_Alloc >* __radd__(const basic_string& v) { std::basic_string< _CharT,_Traits,_Alloc >* res = new std::basic_string< _CharT,_Traits,_Alloc >(v); *res += *self; return res; } std::basic_string< _CharT,_Traits,_Alloc > __str__() { return *self; } std::basic_ostream<_CharT, std::char_traits<_CharT> >& __rlshift__(std::basic_ostream<_CharT, std::char_traits<_CharT> >& out) { out << *self; return out; } } }; } swig-3.0.8/Lib/std/std_carray.swg0000664000175000017500000000261012641054563016535 0ustar williamwilliam%{ #include %} // // std::carray - is really an extension to the 'std' namespace. // // A simple fix C array wrapper, more or less as presented in // // "The C++ Standarf Library", by Nicolai M. Josuttis // // which is also derived from the example in // // "The C++ Programming Language", by Bjarne Stroustup. // %inline %{ namespace std { template class carray { public: typedef _Type value_type; typedef size_t size_type; typedef _Type * iterator; typedef const _Type * const_iterator; carray() { } carray(const carray& c) { std::copy(c.v, c.v + size(), v); } template carray(_Iterator first, _Iterator last) { assign(first, last); } iterator begin() { return v; } iterator end() { return v + _Size; } const_iterator begin() const { return v; } const_iterator end() const { return v + _Size; } _Type& operator[](size_t i) { return v[i]; } const _Type& operator[](size_t i) const { return v[i]; } static size_t size() { return _Size; } template void assign(_Iterator first, _Iterator last) { if (std::distance(first,last) == size()) { std::copy(first, last, v); } else { throw std::length_error("bad range length"); } } private: _Type v[_Size]; }; } %} swig-3.0.8/Lib/std/std_wstring.i0000664000175000017500000000037112641054563016403 0ustar williamwilliam%include %include /* wide strings */ namespace std { %std_comp_methods(basic_string); %naturalvar wstring; typedef basic_string wstring; } %template(wstring) std::basic_string; swig-3.0.8/Lib/std/std_unordered_map.i0000664000175000017500000001014112641054563017526 0ustar williamwilliam// // std::unordered_map // Work in progress - the code is not compilable yet: // operator--() and constructor(compare function) not available for unordered_ // types // %include %include %define %std_unordered_map_methods_common(unordered_map...) %std_container_methods(unordered_map); size_type erase(const key_type& x); size_type count(const key_type& x) const; #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 void erase(iterator position) { $self->erase(position); } void erase(iterator first, iterator last) { $self->erase(first, last); } } iterator find(const key_type& x); iterator lower_bound(const key_type& x); iterator upper_bound(const key_type& x); #endif %enddef %define %std_unordered_map_methods(unordered_map...) %std_unordered_map_methods_common(unordered_map); #ifdef SWIG_EXPORT_ITERATOR_METHODS // iterator insert(const value_type& x); #endif %enddef // ------------------------------------------------------------------------ // std::unordered_map // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::unordered_map), f(const std::unordered_map&): // the parameter being read-only, either a sequence or a // previously wrapped std::unordered_map can be passed. // -- f(std::unordered_map&), f(std::unordered_map*): // the parameter may be modified; therefore, only a wrapped std::unordered_map // can be passed. // -- std::unordered_map f(), const std::unordered_map& f(): // the unordered_map is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::unordered_map& f(), std::unordered_map* f(): // the unordered_map is returned by reference; therefore, a wrapped std::unordered_map // is returned // -- const std::unordered_map* f(), f(const std::unordered_map*): // for consistency, they expect and return a plain unordered_map pointer. // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template, class _Alloc = allocator > > class unordered_map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair< const _Key, _Tp > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", fragment=SWIG_Traits_frag(_Key), fragment=SWIG_Traits_frag(_Tp), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #_Key "," #_Tp " >"; } }; } } %fragment(SWIG_Traits_frag(std::unordered_map< _Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >), fragment="StdMapTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map< _Key, _Tp, _Compare, _Alloc >); unordered_map( const _Compare& ); #ifdef %swig_unordered_map_methods // Add swig/language extra methods %swig_unordered_map_methods(std::unordered_map< _Key, _Tp, _Compare, _Alloc >); #endif %std_unordered_map_methods(unordered_map); }; } swig-3.0.8/Lib/std/std_char_traits.i0000664000175000017500000000616612641054563017221 0ustar williamwilliam%include #if defined(SWIG_WCHAR) %include #endif namespace std { /// 21.1.2 Basis for explicit _Traits specialization /// NB: That for any given actual character type this definition is /// probably wrong. template struct char_traits { }; /// 21.1.4 char_traits specializations template<> struct char_traits { typedef char char_type; typedef int int_type; typedef streampos pos_type; typedef streamoff off_type; typedef mbstate_t state_type; static void assign(char_type& __c1, const char_type& __c2); static bool eq(const char_type& __c1, const char_type& __c2); static bool lt(const char_type& __c1, const char_type& __c2); static int compare(const char_type* __s1, const char_type* __s2, size_t __n); static size_t length(const char_type* __s); static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); static char_type to_char_type(const int_type& __c); // To keep both the byte 0xff and the eof symbol 0xffffffff // from ending up as 0xffffffff. static int_type to_int_type(const char_type& __c); static bool eq_int_type(const int_type& __c1, const int_type& __c2); static int_type eof() ; static int_type not_eof(const int_type& __c); }; #if defined(SWIG_WCHAR) template<> struct char_traits { typedef wchar_t char_type; typedef wint_t int_type; typedef streamoff off_type; typedef wstreampos pos_type; typedef mbstate_t state_type; static void assign(char_type& __c1, const char_type& __c2); static bool eq(const char_type& __c1, const char_type& __c2); static bool lt(const char_type& __c1, const char_type& __c2); static int compare(const char_type* __s1, const char_type* __s2, size_t __n); static size_t length(const char_type* __s); static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, int_type __n); static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); static char_type to_char_type(const int_type& __c) ; static int_type to_int_type(const char_type& __c) ; static bool eq_int_type(const int_type& __c1, const int_type& __c2); static int_type eof() ; static int_type not_eof(const int_type& __c); }; #endif } namespace std { #ifndef SWIG_STL_WRAP_TRAITS %template() char_traits; #if defined(SWIG_WCHAR) %template() char_traits; #endif #else %template(char_traits_c) char_traits; #if defined(SWIG_WCHAR) %template(char_traits_w) char_traits; #endif #endif } swig-3.0.8/Lib/std/std_wstreambuf.i0000664000175000017500000000014612641054563017065 0ustar williamwilliam/* Provide 'std_streambuf.i' with wchar support. */ %include %include swig-3.0.8/Lib/std/std_map.i0000664000175000017500000000714012641054563015464 0ustar williamwilliam// // std::map // %include %include %define %std_map_methods_common(map...) %std_container_methods(map); size_type erase(const key_type& x); size_type count(const key_type& x) const; #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 void erase(iterator position) { $self->erase(position); } void erase(iterator first, iterator last) { $self->erase(first, last); } } iterator find(const key_type& x); iterator lower_bound(const key_type& x); iterator upper_bound(const key_type& x); #endif %enddef %define %std_map_methods(map...) %std_map_methods_common(map); #ifdef SWIG_EXPORT_ITERATOR_METHODS // iterator insert(const value_type& x); #endif %enddef // ------------------------------------------------------------------------ // std::map // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::map), f(const std::map&): // the parameter being read-only, either a sequence or a // previously wrapped std::map can be passed. // -- f(std::map&), f(std::map*): // the parameter may be modified; therefore, only a wrapped std::map // can be passed. // -- std::map f(), const std::map& f(): // the map is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::map& f(), std::map* f(): // the map is returned by reference; therefore, a wrapped std::map // is returned // -- const std::map* f(), f(const std::map*): // for consistency, they expect and return a plain map pointer. // ------------------------------------------------------------------------ %{ #include %} %fragment(""); %fragment(""); // exported class namespace std { template, class _Alloc = allocator > > class map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair< const _Key, _Tp > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", fragment=SWIG_Traits_frag(_Key), fragment=SWIG_Traits_frag(_Tp), fragment="StdPairTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #_Key "," #_Tp " >"; } }; } } %fragment(SWIG_Traits_frag(std::map< _Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >), fragment="StdMapTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map< _Key, _Tp, _Compare, _Alloc >); map( const _Compare& ); #ifdef %swig_map_methods // Add swig/language extra methods %swig_map_methods(std::map< _Key, _Tp, _Compare, _Alloc >); #endif %std_map_methods(map); }; } swig-3.0.8/Lib/std/std_array.i0000664000175000017500000000503012641054563016021 0ustar williamwilliam// // std::array // %include %define %std_array_methods(array...) %std_sequence_methods_non_resizable(array) void fill(const value_type& u); %enddef %define %std_array_methods_val(array...) %std_sequence_methods_non_resizable_val(array) void fill(const value_type& u); %enddef // ------------------------------------------------------------------------ // std::array // // The aim of all that follows would be to integrate std::array with // as much as possible, namely, to allow the user to pass and // be returned tuples or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::array), f(const std::array&): // the parameter being read-only, either a sequence or a // previously wrapped std::array can be passed. // -- f(std::array&), f(std::array*): // the parameter may be modified; therefore, only a wrapped std::array // can be passed. // -- std::array f(), const std::array& f(): // the array is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::array& f(), std::array* f(): // the array is returned by reference; therefore, a wrapped std::array // is returned // -- const std::array* f(), f(const std::array*): // for consistency, they expect and return a plain array pointer. // ------------------------------------------------------------------------ // exported classes namespace std { template class array { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; %traits_swigtype(_Tp); %traits_enum(_Tp); %fragment(SWIG_Traits_frag(std::array< _Tp, _Nm >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdArrayTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::array<" #_Tp "," #_Nm " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_STDARRAY, std::array< _Tp, _Nm >); #ifdef %swig_array_methods // Add swig/language extra methods %swig_array_methods(std::array< _Tp, _Nm >); #endif %std_array_methods(array); }; } swig-3.0.8/Lib/std/std_set.i0000664000175000017500000000644212641054563015506 0ustar williamwilliam// // std::set // %include %include // Set %define %std_set_methods_common(set...) set(); set( const set& ); bool empty() const; size_type size() const; void clear(); void swap(set& v); size_type erase(const key_type& x); size_type count(const key_type& x) const; #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; iterator begin(); iterator end(); reverse_iterator rbegin(); reverse_iterator rend(); %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 void erase(iterator pos) { $self->erase(pos); } void erase(iterator first, iterator last) { $self->erase(first, last); } } iterator find(const key_type& x); iterator lower_bound(const key_type& x); iterator upper_bound(const key_type& x); std::pair equal_range(const key_type& x); #endif %enddef %define %std_set_methods(set...) %std_set_methods_common(set); #ifdef SWIG_EXPORT_ITERATOR_METHODS std::pair insert(const value_type& __x); #endif %enddef // ------------------------------------------------------------------------ // std::set // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::set), f(const std::set&): // the parameter being read-only, either a sequence or a // previously wrapped std::set can be passed. // -- f(std::set&), f(std::set*): // the parameter may be modified; therefore, only a wrapped std::set // can be passed. // -- std::set f(), const std::set& f(): // the set is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::set& f(), std::set* f(): // the set is returned by reference; therefore, a wrapped std::set // is returned // -- const std::set* f(), f(const std::set*): // for consistency, they expect and return a plain set pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template , class _Alloc = allocator< _Key > > class set { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %fragment(SWIG_Traits_frag(std::set< _Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdSetTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::set<" #_Key "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set< _Key, _Compare, _Alloc >); set( const _Compare& ); #ifdef %swig_set_methods // Add swig/language extra methods %swig_set_methods(std::set< _Key, _Compare, _Alloc >); #endif %std_set_methods(set); }; } swig-3.0.8/Lib/std/std_wios.i0000664000175000017500000000013212641054563015662 0ustar williamwilliam/* Provide 'std_ios.i' with wchar support. */ %include %include swig-3.0.8/Lib/std/std_wsstream.i0000664000175000017500000000014212641054563016547 0ustar williamwilliam/* Provide 'std_sstream.i' with wchar support. */ %include %include swig-3.0.8/Lib/std/std_string.i0000664000175000017500000000033312641054563016212 0ustar williamwilliam%include /* plain strings */ namespace std { %std_comp_methods(basic_string); %naturalvar string; typedef basic_string string; } %template(string) std::basic_string; swig-3.0.8/Lib/std/std_stack.i0000664000175000017500000000664712641054563016027 0ustar williamwilliam/** * @file std_stack.i * @date Sun May 6 01:48:07 2007 * * @brief A wrapping of std::stack for Ruby. * * */ %include // Stack %define %std_stack_methods(stack...) stack(); stack( const _Sequence& ); bool empty() const; size_type size() const; const value_type& top() const; void pop(); void push( const value_type& ); %enddef %define %std_stack_methods_val(stack...) %std_stack_methods(stack) %enddef // ------------------------------------------------------------------------ // std::stack // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::stack), f(const std::stack&): // the parameter being read-only, either a sequence or a // previously wrapped std::stack can be passed. // -- f(std::stack&), f(std::stack*): // the parameter may be modified; therefore, only a wrapped std::stack // can be passed. // -- std::stack f(), const std::stack& f(): // the stack is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::stack& f(), std::stack* f(): // the stack is returned by reference; therefore, a wrapped std::stack // is returned // -- const std::stack* f(), f(const std::stack*): // for consistency, they expect and return a plain stack pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class stack { public: typedef size_t size_type; typedef _Tp value_type; typedef value_type& reference; typedef const value_type& const_reference; typedef _Sequence container_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::stack< _Tp, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdStackTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::stack<" #_Tp "," #_Sequence " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack< _Tp, _Sequence >); #ifdef %swig_stack_methods // Add swig/language extra methods %swig_stack_methods(std::stack< _Tp, _Sequence >); #endif %std_stack_methods(stack); }; template class stack< _Tp*, _Sequence > { public: typedef size_t size_type; typedef _Sequence::value_type value_type; typedef value_type reference; typedef value_type const_reference; typedef _Sequence container_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::stack< _Tp*, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdStackTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::stack<" #_Tp "," #_Sequence " * >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack< _Tp*, _Sequence >); #ifdef %swig_stack_methods_val // Add swig/language extra methods %swig_stack_methods_val(std::stack< _Tp*, _Sequence >); #endif %std_stack_methods_val(std::stack< _Tp*, _Sequence >); }; } swig-3.0.8/Lib/std/std_multiset.i0000664000175000017500000000475412641054563016565 0ustar williamwilliam// // std::multiset // %include // Multiset %define %std_multiset_methods(multiset...) %std_set_methods_common(multiset); %enddef // ------------------------------------------------------------------------ // std::multiset // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::multiset), f(const std::multiset&): // the parameter being read-only, either a sequence or a // previously wrapped std::multiset can be passed. // -- f(std::multiset&), f(std::multiset*): // the parameter may be modified; therefore, only a wrapped std::multiset // can be passed. // -- std::multiset f(), const std::multiset& f(): // the set is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::multiset& f(), std::multiset* f(): // the set is returned by reference; therefore, a wrapped std::multiset // is returned // -- const std::multiset* f(), f(const std::multiset*): // for consistency, they expect and return a plain set pointer. // ------------------------------------------------------------------------ // exported classes namespace std { //multiset template , class _Alloc = allocator< _Key > > class multiset { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Key); %fragment(SWIG_Traits_frag(std::multiset< _Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdMultisetTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::multiset<" #_Key "," #_Compare "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset< _Key, _Compare, _Alloc >); multiset( const _Compare& ); #ifdef %swig_multiset_methods // Add swig/language extra methods %swig_multiset_methods(std::multiset< _Key, _Compare, _Alloc >); #endif %std_multiset_methods(multiset); }; } swig-3.0.8/Lib/std/std_streambuf.i0000664000175000017500000000331512641054563016677 0ustar williamwilliam%include %{ #ifndef SWIG_STD_NOMODERN_STL #include #else #include #endif %} namespace std { template > class basic_streambuf { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: virtual ~basic_streambuf(); // Locales: locale pubimbue(const locale &__loc); locale getloc() const; // Buffer and positioning: basic_streambuf<_CharT, _Traits>* pubsetbuf(char_type* __s, streamsize __n); pos_type pubseekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = std::ios_base::in | std::ios_base::out); pos_type pubseekpos(pos_type __sp, ios_base::openmode __mode = std::ios_base::in | std::ios_base::out); int pubsync() ; // Get and put areas: // Get area: streamsize in_avail(); int_type snextc(); int_type sbumpc(); int_type sgetc(); streamsize sgetn(char_type* __s, streamsize __n); // Putback: int_type sputbackc(char_type __c); int_type sungetc(); // Put area: int_type sputc(char_type __c); streamsize sputn(const char_type* __s, streamsize __n); protected: basic_streambuf(); private: basic_streambuf(const basic_streambuf&); }; } namespace std { %template(streambuf) basic_streambuf; #if defined(SWIG_WCHAR) %template(wstreambuf) basic_streambuf; #endif } swig-3.0.8/Lib/std/std_vector.i0000664000175000017500000001402712641054563016213 0ustar williamwilliam// // std::vector // %include // Vector %define %std_vector_methods(vector...) %std_sequence_methods(vector) void reserve(size_type n); size_type capacity() const; %enddef %define %std_vector_methods_val(vector...) %std_sequence_methods_val(vector) void reserve(size_type n); size_type capacity() const; %enddef // ------------------------------------------------------------------------ // std::vector // // The aim of all that follows would be to integrate std::vector with // as much as possible, namely, to allow the user to pass and // be returned tuples or lists. // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::vector), f(const std::vector&): // the parameter being read-only, either a sequence or a // previously wrapped std::vector can be passed. // -- f(std::vector&), f(std::vector*): // the parameter may be modified; therefore, only a wrapped std::vector // can be passed. // -- std::vector f(), const std::vector& f(): // the vector is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::vector& f(), std::vector* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // -- const std::vector* f(), f(const std::vector*): // for consistency, they expect and return a plain vector pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class vector { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %traits_enum(_Tp); %fragment(SWIG_Traits_frag(std::vector< _Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::vector<" #_Tp "," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector< _Tp, _Alloc >); #ifdef %swig_vector_methods // Add swig/language extra methods %swig_vector_methods(std::vector< _Tp, _Alloc >); #endif %std_vector_methods(vector); }; // *** // This specialization should disappear or get simplified when // a 'const SWIGTYPE*&' can be defined // *** template class vector< _Tp*, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::vector< _Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::vector<" #_Tp " *," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector< _Tp*, _Alloc >); #ifdef %swig_vector_methods_val // Add swig/language extra methods %swig_vector_methods_val(std::vector< _Tp*, _Alloc >); #endif %std_vector_methods_val(vector); }; // *** // const pointer specialization // *** template class vector< _Tp const *, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp const * value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::vector< _Tp const*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::vector<" #_Tp " const*," #_Alloc " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector< _Tp const*, _Alloc >); #ifdef %swig_vector_methods_val // Add swig/language extra methods %swig_vector_methods_val(std::vector< _Tp const*, _Alloc >); #endif %std_vector_methods_val(vector); }; // *** // bool specialization // *** template class vector { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef bool value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type reference; typedef value_type const_reference; typedef _Alloc allocator_type; %traits_swigtype(bool); %fragment(SWIG_Traits_frag(std::vector), "header", fragment=SWIG_Traits_frag(bool), fragment="StdVectorTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::vector"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); #ifdef %swig_vector_methods_val // Add swig/language extra methods %swig_vector_methods_val(std::vector); #endif %std_vector_methods_val(vector); #if defined(SWIG_STD_MODERN_STL) && !defined(SWIG_STD_NOMODERN_STL) void flip(); #endif }; } swig-3.0.8/Lib/std/README0000664000175000017500000000117212641054563014542 0ustar williamwilliam/* ----------------------------------------------------------------------------- * C++ STD + STL * ----------------------------------------------------------------------------- */ std_common.i general common code std_container.i general container code std_basic_string.i basic string std_char_traits.i char traits std_complex.i complex std_deque.i deque std_except.i exceptions std_ios.i ios std_iostream.i istream/ostream std_list.i list std_map.i map std_multimap.i multimap std_multiset.i multiset std_pair.i pair std_set.i set std_streambuf.i streambuf std_vector.i vector std_vectora.i vector + allocator swig-3.0.8/Lib/std/std_sstream.i0000664000175000017500000001231312641054563016363 0ustar williamwilliam/* For wchar support, you need to include the wchar.i file before this file, ie: %include %include or equivalently, just include %include */ %include %include %include %include #if defined(SWIG_WCHAR) %include #endif %include %include %{ #include %} namespace std { template, typename _Alloc = allocator<_CharT> > class basic_stringbuf : public basic_streambuf<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: // Constructors: explicit basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out); explicit basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __str, ios_base::openmode __mode = ios_base::in | ios_base::out); // Get and set: basic_string<_CharT, _Traits, _Alloc> str() const; void str(const basic_string<_CharT, _Traits, _Alloc>& __s); }; // 27.7.2 Template class basic_istringstream template, typename _Alloc = allocator<_CharT> > class basic_istringstream : public basic_istream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: // Constructors: explicit basic_istringstream(ios_base::openmode __mode = ios_base::in); explicit basic_istringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, ios_base::openmode __mode = ios_base::in); ~basic_istringstream(); // Members: basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const; basic_string<_CharT, _Traits, _Alloc> str() const; void str(const basic_string<_CharT, _Traits, _Alloc>& __s); }; // 27.7.3 Template class basic_ostringstream template, typename _Alloc = allocator<_CharT> > class basic_ostringstream : public basic_ostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: // Constructors/destructor: explicit basic_ostringstream(ios_base::openmode __mode = ios_base::out); explicit basic_ostringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, ios_base::openmode __mode = ios_base::out); ~basic_ostringstream(); // Members: basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const; basic_string<_CharT, _Traits, _Alloc> str() const; #if 0 void str(const basic_string<_CharT, _Traits, _Alloc>& __s); #endif }; // 27.7.4 Template class basic_stringstream template, typename _Alloc = allocator<_CharT> > class basic_stringstream : public basic_iostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; public: // Constructors/destructors explicit basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in); explicit basic_stringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, ios_base::openmode __m = ios_base::out | ios_base::in); ~basic_stringstream(); // Members: basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const; basic_string<_CharT, _Traits, _Alloc> str() const; void str(const basic_string<_CharT, _Traits, _Alloc>& __s); }; } // namespace std namespace std { %template(istringstream) basic_istringstream; %template(ostringstream) basic_ostringstream; %template(stringstream) basic_stringstream; #if defined(SWIG_WCHAR) %template(wistringstream) basic_istringstream; %template(wostringstream) basic_ostringstream; %template(wstringstream) basic_stringstream; #endif } swig-3.0.8/Lib/std/std_wiostream.i0000664000175000017500000000014412641054563016716 0ustar williamwilliam/* Provide 'std_iostream.i' with wchar support. */ %include %include swig-3.0.8/Lib/std/std_queue.i0000664000175000017500000000670112641054563016035 0ustar williamwilliam/** * @file std_queue.i * @date Sun May 6 01:48:07 2007 * * @brief A wrapping of std::queue for Ruby. * * */ %include // Queue %define %std_queue_methods(queue...) queue(); queue( const _Sequence& ); bool empty() const; size_type size() const; const value_type& front() const; const value_type& back() const; void pop(); void push( const value_type& ); %enddef %define %std_queue_methods_val(queue...) %std_queue_methods(queue) %enddef // ------------------------------------------------------------------------ // std::queue // // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // // -- f(std::queue), f(const std::queue&): // the parameter being read-only, either a sequence or a // previously wrapped std::queue can be passed. // -- f(std::queue&), f(std::queue*): // the parameter may be modified; therefore, only a wrapped std::queue // can be passed. // -- std::queue f(), const std::queue& f(): // the queue is returned by copy; therefore, a sequence of T:s // is returned which is most easily used in other functions // -- std::queue& f(), std::queue* f(): // the queue is returned by reference; therefore, a wrapped std::queue // is returned // -- const std::queue* f(), f(const std::queue*): // for consistency, they expect and return a plain queue pointer. // ------------------------------------------------------------------------ %{ #include %} // exported classes namespace std { template > class queue { public: typedef size_t size_type; typedef _Tp value_type; typedef value_type& reference; typedef const value_type& const_reference; typedef _Sequence container_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::queue< _Tp, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdQueueTraits") { namespace swig { template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::queue<" #_Tp "," #_Sequence " >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue< _Tp, _Sequence >); #ifdef %swig_queue_methods // Add swig/language extra methods %swig_queue_methods(std::queue< _Tp, _Sequence >); #endif %std_queue_methods(queue); }; template class queue< _Tp*, _Sequence > { public: typedef size_t size_type; typedef _Tp value_type; typedef value_type& reference; typedef const value_type& const_reference; typedef _Sequence container_type; %traits_swigtype(_Tp); %fragment(SWIG_Traits_frag(std::queue< _Tp*, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdQueueTraits") { namespace swig { template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::queue<" #_Tp "," #_Sequence " * >"; } }; } } %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue< _Tp*, _Sequence >); #ifdef %swig_queue_methods_val // Add swig/language extra methods %swig_queue_methods_val(std::queue< _Tp*, _Sequence >); #endif %std_queue_methods_val(std::queue< _Tp*, _Sequence >); }; } swig-3.0.8/Lib/modula3/0000775000175000017500000000000012641054563014433 5ustar williamwilliamswig-3.0.8/Lib/modula3/modula3head.swg0000664000175000017500000000374612641054563017355 0ustar williamwilliam/* ----------------------------------------------------------------------------- * modula3head.swg * * Modula3 support code * ----------------------------------------------------------------------------- */ %insert(runtime) %{ #include #include #include %} #if 0 %insert(runtime) %{ /* Support for throwing Modula3 exceptions */ typedef enum { SWIG_JavaOutOfMemoryError = 1, SWIG_JavaIOException, SWIG_JavaRuntimeException, SWIG_JavaIndexOutOfBoundsException, SWIG_JavaArithmeticException, SWIG_JavaIllegalArgumentException, SWIG_JavaNullPointerException, SWIG_JavaUnknownError } SWIG_JavaExceptionCodes; typedef struct { SWIG_JavaExceptionCodes code; const char *java_exception; } SWIG_JavaExceptions_t; #if defined(SWIG_NOINCLUDE) void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg); #else %} %insert(runtime) { void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { jclass excep; static const SWIG_JavaExceptions_t java_exceptions[] = { { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, { SWIG_JavaIOException, "java/io/IOException" }, { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, { SWIG_JavaUnknownError, "java/lang/UnknownError" }, { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; const SWIG_JavaExceptions_t *except_ptr = java_exceptions; while (except_ptr->code != code && except_ptr->code) except_ptr++; JCALL0(ExceptionClear, jenv); excep = JCALL1(FindClass, jenv, except_ptr->java_exception); if (excep) JCALL2(ThrowNew, jenv, excep, msg); } } %insert(runtime) %{ #endif %} #endif swig-3.0.8/Lib/modula3/modula3.swg0000664000175000017500000010564512641054563016534 0ustar williamwilliam/* ----------------------------------------------------------------------------- * modula3.swg * * Modula3 typemaps * ----------------------------------------------------------------------------- */ %include /* The ctype, m3rawtype and m3wraptype typemaps work together and so there should be one of each. * The ctype typemap contains the C type used in the signature of C wrappers for C++ functions. * The m3rawtype typemap contains the M3 type used in the raw interface. * The m3rawintype typemap contains the M3 type used as function argument. * The m3rawrettype typemap contains the M3 type used as return value. * The m3wraptype typemap contains the M3 type used in the M3 type wrapper classes and module class. */ /* Primitive types */ %typemap(ctype) bool, const bool & "bool" %typemap(ctype) char, const char & "char" %typemap(ctype) signed char, const signed char & "signed char" %typemap(ctype) unsigned char, const unsigned char & "unsigned short" %typemap(ctype) short, const short & "short" %typemap(ctype) unsigned short, const unsigned short & "unsigned short" %typemap(ctype) int, const int & "int" %typemap(ctype) unsigned int, const unsigned int & "unsigned int" %typemap(ctype) long, const long & "long" %typemap(ctype) unsigned long, const unsigned long & "unsigned long" %typemap(ctype) long long, const long long & "long long" %typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long" %typemap(ctype) float, const float & "float" %typemap(ctype) double, const double & "double" %typemap(ctype) char * "char *" %typemap(ctype) void "void" %typemap(m3rawtype) bool, const bool & "BOOLEAN" %typemap(m3rawtype) char, const char & "C.char" %typemap(m3rawtype) signed char, const signed char & "C.signed_char" %typemap(m3rawtype) unsigned char, const unsigned char & "C.unsigned_char" %typemap(m3rawtype) short, const short & "C.short" %typemap(m3rawtype) unsigned short, const unsigned short & "C.unsigned_short" %typemap(m3rawtype) int, const int & "C.int" %typemap(m3rawtype) unsigned int, const unsigned int & "C.unsigned_int" %typemap(m3rawtype) long, const long & "C.long" %typemap(m3rawtype) unsigned long, const unsigned long & "C.unsigned_long" %typemap(m3rawtype) long long, const long long & "C.long_long" %typemap(m3rawtype) unsigned long long, const unsigned long long & "C.unsigned_long_long" %typemap(m3rawtype) float, const float & "C.float" %typemap(m3rawtype) double, const double & "C.double" %typemap(m3rawtype) long double, const long double & "C.long_double" %typemap(m3rawtype) char * "C.char_star" %typemap(m3rawtype) void "" %typemap(m3rawtype) FILE "Cstdio.FILE"; %typemap(m3rawtype) FILE * "Cstdio.FILE_star"; %typemap(m3rawintype) bool *, bool &, bool "BOOLEAN" %typemap(m3rawintype) char *, char &, char "C.char" %typemap(m3rawintype) signed char *, signed char &, signed char "C.signed_char" %typemap(m3rawintype) unsigned char *, unsigned char &, unsigned char "C.unsigned_char" %typemap(m3rawintype) short *, short &, short "C.short" %typemap(m3rawintype) unsigned short *, unsigned short &, unsigned short "C.unsigned_short" %typemap(m3rawintype) int *, int &, int "C.int" %typemap(m3rawintype) unsigned int *, unsigned int &, unsigned int "C.unsigned_int" %typemap(m3rawintype) long *, long &, long "C.long" %typemap(m3rawintype) unsigned long *, unsigned long &, unsigned long "C.unsigned_long" %typemap(m3rawintype) long long *, long long &, long long "C.long_long" %typemap(m3rawintype) unsigned long long *, unsigned long long &, unsigned long long "C.unsigned_long_long" %typemap(m3rawintype) float *, float &, float "C.float" %typemap(m3rawintype) double *, double &, double "C.double" %typemap(m3rawintype) long double *, long double &, long double "C.long_double" %typemap(m3rawintype) char * "C.char_star" %typemap(m3rawintype) void "" %typemap(m3rawintype) void * "ADDRESS" %typemap(m3rawintype) FILE "Cstdio.FILE"; %typemap(m3rawintype) FILE * "Cstdio.FILE_star"; %typemap(m3rawinmode) char *, void *, FILE * "" %typemap(m3rawrettype) bool, const bool & "BOOLEAN" %typemap(m3rawrettype) char, const char & "C.char" %typemap(m3rawrettype) signed char, const signed char & "C.signed_char" %typemap(m3rawrettype) unsigned char, const unsigned char & "C.unsigned_char" %typemap(m3rawrettype) short, const short & "C.short" %typemap(m3rawrettype) unsigned short, const unsigned short & "C.unsigned_short" %typemap(m3rawrettype) int, const int & "C.int" %typemap(m3rawrettype) unsigned int, const unsigned int & "C.unsigned_int" %typemap(m3rawrettype) long, const long & "C.long" %typemap(m3rawrettype) unsigned long, const unsigned long & "C.unsigned_long" %typemap(m3rawrettype) long long, const long long & "C.long_long" %typemap(m3rawrettype) unsigned long long, const unsigned long long & "C.unsigned_long_long" %typemap(m3rawrettype) float, const float & "C.float" %typemap(m3rawrettype) double, const double & "C.double" %typemap(m3rawrettype) long double, const long double & "C.long_double" %typemap(m3rawrettype) char * "C.char_star" %typemap(m3rawrettype) void "" %typemap(m3rawrettype) void * "ADDRESS" %typemap(m3rawrettype) FILE "Cstdio.FILE"; %typemap(m3rawrettype) FILE * "Cstdio.FILE_star"; %typemap("m3rawtype:import") char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, long double, const long double &, char * "Ctypes AS C" %typemap("m3rawintype:import") char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, long double, const long double &, char * "Ctypes AS C" %typemap("m3rawrettype:import") char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, long double, const long double &, char * "Ctypes AS C" %typemap("m3rawtype:import") FILE, FILE * "Cstdio"; %typemap("m3rawintype:import") FILE, FILE * "Cstdio"; %typemap("m3rawrettype:import") FILE, FILE * "Cstdio"; %typemap(m3wraptype) bool, const bool & "BOOLEAN" %typemap(m3wraptype) char, const char & "CHAR" %typemap(m3wraptype) signed char, const signed char & "CHAR" %typemap(m3wraptype) unsigned char, const unsigned char & "CHAR" %typemap(m3wraptype) short, const short & "Integer16.T" %typemap(m3wraptype) unsigned short, const unsigned short & "Cardinal16.T" %typemap(m3wraptype) int, const int & "INTEGER" %typemap(m3wraptype) unsigned int, const unsigned int & "CARDINAL" %typemap(m3wraptype) long, const long & "Integer32.T" %typemap(m3wraptype) unsigned long, const unsigned long & "Cardinal32.T" %typemap(m3wraptype) long long, const long long & "Integer64.T" %typemap(m3wraptype) unsigned long long, const unsigned long long & "Cardinal64.T" %typemap(m3wraptype) float, const float & "REAL" %typemap(m3wraptype) double, const double & "LONGREAL" %typemap(m3wraptype) long double, const long double & "EXTENDED" %typemap(m3wraptype) char * "TEXT" %typemap(m3wraptype) void "" %typemap(m3wraptype) FILE "Cstdio.FILE"; %typemap(m3wraptype) FILE * "Cstdio.FILE_star"; %typemap(m3wrapintype) bool, const bool *, const bool & "BOOLEAN" %typemap(m3wrapintype) char, const char *, const char & "CHAR" %typemap(m3wrapintype) signed char, const signed char *, const signed char & "CHAR" %typemap(m3wrapintype) unsigned char, const unsigned char *, const unsigned char & "CHAR" %typemap(m3wrapintype) short, const short *, const short & "INTEGER" %typemap(m3wrapintype) unsigned short, const unsigned short *, const unsigned short & "CARDINAL" %typemap(m3wrapintype) int, const int *, const int & "INTEGER" %typemap(m3wrapintype) unsigned int, const unsigned int *, const unsigned int & "CARDINAL" %typemap(m3wrapintype) long, const long *, const long & "INTEGER" %typemap(m3wrapintype) unsigned long, const unsigned long *, const unsigned long & "CARDINAL" %typemap(m3wrapintype) long long, const long long *, const long long & "INTEGER" %typemap(m3wrapintype) unsigned long long, const unsigned long long *, const unsigned long long & "CARDINAL" %typemap(m3wrapintype) float, const float *, const float & "REAL" %typemap(m3wrapintype) double, const double *, const double & "LONGREAL" %typemap(m3wrapintype) long double, const long double *, const long double & "EXTENDED" %typemap(m3wrapintype) const char *, const char [] "TEXT" %typemap(m3wrapintype,numinputs=0) void "" %typemap(m3wrapintype) FILE "Cstdio.FILE"; %typemap(m3wrapintype) FILE * "Cstdio.FILE_star"; %typemap(m3wrapouttype) bool, bool *, bool & "BOOLEAN" %typemap(m3wrapouttype) char, char *, char & "CHAR" %typemap(m3wrapouttype) signed char, signed char *, signed char & "CHAR" %typemap(m3wrapouttype) unsigned char, unsigned char *, unsigned char & "CHAR" %typemap(m3wrapouttype) short, short *, short & "INTEGER" %typemap(m3wrapouttype) unsigned short, unsigned short *, unsigned short & "CARDINAL" %typemap(m3wrapouttype) int, int *, int & "INTEGER" %typemap(m3wrapouttype) unsigned int, unsigned int *, unsigned int & "CARDINAL" %typemap(m3wrapouttype) long, long *, long & "INTEGER" %typemap(m3wrapouttype) unsigned long, unsigned long *, unsigned long & "CARDINAL" %typemap(m3wrapouttype) long long, long long *, long long & "INTEGER" %typemap(m3wrapouttype) unsigned long long, unsigned long long *, unsigned long long & "CARDINAL" %typemap(m3wrapouttype) float, float *, float & "REAL" %typemap(m3wrapouttype) double, double *, double & "LONGREAL" %typemap(m3wrapouttype) long double, long double *, long double & "EXTENDED" %typemap(m3wrapouttype) char *, char [] "TEXT" %typemap(m3wrapouttype,numinputs=0) void "" %typemap(m3wraprettype) bool, const bool & "BOOLEAN" %typemap(m3wraprettype) char, const char & "CHAR" %typemap(m3wraprettype) signed char, const signed char & "CHAR" %typemap(m3wraprettype) unsigned char, const unsigned char & "CHAR" %typemap(m3wraprettype) short, const short & "INTEGER" %typemap(m3wraprettype) unsigned short, const unsigned short & "CARDINAL" %typemap(m3wraprettype) int, const int & "INTEGER" %typemap(m3wraprettype) unsigned int, const unsigned int & "CARDINAL" %typemap(m3wraprettype) long, const long & "INTEGER" %typemap(m3wraprettype) unsigned long, const unsigned long & "CARDINAL" %typemap(m3wraprettype) long long, const long long & "INTEGER" %typemap(m3wraprettype) unsigned long long, const unsigned long long & "CARDINAL" %typemap(m3wraprettype) float, const float & "REAL" %typemap(m3wraprettype) double, const double & "LONGREAL" %typemap(m3wraprettype) long double, const long double & "EXTENDED" %typemap(m3wraprettype) char * "TEXT" %typemap(m3wraprettype) void "" %typemap(m3wraprettype) FILE "Cstdio.FILE"; %typemap(m3wraprettype) FILE * "Cstdio.FILE_star"; %typemap(ctype) char[ANY] "char *" %typemap(m3rawtype) char[ANY] "C.char_star" %typemap(m3rawintype) char[ANY] "C.char_star" %typemap(m3rawrettype) char[ANY] "C.char_star" %typemap(m3wraptype) char[ANY] "TEXT" %typemap(m3wrapintype) char[ANY] "TEXT" %typemap(m3wrapouttype) char[ANY] "TEXT" %typemap(m3wraprettype) char[ANY] "TEXT" %typemap(m3wrapinmode) const char * %{%} %typemap(m3wrapargvar) const char * %{$1 : C.char_star;%} %typemap(m3wrapinconv) const char * %{$1 := M3toC.SharedTtoS($1_name);%} %typemap(m3wrapfreearg) const char * %{M3toC.FreeSharedS($1_name,$1);%} %typemap(m3wrapargraw) const char * %{$1%} %typemap("m3wrapargvar:import") const char * "Ctypes AS C" %typemap("m3wrapinconv:import") const char * "M3toC" %typemap("m3wrapfreearg:import") const char * "M3toC" %typemap(m3wrapretvar) char * %{result : C.char_star;%} %typemap(m3wrapretraw) char * %{result%} %typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result)%} %typemap("m3wrapretvar:import") char * "Ctypes AS C" %typemap("m3wrapretconv:import") char * "M3toC" %typemap(m3wrapinmode) FILE * %{%} %typemap("m3wraptype:import") FILE, FILE * "Cstdio"; %typemap("m3wrapintype:import") FILE, FILE * "Cstdio"; %typemap("m3wraprettype:import") FILE, FILE * "Cstdio"; /* Composed types */ %typemap(ctype) SWIGTYPE "$1_type" %typemap(m3rawtype) SWIGTYPE "$1_basetype" %typemap(m3rawrettype) SWIGTYPE "UNTRACED REF $1_basetype" %typemap(m3wraptype) SWIGTYPE "$1_basetype" %typemap(m3wrapintype) SWIGTYPE "$1_basetype" %typemap(m3wrapouttype) SWIGTYPE "$1_basetype" %typemap(m3wraprettype) SWIGTYPE "$1_basetype" %typemap(ctype) SWIGTYPE [] "$1_type" %typemap(m3rawtype) const SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" %typemap(m3rawtype) SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" %typemap(m3rawintype) const SWIGTYPE [] "(*ARRAY OF*) $1_basetype" %typemap(m3rawinmode) const SWIGTYPE [] "READONLY" %typemap(m3rawintype) SWIGTYPE [] "(*ARRAY OF*) $1_basetype" %typemap(m3rawinmode) SWIGTYPE [] "VAR" %typemap(m3rawrettype) const SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" %typemap(m3rawrettype) SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" %typemap(m3wraptype) SWIGTYPE [] "$1_basetype" %typemap(m3wrapintype) const SWIGTYPE [] "ARRAY OF $1_basetype" %typemap(m3wrapinmode) const SWIGTYPE [] "READONLY" %typemap(m3wrapintype) SWIGTYPE [] "ARRAY OF $1_basetype" %typemap(m3wrapinmode) SWIGTYPE [] "VAR" %typemap(m3wrapouttype) SWIGTYPE [] "ARRAY OF $1_basetype" %typemap(m3wraprettype) SWIGTYPE [] "REF ARRAY OF $1_basetype" %typemap(ctype) SWIGTYPE * "$1_type" %typemap(m3rawtype) const SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(m3rawtype) SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(m3rawintype) const SWIGTYPE * "$1_basetype" %typemap(m3rawinmode) const SWIGTYPE * "READONLY" %typemap(m3rawintype) SWIGTYPE * "$1_basetype" %typemap(m3rawinmode) SWIGTYPE * "VAR" %typemap(m3rawrettype) const SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(m3rawrettype) SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(m3wraptype) SWIGTYPE * "$1_basetype" %typemap(m3wrapintype) const SWIGTYPE * "$1_basetype" %typemap(m3wrapinmode) const SWIGTYPE * "READONLY" %typemap(m3wrapintype) SWIGTYPE * "$1_basetype" %typemap(m3wrapinmode) SWIGTYPE * "VAR" %typemap(m3wrapouttype) SWIGTYPE * "$1_basetype" %typemap(m3wraprettype) SWIGTYPE * "UNTRACED REF $1_basetype" %typemap(ctype) SWIGTYPE & "$1_type" %typemap(m3rawtype) const SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(m3rawtype) SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(m3rawintype) const SWIGTYPE & "$1_basetype" %typemap(m3rawinmode) const SWIGTYPE & "READONLY" %typemap(m3rawintype) SWIGTYPE & "$1_basetype" %typemap(m3rawinmode) SWIGTYPE & "VAR" %typemap(m3rawrettype) const SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(m3rawrettype) SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(m3wraptype) SWIGTYPE & "$1_basetype" %typemap(m3wrapintype) const SWIGTYPE & "$1_basetype" %typemap(m3wrapinmode) const SWIGTYPE & "READONLY" %typemap(m3wrapintype) SWIGTYPE & "$1_basetype" %typemap(m3wrapinmode) SWIGTYPE & "VAR" %typemap(m3wrapouttype) SWIGTYPE & "$1_basetype" %typemap(m3wraprettype) SWIGTYPE & "UNTRACED REF $1_basetype" %typemap(ctype) SWIGTYPE && "$1_type" %typemap(m3rawtype) const SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(m3rawtype) SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(m3rawintype) const SWIGTYPE && "$1_basetype" %typemap(m3rawinmode) const SWIGTYPE && "READONLY" %typemap(m3rawintype) SWIGTYPE && "$1_basetype" %typemap(m3rawinmode) SWIGTYPE && "VAR" %typemap(m3rawrettype) const SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(m3rawrettype) SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(m3wraptype) SWIGTYPE && "$1_basetype" %typemap(m3wrapintype) const SWIGTYPE && "$1_basetype" %typemap(m3wrapinmode) const SWIGTYPE && "READONLY" %typemap(m3wrapintype) SWIGTYPE && "$1_basetype" %typemap(m3wrapinmode) SWIGTYPE && "VAR" %typemap(m3wrapouttype) SWIGTYPE && "$1_basetype" %typemap(m3wraprettype) SWIGTYPE && "UNTRACED REF $1_basetype" %typemap(ctype) enum SWIGTYPE "$1_type" %typemap(m3rawtype) enum SWIGTYPE "C.int" %typemap(m3rawintype) enum SWIGTYPE "C.int (* $1_type *)" %typemap(m3rawrettype) enum SWIGTYPE "C.int" %typemap(m3wraptype) enum SWIGTYPE "$*1_type" %typemap(m3wrapintype) enum SWIGTYPE "$1_type" %typemap(m3wrapouttype) enum SWIGTYPE "$1_type" %typemap(m3wraprettype) enum SWIGTYPE "$*1_type" /* pointer to a class member */ %typemap(ctype) SWIGTYPE (CLASS::*) "$1_type" %typemap(m3rawtype) SWIGTYPE (CLASS::*) "REFANY" %typemap(m3wraptype) SWIGTYPE (CLASS::*) "$1_basetype" /* The following are the in, out, freearg, argout typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */ /* primitive types */ %typemap(in) bool %{ $1 = $input ? true : false; %} %typemap(in) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) bool %{ $result = $1; %} %typemap(out) char %{ $result = $1; %} %typemap(out) signed char %{ $result = $1; %} %typemap(out) unsigned char %{ $result = $1; %} %typemap(out) short %{ $result = $1; %} %typemap(out) unsigned short %{ $result = $1; %} %typemap(out) int %{ $result = $1; %} %typemap(out) unsigned int %{ $result = $1; %} %typemap(out) long %{ $result = $1; %} %typemap(out) unsigned long %{ $result = $1; %} %typemap(out) long long %{ $result = $1; %} %typemap(out) unsigned long long %{ $result = $1; %} %typemap(out) float %{ $result = $1; %} %typemap(out) double %{ $result = $1; %} %typemap(out) enum SWIGTYPE %{ $result = $1; %} /* char * - treat as String */ %typemap(in) char * { $1 = $input; } //%typemap(freearg) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } //%typemap(out) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } %typemap(out) void "" /* primitive types by const reference */ %typemap(in) const bool & (bool temp) %{ temp = $input ? true : false; $1 = &temp; %} %typemap(in) const char & (char temp), const signed char & (signed char temp), const unsigned char & (unsigned char temp), const short & (short temp), const unsigned short & (unsigned short temp), const int & (int temp), const unsigned int & (unsigned int temp), const long & (long temp), const unsigned long & (unsigned long temp), const long long & ($*1_ltype temp), const unsigned long long & ($*1_ltype temp), const float & (float temp), const double & (double temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const bool & %{ $result = *$1; %} %typemap(out) const char & %{ $result = *$1; %} %typemap(out) const signed char & %{ $result = *$1; %} %typemap(out) const unsigned char & %{ $result = *$1; %} %typemap(out) const short & %{ $result = *$1; %} %typemap(out) const unsigned short & %{ $result = *$1; %} %typemap(out) const int & %{ $result = *$1; %} %typemap(out) const unsigned int & %{ $result = *$1; %} %typemap(out) const long & %{ $result = *$1; %} %typemap(out) const unsigned long & %{ $result = *$1; %} %typemap(out) const long long & %{ $result = *$1; %} %typemap(out) const unsigned long long & %{ $result = *$1; %} %typemap(out) const float & %{ $result = *$1; %} %typemap(out) const double & %{ $result = *$1; %} /* Default handling. Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (!argp) { // SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); RETURN $null; } $1 = *argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{*($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); *($&1_ltype*)&$result = $1ptr; } #endif /* Generic pointers and references */ %typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %} %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; if(!$1) { //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); RETURN $null; } %} %typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input; if(!$1) { //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); RETURN $null; } %} %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %} /* Default array handling */ %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} /* char[ANY] - treat as String */ %typemap(in) char[ANY] { $1 = $input; } %typemap(argout) char[ANY] "" %typemap(freearg) char[ANY] ""//{ if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } %typemap(out) char[ANY] { if($1) $result = $1; } /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */ %typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */ bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) /* Java char */ char, const char & "" %typecheck(SWIG_TYPECHECK_INT8) /* Java byte */ signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_INT16) /* Java short */ unsigned char, short, const unsigned char &, const short & "" %typecheck(SWIG_TYPECHECK_INT32) /* Java int */ unsigned short, int, long, const unsigned short &, const int &, const long &, enum SWIGTYPE "" %typecheck(SWIG_TYPECHECK_INT64) /* Java long */ unsigned int, unsigned long, long long, const unsigned int &, const unsigned long &, const long long & "" %typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */ unsigned long long "" %typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */ float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */ double, const double & "" %typecheck(SWIG_TYPECHECK_STRING) /* Java String */ char *, char[ANY] "" %typecheck(SWIG_TYPECHECK_POINTER) /* Default */ SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Exception handling */ %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short { char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg); RETURN $null; } %typemap(throws) SWIGTYPE { (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); RETURN $null; } %typemap(throws) char * { SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); RETURN $null; } /* Typemaps for code generation in proxy classes and C# type wrapper classes */ /* The in typemap is used for converting function parameter types from the type * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */ %typemap(m3in) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, char *, char[ANY], enum SWIGTYPE "$input" %typemap(m3in) SWIGTYPE "$&*1_type.getCPtr($input)" %typemap(m3in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "$1_basetype.getCPtr($input)" /* The m3out typemap is used for converting function return types from the return type * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. */ %typemap(m3out) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, char *, char[ANY], enum SWIGTYPE %{$imcall%} %typemap(m3out) void %{$imcall%} %typemap(m3out) SWIGTYPE %{ RETURN NEW(REF $1_basetype, $imcall); %} %typemap(m3out) SWIGTYPE & %{ RETURN NEW($1_basetype, $imcall, $owner); %} %typemap(m3out) SWIGTYPE && %{ RETURN NEW($1_basetype, $imcall, $owner); %} %typemap(m3out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ cPtr := $imcall; RETURN (cPtr = IntPtr.Zero) ? null : NEW($1_basetype, cPtr, $owner); %} /* Properties */ %typemap(m3varin) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ PROCEDURE Set$var (value: $vartype) = BEGIN $imcall; END Set$var; %} %typemap(m3varout) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double &, char *, char[ANY], enum SWIGTYPE %{ PROCEDURE Get$var (): $vartype = BEGIN RETURN $imcall; END Get$var; %} %typemap(m3varout) void %{ get { $imcall; } %} %typemap(m3varout) SWIGTYPE %{ get { RETURN new $&*1_mangle($imcall, true); } %} %typemap(m3varout) SWIGTYPE & %{ get { RETURN new $1_basetype($imcall, $owner); } %} %typemap(m3varout) SWIGTYPE && %{ get { RETURN new $1_basetype($imcall, $owner); } %} %typemap(m3varout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ get { IntPtr cPtr = $imcall; RETURN (cPtr == IntPtr.Zero) ? null : new $1_basetype(cPtr, $owner); } %} /* Typemaps used for the generation of proxy and type wrapper class code */ %typemap(m3base) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public" %typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;" %typemap(m3interfaces) SWIGTYPE "IDisposable" %typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(m3ptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "internal" %typemap(m3finalize) SWIGTYPE %{ ~$1_basetype() { Dispose(); } %} %typemap(m3destruct, methodname="Dispose") SWIGTYPE { if(swigCPtr != IntPtr.Zero && swigCMemOwn) { $imcall; swigCMemOwn = false; } swigCPtr = IntPtr.Zero; GC.SuppressFinalize(this); } %typemap(m3destruct_derived, methodname="Dispose") SWIGTYPE { if(swigCPtr != IntPtr.Zero && swigCMemOwn) { $imcall; swigCMemOwn = false; } swigCPtr = IntPtr.Zero; GC.SuppressFinalize(this); base.Dispose(); } %typemap(m3getcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ internal static IntPtr getCPtr($1_basetype obj) { RETURN (obj == null) ? IntPtr.Zero : obj.swigCPtr; } %} /* M3 specific directives */ #define %m3multiretval %feature("modula3:multiretval") #define %constnumeric(num) %feature("constnumeric","num") %pragma(modula3) moduleimports=%{ IMPORT BlaBla; %} %pragma(modula3) imclassimports=%{ FROM BlaBla IMPORT Bla; %} /* Some ANSI C typemaps */ %apply unsigned long { size_t }; /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-3.0.8/Lib/modula3/typemaps.i0000664000175000017500000001032112641054563016444 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* These typemaps will eventually probably maybe make their way into named typemaps * OUTPUT * and OUTPUT & as they currently break functions that return a pointer or * reference. */ %typemap(ctype) bool *, bool & "bool *" %typemap(ctype) char & "char *" %typemap(ctype) signed char *, signed char & "signed char *" %typemap(ctype) unsigned char *, unsigned char & "unsigned short *" %typemap(ctype) short *, short & "short *" %typemap(ctype) unsigned short *, unsigned short & "unsigned short *" %typemap(ctype) int *, int & "int *" %typemap(ctype) unsigned int *, unsigned int & "unsigned int *" %typemap(ctype) long *, long & "long *" %typemap(ctype) unsigned long *, unsigned long & "unsigned long *" %typemap(ctype) long long *, long long & "long long *" %typemap(ctype) unsigned long long *, unsigned long long & "unsigned long long *" %typemap(ctype) float *, float & "float *" %typemap(ctype) double *, double & "double *" %typemap(imtype) bool *, bool & "ref bool" %typemap(imtype) char & "ref char" %typemap(imtype) signed char *, signed char & "ref sbyte" %typemap(imtype) unsigned char *, unsigned char & "ref byte" %typemap(imtype) short *, short & "ref short" %typemap(imtype) unsigned short *, unsigned short & "ref ushort" %typemap(imtype) int *, int & "ref int" %typemap(imtype) unsigned int *, unsigned int & "ref uint" %typemap(imtype) long *, long & "ref int" %typemap(imtype) unsigned long *, unsigned long & "ref uint" %typemap(imtype) long long *, long long & "ref long" %typemap(imtype) unsigned long long *, unsigned long long & "ref ulong" %typemap(imtype) float *, float & "ref float" %typemap(imtype) double *, double & "ref double" %typemap(cstype) bool *, bool & "ref bool" %typemap(cstype) char & "ref char" %typemap(cstype) signed char *, signed char & "ref sbyte" %typemap(cstype) unsigned char *, unsigned char & "ref byte" %typemap(cstype) short *, short & "ref short" %typemap(cstype) unsigned short *, unsigned short & "ref ushort" %typemap(cstype) int *, int & "ref int" %typemap(cstype) unsigned int *, unsigned int & "ref uint" %typemap(cstype) long *, long & "ref int" %typemap(cstype) unsigned long *, unsigned long & "ref uint" %typemap(cstype) long long *, long long & "ref long" %typemap(cstype) unsigned long long *, unsigned long long & "ref ulong" %typemap(cstype) float *, float & "ref float" %typemap(cstype) double *, double & "ref double" %typemap(csin) bool *, bool &, char &, signed char *, signed char &, unsigned char *, unsigned char &, short *, short &, unsigned short *, unsigned short &, int *, int &, unsigned int *, unsigned int &, long *, long &, unsigned long *, unsigned long &, long long *, long long &, unsigned long long *, unsigned long long &, float *, float &, double *, double & "ref $csinput" swig-3.0.8/Lib/scilab/0000775000175000017500000000000012641054563014324 5ustar williamwilliamswig-3.0.8/Lib/scilab/sciunsignedchar.swg0000664000175000017500000001404412641054563020222 0ustar williamwilliam/* * C-type: unsigned char * Scilab type: double or uint8 */ %fragment(SWIG_AsVal_frag(unsigned char), "header", fragment="SWIG_SciDoubleOrUint8_AsUnsignedChar", fragment="") { #define SWIG_AsVal_unsigned_SS_char(scilabValue, valuePointer) SWIG_SciDoubleOrUint8_AsUnsignedChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDoubleOrUint8_AsUnsignedChar", "header") { SWIGINTERN int SWIG_SciDoubleOrUint8_AsUnsignedChar(void *pvApiCtx, int iVar, unsigned char *pucValue, char *fname) { SciErr sciErr; int iType = 0; int iRows = 0; int iCols = 0; int iPrec = 0; int *piAddrVar = NULL; unsigned char *pucData = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_ints) { if (pucValue) { sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_UINT8) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, piAddrVar, &iRows, &iCols, &pucData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } *pucValue = *pucData; } } else if (iType == sci_matrix) { if (pucValue) { double *pdData = NULL; double dValue = 0.0f; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } dValue = *pdData; if (dValue != floor(dValue)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 8-bit unsigned integer.\n"), fname, iVar); return SWIG_ValueError; } if ((dValue < 0) || (dValue > UCHAR_MAX)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 8-bit unsigned integer.\n"), fname, iVar); return SWIG_OverflowError; } *pucValue = (unsigned char) dValue; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned char), "header", fragment="SWIG_SciDouble_FromUnsignedChar") { #define SWIG_From_unsigned_SS_char(value) SWIG_SciDouble_FromUnsignedChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value) } %fragment("SWIG_SciDouble_FromUnsignedChar", "header") { SWIGINTERN int SWIG_SciDouble_FromUnsignedChar(void *pvApiCtx, int iVarOut, unsigned char ucValue) { if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) ucValue)) return SWIG_ERROR; return SWIG_OK; } } /* * C-type: unsigned char[] * Scilab type: double or uint8 matrix */ %fragment("SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize", "header") { SWIGINTERN int SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned char **pucValue, char *fname) { SciErr sciErr; int iType = 0; int iPrec = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_matrix) { double *pdData = NULL; int size = 0; int i; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } size = (*iRows) * (*iCols); *pucValue = (unsigned char*) malloc(size * sizeof(int*)); for (i = 0; i < size; i++) (*pucValue)[i] = (unsigned char) pdData[i]; } else if (iType == sci_ints) { sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_UINT8) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double vector expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, piAddrVar, iRows, iCols, pucValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double vector expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciDouble_FromUnsignedCharArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromUnsignedCharArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const unsigned char *pucValues) { SciErr sciErr; double *pdValues = NULL; int i; pdValues = (double*) malloc(iRows * iCols * sizeof(double)); for (i=0; i %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/scilab/scisequencebool.swg0000664000175000017500000000527012641054563020235 0ustar williamwilliam/* * * Scilab matrix of bool <-> C++ bool container * */ %include %fragment(SWIG_AsCheck_Sequence_frag(bool), "header") { SWIGINTERN int SWIG_AsCheck_Sequence_dec(bool)(SwigSciObject obj) { SciErr sciErr; int *piAddrVar; sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isBooleanType(pvApiCtx, piAddrVar)) { return SWIG_OK; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } } } %fragment(SWIG_AsGet_Sequence_frag(bool), "header", fragment="SWIG_SciBoolean_AsIntArrayAndSize") { SWIGINTERN int SWIG_AsGet_Sequence_dec(bool)(SwigSciObject obj, int **pSequence) { int iMatrixRowCount; int iMatrixColCount; return (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName())); } } %fragment(SWIG_AsSize_Sequence_frag(bool), "header", fragment="SWIG_SciBoolean_AsIntArrayAndSize") { SWIGINTERN int SWIG_AsSize_Sequence_dec(bool)(SwigSciObject obj, int *piSize) { int *piMatrix; int iMatrixRowCount; int iMatrixColCount; if (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) { if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } *piSize = iMatrixRowCount * iMatrixColCount; return SWIG_OK; } return SWIG_ERROR; } } %fragment(SWIG_FromCreate_Sequence_frag(bool), "header") { SWIGINTERN int SWIG_FromCreate_Sequence_dec(bool)(int size, int **pSequence) { *pSequence = new int[size]; return *pSequence != NULL ? SWIG_OK : SWIG_ERROR; } } %fragment(SWIG_FromSet_Sequence_frag(bool), "header", fragment="SWIG_SciBoolean_FromIntArrayAndSize") { SWIGINTERN SwigSciObject SWIG_FromSet_Sequence_dec(bool)(int size, int *pSequence) { SwigSciObject obj = SWIG_SciBoolean_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence); delete (int *)pSequence; return obj; } } %fragment(SWIG_AsVal_SequenceItem_frag(bool), "header") { SWIGINTERN bool SWIG_AsVal_SequenceItem_dec(bool)(SwigSciObject obj, int *pSequence, int iItemIndex) { return pSequence[iItemIndex]; } } %fragment(SWIG_From_SequenceItem_frag(bool), "header") { SWIGINTERN int SWIG_From_SequenceItem_dec(bool)(int *pSequence, int iItemIndex, bool itemValue) { pSequence[iItemIndex] = itemValue; return SWIG_OK; } } swig-3.0.8/Lib/scilab/scipointer.swg0000664000175000017500000000261212641054563017226 0ustar williamwilliam/* * POINTER */ %fragment("SWIG_ConvertPtr", "header") { #define SWIG_ConvertPtr(scilabValue, voidPointer, pointerDescriptor, flags) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, flags, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_NewPointerObj", "header") { #define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, flags) } /* * FUNCTION POINTER */ %fragment("SWIG_ConvertFunctionPtr", "header") { #define SWIG_ConvertFunctionPtr(scilabValue, voidPointer, pointerDescriptor) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, 0, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_NewFunctionPtrObj", "header") { #define SWIG_NewFunctionPtrObj(pointer, pointerDescriptor) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, 0) } // No fragment used here, the functions "SwigScilabPtrToObject" and "SwigScilabPtrFromObject" are defined in sciruntime.swg /* * C++ member pointers, ie, member methods */ %fragment("SWIG_NewMemberObj", "header") { #define SWIG_NewMemberObj(ptr, sz, tp) SWIG_Scilab_NewMemberObj(pvApiCtx, $result, ptr, sz, tp) } %fragment("SWIG_ConvertMember", "header") { #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Scilab_ConvertPacked(pvApiCtx, obj, ptr, sz, ty, SWIG_Scilab_GetFuncName()) } swig-3.0.8/Lib/scilab/std_container.i0000664000175000017500000000007412641054563017333 0ustar williamwilliam%include %include swig-3.0.8/Lib/scilab/std_except.i0000664000175000017500000000004312641054563016635 0ustar williamwilliam%include swig-3.0.8/Lib/scilab/sciarray.swg0000664000175000017500000000730612641054563016671 0ustar williamwilliam/* -------------------------------------------------------------------------- * * Arrays typemaps * * --------------------------------------------------------------------------*/ %{ #include %} %define %scilab_asarray_withallocatecopy(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPDATATYPE) %typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE { size_t i = 0; int iRows = 0; int iCols = 0; TEMPDATATYPE *pTempData = NULL; if (FRAGMENTNAME(pvApiCtx, $input, &iRows, &iCols, &pTempData, fname)) { return SWIG_ERROR; } $1 = ($1_ltype)MALLOC(sizeof($*1_ltype) * iRows * iCols); for (i = 0; i < iRows * iCols; i++) { $1[i] = ($*1_ltype) pTempData[i]; } } %enddef %define %scilab_asarrayandsize_withcopy(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPDATATYPE) %typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE { int iRows = 0; int iCols = 0; TEMPDATATYPE *pTempData = NULL; if (FRAGMENTNAME(pvApiCtx, $input, &iRows, &iCols, &pTempData, fname)) { return SWIG_ERROR; } if (iRows*iCols <= $1_dim0) { size_t i; for (i = 0; i < $1_dim0; i++) { $1[i] = ($*1_ltype) pTempData[i]; } } else { char errmsg[100]; sprintf(errmsg, "Size of input data (%d) is too big (maximum is %d)", iRows*iCols, $1_dim0); SWIG_exception_fail(SWIG_OverflowError, errmsg); } } %enddef %define %scilab_fromarrayandsize(TYPEMAPTYPE, FRAGMENTNAME, CTYPE) %typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE { %set_output(FRAGMENTNAME(pvApiCtx, $result, 1, $1_dim0, $1)); } %enddef %define %scilab_array_typemaps(CTYPE, ASARRAY_FRAGMENT, FROMARRAY_FRAGMENT, TEMPDATATYPE) %scilab_asarrayandsize_withcopy(varin, ASARRAY_FRAGMENT, CTYPE[ANY], TEMPDATATYPE); %scilab_asarray_withallocatecopy(in, ASARRAY_FRAGMENT, CTYPE[ANY], TEMPDATATYPE); %scilab_fromarrayandsize(varout, FROMARRAY_FRAGMENT, CTYPE[ANY]); %scilab_fromarrayandsize(out, FROMARRAY_FRAGMENT, CTYPE[ANY]); %apply SWIGTYPE[] { CTYPE[] }; %scilab_asarray_withallocatecopy(in, ASARRAY_FRAGMENT, CTYPE[], TEMPDATATYPE); %enddef // Double %scilab_array_typemaps(double, SWIG_SciDouble_AsDoubleArrayAndSize, SWIG_SciDouble_FromDoubleArrayAndSize, double); // Signed char %scilab_array_typemaps(signed char, SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize, SWIG_SciDouble_FromSignedCharArrayAndSize, signed char); // Unsigned char %scilab_array_typemaps(unsigned char, SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize, SWIG_SciDouble_FromUnsignedCharArrayAndSize, unsigned char); // Short %scilab_array_typemaps(short, SWIG_SciDoubleOrInt16_AsShortArrayAndSize, SWIG_SciDouble_FromShortArrayAndSize, short); // Unsigned short %scilab_array_typemaps(unsigned short, SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize, SWIG_SciDouble_FromUnsignedShortArrayAndSize, unsigned short); // Int %scilab_array_typemaps(int, SWIG_SciDoubleOrInt32_AsIntArrayAndSize, SWIG_SciDouble_FromIntArrayAndSize, int); // Unsigned int %scilab_array_typemaps(unsigned int, SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize, SWIG_SciDouble_FromUnsignedIntArrayAndSize, unsigned int); // Long %scilab_array_typemaps(long, SWIG_SciDoubleOrInt32_AsIntArrayAndSize, SWIG_SciDouble_FromLongArrayAndSize, int); // Unsigned long %scilab_array_typemaps(unsigned long, SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize, SWIG_SciDouble_FromUnsignedLongArrayAndSize, unsigned int); // Float %scilab_array_typemaps(float, SWIG_SciDouble_AsFloatArrayAndSize, SWIG_SciDouble_FromFloatArrayAndSize, float); // Bool %scilab_array_typemaps(bool, SWIG_SciBoolean_AsIntArrayAndSize, SWIG_SciBoolean_FromBoolArrayAndSize, int); // Char * %scilab_array_typemaps(char *, SWIG_SciString_AsCharPtrArrayAndSize, SWIG_SciString_FromCharPtrArrayAndSize, char *); swig-3.0.8/Lib/scilab/carrays.i0000664000175000017500000000020112641054563016133 0ustar williamwilliam%define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__) %enddef %include swig-3.0.8/Lib/scilab/scisequence.swg0000664000175000017500000001566312641054563017370 0ustar williamwilliam/* * * Scilab sequence conversions * */ #define SWIG_Traits_Sequence_frag(Type) %fragment_name(AsVal_Traits_Sequence, Type) #define SWIG_AsCheck_Sequence_frag(Type...) %fragment_name(AsCheck_Sequence, Type) #define SWIG_AsCheck_Sequence_dec(Type...) %symbol_name(AsCheck_Sequence, Type) #define SWIG_AsGet_Sequence_frag(Type...) %fragment_name(AsGet_Sequence, Type) #define SWIG_AsGet_Sequence_dec(Type...) %symbol_name(AsGet_Sequence, Type) #define SWIG_AsSize_Sequence_frag(Type...) %fragment_name(AsSize_Sequence, Type) #define SWIG_AsSize_Sequence_dec(Type...) %symbol_name(AsSize_Sequence, Type) #define SWIG_FromCreate_Sequence_frag(Type...) %fragment_name(FromCreate_Sequence, Type) #define SWIG_FromCreate_Sequence_dec(Type...) %symbol_name(FromCreate_Sequence, Type) #define SWIG_FromSet_Sequence_frag(Type...) %fragment_name(FromSet_Sequence, Type) #define SWIG_FromSet_Sequence_dec(Type...) %symbol_name(FromSet_Sequence, Type) #define SWIG_Traits_SequenceItem_frag(Type) %fragment_name(AsVal_Traits_SequenceItem, Type) #define SWIG_AsVal_SequenceItem_frag(Type...) %fragment_name(AsVal_SequenceItem, Type) #define SWIG_AsVal_SequenceItem_dec(Type...) %symbol_name(AsVal_SequenceItem, Type) #define SWIG_From_SequenceItem_frag(Type...) %fragment_name(From_SequenceItem, Type) #define SWIG_From_SequenceItem_dec(Type...) %symbol_name(From_SequenceItem, Type) %include %include %include %include %include %include // // Sequence conversion // %fragment(SWIG_Traits_Sequence_frag(ptr), "header", fragment=SWIG_AsCheck_Sequence_frag(ptr), fragment=SWIG_AsGet_Sequence_frag(ptr), fragment=SWIG_AsSize_Sequence_frag(ptr), fragment=SWIG_FromCreate_Sequence_frag(ptr), fragment=SWIG_FromSet_Sequence_frag(ptr), fragment="StdTraits", fragment="") { namespace swig { // Error returned for sequence containers of default item type template struct traits_as_sequence { static int check(SwigSciObject obj) { SWIG_Error(SWIG_TypeError, type_name()); } static int get(SwigSciObject obj, void **sequence) { SWIG_Error(SWIG_TypeError, type_name()); } static int size(SwigSciObject obj, int *size) { SWIG_Error(SWIG_TypeError, type_name()); } }; template struct traits_from_sequence { static int create(int size, void **sequence) { SWIG_Error(SWIG_TypeError, type_name()); } static SwigSciObject set(int size, void *sequence) { SWIG_Error(SWIG_TypeError, type_name()); } }; // Support sequence containers of pointers template struct traits_as_sequence { static int check(SwigSciObject obj) { return SWIG_AsCheck_Sequence_dec(ptr)(obj); } static int get(SwigSciObject obj, void **sequence) { return SWIG_AsGet_Sequence_dec(ptr)(obj, (int **)sequence); } static int size(SwigSciObject obj, int *size) { return SWIG_AsSize_Sequence_dec(ptr)(obj, size); } }; template struct traits_from_sequence { static int create(int size, void **sequence) { return SWIG_FromCreate_Sequence_dec(ptr)(size, (uintptr_t **)sequence); } static SwigSciObject set(int size, void *sequence) { return SWIG_FromSet_Sequence_dec(ptr)(size, (uintptr_t *)sequence); } }; } } %define %traits_sequence(CppType, ScilabType) %fragment(SWIG_Traits_Sequence_frag(CppType), "header", fragment=SWIG_Traits_Sequence_frag(ptr), fragment=SWIG_AsCheck_Sequence_frag(CppType), fragment=SWIG_AsGet_Sequence_frag(CppType), fragment=SWIG_AsSize_Sequence_frag(CppType), fragment=SWIG_FromCreate_Sequence_frag(CppType), fragment=SWIG_FromSet_Sequence_frag(CppType)) { namespace swig { template <> struct traits_as_sequence { static int check(SwigSciObject obj) { return SWIG_AsCheck_Sequence_dec(CppType)(obj); } static int get(SwigSciObject obj, void **sequence) { return SWIG_AsGet_Sequence_dec(CppType)(obj, (ScilabType **)sequence); } static int size(SwigSciObject obj, int *size) { return SWIG_AsSize_Sequence_dec(CppType)(obj, size); } }; template <> struct traits_from_sequence { static int create(int size, void **sequence) { return SWIG_FromCreate_Sequence_dec(CppType)(size, (ScilabType **)sequence); } static SwigSciObject set(int size, void *sequence) { return SWIG_FromSet_Sequence_dec(CppType)(size, (ScilabType *)sequence); } }; } } %enddef // // Sequence item conversion // %fragment(SWIG_Traits_SequenceItem_frag(ptr), "header", fragment=SWIG_AsVal_SequenceItem_frag(ptr), fragment=SWIG_From_SequenceItem_frag(ptr), fragment="StdTraits", fragment="") { namespace swig { // Error returned for sequence containers of default item type template struct traits_asval_sequenceitem { static T asval(SwigSciObject obj, void *pSequence, int iItemIndex) { SWIG_Error(SWIG_TypeError, type_name()); } }; template struct traits_from_sequenceitem { static int from(void *pSequence, int iItemIndex, T itemValue) { SWIG_Error(SWIG_TypeError, type_name()); } }; // Support sequence containers of pointers template struct traits_asval_sequenceitem { static T* asval(SwigSciObject obj, void *pSequence, int iItemIndex) { return static_cast(SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex)); } }; template struct traits_from_sequenceitem { static int from(void *pSequence, int iItemIndex, T *itemValue) { return SWIG_From_SequenceItem_dec(ptr)((uintptr_t *)pSequence, iItemIndex, (uintptr_t) itemValue); } }; } } %define %traits_sequenceitem(CppType, ScilabType) %fragment(SWIG_Traits_SequenceItem_frag(CppType), "header", fragment=SWIG_Traits_SequenceItem_frag(ptr), fragment=SWIG_AsVal_SequenceItem_frag(CppType), fragment=SWIG_From_SequenceItem_frag(CppType)) { namespace swig { template <> struct traits_asval_sequenceitem { static CppType asval(SwigSciObject obj, void *pSequence, int iItemIndex) { return SWIG_AsVal_SequenceItem_dec(CppType)(obj, (ScilabType *)pSequence, iItemIndex); } }; template <> struct traits_from_sequenceitem { static int from(void *pSequence, int iItemIndex, CppType itemValue) { return SWIG_From_SequenceItem_dec(CppType)((ScilabType *)pSequence, iItemIndex, itemValue); } }; } } %enddef %define %add_traits_sequence(CppType, ScilabType) %traits_sequence(CppType, ScilabType); %fragment(SWIG_Traits_Sequence_frag(CppType)); %traits_sequenceitem(CppType, ScilabType); %fragment(SWIG_Traits_SequenceItem_frag(CppType)); %enddef %add_traits_sequence(int, int); %add_traits_sequence(double, double); %add_traits_sequence(float, float); %add_traits_sequence(std::string, char*); %add_traits_sequence(bool, int); swig-3.0.8/Lib/scilab/scistdcommon.swg0000664000175000017500000001376012641054563017557 0ustar williamwilliam%fragment("StdTraits","header",fragment="StdTraitsCommon") { namespace swig { // Traits that provides the from method template struct traits_from_ptr { static SwigSciObject from(Type *val, int owner = 0) { return SWIG_OK; //SWIG_NewPointerObj(val, type_info(), owner); } }; template struct traits_from { static SwigSciObject from(const Type& val) { return traits_from_ptr::from(new Type(val), 1); } }; template struct traits_from { static SwigSciObject from(Type* val) { return traits_from_ptr::from(val, 0); } }; template struct traits_from { static SwigSciObject from(const Type* val) { return traits_from_ptr::from(const_cast(val), 0); } }; template inline SwigSciObject from(const Type& val) { return traits_from::from(val); } template inline SwigSciObject from_ptr(Type* val, int owner) { return traits_from_ptr::from(val, owner); } // Traits that provides the asval/as/check method template struct traits_asptr { static int asptr(const SwigSciObject& obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; } return res; } }; template inline int asptr(const SwigSciObject& obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } template struct traits_asval { static int asval(const SwigSciObject& obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); if (!SWIG_IsOK(res)) return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; if (SWIG_IsNewObj(res)){ %delete(p); res = SWIG_DelNewMask(res); } return res; } else { return SWIG_ERROR; } } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template struct traits_asval { static int asval(const SwigSciObject& obj, Type **val) { if (val) { typedef typename noconst_traits::noconst_type noconst_type; noconst_type *p = 0; int res = traits_asptr::asptr(obj, &p); if (SWIG_IsOK(res)) { *(const_cast(val)) = p; } return res; } else { return traits_asptr::asptr(obj, (Type **)(0)); } } }; template inline int asval(const SwigSciObject& obj, Type *val) { return traits_asval::asval(obj, val); } template struct traits_as { static Type as(const SwigSciObject& obj, bool throw_error) { Type v; int res = asval(obj, &v); if (SWIG_IsOK(res)) { return v; } else { %type_error(swig::type_name()); if (throw_error) throw std::invalid_argument("bad type"); return res; } } }; template struct traits_as { static Type as(const SwigSciObject& obj, bool throw_error) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { Type r(*v); %delete(v); return r; } else { return *v; } } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); %type_error(swig::type_name()); if (throw_error) throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } } }; template struct traits_as { static Type* as(const SwigSciObject& obj, bool throw_error) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res)) { return v; } else { %type_error(swig::type_name()); if (throw_error) throw std::invalid_argument("bad type"); return SWIG_OK; } } }; template inline Type as(const SwigSciObject& obj, bool te = false) { return traits_as::category>::as(obj, te); } template struct traits_check { static bool check(const SwigSciObject& obj) { int res = asval(obj, (Type *)(0)); return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { static bool check(const SwigSciObject& obj) { int res = asptr(obj, (Type **)(0)); return SWIG_IsOK(res) ? true : false; } }; template inline bool check(const SwigSciObject& obj) { return traits_check::category>::check(obj); } } } %define %specialize_std_container(Type,Check,As,From) %{ namespace swig { template <> struct traits_asval { typedef Type value_type; static int asval(const SwigSciObject& obj, value_type *val) { if (Check(obj)) { if (val) *val = As(obj); return SWIG_OK; } return SWIG_ERROR; } }; template <> struct traits_from { typedef Type value_type; static SwigSciObject from(const value_type& val) { return From(val); } }; template <> struct traits_check { static int check(const SwigSciObject& obj) { int res = Check(obj); return obj && res ? res : 0; } }; } %} %enddef #define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) #define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) swig-3.0.8/Lib/scilab/exception.i0000664000175000017500000000020212641054563016466 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), SWIG_Scilab_Error(code, msg);) } swig-3.0.8/Lib/scilab/std_alloc.i0000664000175000017500000000003412641054563016437 0ustar williamwilliam%include swig-3.0.8/Lib/scilab/std_deque.i0000664000175000017500000000144212641054563016454 0ustar williamwilliam/* * * C++ type : STL deque * Scilab type : matrix (for primitive types) or list (for pointer types) * */ %fragment("StdDequeTraits", "header", fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(const SwigSciObject &obj, std::deque **deq) { return traits_asptr_stdseq >::asptr(obj, deq); } }; template struct traits_from > { static SwigSciObject from(const std::deque& deq) { return traits_from_stdseq >::from(deq); } }; } %} #define %swig_deque_methods(Type...) %swig_sequence_methods(Type) #define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/scilab/std_common.i0000664000175000017500000000443412641054563016645 0ustar williamwilliam%include %include // Generate the traits for a 'primitive' type, such as 'double', // for which the SWIG_AsVal and SWIG_From methods are already defined. %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", fragment=SWIG_AsVal_frag(Type), fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } }; template <> struct traits_asval< Type > { typedef Type value_type; static int asval(SwigSciObject obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; template <> struct traits_from< Type > { typedef Type value_type; static SwigSciObject from(const value_type& val) { return SWIG_From(Type)(val); } }; } } %enddef /* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit instantiations required using %template). The STL containers define the 'front' method and the typemap below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from required in the generated code for enums. */ %define %traits_enum(Type...) %fragment("SWIG_Traits_enum_"{Type},"header", fragment=SWIG_AsVal_frag(int), fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { template <> struct traits_asval< Type > { typedef Type value_type; static int asval(SwigSciObject obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; template <> struct traits_from< Type > { typedef Type value_type; static SwigSciObject from(const value_type& val) { return SWIG_From(int)((int)val); } }; } } %typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} %enddef %include // // Generates the traits for all the known primitive // C++ types (int, double, ...) // %apply_cpptypes(%traits_ptypen); swig-3.0.8/Lib/scilab/scilab.swg0000664000175000017500000000022412641054563016301 0ustar williamwilliam%include %include %include %include %include swig-3.0.8/Lib/scilab/scimatrixdouble.swg0000664000175000017500000001102312641054563020241 0ustar williamwilliam/* * C-type: double array * Scilab type: double matrix */ %include // in (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT) %typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) { return SWIG_ERROR; } } // in (int IN_ROWCOUNT, int IN_COLCOUNT, double *IN) %typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, double *IN) { if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) { return SWIG_ERROR; } } // in (double *IN, int IN_SIZE) %typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_SIZE) (int rowCount, int colCount) { if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) { $2 = rowCount * colCount; } else { return SWIG_ERROR; } } // in (int IN_SIZE, double *IN) %typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_SIZE, double *IN) (int rowCount, int colCount) { if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) { $1 = rowCount * colCount; } else { return SWIG_ERROR; } } // out (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) %typemap(in, noblock=1, numinputs=0) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { } %typemap(arginit, noblock=1) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { $1 = (double**) malloc(sizeof(double*)); $2 = (int*) malloc(sizeof(int)); $3 = (int*) malloc(sizeof(int)); } %typemap(freearg, noblock=1) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { free(*$1); free($1); free($2); free($3); } %typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } // out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT) %typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT) { } %typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT) { $1 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int)); $3 = (double**) malloc(sizeof(double*)); } %typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int *IN_ROWCOUNT, int *IN_COLCOUNT, double **OUT) { if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT) { free($1); free($2); free(*$3); free($3); } // out (double **OUT, int *OUT_SIZE) %typemap(in, noblock=1, numinputs=0) (double **OUT, int *OUT_SIZE) { } %typemap(arginit, noblock=1) (double **OUT, int *OUT_SIZE) { $1 = (double**) malloc(sizeof(double*)); $2 = (int*) malloc(sizeof(int)); } %typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double **OUT, int *OUT_SIZE) { if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (double **OUT, int *OUT_SIZE) { free(*$1); free($1); free($2); } // out (int *OUT_SIZE, double **OUT) %typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, double **OUT) { } %typemap(arginit, noblock=1) (int *OUT_SIZE, double **OUT) { $1 = (int*) malloc(sizeof(int)); $2 = (double**) malloc(sizeof(double*)); } %typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int *OUT_SIZE, double **OUT) { if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int *OUT_SIZE, double **OUT) { free($1); free(*$2); free($2); } swig-3.0.8/Lib/scilab/scimatrixchar.swg0000664000175000017500000001201312641054563017704 0ustar williamwilliam/* * C-type: char* * Scilab type: string matrix */ %include // in (char **IN, int IN_ROWCOUNT, int IN_COLCOUNT) %typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (char **IN, int IN_ROWCOUNT, int IN_COLCOUNT) { if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) { return SWIG_ERROR; } } // in (int IN_ROWCOUNT, int IN_COLCOUNT, char **IN) %typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, char **IN) { if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) { return SWIG_ERROR; } } // in (char **IN, int IN_SIZE) %typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (char **IN, int IN_SIZE) (int rowCount, int colCount) { if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) { $2 = rowCount * colCount; } else { return SWIG_ERROR; } } // in (int IN_SIZE, char **IN) %typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_SIZE, char **IN) (int rowCount, int colCount) { if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) { $1 = rowCount * colCount; } else { return SWIG_ERROR; } } // out (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) %typemap(in, noblock=1, numinputs=0) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { } %typemap(arginit, noblock=1) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { $1 = (char***) malloc(sizeof(char**)); $2 = (int*) malloc(sizeof(int)); $3 = (int*) malloc(sizeof(int)); } %typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { { int i; for (i = 0; i < (*$2) * (*$3); i++) free((*$1)[i]); } free(*$1); free($1); free($2); free($3); } // out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT) %typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT) { } %typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT) { $1 = (char***) malloc(sizeof(char**)); $2 = (int*) malloc(sizeof(int)); $3 = (int**) malloc(sizeof(int*)); } %typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT) { if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT) { free($1); free($2); { int i; for (i = 0; i < (*$1) * (*$2); i++) free((*$3)[i]); } free(*$3); free($3); } // out (char ***OUT, int *OUT_SIZE) %typemap(in, noblock=1, numinputs=0) (char ***OUT, int *OUT_SIZE) { } %typemap(arginit, noblock=1) (char ***OUT, int *OUT_SIZE) { $1 = (char***) malloc(sizeof(char**)); $2 = (int*) malloc(sizeof(int)); } %typemap(freearg, noblock=1) (char ***OUT, int *OUT_SIZE) { { int i; for (i = 0; i < *$2; i++) free((*$1)[i]); } free(*$1); free($1); free($2); } %typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (char ***OUT, int *OUT_SIZE) { if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } // in (int IN_SIZE, char **IN) %typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_SIZE, char **IN) { if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, 1, &$1, &$2, fname) != SWIG_OK) { return SWIG_ERROR; } } // out (int *OUT_SIZE, char ***OUT) %typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, char ***OUT) { } %typemap(arginit, noblock=1) (int *OUT_SIZE, char ***OUT) { $1 = (int*) malloc(sizeof(int)); $2 = (char***) malloc(sizeof(char**)); } %typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (int *OUT_SIZE, char ***OUT) { if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int *OUT_SIZE, char ***OUT) { free($1); { int i; for (i = 0; i < *$1; i++) free((*$2)[i]); } free(*$2); free($2); } swig-3.0.8/Lib/scilab/scisequencefloat.swg0000664000175000017500000000534012641054563020405 0ustar williamwilliam/* * * Scilab matrix of float <-> C++ float container * */ %include %fragment(SWIG_AsCheck_Sequence_frag(float), "header") { SWIGINTERN int SWIG_AsCheck_Sequence_dec(float)(SwigSciObject obj) { SciErr sciErr; int *piAddrVar; sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isDoubleType(pvApiCtx, piAddrVar)) { return SWIG_OK; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A double is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } } } %fragment(SWIG_AsGet_Sequence_frag(float), "header", fragment="SWIG_SciDouble_AsFloatArrayAndSize") { SWIGINTERN int SWIG_AsGet_Sequence_dec(float)(SwigSciObject obj, float **pSequence) { int iMatrixRowCount; int iMatrixColCount; return (SWIG_SciDouble_AsFloatArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName())); } } %fragment(SWIG_AsSize_Sequence_frag(float), "header", fragment="SWIG_SciDouble_AsFloatArrayAndSize") { SWIGINTERN int SWIG_AsSize_Sequence_dec(float)(SwigSciObject obj, int *piSize) { float *pdblMatrix; int iMatrixRowCount; int iMatrixColCount; if (SWIG_SciDouble_AsFloatArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &pdblMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) { if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A float vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } *piSize = iMatrixRowCount * iMatrixColCount; return SWIG_OK; } return SWIG_ERROR; } } %fragment(SWIG_FromCreate_Sequence_frag(float), "header") { SWIGINTERN int SWIG_FromCreate_Sequence_dec(float)(int size, float **pSequence) { *pSequence = new float[size]; return *pSequence != NULL ? SWIG_OK : SWIG_ERROR; } } %fragment(SWIG_FromSet_Sequence_frag(float), "header", fragment="SWIG_SciDouble_FromFloatArrayAndSize") { SWIGINTERN SwigSciObject SWIG_FromSet_Sequence_dec(float)(int size, float *pSequence) { SwigSciObject obj = SWIG_SciDouble_FromFloatArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence); delete (float *)pSequence; return obj; } } %fragment(SWIG_AsVal_SequenceItem_frag(float), "header") { SWIGINTERN float SWIG_AsVal_SequenceItem_dec(float)(SwigSciObject obj, float *pSequence, int iItemIndex) { return pSequence[iItemIndex]; } } %fragment(SWIG_From_SequenceItem_frag(float), "header") { SWIGINTERN int SWIG_From_SequenceItem_dec(float)(float *pSequence, int iItemIndex, float itemValue) { pSequence[iItemIndex] = itemValue; return SWIG_OK; } } swig-3.0.8/Lib/scilab/sciprimtypes.swg0000664000175000017500000000062612641054563017605 0ustar williamwilliam%include %include %include %include %include %include %include %include %include %include %include %include %include %include %include swig-3.0.8/Lib/scilab/std_list.i0000664000175000017500000000141712641054563016326 0ustar williamwilliam/* * * C++ type : STL list * Scilab type : matrix (for primitive types) or list (for pointer types) * */ %fragment("StdListTraits", "header", fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(SwigSciObject obj, std::list **lis) { return traits_asptr_stdseq >::asptr(obj, lis); } }; template struct traits_from > { static SwigSciObject from(const std::list &lis) { return traits_from_stdseq >::from(lis); } }; } %} #define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/scilab/matrix.i0000664000175000017500000000022512641054563016001 0ustar williamwilliam/* * Matrix typemaps * */ %include %include %include %include swig-3.0.8/Lib/scilab/scimacros.swg0000664000175000017500000000041212641054563017026 0ustar williamwilliam #define %scilabconst(flag) %feature("scilab:const","flag") // Create Scilab variable #define SWIG_CreateScilabVariable_frag(Type...) %fragment_name(CreateScilabVariable, Type) #define SWIG_CreateScilabVariable_dec(Type...) %symbol_name(CreateScilabVariable, Type) swig-3.0.8/Lib/scilab/std_basic_string.i0000664000175000017500000000233212641054563020017 0ustar williamwilliam/* * C++: basic_string * Scilab: string */ #define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) %fragment(SWIG_AsPtr_frag(std::basic_string), "header", fragment="SWIG_SciString_AsCharPtrAndLength") { SWIGINTERN int SWIG_AsPtr_dec(std::basic_string)(int _iVar, std::basic_string **_pstValue) { char* buf = 0; size_t len = 0; int alloc = SWIG_OLDOBJ; if (SWIG_IsOK((SWIG_SciString_AsCharPtrAndSize(pvApiCtx, _iVar, &buf, &len, &alloc, SWIG_Scilab_GetFuncName())))) { if (buf) { if (_pstValue) { *_pstValue = new std::string(buf, len - 1); sciprint("%s\n", (*_pstValue)->c_str()); } if (alloc == SWIG_NEWOBJ) { delete[] buf; } return SWIG_NEWOBJ; } else { if (_pstValue) { *_pstValue = NULL; } return SWIG_OLDOBJ; } } else { return SWIG_ERROR; } } } %fragment(SWIG_From_frag(std::basic_string), "header", fragment="SWIG_SciString_FromCharPtr") { SWIGINTERN int SWIG_From_dec(std::basic_string)(std::basic_string _pstValue) { return SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), _pstValue.c_str()); } } %include swig-3.0.8/Lib/scilab/scilonglong.swg0000664000175000017500000000446212641054563017372 0ustar williamwilliam/* * C-type: long long * Scilab 5 type: NONE * Scilab 6 type: int64 */ %fragment(SWIG_AsVal_frag(long long), "header", fragment="SWIG_SciInt64_ToLongLong") { %#define SWIG_AsVal_long_SS_long(scilabValue, valuePointer) SWIG_SciInt64_ToLongLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciInt64_ToLongLong", "header") { SWIGINTERN int SWIG_SciInt64_ToLongLong(void *pvApiCtx, int iVar, long long *pllValue, char *fname) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciInt64_ToLongLong", "int64"); return SWIG_ERROR; } } %fragment(SWIG_From_frag(long long), "header", fragment="SWIG_SciInt64_FromLongLong") { #define SWIG_From_long_SS_long(value) SWIG_SciInt64_FromLongLong(pvApiCtx, $result, value) } %fragment("SWIG_SciInt64_FromLongLong", "header") { SWIGINTERN int SWIG_SciInt64_FromLongLong(void *pvApiCtx, int iVarOut, long long llValue) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciInt64_ToLongLong", "int64"); return SWIG_ERROR; } } /* * C-type: unsigned long long * Scilab 5 type: NONE * Scilab 6 type: uint64 */ %fragment(SWIG_AsVal_frag(unsigned long long), "header", fragment="SWIG_SciUint64_ToUnsignedLongLong") { #define SWIG_AsVal_unsigned_SS_long_SS_long(scilabValue, valuePointer) SWIG_SciUint64_ToUnsignedLongLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciUint64_ToUnsignedLongLong", "header") { SWIGINTERN int SWIG_SciUint64_ToUnsignedLongLong(void *pvApiCtx, int iVar, unsigned long long *pullValue, char *fname) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciUint64_ToLongLong", "uint64"); return SWIG_ERROR; } } %fragment(SWIG_From_frag(unsigned long long), "header", fragment="SWIG_SciUint64_FromUnsignedLongLong") { #define SWIG_From_unsigned_SS_long_SS_long(value) SWIG_SciUint64_FromUnsignedLongLong(pvApiCtx, $result, value) } %fragment("SWIG_SciUint64_FromUnsignedLongLong", "header") { SWIGINTERN int SWIG_SciUint64_FromUnsignedLongLong(void *pvApiCtx, int iVarOut, unsigned long long llValue) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciUint64_ToLongLong", "uint64"); return SWIG_ERROR; } } swig-3.0.8/Lib/scilab/scisequencepointer.swg0000664000175000017500000000551712641054563020766 0ustar williamwilliam/* * * Scilab list of pointer <-> C++ pointer container * */ %include %fragment("", "header") { %#include } %fragment(SWIG_AsCheck_Sequence_frag(ptr), "header", fragment="SWIG_ScilabList") { SWIGINTERN int SWIG_AsCheck_Sequence_dec(ptr)(SwigSciObject obj) { return SWIG_CheckScilabList(obj); } } %fragment(SWIG_AsGet_Sequence_frag(ptr), "header", fragment="SWIG_ScilabList") { SWIGINTERN int SWIG_AsGet_Sequence_dec(ptr)(SwigSciObject obj, int **piSequence) { return SWIG_GetScilabList(obj, piSequence); } } %fragment(SWIG_AsSize_Sequence_frag(ptr), "header", fragment="SWIG_ScilabList") { SWIGINTERN int SWIG_AsSize_Sequence_dec(ptr)(SwigSciObject obj, int *piSize) { return SWIG_GetScilabListSize(obj, piSize); } } %fragment(SWIG_FromCreate_Sequence_frag(ptr), "header", fragment="") { SWIGINTERN int SWIG_FromCreate_Sequence_dec(ptr)(int size, uintptr_t **pSequence) { *pSequence = new uintptr_t[size]; return *pSequence != NULL ? SWIG_OK : SWIG_ERROR; } } %fragment(SWIG_FromSet_Sequence_frag(ptr), "header", fragment="") { SWIGINTERN SwigSciObject SWIG_FromSet_Sequence_dec(ptr)(int size, uintptr_t *pSequence) { SciErr sciErr; int *piListAddr; int iVarOut = SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition(); sciErr = createList(pvApiCtx, iVarOut, size, &piListAddr); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } for (int i=0; i swig-3.0.8/Lib/scilab/std_map.i0000664000175000017500000000400312641054563016122 0ustar williamwilliam// // SWIG typemaps for std::map // // Common implementation %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.8/Lib/scilab/scibool.swg0000664000175000017500000000776712641054563016521 0ustar williamwilliam/* * C-type: bool * Scilab type: boolean scalar */ %fragment(SWIG_AsVal_frag(bool), "header") { SWIGINTERN int SWIG_AsVal_dec(bool)(SwigSciObject iVar, bool *pbValue) { SciErr sciErr; int iRet = 0; int *piAddrVar = NULL; int iTempValue = 0; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (!isBooleanType(pvApiCtx, piAddrVar)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), SWIG_Scilab_GetFuncName(), iVar); return SWIG_ERROR; } if (!isScalar(pvApiCtx, piAddrVar)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A boolean expected.\n"), SWIG_Scilab_GetFuncName(), iVar); return SWIG_ERROR; } iRet = getScalarBoolean(pvApiCtx, piAddrVar, &iTempValue); if (iRet) { return SWIG_ERROR; } *pbValue = iTempValue; return SWIG_OK; } } %fragment(SWIG_From_frag(bool), "header") { SWIGINTERN int SWIG_From_dec(bool)(bool bValue) { if (createScalarBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition(), bValue)) return SWIG_ERROR; return SWIG_OK; } } /* * C-type: bool[] * Scilab type: boolean matrix */ %fragment("SWIG_SciBoolean_AsBoolArrayAndSize", "header") { SWIGINTERN int SWIG_SciBoolean_AsBoolArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, bool **pbValue, char *fname) { SciErr sciErr; int *piAddrVar = NULL; int *piValue = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isBooleanType(pvApiCtx, piAddrVar)) { int i; sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, &piValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } *pbValue = (bool*) malloc((*iRows) * (*iCols) * sizeof(bool)); for (i = 0; i < (*iRows) * (*iCols); i++) (*pbValue)[i] = piValue[i] != 0; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciBoolean_FromBoolArrayAndSize", "header") { SWIGINTERN int SWIG_SciBoolean_FromBoolArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, bool *pbValue) { SciErr sciErr; int *piValue = NULL; int i; piValue = (int*) malloc(iRows * iCols * sizeof(int)); for (i = 0; i < iRows * iCols; i++) piValue[i] = pbValue[i]; sciErr = createMatrixOfBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, piValue); if(sciErr.iErr) { printError(&sciErr, 0); free(piValue); return SWIG_ERROR; } free(piValue); return SWIG_OK; } } /* * C-type: int[] * Scilab type: boolean matrix */ %fragment("SWIG_SciBoolean_AsIntArrayAndSize", "header") { SWIGINTERN int SWIG_SciBoolean_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, int **piValue, char *fname) { SciErr sciErr; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isBooleanType(pvApiCtx, piAddrVar)) { int i; sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, piValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciBoolean_FromIntArrayAndSize", "header") { SWIGINTERN int SWIG_SciBoolean_FromIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, int *piValue) { SciErr sciErr; sciErr = createMatrixOfBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, piValue); if(sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } } swig-3.0.8/Lib/scilab/scilong.swg0000664000175000017500000000775012641054563016515 0ustar williamwilliam/* * C-type: long * Scilab type: double or int32 */ %fragment(SWIG_AsVal_frag(long), "header", fragment="SWIG_SciDoubleOrInt32_AsLong", fragment="") { %#define SWIG_AsVal_long(scilabValue, valuePointer) SWIG_SciDoubleOrInt32_AsLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()); } %fragment("SWIG_SciDoubleOrInt32_AsLong", "header") { SWIGINTERN int SWIG_SciDoubleOrInt32_AsLong(void *pvApiCtx, SwigSciObject iVar, long *plValue, char *fname) { SciErr sciErr; int iType = 0; int iRows = 0; int iCols = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_ints) { int iPrec = 0; int *piData = NULL; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_INT32) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } *plValue = (long) *piData; } else if (iType == sci_matrix) { double *pdData = NULL; double dValue = 0.0f; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } dValue = *pdData; if (dValue != floor(dValue)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar); return SWIG_ValueError; } if ((dValue < LONG_MIN) || (dValue > LONG_MAX)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar); return SWIG_OverflowError; } *plValue = (long) dValue; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } return SWIG_OK; } } %fragment(SWIG_From_frag(long), "header", fragment="SWIG_SciDouble_FromLong") { %#define SWIG_From_long(scilabValue) SWIG_SciDouble_FromLong(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDouble_FromLong", "header") { SWIGINTERN int SWIG_SciDouble_FromLong(void *pvApiCtx, int iVarOut, long lValue, char *fname) { if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) lValue)) return SWIG_ERROR; return SWIG_OK; } } %fragment("SWIG_SciDouble_FromLongArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromLongArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const long *plData) { SciErr sciErr; int i; double *pdValues = NULL; pdValues = (double*) malloc(iRows * iCols * sizeof(double)); for (i=0; i struct traits_asptr > { static int asptr(const SwigSciObject &obj, std::set **set) { return traits_asptr_stdseq >::asptr(obj, set); } }; template struct traits_from > { static SwigSciObject from(const std::set& set) { return traits_from_stdseq >::from(set); } }; } %} #define %swig_set_methods(Type...) %swig_sequence_methods(Type) #define %swig_set_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/scilab/scimisctypes.swg0000664000175000017500000000417112641054563017570 0ustar williamwilliam// Other primitive such as size_t and ptrdiff_t /* * C-type: size_t * Scilab type: double or int32 */ %fragment(SWIG_AsVal_frag(size_t), "header", fragment="SWIG_Int_AsSize") { %#define SWIG_AsVal_size_t(scilabValue, valuePointer) SWIG_Int_AsSize(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_Int_AsSize", "header", fragment=SWIG_AsVal_frag(int)) { SWIGINTERN int SWIG_Int_AsSize(void *pvApiCtx, SwigSciObject iVar, size_t *piValue, char *fname) { int iValue = 0; if (SWIG_AsVal_dec(int)(iVar, &iValue) != SWIG_OK) return SWIG_ERROR; if (piValue) *piValue = (size_t) iValue; return SWIG_OK; } } %fragment(SWIG_From_frag(size_t), "header", fragment="SWIG_Int_FromSize") { %#define SWIG_From_size_t(scilabValue) SWIG_Int_FromSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_Int_FromSize", "header", fragment=SWIG_From_frag(int)) { SWIGINTERN int SWIG_Int_FromSize(void *pvApiCtx, int iVarOut, size_t iValue, char *fname) { return SWIG_From_dec(int)((int)iValue); } } /* * C-type: ptrdiff_t * Scilab type: double or int32 */ %fragment(SWIG_AsVal_frag(ptrdiff_t), "header", fragment="SWIG_Int_AsPtrDiff") { %#define SWIG_AsVal_ptrdiff_t(scilabValue, valuePointer) SWIG_Int_AsPtrDiff(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_Int_AsPtrDiff", "header", fragment=SWIG_AsVal_frag(int)) { SWIGINTERN int SWIG_Int_AsPtrDiff(void *pvApiCtx, SwigSciObject iVar, ptrdiff_t *piValue, char *fname) { int iValue = 0; if (SWIG_AsVal_dec(int)(iVar, &iValue) != SWIG_OK) return SWIG_ERROR; if (piValue) *piValue = (ptrdiff_t) iValue; return SWIG_OK; } } %fragment(SWIG_From_frag(ptrdiff_t), "header", fragment="SWIG_Int_FromPtrDiff") { %#define SWIG_From_ptrdiff_t(scilabValue) SWIG_Int_FromPtrDiff(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_Int_FromPtrDiff", "header", fragment=SWIG_From_frag(int)) { SWIGINTERN int SWIG_Int_FromPtrDiff(void *pvApiCtx, int iVarOut, ptrdiff_t iValue, char *fname) { return SWIG_From_dec(int)((int)iValue); } } swig-3.0.8/Lib/scilab/scienum.swg0000664000175000017500000000217412641054563016515 0ustar williamwilliam/* * C-type: enum * Scilab type: double or int32 */ %fragment(SWIG_AsVal_frag(Enum), "header", fragment="SWIG_Int_AsEnum") { %#define SWIG_AsVal_Enum(scilabValue, valuePointer) SWIG_Int_AsEnum(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_Int_AsEnum", "header", fragment="SWIG_SciDoubleOrInt32_AsInt") { SWIGINTERN int SWIG_Int_AsEnum(void *pvApiCtx, int iVar, int *enumValue, char *fname) { int iValue = 0; if (SWIG_SciDoubleOrInt32_AsInt(pvApiCtx, iVar, &iValue, fname) != SWIG_OK) return SWIG_ERROR; *enumValue = iValue; return SWIG_OK; } } %fragment(SWIG_From_frag(Enum), "header", fragment="SWIG_Int_FromEnum") { %#define SWIG_From_Enum(scilabValue) SWIG_Int_FromEnum(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_Int_FromEnum", "header", fragment="SWIG_SciDouble_FromInt") { SWIGINTERN int SWIG_Int_FromEnum(void *pvApiCtx, int iVarOut, int enumValue, char *fname) { if (SWIG_SciDouble_FromInt(pvApiCtx, iVarOut, enumValue, fname) != SWIG_OK) return SWIG_ERROR; SWIG_Scilab_SetOutput(pvApiCtx, iVarOut); return SWIG_OK; } } swig-3.0.8/Lib/scilab/scisequencedouble.swg0000664000175000017500000000540312641054563020552 0ustar williamwilliam/* * * Scilab matrix of double <-> C++ double container * */ %include %fragment(SWIG_AsCheck_Sequence_frag(double), "header") { SWIGINTERN int SWIG_AsCheck_Sequence_dec(double)(SwigSciObject obj) { SciErr sciErr; int *piAddrVar; sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isDoubleType(pvApiCtx, piAddrVar)) { return SWIG_OK; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A double is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } } } %fragment(SWIG_AsGet_Sequence_frag(double), "header", fragment="SWIG_SciDouble_AsDoubleArrayAndSize") { SWIGINTERN int SWIG_AsGet_Sequence_dec(double)(SwigSciObject obj, double **pSequence) { int iMatrixRowCount; int iMatrixColCount; return (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName())); } } %fragment(SWIG_AsSize_Sequence_frag(double), "header", fragment="SWIG_SciDouble_AsDoubleArrayAndSize") { SWIGINTERN int SWIG_AsSize_Sequence_dec(double)(SwigSciObject obj, int *piSize) { double *pdblMatrix; int iMatrixRowCount; int iMatrixColCount; if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &pdblMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) { if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A double vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } *piSize = iMatrixRowCount * iMatrixColCount; return SWIG_OK; } return SWIG_ERROR; } } %fragment(SWIG_FromCreate_Sequence_frag(double), "header") { SWIGINTERN int SWIG_FromCreate_Sequence_dec(double)(int size, double **pSequence) { *pSequence = new double[size]; return *pSequence != NULL ? SWIG_OK : SWIG_ERROR; } } %fragment(SWIG_FromSet_Sequence_frag(double), "header", fragment="SWIG_SciDouble_FromDoubleArrayAndSize") { SWIGINTERN SwigSciObject SWIG_FromSet_Sequence_dec(double)(int size, double *pSequence) { SwigSciObject obj = SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence); delete (double *)pSequence; return obj; } } %fragment(SWIG_AsVal_SequenceItem_frag(double), "header") { SWIGINTERN double SWIG_AsVal_SequenceItem_dec(double)(SwigSciObject obj, double *pSequence, int iItemIndex) { return pSequence[iItemIndex]; } } %fragment(SWIG_From_SequenceItem_frag(double), "header") { SWIGINTERN int SWIG_From_SequenceItem_dec(double)(double *pSequence, int iItemIndex, double itemValue) { pSequence[iItemIndex] = itemValue; return SWIG_OK; } } swig-3.0.8/Lib/scilab/scirun.swg0000664000175000017500000002164112641054563016355 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Scilab support runtime * -----------------------------------------------------------------------------*/ /* Scilab version macro */ #include "version.h" #define SWIG_SCILAB_VERSION (SCI_VERSION_MAJOR * 100) + (SCI_VERSION_MINOR * 10) + SCI_VERSION_MAINTENANCE /* Scilab standard headers */ #ifdef __cplusplus extern "C" { #endif #include "api_scilab.h" #if SWIG_SCILAB_VERSION < 540 #define __USE_DEPRECATED_STACK_FUNCTIONS__ #include "stack-c.h" #endif #include "MALLOC.h" #include "Scierror.h" #include "localization.h" #include "freeArrayOfString.h" #include #include #ifdef __cplusplus } #endif /* Gateway signature */ #if SWIG_SCILAB_VERSION >= 600 #define SWIG_GatewayParameters char* fname, void *pvApiCtx #define SWIG_GatewayArguments fname, pvApiCtx #else #define SWIG_GatewayParameters char* fname, unsigned long fname_len #define SWIG_GatewayArguments fname, fname_len #endif /* Function name management functions */ #include static char *SwigFuncName = NULL; static char *SWIG_Scilab_GetFuncName(void) { return SwigFuncName; } static void SWIG_Scilab_SetFuncName(char *funcName) { if (SwigFuncName != NULL) { free(SwigFuncName); } SwigFuncName = strdup(funcName); } /* Api context management functions */ #if SWIG_SCILAB_VERSION >= 600 static void *pvApiCtx = NULL; static void SWIG_Scilab_SetApiContext(void *apiCtx) { pvApiCtx = apiCtx; } #else #define SWIG_Scilab_SetApiContext(apiCtx) #endif /* Argument management functions */ #if SWIG_SCILAB_VERSION >= 540 #define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) #define SWIG_CheckInputArgumentAtLeast(pvApiCtx, minInputArgument) CheckInputArgumentAtLeast(pvApiCtx, minInputArgument) #define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) #define SWIG_NbInputArgument(pvApiCtx) nbInputArgument(pvApiCtx) #define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) AssignOutputVariable(pvApiCtx, outputArgumentPos) = argumentPos #else #define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckRhs(minInputArgument, maxInputArgument) #define SWIG_CheckInputArgumentAtLeast(pvApiCtx, minInputArgument) CheckRhs(minInputArgument, 256) #define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckLhs(minOutputArgument, maxOutputArgument) #define SWIG_NbInputArgument(pvApiCtx) Rhs #define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) LhsVar(outputArgumentPos) = argumentPos #endif typedef int SwigSciObject; static int SwigOutputPosition = -1; static int SWIG_Scilab_GetOutputPosition(void) { return SwigOutputPosition; } static void SWIG_Scilab_SetOutputPosition(int outputPosition) { SwigOutputPosition = outputPosition; } SWIGRUNTIME int SWIG_Scilab_SetOutput(void *pvApiCtx, SwigSciObject output) { int outputPosition = SWIG_Scilab_GetOutputPosition(); if (outputPosition < 0) return SWIG_ERROR; SWIG_AssignOutputArgument(pvApiCtx, outputPosition, SWIG_NbInputArgument(pvApiCtx) + outputPosition); return SWIG_OK; } /* Pointer conversion functions */ SWIGINTERN int SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pObjValue, swig_type_info *descriptor, int flags, char *fname) { SciErr sciErr; int iType = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_pointer) { sciErr = getPointer(pvApiCtx, piAddrVar, pObjValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { return SWIG_ERROR; } return SWIG_OK; } SWIGRUNTIMEINLINE int SwigScilabPtrFromObject(void *pvApiCtx, int iVarOut, void *obj, swig_type_info *descriptor, int flags) { SciErr sciErr; sciErr = createPointer(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (void *)obj); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } SWIGRUNTIME int SWIG_Scilab_ConvertPacked(void *pvApiCtx, int iVar, void *ptr, int sz, swig_type_info *ty, char *fname) { swig_cast_info *tc; int *piAddrVar = NULL; char *pstString = NULL; char *pstStringPtr = NULL; SciErr sciErr; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (getAllocatedSingleString(pvApiCtx, piAddrVar, &pstString)) { return SWIG_ERROR; } /* Pointer values must start with leading underscore */ if (*pstString != '_') { freeAllocatedSingleString(pstString); return SWIG_ERROR; } pstStringPtr = pstString; pstStringPtr++; pstStringPtr = (char*)SWIG_UnpackData(pstStringPtr, ptr, sz); if (ty) { if (!pstStringPtr) { freeAllocatedSingleString(pstString); return SWIG_ERROR; } tc = SWIG_TypeCheck(pstStringPtr, ty); if (!tc) { freeAllocatedSingleString(pstString); return SWIG_ERROR; } } freeAllocatedSingleString(pstString); return SWIG_OK; } SWIGRUNTIME int SWIG_Scilab_NewMemberObj(void *pvApiCtx, int iVarOut, void *ptr, int sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 1 + strlen(type->name)) > 1000) { return SWIG_ERROR; } *(r++) = '_'; r = SWIG_PackData(r, ptr, sz); strcpy(r, type->name); if (createSingleString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, &result[0])) return SWIG_ERROR; return SWIG_OK; } /* Error functions */ #define SCILAB_API_ARGUMENT_ERROR 999 SWIGINTERN const char* SWIG_Scilab_ErrorType(int code) { switch(code) { case SWIG_MemoryError: return "MemoryError"; case SWIG_IOError: return "IOError"; case SWIG_RuntimeError: return "RuntimeError"; case SWIG_IndexError: return "IndexError"; case SWIG_TypeError: return "TypeError"; case SWIG_DivisionByZero: return "ZeroDivisionError"; case SWIG_OverflowError: return "OverflowError"; case SWIG_SyntaxError: return "SyntaxError"; case SWIG_ValueError: return "ValueError"; case SWIG_SystemError: return "SystemError"; case SWIG_AttributeError: return "AttributeError"; default: return "RuntimeError"; } } #define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code) #ifndef SWIG_SCILAB_ERROR #define SWIG_SCILAB_ERROR 20000 #endif SWIGINTERN void SWIG_Scilab_Error(int code, const char *msg) { Scierror(SWIG_SCILAB_ERROR - code, _("SWIG/Scilab: %s: %s\n"), SWIG_Scilab_ErrorType(code), msg); } #define SWIG_Error(code, msg) SWIG_Scilab_Error(code, msg) #define SWIG_fail return SWIG_ERROR; SWIGRUNTIME void SWIG_Scilab_Raise_Ex(const char *obj, const char *type, swig_type_info *descriptor) { if (type) { if (obj) Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured: %s\n", type, obj); else Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type); } } SWIGRUNTIME void SWIG_Scilab_Raise(const int obj, const char *type, swig_type_info *descriptor) { Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type); } /* * Pointer utility functions */ #include #ifdef __cplusplus extern "C" #endif int SWIG_this(SWIG_GatewayParameters) { void *ptrValue = NULL; if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) { SWIG_Scilab_SetOutputPosition(1); return SWIG_Scilab_SetOutput(pvApiCtx, createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + 1, (double)(uintptr_t)ptrValue)); } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The value is not a pointer.\n"), fname, 1); return SWIG_ERROR; } } #ifdef __cplusplus extern "C" #endif int SWIG_ptr(SWIG_GatewayParameters) { double dValue = 0; int *piAddr; SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if(sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (getScalarDouble(pvApiCtx, piAddr, &dValue) == 0) { if (dValue != (uintptr_t)dValue) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1); return SWIG_ValueError; } if ((dValue < 0) || (dValue > ULONG_MAX)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1); return SWIG_OverflowError; } SWIG_Scilab_SetOutputPosition(1); return SWIG_Scilab_SetOutput(pvApiCtx, SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0)); } else { return SWIG_ERROR; } } swig-3.0.8/Lib/scilab/scisignedchar.swg0000664000175000017500000001354212641054563017661 0ustar williamwilliam/* * C-type: signed char * Scilab type: double or int8 */ %fragment(SWIG_AsVal_frag(signed char), "header", fragment="SWIG_SciDoubleOrInt8_AsSignedChar", fragment="") { #define SWIG_AsVal_signed_SS_char(scilabValue, valuePointer) SWIG_SciDoubleOrInt8_AsSignedChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDoubleOrInt8_AsSignedChar", "header") { SWIGINTERN int SWIG_SciDoubleOrInt8_AsSignedChar(void *pvApiCtx, int iVar, signed char *pscValue, char *fname) { SciErr sciErr; int iType = 0; int iRows = 0; int iCols = 0; int iPrec = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_ints) { char *pcData = NULL; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_INT8) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } sciErr = getMatrixOfInteger8(pvApiCtx, piAddrVar, &iRows, &iCols, &pcData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } *pscValue = *pcData; } else if (iType == sci_matrix) { double *pdData = NULL; double dValue = 0.0f; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } dValue = *pdData; if (dValue != floor(dValue)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 8-bit signed integer.\n"), fname, iVar); return SWIG_ValueError; } if ((dValue < SCHAR_MIN) || (dValue > SCHAR_MAX)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 8-bit signed integer.\n"), fname, iVar); return SWIG_OverflowError; } *pscValue = (signed char) dValue; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } return SWIG_OK; } } %fragment(SWIG_From_frag(signed char), "header", fragment="SWIG_SciDouble_FromSignedChar") { #define SWIG_From_signed_SS_char(scilabValue) SWIG_SciDouble_FromSignedChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue) } %fragment("SWIG_SciDouble_FromSignedChar", "header") { SWIGINTERN int SWIG_SciDouble_FromSignedChar(void *pvApiCtx, int iVarOut, signed char scValue) { if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) scValue)) return SWIG_ERROR; return SWIG_OK; } } /* * C-type: signed char[] * Scilab type: double or int8 matrix */ %fragment("SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize", "header") { SWIGINTERN int SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, signed char **pscValue, char *fname) { SciErr sciErr; int iType = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_matrix) { double *pdData = NULL; int size = 0; int i; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } size = (*iRows) * (*iCols); *pscValue = (signed char*) malloc(size * sizeof(int*)); for (i = 0; i < size; i++) (*pscValue)[i] = (signed char) pdData[i]; } else if (iType == sci_ints) { int iPrec = 0; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_INT8) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double matrix expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfInteger8(pvApiCtx, piAddrVar, iRows, iCols, (char **)pscValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double matrix expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciDouble_FromSignedCharArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromSignedCharArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const signed char *pscValue) { SciErr sciErr; int i; double *pdValues = NULL; pdValues = (double*) malloc(iRows * iCols * sizeof(double)); for (i=0; i swig-3.0.8/Lib/scilab/sciunsignedlong.swg0000664000175000017500000000357512641054563020253 0ustar williamwilliam/* * C-type: unsigned long * Scilab type: see unsigned int */ %fragment(SWIG_AsVal_frag(unsigned long), "header", fragment="SWIG_UnsignedInt_AsUnsignedLong") { #define SWIG_AsVal_unsigned_SS_long(scilabValue, valuePointer) SWIG_UnsignedInt_AsUnsignedLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_UnsignedInt_AsUnsignedLong", "header", fragment=SWIG_AsVal_frag(unsigned int)) { SWIGINTERN int SWIG_UnsignedInt_AsUnsignedLong(void *pvApiCtx, SwigSciObject iVar, unsigned long *pulValue, char *fname) { unsigned int uiValue = 0; if(SWIG_AsVal_unsigned_SS_int(iVar, &uiValue) != SWIG_OK) { return SWIG_ERROR; } *pulValue = (unsigned long) uiValue; return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned long), "header", fragment="SWIG_UnsignedInt_FromUnsignedLong") { #define SWIG_From_unsigned_SS_long(scilabValue) SWIG_UnsignedInt_FromUnsignedLong(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_UnsignedInt_FromUnsignedLong", "header", fragment=SWIG_From_frag(unsigned int)) { SWIGINTERN int SWIG_UnsignedInt_FromUnsignedLong(void *pvApiCtx, int iVarOut, unsigned long ulValue, char *fname) { return SWIG_From_unsigned_SS_int((unsigned int)ulValue); } } %fragment("SWIG_SciDouble_FromUnsignedLongArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromUnsignedLongArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const unsigned long *pulValues) { SciErr sciErr; double *pdValues = NULL; int i; pdValues = (double*) malloc(iRows * iCols * sizeof(double)); for (i=0; i %include %include %include %include swig-3.0.8/Lib/scilab/boost_shared_ptr.i0000664000175000017500000003744412641054563020053 0ustar williamwilliam%include // Set SHARED_PTR_DISOWN to $disown if required, for example // #define SHARED_PTR_DISOWN $disown #if !defined(SHARED_PTR_DISOWN) #define SHARED_PTR_DISOWN 0 #endif // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(out) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } if (!argp) { %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); } } %typemap(varout) CONST TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE * { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = %const_cast(tempshared.get(), $1_ltype); } else { $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) CONST TYPE & { void *argp = 0; int newmem = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; if (!argp) { %variable_nullref("$type", "$name"); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); $1 = *%const_cast(tempshared.get(), $1_ltype); } else { $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); } } %typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // plain pointer by reference // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); temp = %const_cast(tempshared.get(), $*1_ltype); } else { temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); } $1 = &temp; } %typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) TYPE *CONST& %{ #error "varin typemap not implemented" %} %typemap(varout) TYPE *CONST& %{ #error "varout typemap not implemented" %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { int newmem = 0; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); } %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ #error "varout typemap not implemented" %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); delete %reinterpret_cast(argp, $ltype); $1 = &tempshared; } else { $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; } } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); if ($owner) delete $1; } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ #error "varout typemap not implemented" %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); temp = &tempshared; $1 = &temp; } %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varin typemap not implemented" %} %typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ #error "varout typemap not implemented" %} // Typecheck typemaps // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, TYPE *CONST&, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); $1 = SWIG_CheckState(res); } // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/scilab/scishort.swg0000664000175000017500000001340712641054563016711 0ustar williamwilliam/* * C-type: short * Scilab type: double or int16 */ %fragment(SWIG_AsVal_frag(short), "header", fragment="SWIG_SciDoubleOrInt16_AsShort", fragment="") { #define SWIG_AsVal_short(scilabValue, valuePointer) SWIG_SciDoubleOrInt16_AsShort(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDoubleOrInt16_AsShort", "header") { SWIGINTERN int SWIG_SciDoubleOrInt16_AsShort(void *pvApiCtx, int iVar, short *psValue, char *fname) { SciErr sciErr; int iType = 0; int iRows = 0; int iCols = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_ints) { int iPrec = 0; short *psData = NULL; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_INT16) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } sciErr = getMatrixOfInteger16(pvApiCtx, piAddrVar, &iRows, &iCols, &psData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } *psValue = *psData; } else if (iType == sci_matrix) { double *pdData = NULL; double dValue = 0.0f; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } dValue = *pdData; if (dValue != floor(dValue)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 16-bit signed integer.\n"), fname, iVar); return SWIG_ValueError; } if ((dValue < SHRT_MIN) || (dValue > SHRT_MAX)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 16-bit signed integer.\n"), fname, iVar); return SWIG_OverflowError; } *psValue = (short) dValue; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } return SWIG_OK; } } %fragment(SWIG_From_frag(short), "header", fragment="SWIG_SciDouble_FromShort") { #define SWIG_From_short(scilabValue) SWIG_SciDouble_FromShort(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDouble_FromShort", "header") { SWIGINTERN int SWIG_SciDouble_FromShort(void *pvApiCtx, int iVarOut, short sValue, char *fname) { if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) sValue)) return SWIG_ERROR; return SWIG_OK; } } /* * C-type: short[] * Scilab type: double or int16 matrix */ %fragment("SWIG_SciDoubleOrInt16_AsShortArrayAndSize", "header") { SWIGINTERN int SWIG_SciDoubleOrInt16_AsShortArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, short **psValue, char *fname) { SciErr sciErr; int iType = 0; int iPrec = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_matrix) { double *pdData = NULL; int size = 0; int i; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } size = (*iRows) * (*iCols); *psValue = (short*) malloc(size * sizeof(int*)); for (i = 0; i < size; i++) (*psValue)[i] = (short) pdData[i]; } else if (iType == sci_ints) { int iPrec = 0; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_INT16) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double matrix expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfInteger16(pvApiCtx, piAddrVar, iRows, iCols, psValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double matrix expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciDouble_FromShortArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromShortArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, short *psValue) { SciErr sciErr; int i; double *pdValues = NULL; pdValues = (double*) malloc(iRows * iCols * sizeof(double)); for (i=0; i %typemap(throws, noblock=1) int, unsigned int, signed int, int&,unsigned int&, signed int&, long, unsigned long, signed long, short, unsigned short,signed short, long long, unsigned long long, unsigned char, signed char, long&, unsigned long&, signed long&, short&, unsigned short&, signed short&, long long&, unsigned long long&, unsigned char&, signed char&, size_t, size_t&, ptrdiff_t, ptrdiff_t& { char obj[20]; sprintf(obj, "%d", (int)$1); SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor); } %typemap(throws, noblock=1) enum SWIGTYPE { char obj[20]; sprintf(obj, "%d", (int)$1); SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor); } %typemap(throws, noblock=1) float, double, float&, double& { char obj[20]; sprintf(obj, "%5.3f", (double)$1); SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor); } %typemap(throws, noblock=1) bool, bool& { SWIG_Scilab_Raise_Ex($1 ? "true" : "false", "$type", $descriptor); } %typemap(throws, noblock=1) char*, char[ANY] { SWIG_Scilab_Raise_Ex($1, "$type", $descriptor); } %typemap(throws, noblock=1) char, char& { char obj[1]; sprintf(obj, "%c", (char)$1); SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor); } %typemap(throws, noblock=1) SWIGTYPE, SWIGTYPE*, SWIGTYPE [ANY], SWIGTYPE & { SWIG_Scilab_Raise_Ex((char*)NULL, "$type", $descriptor); } %typemap(throws, noblock=1) (...) { SWIG_exception(SWIG_RuntimeError, "unknown exception"); } swig-3.0.8/Lib/scilab/scisequenceint.swg0000664000175000017500000000552712641054563020101 0ustar williamwilliam/* * * Scilab matrix of int <-> C++ int container * */ %include %fragment(SWIG_AsCheck_Sequence_frag(int), "header") { SWIGINTERN int SWIG_AsCheck_Sequence_dec(int)(SwigSciObject obj) { SciErr sciErr; int *piAddrVar; int iType = 0; sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if ((iType == sci_matrix) || (iType == sci_ints)) { return SWIG_OK; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: An integer is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } } } %fragment(SWIG_AsGet_Sequence_frag(int), "header", fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") { SWIGINTERN int SWIG_AsGet_Sequence_dec(int)(SwigSciObject obj, int **pSequence) { int iMatrixRowCount; int iMatrixColCount; return (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName())); } } %fragment(SWIG_AsSize_Sequence_frag(int), "header", fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") { SWIGINTERN int SWIG_AsSize_Sequence_dec(int)(SwigSciObject obj, int *piSize) { int *piMatrix; int iMatrixRowCount; int iMatrixColCount; if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) { if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } *piSize = iMatrixRowCount * iMatrixColCount; return SWIG_OK; } return SWIG_ERROR; } } %fragment(SWIG_FromCreate_Sequence_frag(int), "header") { SWIGINTERN int SWIG_FromCreate_Sequence_dec(int)(int size, int **pSequence) { *pSequence = new int[size]; return *pSequence != NULL ? SWIG_OK : SWIG_ERROR; } } %fragment(SWIG_FromSet_Sequence_frag(int), "header", fragment="SWIG_SciDouble_FromIntArrayAndSize") { SWIGINTERN SwigSciObject SWIG_FromSet_Sequence_dec(int)(int size, int *pSequence) { SwigSciObject obj = SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence); delete (int *)pSequence; return obj; } } %fragment(SWIG_AsVal_SequenceItem_frag(int), "header") { SWIGINTERN int SWIG_AsVal_SequenceItem_dec(int)(SwigSciObject obj, int *pSequence, int iItemIndex) { return pSequence[iItemIndex]; } } %fragment(SWIG_From_SequenceItem_frag(int), "header") { SWIGINTERN int SWIG_From_SequenceItem_dec(int)(int *pSequence, int iItemIndex, int itemValue) { pSequence[iItemIndex] = itemValue; return SWIG_OK; } } swig-3.0.8/Lib/scilab/std_multiset.i0000664000175000017500000000152612641054563017222 0ustar williamwilliam/* * * C++ type : STL multiset * Scilab type : matrix (for primitive types) or list (for pointer types) * */ %fragment("StdMultisetTraits", "header", fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(const SwigSciObject &obj, std::multiset **multiset) { return traits_asptr_stdseq >::asptr(obj, multiset); } }; template struct traits_from > { static SwigSciObject from(const std::multiset& multiset) { return traits_from_stdseq >::from(multiset); } }; } %} #define %swig_multiset_methods(Set...) %swig_sequence_methods(Type) #define %swig_multiset_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/scilab/scimatrixint.swg0000664000175000017500000001065412641054563017572 0ustar williamwilliam/* * C-type: int array * Scilab type: 32-bit integer matrix */ %include // in (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT) %typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) { return SWIG_ERROR; } } // in (int IN_ROWCOUNT, int IN_COLCOUNT, int *IN) %typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, int *IN) { if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) { return SWIG_ERROR; } } // in (int *IN, int IN_SIZE) %typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_SIZE) (int rowCount, int colCount) { if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) { $2 = rowCount * colCount; } else { return SWIG_ERROR; } } // in (int IN_SIZE, int *IN) %typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_SIZE, int *IN) (int rowCount, int colCount) { if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) { $1 = rowCount * colCount; } else { return SWIG_ERROR; } } // out (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) %typemap(in, noblock=1, numinputs=0) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { } %typemap(arginit, noblock=1) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { $1 = (int**) malloc(sizeof(int*)); $2 = (int*) malloc(sizeof(int)); $3 = (int*) malloc(sizeof(int)); } %typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { free(*$1); free($1); free($2); free($3); } // out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT) %typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT) { } %typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT) { $1 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int)); $3 = (int**) malloc(sizeof(int*)); } %typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT) { if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT) { free($1); free($2); free(*$3); free($3); } // out (int **OUT, int *OUT_SIZE) %typemap(in, noblock=1, numinputs=0) (int **OUT, int *OUT_SIZE) { } %typemap(arginit) (int **OUT, int *OUT_SIZE) { $1 = (int**) malloc(sizeof(int*)); $2 = (int*) malloc(sizeof(int)); } %typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int **OUT, int *OUT_SIZE) { if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int **OUT, int *OUT_SIZE) { free(*$1); free($1); free($2); } // out (int *OUT_SIZE, int **OUT) %typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, int **OUT) { } %typemap(arginit, noblock=1) (int *OUT_SIZE, int **OUT) { $1 = (int*) malloc(sizeof(int)); $2 = (int**) malloc(sizeof(int*)); } %typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int *OUT_SIZE, int **OUT) { if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int *IN_SIZE, int **OUT) { free($1); free(*$2); free($2); } swig-3.0.8/Lib/scilab/sciiterators.swg0000664000175000017500000002211412641054563017561 0ustar williamwilliam/* ----------------------------------------------------------------------------- * sciiterators.swg * * Users can derive form the SciSwigIterator to implemet their * own iterators. As an example (real one since we use it for STL/STD * containers), the template SwigSciIterator_T does the * implementation for generic C++ iterators. * ----------------------------------------------------------------------------- */ %include %fragment("SciSwigIterator","header",fragment="") { namespace swig { struct stop_iteration { }; struct SciSwigIterator { private: SwigSciObject _seq; protected: SciSwigIterator(SwigSciObject seq) : _seq(seq) { } public: virtual ~SciSwigIterator() {} virtual SwigSciObject value() const = 0; virtual SciSwigIterator *incr(size_t n = 1) = 0; virtual SciSwigIterator *decr(size_t n = 1) { throw stop_iteration(); } virtual ptrdiff_t distance(const SciSwigIterator &x) const { throw std::invalid_argument("operation not supported"); } virtual bool equal (const SciSwigIterator &x) const { throw std::invalid_argument("operation not supported"); } virtual SciSwigIterator *copy() const = 0; SwigSciObject next() { SwigSciObject obj = value(); incr(); return obj; } SwigSciObject previous() { decr(); return value(); } SciSwigIterator *advance(ptrdiff_t n) { return (n > 0) ? incr(n) : decr(-n); } bool operator == (const SciSwigIterator& x) const { return equal(x); } bool operator != (const SciSwigIterator& x) const { return ! operator==(x); } SciSwigIterator* operator ++ () { incr(); return this; } SciSwigIterator* operator -- () { decr(); return this; } SciSwigIterator* operator + (ptrdiff_t n) const { return copy()->advance(n); } SciSwigIterator* operator - (ptrdiff_t n) const { return copy()->advance(-n); } ptrdiff_t operator - (const SciSwigIterator& x) const { return x.distance(*this); } static swig_type_info* descriptor() { static int init = 0; static swig_type_info* desc = 0; if (!init) { desc = SWIG_TypeQuery("swig::SciSwigIterator *"); init = 1; } return desc; } }; } } %fragment("SwigSciIterator_T","header",fragment="",fragment="SciSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { template class SwigSciIterator_T : public SciSwigIterator { public: typedef OutIterator out_iterator; typedef typename std::iterator_traits::value_type value_type; typedef SwigSciIterator_T self_type; SwigSciIterator_T(out_iterator curr, SwigSciObject seq) : SciSwigIterator(seq), current(curr) { } const out_iterator& get_current() const { return current; } bool equal (const SciSwigIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return (current == iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } ptrdiff_t distance(const SciSwigIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { return std::distance(current, iters->get_current()); } else { throw std::invalid_argument("bad iterator type"); } } protected: out_iterator current; }; template struct from_oper { typedef const ValueType& argument_type; typedef SwigSciObject result_type; result_type operator()(argument_type v) const { return swig::from(v); } }; template::value_type, typename FromOper = from_oper > class SciSwigIteratorOpen_T : public SwigSciIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef SwigSciIterator_T base; typedef SciSwigIteratorOpen_T self_type; SciSwigIteratorOpen_T(out_iterator curr, SwigSciObject seq) : SwigSciIterator_T(curr, seq) { } SwigSciObject value() const { return from(static_cast(*(base::current))); } SciSwigIterator *copy() const { return new self_type(*this); } SciSwigIterator *incr(size_t n = 1) { while (n--) { ++base::current; } return this; } SciSwigIterator *decr(size_t n = 1) { while (n--) { --base::current; } return this; } }; template::value_type, typename FromOper = from_oper > class SciSwigIteratorClosed_T : public SwigSciIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; typedef SwigSciIterator_T base; typedef SciSwigIteratorClosed_T self_type; SciSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, SwigSciObject seq) : SwigSciIterator_T(curr, seq), begin(first), end(last) { } SwigSciObject value() const { if (base::current == end) { throw stop_iteration(); } else { return from(static_cast(*(base::current))); } } SciSwigIterator *copy() const { return new self_type(*this); } SciSwigIterator *incr(size_t n = 1) { while (n--) { if (base::current == end) { throw stop_iteration(); } else { ++base::current; } } return this; } SciSwigIterator *decr(size_t n = 1) { while (n--) { if (base::current == begin) { throw stop_iteration(); } else { --base::current; } } return this; } private: out_iterator begin; out_iterator end; }; template inline SciSwigIterator* make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, SwigSciObject seq = SwigSciObject()) { return new SciSwigIteratorClosed_T(current, begin, end, seq); } template inline SciSwigIterator* make_output_iterator(const OutIter& current, SwigSciObject seq = SwigSciObject()) { return new SciSwigIteratorOpen_T(current, seq); } } } %fragment("SciSwigIterator"); namespace swig { // Throw a StopIteration exception %ignore stop_iteration; struct stop_iteration {}; %typemap(throws, noblock=1) stop_iteration { SWIG_Scilab_Raise(0, "stop_iteration", NULL); return SWIG_ERROR; } // Mark methods that return new objects %newobject SciSwigIterator::copy; %newobject SciSwigIterator::operator + (ptrdiff_t n) const; %newobject SciSwigIterator::operator - (ptrdiff_t n) const; %nodirector SciSwigIterator; %catches(swig::stop_iteration) SciSwigIterator::value() const; %catches(swig::stop_iteration) SciSwigIterator::incr(size_t n = 1); %catches(swig::stop_iteration) SciSwigIterator::decr(size_t n = 1); %catches(std::invalid_argument) SciSwigIterator::distance(const SciSwigIterator &x) const; %catches(std::invalid_argument) SciSwigIterator::equal (const SciSwigIterator &x) const; %catches(swig::stop_iteration) SciSwigIterator::next(); %catches(swig::stop_iteration) SciSwigIterator::previous(); %catches(swig::stop_iteration) SciSwigIterator::advance(ptrdiff_t n); %catches(swig::stop_iteration) SciSwigIterator::operator += (ptrdiff_t n); %catches(swig::stop_iteration) SciSwigIterator::operator -= (ptrdiff_t n); %catches(swig::stop_iteration) SciSwigIterator::operator + (ptrdiff_t n) const; %catches(swig::stop_iteration) SciSwigIterator::operator - (ptrdiff_t n) const; %ignore SciSwigIterator::operator==; %ignore SciSwigIterator::operator!=; %ignore SciSwigIterator::operator++; %ignore SciSwigIterator::operator--; %ignore SciSwigIterator::operator+; %ignore SciSwigIterator::operator-; struct SciSwigIterator { protected: SciSwigIterator(SwigSciObject seq); public: virtual ~SciSwigIterator(); virtual SwigSciObject value() const = 0; virtual SciSwigIterator *incr(size_t n = 1) = 0; virtual SciSwigIterator *decr(size_t n = 1); virtual ptrdiff_t distance(const SciSwigIterator &x) const; virtual bool equal (const SciSwigIterator &x) const; virtual SciSwigIterator *copy() const = 0; SwigSciObject next(); SwigSciObject previous(); SciSwigIterator *advance(ptrdiff_t n); bool operator == (const SciSwigIterator& x) const; bool operator != (const SciSwigIterator& x) const; SciSwigIterator* operator ++ (); SciSwigIterator* operator -- (); SciSwigIterator* operator + (ptrdiff_t n) const; SciSwigIterator* operator - (ptrdiff_t n) const; ptrdiff_t operator - (const SciSwigIterator& x) const; }; } swig-3.0.8/Lib/scilab/sciruntime.swg0000664000175000017500000000117112641054563017230 0ustar williamwilliam%insert(runtime) "swigrun.swg"; %insert(runtime) "swigerrors.swg"; #define %scilabcode %insert("scilab") %insert(runtime) "scirun.swg"; %init %{ #define SWIG_GetModule(clientdata) SWIG_Scilab_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Scilab_SetModule(pointer) SWIGRUNTIME swig_module_info* SWIG_Scilab_GetModule(void) { return NULL; } SWIGRUNTIME void SWIG_Scilab_SetModule(swig_module_info *swig_module) { } %} %insert(init) "swiginit.swg" %init %{ #ifdef __cplusplus extern "C" #endif int _Init(SWIG_GatewayParameters) { SWIG_InitializeModule(NULL); SWIG_CreateScilabVariables(pvApiCtx); %} swig-3.0.8/Lib/scilab/typemaps.i0000664000175000017500000000315312641054563016342 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * ----------------------------------------------------------------------------- */ // INPUT typemaps %define %scilab_input_typemap(Type) %typemap(in, noblock=1, fragment=SWIG_AsVal_frag(Type)) Type *INPUT(Type temp)(int ecode), Type &INPUT(Type temp)(int ecode) { ecode = SWIG_AsVal_dec(Type)($input, &temp); if (!SWIG_IsOK(ecode)) { %argument_fail(ecode, "$type", $symname, $argnum); } $1 = &temp; } %typemap(freearg, noblock=1) Type *INPUT, Type &INPUT { } %typemap(typecheck) Type *INPUT, Type &INPUT { } %enddef // OUTPUT typemaps %define %scilab_output_typemap(Type) %typemap(argout, noblock=1, fragment=SWIG_From_frag(Type)) Type *OUTPUT, Type &OUTPUT { %set_output(SWIG_From_dec(Type)(*$1)); } %enddef // INOUT typemaps %define %scilab_inout_typemap(Type) %typemap(in) Type *INOUT = Type *INPUT; %typemap(in) Type &INOUT = Type &INPUT; %typemap(argout) Type *INOUT = Type *OUTPUT; %typemap(argout) Type &INOUT = Type &OUTPUT; %enddef %define %scilab_inout_typemaps(Type) %scilab_input_typemap(%arg(Type)) %scilab_output_typemap(%arg(Type)) %scilab_inout_typemap(%arg(Type)) %enddef %scilab_inout_typemaps(double); %scilab_inout_typemaps(signed char); %scilab_inout_typemaps(unsigned char); %scilab_inout_typemaps(short); %scilab_inout_typemaps(unsigned short); %scilab_inout_typemaps(int); %scilab_inout_typemaps(unsigned int); %scilab_inout_typemaps(long); %scilab_inout_typemaps(unsigned long); %scilab_inout_typemaps(bool); %scilab_inout_typemaps(float); //%apply_ctypes(%scilab_inout_typemaps); swig-3.0.8/Lib/scilab/std_vector.i0000664000175000017500000000145512641054563016657 0ustar williamwilliam/* * * C++ type : STL vector * Scilab type : matrix (for primitive types) or list (for pointer types) * */ %fragment("StdVectorTraits", "header", fragment="StdSequenceTraits") %{ namespace swig { template struct traits_asptr > { static int asptr(const SwigSciObject &obj, std::vector **vec) { return traits_asptr_stdseq >::asptr(obj, vec); } }; template struct traits_from > { static SwigSciObject from(const std::vector& vec) { return traits_from_stdseq >::from(vec); } }; } %} #define %swig_vector_methods(Type...) %swig_sequence_methods(Type) #define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-3.0.8/Lib/scilab/scilist.swg0000664000175000017500000000344212641054563016523 0ustar williamwilliam/* * Scilab list related functions * */ %fragment("SWIG_ScilabList", "header") { SWIGINTERN int SWIG_GetScilabList(SwigSciObject obj, int **piListAddr) { SciErr sciErr; sciErr = getVarAddressFromPosition(pvApiCtx, obj, piListAddr); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } SWIGINTERN int SWIG_GetScilabListSize(SwigSciObject obj, int *piListSize) { SciErr sciErr; int *piListAddr; sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piListAddr); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getListItemNumber(pvApiCtx, piListAddr, piListSize); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } SWIGINTERN int SWIG_GetScilabListAndSize(SwigSciObject obj, int **piListAddr, int *piListSize) { SciErr sciErr; sciErr = getVarAddressFromPosition(pvApiCtx, obj, piListAddr); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getListItemNumber(pvApiCtx, *piListAddr, piListSize); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } SWIGINTERN int SWIG_CheckScilabList(SwigSciObject obj) { SciErr sciErr; int *piListAddr; int iType; sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piListAddr); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piListAddr, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if ((iType != sci_list) && (iType != sci_tlist) && (iType != sci_mlist)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A list is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } return SWIG_OK; } } swig-3.0.8/Lib/scilab/scifloat.swg0000664000175000017500000000425212641054563016655 0ustar williamwilliam/* * FLOAT SCALAR */ %fragment(SWIG_AsVal_frag(float), "header", fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int SWIG_AsVal_dec(float)(SwigSciObject iVar, float *pfValue) { double dblValue = 0.0; if(SWIG_AsVal_dec(double)(iVar, &dblValue) != SWIG_OK) { return SWIG_ERROR; } if (pfValue) *pfValue = (float) dblValue; return SWIG_OK; } } %fragment(SWIG_From_frag(float), "header") { SWIGINTERN int SWIG_From_dec(float)(float flValue) { if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition(), (double)flValue)) return SWIG_ERROR; return SWIG_OK; } } %fragment("SWIG_SciDouble_AsFloatArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_AsFloatArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, float **pfValue, char *fname) { SciErr sciErr; int *piAddrVar = NULL; double *pdValue = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) { int i; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } *pfValue = (float *) malloc((*iRows) * (*iCols) * sizeof(float)); for (i=0; i < (*iRows) * (*iCols); i++) (*pfValue)[i] = (float) pdValue[i]; return SWIG_OK; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar); return SWIG_ERROR; } } } %fragment("SWIG_SciDouble_FromFloatArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromFloatArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, float *pfValue) { SciErr sciErr; double *pdValue; int i; pdValue = (double *) malloc(iRows * iCols * sizeof(double)); for (i = 0; i < iRows * iCols; i++) pdValue[i] = pfValue[i]; sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } free(pdValue); return SWIG_OK; } } swig-3.0.8/Lib/scilab/scidouble.swg0000664000175000017500000000636012641054563017024 0ustar williamwilliam/* * DOUBLE SCALAR */ %fragment(SWIG_AsVal_frag(double), "header", fragment="SWIG_SciDouble_AsDouble") { %#define SWIG_AsVal_double(scilabValue, valuePointer) SWIG_SciDouble_AsDouble(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDouble_AsDouble", "header") { SWIGINTERN int SWIG_SciDouble_AsDouble(void *pvApiCtx, SwigSciObject iVar, double *pdblValue, char *fname) { SciErr sciErr; int iRet = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (!isDoubleType(pvApiCtx, piAddrVar) || isVarComplex(pvApiCtx, piAddrVar)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, iVar); return SWIG_ERROR; } if (!isScalar(pvApiCtx, piAddrVar)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A real expected.\n"), fname, iVar); return SWIG_ERROR; } iRet = getScalarDouble(pvApiCtx, piAddrVar, pdblValue); if (iRet) { return SWIG_ERROR; } return SWIG_OK; } } %fragment(SWIG_From_frag(double), "header", fragment="SWIG_SciDouble_FromDouble") { %#define SWIG_From_double(scilabValue) SWIG_SciDouble_FromDouble(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDouble_FromDouble", "header") { SWIGINTERN int SWIG_SciDouble_FromDouble(void *pvApiCtx, int iVarOut, double dblValue, char *fname) { if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, dblValue)) return SWIG_ERROR; return SWIG_OK; } } /* * DOUBLE ARRAY */ %fragment("SWIG_SciDouble_AsDoubleArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, double **pdValue, char *fname) { SciErr sciErr; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) { sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, pdValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciDouble_FromDoubleArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromDoubleArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, double *pdblValue) { SciErr sciErr; sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdblValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } } %fragment(SWIG_CreateScilabVariable_frag(double), "wrapper") { SWIGINTERN int SWIG_CreateScilabVariable_dec(double)(void *pvApiCtx, const char* psVariableName, const double dVariableValue) { SciErr sciErr; sciErr = createNamedMatrixOfDouble(pvApiCtx, psVariableName, 1, 1, &dVariableValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } } swig-3.0.8/Lib/scilab/sciunsignedshort.swg0000664000175000017500000001416312641054563020446 0ustar williamwilliam/* * C-type: unsigned short * Scilab type: double or uint16 */ %fragment(SWIG_AsVal_frag(unsigned short), "header", fragment="SWIG_SciDoubleOrUint16_AsUnsignedShort", fragment="") { %#define SWIG_AsVal_unsigned_SS_short(scilabValue, valuePointer) SWIG_SciDoubleOrUint16_AsUnsignedShort(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDoubleOrUint16_AsUnsignedShort", "header") { SWIGINTERN int SWIG_SciDoubleOrUint16_AsUnsignedShort(void *pvApiCtx, int iVar, unsigned short *pusValue, char *fname) { SciErr sciErr; int iType = 0; int iRows = 0; int iCols = 0; int iPrec = 0; int *piAddrVar = NULL; unsigned short *pusData = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_ints) { if (pusValue) { sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_UINT16) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, piAddrVar, &iRows, &iCols, &pusData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } *pusValue = *pusData; } } else if (iType == sci_matrix) { if (pusValue) { double *pdData = NULL; double dValue = 0.0f; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } dValue = *pdData; if (dValue != floor(dValue)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 16-bit unsigned integer.\n"), fname, iVar); return SWIG_ValueError; } if ((dValue < 0) || (dValue > USHRT_MAX)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 16-bit unsigned integer.\n"), fname, iVar); return SWIG_OverflowError; } *pusValue = (unsigned short) dValue; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned short), "header", fragment="SWIG_SciDouble_FromUnsignedShort") { %#define SWIG_From_unsigned_SS_short(scilabValue) SWIG_SciDouble_FromUnsignedShort(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDouble_FromUnsignedShort", "header") { SWIGINTERN int SWIG_SciDouble_FromUnsignedShort(void *pvApiCtx, int iVarOut, unsigned short usValue, char *fname) { if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) usValue)) return SWIG_ERROR; return SWIG_OK; } } /* * C-type: unsigned short[] * Scilab type: uint16 vector */ %fragment("SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize", "header") { SWIGINTERN int SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned short **pusValue, char *fname) { SciErr sciErr; int iType = 0; int iPrec = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_matrix) { double *pdData = NULL; int size = 0; int i; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } size = (*iRows) * (*iCols); *pusValue = (unsigned short*) malloc(size * sizeof(int*)); for (i = 0; i < size; i++) (*pusValue)[i] = (unsigned short) pdData[i]; } else if (iType == sci_ints) { sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_UINT16) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double vector expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, piAddrVar, iRows, iCols, pusValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double vector expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciDouble_FromUnsignedShortArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromUnsignedShortArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, unsigned short *pusValues) { SciErr sciErr; double *pdValues = NULL; int i; pdValues = (double*) malloc(iRows * iCols * sizeof(double)); for (i=0; i C++ container wrapper * * This wrapper, and its iterator, allows a general use (and reuse) of * the mapping between C++ and Scilab, thanks to the C++ templates. * * Of course, it needs the C++ compiler to support templates, but * since we will use this wrapper with the STL containers, that should * be the case. * ----------------------------------------------------------------------------- */ %{ #include %} #if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) # if !defined(SWIG_EXPORT_ITERATOR_METHODS) # define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS # endif #endif // #define (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS) // if defined: sequences in return are converted from/to Scilab lists or matrices // if not defined: sequences are passed from/to Scilab as pointers %{ #define SWIG_STD_NOASSIGN_STL %} %include %include %{ #include %} %include %include %fragment("SciSequence_Cont", "header", fragment="StdTraits", fragment="SwigSciIterator_T") { namespace swig { template struct SciSequence_Ref { SciSequence_Ref(const SwigSciObject& seq, int index) : _seq(seq), _index(index) { if (traits_as_sequence::get(_seq, &piSeqAddr) != SWIG_OK) { throw std::invalid_argument("Cannot get sequence data."); } } operator T () const { try { return traits_asval_sequenceitem::asval(_seq, piSeqAddr, _index); } catch (std::exception& e) { SWIG_exception(SWIG_RuntimeError, e.what()); } } SciSequence_Ref& operator=(const T& v) { // TODO return *this; } private: SwigSciObject _seq; int _index; void *piSeqAddr; }; template struct SciSequence_ArrowProxy { SciSequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; template struct SwigSciSequence_InputIterator { typedef SwigSciSequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; typedef T value_type; typedef T* pointer; typedef int difference_type; SwigSciSequence_InputIterator() { } SwigSciSequence_InputIterator(const SwigSciObject& seq, int index) : _seq(seq), _index(index) { } reference operator*() const { return reference(_seq, _index); } SciSequence_ArrowProxy operator->() const { return SciSequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const { return (_index == ri._index); } bool operator!=(const self& ri) const { return !(operator==(ri)); } self& operator ++ () { ++_index; return *this; } self& operator -- () { --_index; return *this; } self& operator += (difference_type n) { _index += n; return *this; } self operator +(difference_type n) const { return self(_seq, _index + n); } self& operator -= (difference_type n) { _index -= n; return *this; } self operator -(difference_type n) const { return self(_seq, _index - n); } difference_type operator - (const self& ri) const { return _index - ri._index; } bool operator < (const self& ri) const { return _index < ri._index; } reference operator[](difference_type n) const { return reference(_seq, _index + n); } private: SwigSciObject _seq; difference_type _index; }; template struct SciSequence_Cont { typedef SciSequence_Ref reference; typedef const SciSequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef int difference_type; typedef int size_type; typedef const pointer const_pointer; typedef SwigSciSequence_InputIterator iterator; typedef SwigSciSequence_InputIterator const_iterator; SciSequence_Cont(const SwigSciObject& seq) : _seq(seq) { } ~SciSequence_Cont() { } size_type size() const { int iSeqSize; if (traits_as_sequence::size(_seq, &iSeqSize) == SWIG_OK) { return iSeqSize; } else { return SWIG_ERROR; } } bool empty() const { return size() == 0; } iterator begin() { return iterator(_seq, 0); } const_iterator begin() const { return const_iterator(_seq, 0); } iterator end() { return iterator(_seq, size()); } const_iterator end() const { return const_iterator(_seq, size()); } reference operator[](difference_type n) { return reference(_seq, n); } const_reference operator[](difference_type n) const { return const_reference(_seq, n); } private: SwigSciObject _seq; }; } } %define %swig_sequence_iterator(Sequence...) #if defined(SWIG_EXPORT_ITERATOR_METHODS) class iterator; class reverse_iterator; class const_iterator; class const_reverse_iterator; %typemap(out,noblock=1,fragment="SciSequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { %set_output(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), swig::SciSwigIterator::descriptor(),SWIG_POINTER_OWN)); } %typemap(out,fragment="SciSequence_Cont") std::pair, std::pair { // TODO: return a Scilab list from the pair (see code for Octave) } %fragment("SciSwigPairBoolOutputIterator", "header", fragment=SWIG_From_frag(bool), fragment="SciSequence_Cont") {} %typemap(out,fragment="SciSwigPairBoolOutputIterator") std::pair, std::pair { // TODO: return a Scilab list from the pair (see code for Octave) } %typemap(in,noblock=1,fragment="SciSequence_Cont") iterator(swig::SciSwigIterator *iter = 0, int res), reverse_iterator(swig::SciSwigIterator *iter = 0, int res), const_iterator(swig::SciSwigIterator *iter = 0, int res), const_reverse_iterator(swig::SciSwigIterator *iter = 0, int res) { res = SWIG_ConvertPtr((SwigSciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { swig::SwigSciIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } } } %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SciSequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { swig::SciSwigIterator *iter = 0; int res = SWIG_ConvertPtr((SwigSciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0); $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } %fragment("SciSequence_Cont"); #endif //SWIG_EXPORT_ITERATOR_METHODS %enddef // The Scilab container methods %define %swig_container_methods(Container...) %enddef %define %swig_sequence_methods_common(Sequence...) %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) %enddef %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %enddef %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %enddef // // Common fragments // %fragment("StdSequenceTraits","header", fragment="StdTraits", fragment="SciSequence_Cont", fragment=SWIG_Traits_SequenceItem_frag(ptr)) { namespace swig { template inline void assign(const SciSeq& sciSeq, Seq* seq) { %#ifdef SWIG_STD_NOASSIGN_STL typedef typename SciSeq::value_type value_type; typename SciSeq::const_iterator it = sciSeq.begin(); for (;it != sciSeq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } %#else seq->assign(sciSeq.begin(), sciSeq.end()); %#endif } template struct traits_asptr_stdseq { typedef Seq sequence; typedef T value_type; static int asptr(const SwigSciObject& obj, sequence **seq) { swig_type_info *typeInfo = swig::type_info(); if (typeInfo) { sequence *p; if (SWIG_ConvertPtr(obj, (void**)&p, typeInfo, 0) == SWIG_OK) { if (seq) *seq = p; return SWIG_OLDOBJ; } } if (traits_as_sequence::check(obj) == SWIG_OK) { try { SciSequence_Cont sciSeq(obj); if (seq) { *seq = new sequence(); assign(sciSeq, *seq); return SWIG_NEWOBJ; } else { return true; } } catch (std::exception& e) { SWIG_exception(SWIG_RuntimeError, e.what()); } } } }; template struct traits_from_stdseq { typedef Seq sequence; typedef T value_type; typedef typename Seq::size_type size_type; typedef typename sequence::const_iterator const_iterator; static SwigSciObject from(const sequence& seq) { %#ifdef SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS swig_type_info *typeInfo = swig::type_info(); if (typeInfo) { return SWIG_NewPointerObj(new sequence(seq), typeInfo, SWIG_POINTER_OWN); } %#endif try { void *data; size_type size = seq.size(); if (traits_from_sequence::create(size, &data) == SWIG_OK) { const_iterator it; int index = 0; for (it = seq.begin(); it != seq.end(); ++it) { traits_from_sequenceitem::from(data, index, *it); index++; } return traits_from_sequence::set(size, data); } return SWIG_OK; } catch (std::exception& e) { SWIG_exception(SWIG_RuntimeError, e.what()); } } }; } } swig-3.0.8/Lib/scilab/scichar.swg0000664000175000017500000001741212641054563016467 0ustar williamwilliam/* * C-type: char or char* * Scilab type: string */ /* * CHAR */ %fragment(SWIG_AsVal_frag(char), "header", fragment="SWIG_SciString_AsChar") { #define SWIG_AsVal_char(scilabValue, valuePointer) SWIG_SciString_AsChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciString_AsChar", "header") { SWIGINTERN int SWIG_SciString_AsChar(void *pvApiCtx, int iVar, char *pcValue, char *fname) { SciErr sciErr; int *piAddrVar = NULL; char *pstValue = NULL; int iRet; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isStringType(pvApiCtx, piAddrVar) == 0) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A single string expected.\n"), fname, iVar); return SWIG_TypeError; } iRet = getAllocatedSingleString(pvApiCtx, piAddrVar, &pstValue); if (iRet) { return SWIG_ERROR; } if (pcValue != NULL) { *pcValue = pstValue[0]; } freeAllocatedSingleString(pstValue); return SWIG_OK; } } %fragment(SWIG_From_frag(char), "header", fragment="SWIG_SciString_FromChar") { #define SWIG_From_char(value) SWIG_SciString_FromChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value) } %fragment("SWIG_SciString_FromChar", "header") { SWIGINTERN int SWIG_SciString_FromChar(void *pvApiCtx, int iVarOut, char chValue) { char *pchValue = (char*)malloc(sizeof(char) * 2); pchValue[0] = chValue; pchValue[1] = '\0'; if (createSingleString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, pchValue)) return SWIG_ERROR; free(pchValue); return SWIG_OK; } } /* * CHAR * */ %fragment("SWIG_AsCharArray", "header", fragment = "SWIG_SciString_AsCharPtr") { #define SWIG_AsCharArray(scilabValue, charPtrPointer, charPtrLength) SWIG_SciString_AsCharPtr(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciString_AsCharPtr", "header") { SWIGINTERN int SWIG_SciString_AsCharPtr(void *pvApiCtx, int iVar, char *pcValue, int iLength, char *fname) { SciErr sciErr; int *piAddrVar = NULL; char* pcTmpValue = NULL; int iRet; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } iRet = getAllocatedSingleString(pvApiCtx, piAddrVar, &pcTmpValue); if (iRet) { return SWIG_ERROR; } if (pcValue != NULL) { strncpy(pcValue, pcTmpValue, iLength); } freeAllocatedSingleString(pcTmpValue); return SWIG_OK; } } %fragment("SWIG_AsCharPtrAndSize", "header", fragment = "SWIG_SciString_AsCharPtrAndSize") { #define SWIG_AsCharPtrAndSize(scilabValue, charPtrPointer, charPtrLength, allocMemory) SWIG_SciString_AsCharPtrAndSize(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, allocMemory, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciString_AsCharPtrAndSize", "header") { SWIGINTERN int SWIG_SciString_AsCharPtrAndSize(void *pvApiCtx, int iVar, char **pcValue, size_t *piLength, int *alloc, char *fname) { SciErr sciErr; int *piAddrVar = NULL; char *pstString = NULL; int iRows = 0; int iCols = 0; int iLen = 0; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isScalar(pvApiCtx, piAddrVar) == 0 || isStringType(pvApiCtx, piAddrVar) == 0) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A single string expected.\n"), fname, iVar); return SWIG_TypeError; } sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &iLen, NULL); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } pstString = %new_array(iLen + 1, char); sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &iLen, &pstString); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } // TODO: return SWIG_ERROR if pcValue NULL (now returning SWIG_ERROR fails some typechecks) if (pcValue) { *pcValue = pstString; } if (alloc != NULL) { *alloc = SWIG_NEWOBJ; } if (piLength != NULL) { *piLength = strlen(pstString); } return SWIG_OK; } } %fragment("SWIG_FromCharPtr", "header", fragment = "SWIG_SciString_FromCharPtr") { #define SWIG_FromCharPtr(charPtr) SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr) } %fragment("SWIG_SciString_FromCharPtr", "header") { SWIGINTERN int SWIG_SciString_FromCharPtr(void *pvApiCtx, int iVarOut, const char *pchValue) { if (pchValue) { SciErr sciErr; const char* pstStrings[1]; pstStrings[0] = pchValue; sciErr = createMatrixOfString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, 1, 1, pstStrings); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { int iRet = createEmptyMatrix(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut); if (iRet) { return SWIG_ERROR; } } return SWIG_OK; } } /* * CHAR * ARRAY */ %fragment("SWIG_SciString_AsCharPtrArrayAndSize", "header") { SWIGINTERN int SWIG_SciString_AsCharPtrArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, char ***charPtrArray, char *fname) { SciErr sciErr; int i = 0; int *piAddrVar = NULL; int* piLength = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, NULL, NULL); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } piLength = (int*) malloc((*iRows) * (*iCols) * sizeof(int)); sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, piLength, NULL); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } *charPtrArray = (char**) malloc((*iRows) * (*iCols) * sizeof(char*)); for(i = 0 ; i < (*iRows) * (*iCols); i++) { (*charPtrArray)[i] = (char*) malloc(sizeof(char) * (piLength[i] + 1)); } sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, piLength, *charPtrArray); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } free(piLength); return SWIG_OK; } } %fragment("SWIG_SciString_FromCharPtrArrayAndSize", "header") { SWIGINTERN int SWIG_SciString_FromCharPtrArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, char **charPtrArray) { SciErr sciErr; sciErr = createMatrixOfString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, (const char* const*) charPtrArray); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SWIG_SciString_FromCharPtr") { #define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr) } /* * Char* Scilab variable */ %fragment(SWIG_CreateScilabVariable_frag(char), "wrapper") { SWIGINTERN int SWIG_CreateScilabVariable_dec(char)(void *pvApiCtx, const char* psVariableName, const char cVariableValue) { SciErr sciErr; char sValue[2]; const char* psStrings[1]; sValue[0] = cVariableValue; sValue[1] = '\0'; psStrings[0] = sValue; sciErr = createNamedMatrixOfString(pvApiCtx, psVariableName, 1, 1, psStrings); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } } %fragment(SWIG_CreateScilabVariable_frag(charptr), "wrapper") { SWIGINTERN int SWIG_CreateScilabVariable_dec(charptr)(void *pvApiCtx, const char* psVariableName, const char* psVariableValue) { SciErr sciErr; const char* psStrings[1]; psStrings[0] = psVariableValue; sciErr = createNamedMatrixOfString(pvApiCtx, psVariableName, 1, 1, psStrings); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } return SWIG_OK; } } swig-3.0.8/Lib/scilab/scisequencestring.swg0000664000175000017500000000515712641054563020614 0ustar williamwilliam/* *char * Scilab matrix of string <-> C++ std::string container * */ %include %fragment(SWIG_AsCheck_Sequence_frag(std::string), "header") { SWIGINTERN int SWIG_AsCheck_Sequence_dec(std::string)(SwigSciObject obj) { SciErr sciErr; int *piAddrVar; sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (isStringType(pvApiCtx, piAddrVar)) { return SWIG_OK; } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A string is expected.\n"), SWIG_Scilab_GetFuncName(), obj); return SWIG_ERROR; } } } %fragment(SWIG_AsGet_Sequence_frag(std::string), "header", fragment="SWIG_SciString_AsCharPtrArrayAndSize") { SWIGINTERN int SWIG_AsGet_Sequence_dec(std::string)(SwigSciObject obj, char ***pSequence) { int iRows = 0; int iCols = 0; return (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, obj, &iRows, &iCols, pSequence, SWIG_Scilab_GetFuncName())); } } %fragment(SWIG_AsSize_Sequence_frag(std::string), "header", fragment="SWIG_SciString_AsCharPtrArrayAndSize") { SWIGINTERN int SWIG_AsSize_Sequence_dec(std::string)(SwigSciObject obj, int *piSize) { char **pstMatrix; int iCols = 0; int iRows = 0; if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, obj, &iRows, &iCols, &pstMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) { *piSize = iRows * iCols; return SWIG_OK; } return SWIG_ERROR; } } %fragment(SWIG_FromCreate_Sequence_frag(std::string), "header") { SWIGINTERN int SWIG_FromCreate_Sequence_dec(std::string)(int size, char ***pSequence) { *pSequence = new char*[size]; return *pSequence != NULL ? SWIG_OK : SWIG_ERROR; } } %fragment(SWIG_FromSet_Sequence_frag(std::string), "header", fragment="SWIG_SciString_FromCharPtrArrayAndSize") { SWIGINTERN SwigSciObject SWIG_FromSet_Sequence_dec(std::string)(int size, char **pSequence) { SwigSciObject obj = SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence); delete (char **)pSequence; return obj; } } %fragment(SWIG_AsVal_SequenceItem_frag(std::string), "header") { SWIGINTERN std::string SWIG_AsVal_SequenceItem_dec(std::string)(SwigSciObject obj, char **pSequence, int iItemIndex) { return std::string(pSequence[iItemIndex]); } } %fragment(SWIG_From_SequenceItem_frag(std::string), "header") { SWIGINTERN int SWIG_From_SequenceItem_dec(std::string)(char **pSequence, int iItemIndex, std::string itemValue) { char *pChar = new char(itemValue.size() + 1); strcpy(pChar, itemValue.c_str()); pSequence[iItemIndex] = pChar; return SWIG_OK; } } swig-3.0.8/Lib/scilab/sciunsignedint.swg0000664000175000017500000001473412641054563020105 0ustar williamwilliam/* * C-type: unsigned int * Scilab type: double or uint32 */ %fragment(SWIG_AsVal_frag(unsigned int), "header", fragment="SWIG_SciDoubleOrUint32_AsUnsignedInt", fragment="") { %#define SWIG_AsVal_unsigned_SS_int(scilabValue, valuePointer) SWIG_SciDoubleOrUint32_AsUnsignedInt(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDoubleOrUint32_AsUnsignedInt", "header") { SWIGINTERN int SWIG_SciDoubleOrUint32_AsUnsignedInt(void *pvApiCtx, int iVar, unsigned int *puiValue, char *fname) { SciErr sciErr; int iType = 0; int iRows = 0; int iCols = 0; int iPrec = 0; int *piAddrVar = NULL; unsigned int *puiData = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_ints) { if (puiValue) { sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_UINT32) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &puiData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } *puiValue = *puiData; } } else if (iType == sci_matrix) { if (puiValue) { double *pdData = NULL; double dValue = 0.0f; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } dValue = *pdData; if (dValue != floor(dValue)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit unsigned integer.\n"), fname, iVar); return SWIG_ValueError; } if ((dValue < 0) || (dValue > UINT_MAX)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit unsigned integer.\n"), fname, iVar); return SWIG_OverflowError; } *puiValue = (unsigned int) dValue; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment(SWIG_From_frag(unsigned int), "header", fragment="SWIG_SciDouble_FromUnsignedInt") { %#define SWIG_From_unsigned_SS_int(scilabValue) SWIG_SciDouble_FromUnsignedInt(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDouble_FromUnsignedInt", "header") { SWIGINTERN int SWIG_SciDouble_FromUnsignedInt(void *pvApiCtx, int iVarOut, unsigned int uiValue, char *fname) { if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) uiValue)) return SWIG_ERROR; return SWIG_OK; } } /* * C-type: unsigned int[] * Scilab type: uint32 vector */ %fragment("SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize", "header") { SWIGINTERN int SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned int **puiValue, char *fname) { SciErr sciErr; int iType = 0; int iPrec = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_matrix) { double *pdData = NULL; int size = 0; int i; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } size = (*iRows) * (*iCols); *puiValue = (unsigned int*) malloc(size * sizeof(int*)); for (i = 0; i < size; i++) (*puiValue)[i] = (unsigned int) pdData[i]; } else if (iType == sci_ints) { sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_UINT32) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double vector expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, piAddrVar, iRows, iCols, puiValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double vector expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciDouble_FromUnsignedIntArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromUnsignedIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, unsigned int *puiValues) { SciErr sciErr; double *pdValues = NULL; int i; pdValues = (double*) malloc(iRows * iCols * sizeof(double)); for (i=0; i swig-3.0.8/Lib/scilab/scitypemaps.swg0000664000175000017500000002306512641054563017415 0ustar williamwilliam// Scilab fragments for primitive types %include %include // Scilab object type #define SWIG_Object int #define %append_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR #define %set_constant(name, obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Name is managed by the the function name #define %raise(obj, type, desc) SWIG_Scilab_Raise(obj, type, desc) #define %set_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR #define %set_varoutput(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR #define %set_argoutput(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Include the unified typemap library %include /* ---------------------------------------------------------------------------*/ /* Generic typmemaps */ /* */ /* This typemap is used when Scilab does not store this type directly */ /* For example, a 'float' is stored in Scilab as a 'double' */ /* So we read a 'double' in Scilab and cast it to a 'float' */ /* ---------------------------------------------------------------------------*/ %define %scilab_in_typemap_withcast(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPTYPE, TEMPINIT) %typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE { TEMPTYPE tempValue = TEMPINIT; if(FRAGMENTNAME(pvApiCtx, $input, &tempValue, SWIG_Scilab_GetFuncName()) != SWIG_OK) { return SWIG_ERROR; } $1 = (CTYPE) tempValue; } %enddef %define %scilab_inptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE) %typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE { if (FRAGMENTNAME(pvApiCtx, $input, %as_voidptrptr(&$1), SWIG_Scilab_GetFuncName()) != SWIG_OK) { return SWIG_ERROR; } } %enddef %define %scilab_out_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE) %typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE { if (FRAGMENTNAME(pvApiCtx, $result, $1) != SWIG_OK) { return SWIG_ERROR; } } %enddef %define %scilab_outptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE) %typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE { if (FRAGMENTNAME(pvApiCtx, $result, %as_voidptr($1)) != SWIG_OK) { return SWIG_ERROR; } } %enddef %define %scilab_varout_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE) %typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE { if (FRAGMENTNAME(pvApiCtx, $result, $value) != SWIG_OK) { return SWIG_ERROR; } } %enddef %define %scilab_varoutptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE) %typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE { if (FRAGMENTNAME(pvApiCtx, $result, %as_voidptr($value)) != SWIG_OK) { return SWIG_ERROR; } } %enddef %define %scilab_in_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE) %typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE { if (FRAGMENTNAME(pvApiCtx, $input, &$1, SWIG_Scilab_GetFuncName()) != SWIG_OK) { return SWIG_ERROR; } } %enddef /* ---------------------------------------------------------------------------*/ /* Array typmemaps */ /* ---------------------------------------------------------------------------*/ %include /* ---------------------------------------------------------------------------*/ /* Enum typemaps */ /* ---------------------------------------------------------------------------*/ %typemap(in, noblock=1, fragment=SWIG_AsVal_frag(Enum)) enum SWIGTYPE (int val) { if (SWIG_AsVal_dec(Enum)($input, &val) != SWIG_OK) { return SWIG_ERROR; } $1 = %reinterpret_cast(val, $ltype); } %typemap(out, fragment=SWIG_From_frag(Enum)) enum SWIGTYPE { if (SWIG_From_dec(Enum)($1) != SWIG_OK) { return SWIG_ERROR; } } /* ---------------------------------------------------------------------------*/ /* Typecheck typemaps */ /* ---------------------------------------------------------------------------*/ %define %scilab_typecheck_generic(PRECEDENCE, TYPE_CHECK_FUNCTION, TYPE) %typecheck(PRECEDENCE) TYPE { int *piAddrVar = NULL; SciErr sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } $1 = TYPE_CHECK_FUNCTION(pvApiCtx, piAddrVar); } %enddef /* Scilab equivalent for C integers can be sci_ints or sci_matrix */ %define %scilab_typecheck_integer(PRECEDENCE, INTTYPE, TYPE) %typecheck(PRECEDENCE) TYPE { int *piAddrVar = NULL; SciErr sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } $1 = isIntegerType(pvApiCtx, piAddrVar); if ($1 == 1) { int iPrec = 0; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } $1 = (iPrec == INTTYPE) ? 1 : 0; } else { $1 = isDoubleType(pvApiCtx, piAddrVar); } } %enddef // Double (and Float) have priority over before Integer type. // Primitive types %scilab_typecheck_generic(SWIG_TYPECHECK_VOIDPTR, isPointerType, SWIGTYPE *) %scilab_typecheck_generic(SWIG_TYPECHECK_POINTER, isPointerType, SWIGTYPE *) %scilab_typecheck_generic(SWIG_TYPECHECK_BOOL, isBooleanType, bool) %scilab_typecheck_generic(16, isDoubleType, double) %scilab_typecheck_generic(17, isDoubleType, float) %scilab_typecheck_integer(SWIG_TYPECHECK_INT8, SCI_INT8, signed char) %scilab_typecheck_integer(SWIG_TYPECHECK_UINT8, SCI_UINT8, unsigned char) %scilab_typecheck_integer(SWIG_TYPECHECK_INT16, SCI_INT16, short) %scilab_typecheck_integer(SWIG_TYPECHECK_UINT16, SCI_UINT16, unsigned short) %scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, int) %scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, long) %scilab_typecheck_integer(SWIG_TYPECHECK_UINT32, SCI_UINT32, unsigned int) %scilab_typecheck_integer(SWIG_TYPECHECK_UINT32, SCI_UINT32, unsigned long) %scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, enum SWIGTYPE) %scilab_typecheck_generic(SWIG_TYPECHECK_CHAR, isStringType, char) // Arrays %scilab_typecheck_generic(SWIG_TYPECHECK_BOOL_ARRAY, isBooleanType, bool) %scilab_typecheck_generic(1016, isDoubleType, double [ANY]) %scilab_typecheck_generic(1017, isDoubleType, float [ANY]) %scilab_typecheck_integer(SWIG_TYPECHECK_INT8_ARRAY, SCI_INT8, signed char [ANY]) %scilab_typecheck_integer(1026, SCI_UINT8, unsigned char [ANY]) %scilab_typecheck_integer(SWIG_TYPECHECK_INT16_ARRAY, SCI_INT16, short [ANY]) %scilab_typecheck_integer(1036, SCI_UINT16, unsigned short [ANY]) %scilab_typecheck_integer(SWIG_TYPECHECK_INT32_ARRAY, SCI_INT32, int [ANY]) %scilab_typecheck_integer(SWIG_TYPECHECK_INT32_ARRAY, SCI_INT32, long [ANY]) %scilab_typecheck_integer(1046, SCI_UINT32, unsigned int [ANY]) %scilab_typecheck_integer(1046, SCI_UINT32, unsigned long [ANY]) %scilab_typecheck_generic(SWIG_TYPECHECK_CHAR_ARRAY, isStringType, char [ANY]) %scilab_typecheck_generic(SWIG_TYPECHECK_STRING_ARRAY, isStringType, char *[ANY]) %scilab_typecheck_generic(SWIG_TYPECHECK_STRING_ARRAY, isStringType, char **) /* ---------------------------------------------------------------------------*/ /* %scilabconstcode() feature typemaps */ /* ---------------------------------------------------------------------------*/ %typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(double)) double %{ if (SWIG_CreateScilabVariable_double(pvApiCtx, "$result", $value) != SWIG_OK) return SWIG_ERROR; %} %typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(int)) int %{ if (SWIG_CreateScilabVariable_int(pvApiCtx, "$result", $value) != SWIG_OK) return SWIG_ERROR; %} %typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(uint)) unsigned int %{ if (SWIG_CreateScilabVariable_uint(pvApiCtx, "$result", $value) != SWIG_OK) return SWIG_ERROR; %} %typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(int)) long %{ if (SWIG_CreateScilabVariable_int(pvApiCtx, "$result", $value) != SWIG_OK) return SWIG_ERROR; %} %typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(uint)) unsigned long %{ if (SWIG_CreateScilabVariable_uint(pvApiCtx, "$result", $value) != SWIG_OK) return SWIG_ERROR; %} %typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(char)) char %{ if (SWIG_CreateScilabVariable_char(pvApiCtx, "$result", $value) != SWIG_OK) return SWIG_ERROR; %} %typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(charptr)) char * %{ if (SWIG_CreateScilabVariable_charptr(pvApiCtx, "$result", $value) != SWIG_OK) return SWIG_ERROR; %} %typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(double)) enum SWIGTYPE %{ if (SWIG_CreateScilabVariable_double(pvApiCtx, "$result", $value) != SWIG_OK) return SWIG_ERROR; %} /* ---------------------------------------------------------------------------*/ /* Exception typmemaps */ /* ---------------------------------------------------------------------------*/ %include swig-3.0.8/Lib/scilab/scimatrixbool.swg0000664000175000017500000001061012641054563017723 0ustar williamwilliam/* * C-type: bool array * Scilab type: bool matrix */ %include // in (bool *IN, int IN_ROWCOUNT, int IN_COLCOUNT) %typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) { return SWIG_ERROR; } } // in (int IN_ROWCOUNT, int IN_COLCOUNT, bool *IN) %typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, bool *IN) { if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) { return SWIG_ERROR; } } // in (bool *IN, int IN_SIZE) %typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_SIZE) (int rowCount, int colCount) { if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) { $2 = rowCount * colCount; } else { return SWIG_ERROR; } } // in (int IN_SIZE, bool *IN) %typemap(in, noblock=1) (int IN_SIZE, bool *IN) (int rowCount, int colCount) { if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) { $1 = rowCount * colCount; } else { return SWIG_ERROR; } } // out (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) %typemap(in, noblock=1, numinputs=0) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { } %typemap(arginit, noblock=1) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { $1 = (bool**) malloc(sizeof(bool*)); $2 = (int*) malloc(sizeof(int)); $3 = (int*) malloc(sizeof(int)); } %typemap(freearg, noblock=1) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { free(*$1); free($1); free($2); free($3); } %typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } // out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT) %typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT) { } %typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT) { $1 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int)); $3 = (bool**) malloc(sizeof(bool*)); } %typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT) { if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT) { free($1); free($2); free(*$3); free($3); } // out (bool **OUT, int *OUT_SIZE) %typemap(in, noblock=1, numinputs=0) (bool **OUT, int *OUT_SIZE) { } %typemap(arginit, noblock=1) (bool **OUT, int *OUT_SIZE) { $1 = (bool**) malloc(sizeof(bool*)); $2 = (int*) malloc(sizeof(int)); } %typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (bool **OUT, int *OUT_SIZE) { if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (bool **OUT, int *OUT_SIZE) { free(*$1); free($1); free($2); } // out (int *OUT_SIZE, bool **OUT) %typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, bool **OUT) { } %typemap(arginit, noblock=1) (int *OUT_SIZE, bool **OUT) { $1 = (int*) malloc(sizeof(int)); $2 = (bool**) malloc(sizeof(bool*)); } %typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (int *OUT_SIZE, bool **OUT) { if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) { SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); } else { return SWIG_ERROR; } } %typemap(freearg, noblock=1) (int *OUT_SIZE, bool **OUT) { free($1); free(*$2); free($2); } swig-3.0.8/Lib/scilab/sciint.swg0000664000175000017500000001432612641054563016345 0ustar williamwilliam/* * C-type: int * Scilab type: double or int32 */ %fragment(SWIG_AsVal_frag(int), "header", fragment="SWIG_SciDoubleOrInt32_AsInt", fragment="") { %#define SWIG_AsVal_int(scilabValue, valuePointer) SWIG_SciDoubleOrInt32_AsInt(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDoubleOrInt32_AsInt", "header") { SWIGINTERN int SWIG_SciDoubleOrInt32_AsInt(void *pvApiCtx, SwigSciObject iVar, int *piValue, char *fname) { SciErr sciErr; int iType = 0; int iRows = 0; int iCols = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_ints) { if (piValue) { int iPrec = 0; int *piData = NULL; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_INT32) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } *piValue = *piData; } } else if (iType == sci_matrix) { if (piValue) { double *pdData = NULL; double dValue = 0.0f; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iRows * iCols != 1) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } dValue = *pdData; if (dValue != floor(dValue)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar); return SWIG_ValueError; } if ((dValue < INT_MIN) || (dValue > INT_MAX)) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar); return SWIG_OverflowError; } *piValue = (int) dValue; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar); return SWIG_TypeError; } return SWIG_OK; } } %fragment(SWIG_From_frag(int), "header", fragment="SWIG_SciDouble_FromInt") { %#define SWIG_From_int(scilabValue) SWIG_SciDouble_FromInt(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName()) } %fragment("SWIG_SciDouble_FromInt", "header") { SWIGINTERN int SWIG_SciDouble_FromInt(void *pvApiCtx, int iVarOut, int iValue, char *fname){ if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) iValue)) return SWIG_ERROR; return SWIG_OK; } } /* * C-type: int[] * Scilab type: double or int32 matrix */ %fragment("SWIG_SciDoubleOrInt32_AsIntArrayAndSize", "header") { SWIGINTERN int SWIG_SciDoubleOrInt32_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, int **piValue, char *fname) { SciErr sciErr; int iType = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } sciErr = getVarType(pvApiCtx, piAddrVar, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iType == sci_matrix) { double *pdData = NULL; int size = 0; int i; sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } size = (*iRows) * (*iCols); *piValue = (int*) malloc(size * sizeof(int*)); for (i = 0; i < size; i++) (*piValue)[i] = (int) pdData[i]; } else if (iType == sci_ints) { int iPrec = 0; sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } if (iPrec != SCI_INT32) { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar); return SWIG_ERROR; } sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, iRows, iCols, piValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar); return SWIG_ERROR; } return SWIG_OK; } } %fragment("SWIG_SciDouble_FromIntArrayAndSize", "header") { SWIGINTERN int SWIG_SciDouble_FromIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const int *piData) { SciErr sciErr; double *pdValues = NULL; int i; pdValues = (double*) malloc(iRows * iCols * sizeof(double)); for (i=0; i swig-3.0.8/Lib/linkruntime.c0000664000175000017500000000100012641054563015563 0ustar williamwilliam#ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define SWIGEXPORT # else # define SWIGEXPORT __declspec(dllexport) # endif # else # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) # define SWIGEXPORT __attribute__ ((visibility("default"))) # else # define SWIGEXPORT # endif # endif #endif static void *ptr = 0; SWIGEXPORT void * SWIG_ReturnGlobalTypeList(void *t) { if (!ptr && !t) ptr = t; return ptr; } swig-3.0.8/Lib/intrusive_ptr.i0000664000175000017500000000537612641054563016171 0ustar williamwilliam// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1 // For example for std::tr1, use: // #define SWIG_SHARED_PTR_NAMESPACE std // #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 // #define SWIG_INTRUSIVE_PTR_NAMESPACE boost // #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE #if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE) # define SWIG_INTRUSIVE_PTR_NAMESPACE boost #endif #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) # define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE #else # define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE #endif namespace SWIG_INTRUSIVE_PTR_NAMESPACE { #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE { #endif template class intrusive_ptr { }; #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) } #endif } %fragment("SWIG_intrusive_deleter", "header") { template struct SWIG_intrusive_deleter { void operator()(T *p) { if (p) intrusive_ptr_release(p); } }; } %fragment("SWIG_null_deleter", "header") { struct SWIG_null_deleter { void operator() (void const *) const { } }; %#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() %#define SWIG_NO_NULL_DELETER_1 } // Workaround empty first macro argument bug #define SWIGEMPTYHACK // Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types %define %intrusive_ptr(TYPE...) %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } SWIG_INTRUSIVE_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE) SWIG_INTRUSIVE_PTR_TYPEMAPS(const, TYPE) %enddef %define %intrusive_ptr_no_wrap(TYPE...) %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(SWIGEMPTYHACK, TYPE) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(const, TYPE) %enddef // Legacy macros %define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...) #warning "SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead." %intrusive_ptr(TYPE) %enddef %define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) #warning "SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead." %intrusive_ptr(TYPE) %enddef %define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...) #warning "SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead." %intrusive_ptr_no_wrap(TYPE) %enddef %define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...) #warning "SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead." %intrusive_ptr_no_wrap(TYPE) %enddef swig-3.0.8/Lib/swiglabels.swg0000664000175000017500000000726112641054563015753 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. * ----------------------------------------------------------------------------- */ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) # define SWIGTEMPLATEDISAMBIGUATOR template # elif defined(__HP_aCC) /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ # define SWIGTEMPLATEDISAMBIGUATOR template # else # define SWIGTEMPLATEDISAMBIGUATOR # endif #endif /* inline attribute */ #ifndef SWIGINLINE # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline # else # define SWIGINLINE # endif #endif /* attribute recognised by some compilers to avoid 'unused' warnings */ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ # endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else # define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif /* internal SWIG method */ #ifndef SWIGINTERN # define SWIGINTERN static SWIGUNUSED #endif /* internal inline SWIG method */ #ifndef SWIGINTERNINLINE # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif /* exporting methods */ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) # ifndef GCC_HASCLASSVISIBILITY # define GCC_HASCLASSVISIBILITY # endif #endif #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define SWIGEXPORT # else # define SWIGEXPORT __declspec(dllexport) # endif # else # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) # define SWIGEXPORT __attribute__ ((visibility("default"))) # else # define SWIGEXPORT # endif # endif #endif /* calling conventions for Windows */ #ifndef SWIGSTDCALL # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL # endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) # define _SCL_SECURE_NO_DEPRECATE #endif /* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ #if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) # define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 #endif /* Intel's compiler complains if a variable which was never initialised is * cast to void, which is a common idiom which we use to indicate that we * are aware a variable isn't used. So we just silence that warning. * See: https://github.com/swig/swig/issues/192 for more discussion. */ #ifdef __INTEL_COMPILER # pragma warning disable 592 #endif swig-3.0.8/Lib/swigrun.i0000664000175000017500000000040012641054563014731 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigrun.i * * Empty module (for now). Placeholder for runtime libs * ----------------------------------------------------------------------------- */ %module swigrun swig-3.0.8/Lib/java/0000775000175000017500000000000012641054563014010 5ustar williamwilliamswig-3.0.8/Lib/java/boost_intrusive_ptr.i0000664000175000017500000004734412641054563020321 0ustar williamwilliam// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the // visibility of the constructor and getCPtr method if desired to public if using multiple modules. #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP #define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(protected, protected, CONST, TYPE) #endif #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS #define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE) #endif %include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE "(void)arg1; delete smartarg1;" // Typemap customisations... %typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain value argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{ //plain value(out) $1_ltype* resultp = new $1_ltype(($1_ltype &)$1); intrusive_ptr_add_ref(resultp); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); %} %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{ //plain pointer(out) #if ($owner) if ($1) { intrusive_ptr_add_ref($1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} %typemap(in) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain reference $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if(!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{ //plain reference(out) #if ($owner) if ($1) { intrusive_ptr_add_ref($1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; #endif %} %typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer by reference temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{ // plain pointer by reference(out) #if ($owner) if (*$1) { intrusive_ptr_add_ref(*$1); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } #else *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); #endif %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by value smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if (smartarg) { $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ if ($1) { intrusive_ptr_add_ref(result.get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by reference if ( $input ) { smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ delete &($1); if ($self) { SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); $1 = *temp; } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ if (*$1) { intrusive_ptr_add_ref($1->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer if ( $input ) { smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); $1 = &temp; } else { $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ delete $1; if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ if ($1 && *$1) { intrusive_ptr_add_ref($1->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } if ($owner) delete $1; %} %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer reference smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if ($input) { temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } tempp = &temp; $1 = &tempp; %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if ($self) $1 = *$input; %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ if (*$1 && **$1) { intrusive_ptr_add_ref((*$1)->get()); *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong" %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "long" %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)" %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)" %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) CONST TYPE { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE & { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(javabody) TYPE %{ private transient long swigCPtr; private boolean swigCMemOwnBase; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} // Derived proxy classes %typemap(javabody_derived) TYPE %{ private transient long swigCPtr; private boolean swigCMemOwnDerived; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { if(swigCPtr != 0 && swigCMemOwnBase) { swigCMemOwnBase = false; $jnicall; } swigCPtr = 0; } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { if(swigCPtr != 0 && swigCMemOwnDerived) { swigCMemOwnDerived = false; $jnicall; } swigCPtr = 0; super.delete(); } // CONST version needed ???? also for C# %typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" %typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; %enddef ///////////////////////////////////////////////////////////////////// %include %define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods %feature("unref") TYPE "(void)arg1; delete smartarg1;" // plain value %typemap(in) CONST TYPE ($&1_type argp = 0) %{ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ // shared_ptr by value smartarg = *($&1_ltype*)&$input; if (smartarg) $1 = *smartarg; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong" %typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long" %typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE)" %typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE).getCPtr($javainput)" %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) CONST TYPE { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE & { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(javabody) TYPE %{ private transient long swigCPtr; private boolean swigCMemOwnBase; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} // Derived proxy classes %typemap(javabody_derived) TYPE %{ private transient long swigCPtr; private boolean swigCMemOwnDerived; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { if (swigCPtr != 0) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $jnicall; } swigCPtr = 0; } } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { if (swigCPtr != 0) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $jnicall; } swigCPtr = 0; } super.delete(); } // CONST version needed ???? also for C# %typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" %typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/java/std_pair.i0000664000175000017500000000131012641054563015762 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/java/enumtypesafe.swg0000664000175000017500000001103112641054563017233 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumtypesafe.swg * * Include this file in order for C/C++ enums to be wrapped by the so called * typesafe enum pattern. Each enum has an equivalent Java class named after the * enum and each enum item is a static instance of this class. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(jni) const enum SWIGTYPE & "jint" %typemap(jtype) const enum SWIGTYPE & "int" %typemap(jstype) const enum SWIGTYPE & "$*javaclassname" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$*javaclassname.swigToEnum($jniinput)" %typemap(javadirectorout) const enum SWIGTYPE & "($javacall).swigValue()" %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" %typemap(throws) const enum SWIGTYPE & %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput.swigValue()" %typemap(javaout) const enum SWIGTYPE & { return $*javaclassname.swigToEnum($jnicall); } // enum SWIGTYPE typemaps %typemap(jni) enum SWIGTYPE "jint" %typemap(jtype) enum SWIGTYPE "int" %typemap(jstype) enum SWIGTYPE "$javaclassname" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$javaclassname.swigToEnum($jniinput)" %typemap(javadirectorout) enum SWIGTYPE "($javacall).swigValue()" %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" %typemap(throws) enum SWIGTYPE %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput.swigValue()" %typemap(javaout) enum SWIGTYPE { return $javaclassname.swigToEnum($jnicall); } // '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not %typemap(javaclassmodifiers) enum SWIGTYPE "public final $static class" %typemap(javabase) enum SWIGTYPE "" %typemap(javacode) enum SWIGTYPE "" %typemap(javaimports) enum SWIGTYPE "" %typemap(javainterfaces) enum SWIGTYPE "" /* * The swigToEnum method is used to find the Java enum from a C++ enum integer value. The default one here takes * advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial * values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be * written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum. * The special variable, $enumvalues, is replaced with a comma separated list of all the enum values. */ %typemap(javabody) enum SWIGTYPE %{ public final int swigValue() { return swigValue; } public String toString() { return swigName; } public static $javaclassname swigToEnum(int swigValue) { if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) return swigValues[swigValue]; for (int i = 0; i < swigValues.length; i++) if (swigValues[i].swigValue == swigValue) return swigValues[i]; throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue); } private $javaclassname(String swigName) { this.swigName = swigName; this.swigValue = swigNext++; } private $javaclassname(String swigName, int swigValue) { this.swigName = swigName; this.swigValue = swigValue; swigNext = swigValue+1; } private $javaclassname(String swigName, $javaclassname swigEnum) { this.swigName = swigName; this.swigValue = swigEnum.swigValue; swigNext = this.swigValue+1; } private static $javaclassname[] swigValues = { $enumvalues }; private static int swigNext = 0; private final int swigValue; private final String swigName; %} %javaenum(typesafe); swig-3.0.8/Lib/java/std_except.i0000664000175000017500000000360412641054563016327 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. * These typemaps are used when methods are declared with an STL exception specification, such as * size_t at() const throw (std::out_of_range); * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %ignore exception; struct exception {}; } %typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::invalid_argument "SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, $1.what());\n return $null;" %typemap(throws) std::length_error "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" %typemap(throws) std::logic_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::out_of_range "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" %typemap(throws) std::overflow_error "SWIG_JavaThrowException(jenv, SWIG_JavaArithmeticException, $1.what());\n return $null;" %typemap(throws) std::range_error "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" %typemap(throws) std::runtime_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" %typemap(throws) std::underflow_error "SWIG_JavaThrowException(jenv, SWIG_JavaArithmeticException, $1.what());\n return $null;" swig-3.0.8/Lib/java/std_auto_ptr.i0000664000175000017500000000151612641054563016674 0ustar williamwilliam/* The typemaps here allow to handle functions returning std::auto_ptr<>, which is the most common use of this type. If you have functions taking it as parameter, these typemaps can't be used for them and you need to do something else (e.g. use shared_ptr<> which SWIG supports fully). */ %define %auto_ptr(TYPE) %typemap (jni) std::auto_ptr "jlong" %typemap (jtype) std::auto_ptr "long" %typemap (jstype) std::auto_ptr "$typemap(jstype, TYPE)" %typemap (out) std::auto_ptr %{ jlong lpp = 0; *(TYPE**) &lpp = $1.release(); $result = lpp; %} %typemap(javaout) std::auto_ptr { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %template() std::auto_ptr; %enddef namespace std { template class auto_ptr {}; } swig-3.0.8/Lib/java/enumsimple.swg0000664000175000017500000000501712641054563016713 0ustar williamwilliam/* ----------------------------------------------------------------------------- * enumsimple.swg * * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 * and earlier wrapped global enums with constant integers in the module class * or Constants interface. Enums declared within a C++ class were wrapped by * constant integers in the Java proxy class. * ----------------------------------------------------------------------------- */ // const enum SWIGTYPE & typemaps %typemap(jni) const enum SWIGTYPE & "jint" %typemap(jtype) const enum SWIGTYPE & "int" %typemap(jstype) const enum SWIGTYPE & "int" %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$jniinput" %typemap(javadirectorout) const enum SWIGTYPE & "$javacall" %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" %typemap(throws) const enum SWIGTYPE & %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput" %typemap(javaout) const enum SWIGTYPE & { return $jnicall; } // enum SWIGTYPE typemaps %typemap(jni) enum SWIGTYPE "jint" %typemap(jtype) enum SWIGTYPE "int" %typemap(jstype) enum SWIGTYPE "int" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$jniinput" %typemap(javadirectorout) enum SWIGTYPE "$javacall" %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" %typemap(throws) enum SWIGTYPE %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput" %typemap(javaout) enum SWIGTYPE { return $jnicall; } %typemap(javaclassmodifiers) enum SWIGTYPE "" %typemap(javabase) enum SWIGTYPE "" %typemap(javacode) enum SWIGTYPE "" %typemap(javaimports) enum SWIGTYPE "" %typemap(javainterfaces) enum SWIGTYPE "" %typemap(javabody) enum SWIGTYPE "" %javaenum(simple); swig-3.0.8/Lib/java/std_deque.i0000664000175000017500000000003412641054563016134 0ustar williamwilliam%include swig-3.0.8/Lib/java/std_common.i0000664000175000017500000000014612641054563016325 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.8/Lib/java/arrays_java.i0000664000175000017500000003260112641054563016466 0ustar williamwilliam/* ----------------------------------------------------------------------------- * arrays_java.i * * These typemaps give more natural support for arrays. The typemaps are not efficient * as there is a lot of copying of the array values whenever the array is passed to C/C++ * from Java and vice versa. The Java array is expected to be the same size as the C array. * An exception is thrown if they are not. * * Example usage: * Wrapping: * * %include * %inline %{ * short FiddleSticks[3]; * %} * * Use from Java like this: * * short[] fs = new short[] {10, 11, 12}; * example.setFiddleSticks(fs); * fs = example.getFiddleSticks(); * ----------------------------------------------------------------------------- */ /* Primitive array support is a combination of SWIG macros and functions in order to reduce * code bloat and aid maintainability. The SWIG preprocessor expands the macros into functions * for inclusion in the generated code. */ /* Array support functions declarations macro */ %define JAVA_ARRAYS_DECL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME) %{ static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input); static void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input); static JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz); %} %enddef /* Array support functions macro */ %define JAVA_ARRAYS_IMPL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME) %{ /* CTYPE[] support */ static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input) { int i; jsize sz; if (!input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); return 0; } sz = JCALL1(GetArrayLength, jenv, input); *jarr = JCALL2(Get##JAVATYPE##ArrayElements, jenv, input, 0); if (!*jarr) return 0; %} #ifdef __cplusplus %{ *carr = new CTYPE[sz]; %} #else %{ *carr = (CTYPE*) malloc(sz * sizeof(CTYPE)); %} #endif %{ if (!*carr) { SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); return 0; } for (i=0; i /* The jni, jtype and jstype typemaps work together and so there should be one of each. * The jni typemap contains the JNI type used in the JNI (C/C++) code. * The jtype typemap contains the Java type used in the JNI intermediary class. * The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */ /* Fragments */ %fragment("SWIG_PackData", "header") { /* Pack binary data into a string */ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } } %fragment("SWIG_UnPackData", "header") { /* Unpack binary data from a string */ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } } /* Primitive types */ %typemap(jni) bool, const bool & "jboolean" %typemap(jni) char, const char & "jchar" %typemap(jni) signed char, const signed char & "jbyte" %typemap(jni) unsigned char, const unsigned char & "jshort" %typemap(jni) short, const short & "jshort" %typemap(jni) unsigned short, const unsigned short & "jint" %typemap(jni) int, const int & "jint" %typemap(jni) unsigned int, const unsigned int & "jlong" %typemap(jni) long, const long & "jint" %typemap(jni) unsigned long, const unsigned long & "jlong" %typemap(jni) long long, const long long & "jlong" %typemap(jni) unsigned long long, const unsigned long long & "jobject" %typemap(jni) float, const float & "jfloat" %typemap(jni) double, const double & "jdouble" %typemap(jni) void "void" %typemap(jtype) bool, const bool & "boolean" %typemap(jtype) char, const char & "char" %typemap(jtype) signed char, const signed char & "byte" %typemap(jtype) unsigned char, const unsigned char & "short" %typemap(jtype) short, const short & "short" %typemap(jtype) unsigned short, const unsigned short & "int" %typemap(jtype) int, const int & "int" %typemap(jtype) unsigned int, const unsigned int & "long" %typemap(jtype) long, const long & "int" %typemap(jtype) unsigned long, const unsigned long & "long" %typemap(jtype) long long, const long long & "long" %typemap(jtype) unsigned long long, const unsigned long long & "java.math.BigInteger" %typemap(jtype) float, const float & "float" %typemap(jtype) double, const double & "double" %typemap(jtype) void "void" %typemap(jstype) bool, const bool & "boolean" %typemap(jstype) char, const char & "char" %typemap(jstype) signed char, const signed char & "byte" %typemap(jstype) unsigned char, const unsigned char & "short" %typemap(jstype) short, const short & "short" %typemap(jstype) unsigned short, const unsigned short & "int" %typemap(jstype) int, const int & "int" %typemap(jstype) unsigned int, const unsigned int & "long" %typemap(jstype) long, const long & "int" %typemap(jstype) unsigned long, const unsigned long & "long" %typemap(jstype) long long, const long long & "long" %typemap(jstype) unsigned long long, const unsigned long long & "java.math.BigInteger" %typemap(jstype) float, const float & "float" %typemap(jstype) double, const double & "double" %typemap(jstype) void "void" %typemap(jni) char *, char *&, char[ANY], char[] "jstring" %typemap(jtype) char *, char *&, char[ANY], char[] "String" %typemap(jstype) char *, char *&, char[ANY], char[] "String" /* JNI types */ %typemap(jni) jboolean "jboolean" %typemap(jni) jchar "jchar" %typemap(jni) jbyte "jbyte" %typemap(jni) jshort "jshort" %typemap(jni) jint "jint" %typemap(jni) jlong "jlong" %typemap(jni) jfloat "jfloat" %typemap(jni) jdouble "jdouble" %typemap(jni) jstring "jstring" %typemap(jni) jobject "jobject" %typemap(jni) jbooleanArray "jbooleanArray" %typemap(jni) jcharArray "jcharArray" %typemap(jni) jbyteArray "jbyteArray" %typemap(jni) jshortArray "jshortArray" %typemap(jni) jintArray "jintArray" %typemap(jni) jlongArray "jlongArray" %typemap(jni) jfloatArray "jfloatArray" %typemap(jni) jdoubleArray "jdoubleArray" %typemap(jni) jobjectArray "jobjectArray" %typemap(jtype) jboolean "boolean" %typemap(jtype) jchar "char" %typemap(jtype) jbyte "byte" %typemap(jtype) jshort "short" %typemap(jtype) jint "int" %typemap(jtype) jlong "long" %typemap(jtype) jfloat "float" %typemap(jtype) jdouble "double" %typemap(jtype) jstring "String" %typemap(jtype) jobject "Object" %typemap(jtype) jbooleanArray "boolean[]" %typemap(jtype) jcharArray "char[]" %typemap(jtype) jbyteArray "byte[]" %typemap(jtype) jshortArray "short[]" %typemap(jtype) jintArray "int[]" %typemap(jtype) jlongArray "long[]" %typemap(jtype) jfloatArray "float[]" %typemap(jtype) jdoubleArray "double[]" %typemap(jtype) jobjectArray "Object[]" %typemap(jstype) jboolean "boolean" %typemap(jstype) jchar "char" %typemap(jstype) jbyte "byte" %typemap(jstype) jshort "short" %typemap(jstype) jint "int" %typemap(jstype) jlong "long" %typemap(jstype) jfloat "float" %typemap(jstype) jdouble "double" %typemap(jstype) jstring "String" %typemap(jstype) jobject "Object" %typemap(jstype) jbooleanArray "boolean[]" %typemap(jstype) jcharArray "char[]" %typemap(jstype) jbyteArray "byte[]" %typemap(jstype) jshortArray "short[]" %typemap(jstype) jintArray "int[]" %typemap(jstype) jlongArray "long[]" %typemap(jstype) jfloatArray "float[]" %typemap(jstype) jdoubleArray "double[]" %typemap(jstype) jobjectArray "Object[]" /* Non primitive types */ %typemap(jni) SWIGTYPE "jlong" %typemap(jtype) SWIGTYPE "long" %typemap(jstype) SWIGTYPE "$&javaclassname" %typemap(jni) SWIGTYPE [] "jlong" %typemap(jtype) SWIGTYPE [] "long" %typemap(jstype) SWIGTYPE [] "$javaclassname" %typemap(jni) SWIGTYPE * "jlong" %typemap(jtype) SWIGTYPE * "long" %typemap(jstype) SWIGTYPE * "$javaclassname" %typemap(jni) SWIGTYPE & "jlong" %typemap(jtype) SWIGTYPE & "long" %typemap(jstype) SWIGTYPE & "$javaclassname" %typemap(jni) SWIGTYPE && "jlong" %typemap(jtype) SWIGTYPE && "long" %typemap(jstype) SWIGTYPE && "$javaclassname" /* pointer to a class member */ %typemap(jni) SWIGTYPE (CLASS::*) "jstring" %typemap(jtype) SWIGTYPE (CLASS::*) "String" %typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname" /* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */ /* primitive types */ %typemap(in) bool %{ $1 = $input ? true : false; %} %typemap(directorout) bool %{ $result = $input ? true : false; %} %typemap(javadirectorin) bool "$jniinput" %typemap(javadirectorout) bool "$javacall" %typemap(in) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, float, double %{ $1 = ($1_ltype)$input; %} %typemap(directorout) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, float, double %{ $result = ($1_ltype)$input; %} %typemap(directorin, descriptor="Z") bool "$input = (jboolean) $1;" %typemap(directorin, descriptor="C") char "$input = (jint) $1;" %typemap(directorin, descriptor="B") signed char "$input = (jbyte) $1;" %typemap(directorin, descriptor="S") unsigned char "$input = (jshort) $1;" %typemap(directorin, descriptor="S") short "$input = (jshort) $1;" %typemap(directorin, descriptor="I") unsigned short "$input = (jint) $1;" %typemap(directorin, descriptor="I") int "$input = (jint) $1;" %typemap(directorin, descriptor="J") unsigned int "$input = (jlong) $1;" %typemap(directorin, descriptor="I") long "$input = (jint) $1;" %typemap(directorin, descriptor="J") unsigned long "$input = (jlong) $1;" %typemap(directorin, descriptor="J") long long "$input = (jlong) $1;" %typemap(directorin, descriptor="F") float "$input = (jfloat) $1;" %typemap(directorin, descriptor="D") double "$input = (jdouble) $1;" %typemap(javadirectorin) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, float, double "$jniinput" %typemap(javadirectorout) char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, float, double "$javacall" %typemap(out) bool %{ $result = (jboolean)$1; %} %typemap(out) char %{ $result = (jchar)$1; %} %typemap(out) signed char %{ $result = (jbyte)$1; %} %typemap(out) unsigned char %{ $result = (jshort)$1; %} %typemap(out) short %{ $result = (jshort)$1; %} %typemap(out) unsigned short %{ $result = (jint)$1; %} %typemap(out) int %{ $result = (jint)$1; %} %typemap(out) unsigned int %{ $result = (jlong)$1; %} %typemap(out) long %{ $result = (jint)$1; %} %typemap(out) unsigned long %{ $result = (jlong)$1; %} %typemap(out) long long %{ $result = (jlong)$1; %} %typemap(out) float %{ $result = (jfloat)$1; %} %typemap(out) double %{ $result = (jdouble)$1; %} /* unsigned long long */ /* Convert from BigInteger using the toByteArray member function */ %typemap(in) unsigned long long { jclass clazz; jmethodID mid; jbyteArray ba; jbyte* bae; jsize sz; int i; if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); return $null; } clazz = JCALL1(GetObjectClass, jenv, $input); mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); bae = JCALL2(GetByteArrayElements, jenv, ba, 0); sz = JCALL1(GetArrayLength, jenv, ba); $1 = 0; for(i=0; i", "([B)V"); jobject bigint; int i; bae[0] = 0; for(i=1; i<9; i++ ) { bae[i] = (jbyte)($1>>8*(8-i)); } JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); bigint = JCALL3(NewObject, jenv, clazz, mid, ba); $result = bigint; } /* Convert to BigInteger (see out typemap) */ %typemap(directorin, descriptor="Ljava/math/BigInteger;") unsigned long long, const unsigned long long & { jbyteArray ba = JCALL1(NewByteArray, jenv, 9); jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "", "([B)V"); jobject bigint; int swig_i; bae[0] = 0; for(swig_i=1; swig_i<9; swig_i++ ) { bae[swig_i] = (jbyte)($1>>8*(8-swig_i)); } JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); bigint = JCALL3(NewObject, jenv, clazz, mid, ba); $input = bigint; } %typemap(javadirectorin) unsigned long long "$jniinput" %typemap(javadirectorout) unsigned long long "$javacall" /* char * - treat as String */ %typemap(in, noblock=1) char * { $1 = 0; if ($input) { $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!$1) return $null; } } %typemap(directorout, noblock=1, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * { $1 = 0; if ($input) { $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!$result) return $null; } } %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * { $input = 0; if ($1) { $input = JCALL1(NewStringUTF, jenv, (const char *)$1); if (!$input) return $null; } Swig::LocalRefGuard $1_refguard(jenv, $input); // boohoo } %typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } %typemap(out, noblock=1) char * { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } %typemap(javadirectorin) char * "$jniinput" %typemap(javadirectorout) char * "$javacall" /* char *& - treat as String */ %typemap(in, noblock=1) char *& ($*1_ltype temp = 0) { $1 = 0; if ($input) { temp = ($*1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!temp) return $null; } $1 = &temp; } %typemap(freearg, noblock=1) char *& { if ($1 && *$1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)*$1); } %typemap(out, noblock=1) char *& { if (*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); } %typemap(out) void "" %typemap(javadirectorin) void "$jniinput" %typemap(javadirectorout) void "$javacall" %typemap(directorin, descriptor="V") void "" /* primitive types by reference */ %typemap(in) const bool & ($*1_ltype temp) %{ temp = $input ? true : false; $1 = &temp; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & %{ static $*1_ltype temp; temp = $input ? true : false; $result = &temp; %} %typemap(javadirectorin) const bool & "$jniinput" %typemap(javadirectorout) const bool & "$javacall" %typemap(in) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const float &, const double & %{ static $*1_ltype temp; temp = ($*1_ltype)$input; $result = &temp; %} %typemap(directorin, descriptor="Z") const bool & "$input = (jboolean)$1;" %typemap(directorin, descriptor="C") const char & "$input = (jchar)$1;" %typemap(directorin, descriptor="B") const signed char & "$input = (jbyte)$1;" %typemap(directorin, descriptor="S") const unsigned char & "$input = (jshort)$1;" %typemap(directorin, descriptor="S") const short & "$input = (jshort)$1;" %typemap(directorin, descriptor="I") const unsigned short & "$input = (jint)$1;" %typemap(directorin, descriptor="I") const int & "$input = (jint)$1;" %typemap(directorin, descriptor="J") const unsigned int & "$input = (jlong)$1;" %typemap(directorin, descriptor="I") const long & "$input = (jint)$1;" %typemap(directorin, descriptor="J") const unsigned long & "$input = (jlong)$1;" %typemap(directorin, descriptor="J") const long long & "$input = (jlong)$1;" %typemap(directorin, descriptor="F") const float & "$input = (jfloat)$1;" %typemap(directorin, descriptor="D") const double & "$input = (jdouble)$1;" %typemap(javadirectorin) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) "$jniinput" %typemap(javadirectorout) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), const unsigned char & ($*1_ltype temp), const short & ($*1_ltype temp), const unsigned short & ($*1_ltype temp), const int & ($*1_ltype temp), const unsigned int & ($*1_ltype temp), const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp), const long long & ($*1_ltype temp), const float & ($*1_ltype temp), const double & ($*1_ltype temp) "$javacall" %typemap(out) const bool & %{ $result = (jboolean)*$1; %} %typemap(out) const char & %{ $result = (jchar)*$1; %} %typemap(out) const signed char & %{ $result = (jbyte)*$1; %} %typemap(out) const unsigned char & %{ $result = (jshort)*$1; %} %typemap(out) const short & %{ $result = (jshort)*$1; %} %typemap(out) const unsigned short & %{ $result = (jint)*$1; %} %typemap(out) const int & %{ $result = (jint)*$1; %} %typemap(out) const unsigned int & %{ $result = (jlong)*$1; %} %typemap(out) const long & %{ $result = (jint)*$1; %} %typemap(out) const unsigned long & %{ $result = (jlong)*$1; %} %typemap(out) const long long & %{ $result = (jlong)*$1; %} %typemap(out) const float & %{ $result = (jfloat)*$1; %} %typemap(out) const double & %{ $result = (jdouble)*$1; %} /* const unsigned long long & */ /* Similar to unsigned long long */ %typemap(in) const unsigned long long & ($*1_ltype temp) { jclass clazz; jmethodID mid; jbyteArray ba; jbyte* bae; jsize sz; int i; if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); return $null; } clazz = JCALL1(GetObjectClass, jenv, $input); mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); bae = JCALL2(GetByteArrayElements, jenv, ba, 0); sz = JCALL1(GetArrayLength, jenv, ba); $1 = &temp; temp = 0; for(i=0; i", "([B)V"); jobject bigint; int i; bae[0] = 0; for(i=1; i<9; i++ ) { bae[i] = (jbyte)(*$1>>8*(8-i)); } JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); bigint = JCALL3(NewObject, jenv, clazz, mid, ba); $result = bigint; } %typemap(javadirectorin) const unsigned long long & "$jniinput" %typemap(javadirectorout) const unsigned long long & "$javacall" /* Default handling. Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(directorout) SWIGTYPE ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type"); return $null; } $result = *argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{ *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); *($&1_ltype*)&$result = $1ptr; } #endif %typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE %{ $input = 0; *(($&1_ltype*)&$input) = &$1; %} %typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)" %typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)" /* Generic pointers and references */ %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %} %typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) { const char *temp = 0; if ($input) { temp = JCALL2(GetStringUTFChars, jenv, $input, 0); if (!temp) return $null; } SWIG_UnpackData(temp, (void *)&$1, sizeof($1)); } %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input; if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out) SWIGTYPE * %{ *($&1_ltype)&$result = $1; %} %typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) { char buf[128]; char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1)); *data = '\0'; $result = JCALL1(NewStringUTF, jenv, buf); } %typemap(out) SWIGTYPE & %{ *($&1_ltype)&$result = $1; %} %typemap(out) SWIGTYPE && %{ *($&1_ltype)&$result = $1; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE * %{ $result = *($&1_ltype)&$input; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*) %{ $result = *($&1_ltype)&$input; %} %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE * %{ *(($&1_ltype)&$input) = ($1_ltype) $1; %} %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE (CLASS::*) %{ *(($&1_ltype)&$input) = ($1_ltype) $1; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & %{ if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type"); return $null; } $result = *($&1_ltype)&$input; %} %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE && %{ if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type"); return $null; } $result = *($&1_ltype)&$input; %} %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE & %{ *($&1_ltype)&$input = ($1_ltype) &$1; %} %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE && %{ *($&1_ltype)&$input = ($1_ltype) &$1; %} %typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)" %typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)" %typemap(javadirectorin) SWIGTYPE && "new $javaclassname($jniinput, false)" %typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$javaclassname.getCPtr($javacall)" /* Default array handling */ %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} %typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] "" /* char arrays - treat as String */ %typemap(in, noblock=1) char[ANY], char[] { $1 = 0; if ($input) { $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!$1) return $null; } } %typemap(directorout, noblock=1) char[ANY], char[] { $1 = 0; if ($input) { $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); if (!$result) return $null; } } %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char[ANY], char[] { $input = 0; if ($1) { $input = JCALL1(NewStringUTF, jenv, (const char *)$1); if (!$input) return $null; } Swig::LocalRefGuard $1_refguard(jenv, $input); } %typemap(argout) char[ANY], char[] "" %typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } %typemap(out, noblock=1) char[ANY], char[] { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } %typemap(javadirectorin) char[ANY], char[] "$jniinput" %typemap(javadirectorout) char[ANY], char[] "$javacall" /* JNI types */ %typemap(in) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray %{ $1 = $input; %} %typemap(directorout) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray %{ $result = $input; %} %typemap(out) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray %{ $result = $1; %} %typemap(directorin,descriptor="Z") jboolean "$input = $1;" %typemap(directorin,descriptor="C") jchar "$input = $1;" %typemap(directorin,descriptor="B") jbyte "$input = $1;" %typemap(directorin,descriptor="S") jshort "$input = $1;" %typemap(directorin,descriptor="I") jint "$input = $1;" %typemap(directorin,descriptor="J") jlong "$input = $1;" %typemap(directorin,descriptor="F") jfloat "$input = $1;" %typemap(directorin,descriptor="D") jdouble "$input = $1;" %typemap(directorin,descriptor="Ljava/lang/String;") jstring "$input = $1;" %typemap(directorin,descriptor="Ljava/lang/Object;",nouse="1") jobject "$input = $1;" %typemap(directorin,descriptor="[Z") jbooleanArray "$input = $1;" %typemap(directorin,descriptor="[C") jcharArray "$input = $1;" %typemap(directorin,descriptor="[B") jbyteArray "$input = $1;" %typemap(directorin,descriptor="[S") jshortArray "$input = $1;" %typemap(directorin,descriptor="[I") jintArray "$input = $1;" %typemap(directorin,descriptor="[J") jlongArray "$input = $1;" %typemap(directorin,descriptor="[F") jfloatArray "$input = $1;" %typemap(directorin,descriptor="[D") jdoubleArray "$input = $1;" %typemap(directorin,descriptor="[Ljava/lang/Object;",nouse="1") jobjectArray "$input = $1;" %typemap(javadirectorin) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray "$jniinput" %typemap(javadirectorout) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray "$javacall" /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions * that cannot be overloaded in Java as more than one C++ type maps to a single Java type */ %typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */ jboolean, bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) /* Java char */ jchar, char, const char & "" %typecheck(SWIG_TYPECHECK_INT8) /* Java byte */ jbyte, signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_INT16) /* Java short */ jshort, unsigned char, short, const unsigned char &, const short & "" %typecheck(SWIG_TYPECHECK_INT32) /* Java int */ jint, unsigned short, int, long, const unsigned short &, const int &, const long & "" %typecheck(SWIG_TYPECHECK_INT64) /* Java long */ jlong, unsigned int, unsigned long, long long, const unsigned int &, const unsigned long &, const long long & "" %typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */ unsigned long long, const unsigned long long & "" %typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */ jfloat, float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */ jdouble, double, const double & "" %typecheck(SWIG_TYPECHECK_STRING) /* Java String */ jstring, char *, char *&, char[ANY], char [] "" %typecheck(SWIG_TYPECHECK_BOOL_ARRAY) /* Java boolean[] */ jbooleanArray "" %typecheck(SWIG_TYPECHECK_CHAR_ARRAY) /* Java char[] */ jcharArray "" %typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */ jbyteArray "" %typecheck(SWIG_TYPECHECK_INT16_ARRAY) /* Java short[] */ jshortArray "" %typecheck(SWIG_TYPECHECK_INT32_ARRAY) /* Java int[] */ jintArray "" %typecheck(SWIG_TYPECHECK_INT64_ARRAY) /* Java long[] */ jlongArray "" %typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) /* Java float[] */ jfloatArray "" %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) /* Java double[] */ jdoubleArray "" %typecheck(SWIG_TYPECHECK_OBJECT_ARRAY) /* Java jobject[] */ jobjectArray "" %typecheck(SWIG_TYPECHECK_POINTER) /* Default */ SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Exception handling */ %typemap(throws) int, long, short, unsigned int, unsigned long, unsigned short %{ char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg); return $null; %} %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ (void)$1; SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); return $null; %} %typemap(throws) char * %{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); return $null; %} /* Typemaps for code generation in proxy classes and Java type wrapper classes */ /* The javain typemap is used for converting function parameter types from the type * used in the proxy, module or type wrapper class to the type used in the JNI class. */ %typemap(javain) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double & "$javainput" %typemap(javain) char *, char *&, char[ANY], char[] "$javainput" %typemap(javain) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray "$javainput" %typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)" %typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$javaclassname.getCPtr($javainput)" %typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)" /* The javaout typemap is used for converting function return types from the return type * used in the JNI class to the type returned by the proxy, module or type wrapper class. */ %typemap(javaout) bool, const bool &, char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, unsigned short, const unsigned short &, int, const int &, unsigned int, const unsigned int &, long, const long &, unsigned long, const unsigned long &, long long, const long long &, unsigned long long, const unsigned long long &, float, const float &, double, const double & { return $jnicall; } %typemap(javaout) char *, char *&, char[ANY], char[] { return $jnicall; } %typemap(javaout) jboolean, jchar, jbyte, jshort, jint, jlong, jfloat, jdouble, jstring, jobject, jbooleanArray, jcharArray, jbyteArray, jshortArray, jintArray, jlongArray, jfloatArray, jdoubleArray, jobjectArray { return $jnicall; } %typemap(javaout) void { $jnicall; } %typemap(javaout) SWIGTYPE { return new $&javaclassname($jnicall, true); } %typemap(javaout) SWIGTYPE & { return new $javaclassname($jnicall, $owner); } %typemap(javaout) SWIGTYPE && { return new $javaclassname($jnicall, $owner); } %typemap(javaout) SWIGTYPE *, SWIGTYPE [] { long cPtr = $jnicall; return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner); } %typemap(javaout) SWIGTYPE (CLASS::*) { String cMemberPtr = $jnicall; return (cMemberPtr == null) ? null : new $javaclassname(cMemberPtr, $owner); } /* Pointer reference typemaps */ %typemap(jni) SWIGTYPE *const& "jlong" %typemap(jtype) SWIGTYPE *const& "long" %typemap(jstype) SWIGTYPE *const& "$*javaclassname" %typemap(javain) SWIGTYPE *const& "$*javaclassname.getCPtr($javainput)" %typemap(javaout) SWIGTYPE *const& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner); } %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = *($1_ltype)&$input; $1 = ($1_ltype)&temp; %} %typemap(out) SWIGTYPE *const& %{ *($1_ltype)&$result = *$1; %} /* Typemaps used for the generation of proxy and type wrapper class code */ %typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" %typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* javabody typemaps */ %define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE) %enddef // legacy name %define SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Base proxy classes %typemap(javabody) TYPE %{ private transient long swigCPtr; protected transient boolean swigCMemOwn; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} // Derived proxy classes %typemap(javabody_derived) TYPE %{ private transient long swigCPtr; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %enddef %define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Typewrapper classes %typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{ private transient long swigCPtr; PTRCTOR_VISIBILITY $javaclassname(long cPtr, @SuppressWarnings("unused") boolean futureUse) { swigCPtr = cPtr; } DEFAULTCTOR_VISIBILITY $javaclassname() { swigCPtr = 0; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javabody) TYPE (CLASS::*) %{ private String swigCMemberPtr; PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, @SuppressWarnings("unused") boolean futureUse) { swigCMemberPtr = cMemberPtr; } DEFAULTCTOR_VISIBILITY $javaclassname() { swigCMemberPtr = null; } CPTR_VISIBILITY static String getCMemberPtr($javaclassname obj) { return obj.swigCMemberPtr; } %} %enddef /* Set the default javabody typemaps to use protected visibility. Use the macros to change to public if using multiple modules. */ SWIG_JAVABODY_PROXY(protected, protected, SWIGTYPE) SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE) %typemap(javafinalize) SWIGTYPE %{ protected void finalize() { delete(); } %} /* * Java constructor typemaps: * * The javaconstruct typemap is inserted when a proxy class's constructor is generated. * This typemap allows control over what code is executed in the constructor as * well as specifying who owns the underlying C/C++ object. Normally, Java has * ownership and the underlying C/C++ object is deallocated when the Java object * is finalized (swigCMemOwn is true.) If swigCMemOwn is false, C/C++ is * ultimately responsible for deallocating the underlying object's memory. * * The SWIG_PROXY_CONSTRUCTOR macro defines the javaconstruct typemap for a proxy * class for a particular TYPENAME. OWNERSHIP is passed as the value of * swigCMemOwn to the pointer constructor method. WEAKREF determines which kind * of Java object reference will be used by the C++ director class (WeakGlobalRef * vs. GlobalRef.) * * The SWIG_DIRECTOR_OWNED macro sets the ownership of director-based proxy * classes and the weak reference flag to false, meaning that the underlying C++ * object will be reclaimed by C++. */ %define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...) %typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME { this($imcall, OWNERSHIP);$directorconnect } %enddef %define SWIG_DIRECTOR_OWNED(TYPENAME...) SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME) %enddef // Set the default for SWIGTYPE: Java owns the C/C++ object. SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; $jnicall; } swigCPtr = 0; } } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; $jnicall; } swigCPtr = 0; } super.delete(); } %typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{ protected void $methodname() { swigCMemOwn = false; $jnicall; } %} %typemap(directorowner_release, methodname="swigReleaseOwnership") SWIGTYPE %{ public void $methodname() { swigCMemOwn = false; $jnicall; } %} %typemap(directorowner_take, methodname="swigTakeOwnership") SWIGTYPE %{ public void $methodname() { swigCMemOwn = true; $jnicall; } %} /* Java specific directives */ #define %javaconst(flag) %feature("java:const","flag") #define %javaconstvalue(value) %feature("java:constvalue",value) #define %javaenum(wrapapproach) %feature("java:enum","wrapapproach") #define %javamethodmodifiers %feature("java:methodmodifiers") #define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses) #define %nojavaexception %feature("except","0",throws="") #define %clearjavaexception %feature("except","",throws="") %pragma(java) jniclassclassmodifiers="public class" %pragma(java) moduleclassmodifiers="public class" /* Some ANSI C typemaps */ %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* String & length */ %typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray" %typemap(jtype) (char *STRING, size_t LENGTH) "byte[]" %typemap(jstype) (char *STRING, size_t LENGTH) "byte[]" %typemap(javain) (char *STRING, size_t LENGTH) "$javainput" %typemap(freearg) (char *STRING, size_t LENGTH) "" %typemap(in) (char *STRING, size_t LENGTH) { if ($input) { $1 = ($1_ltype) JCALL2(GetByteArrayElements, jenv, $input, 0); $2 = ($2_type) JCALL1(GetArrayLength, jenv, $input); } else { $1 = 0; $2 = 0; } } %typemap(argout) (char *STRING, size_t LENGTH) { if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); } %typemap(directorin, descriptor="[B") (char *STRING, size_t LENGTH) { jbyteArray jb = (jenv)->NewByteArray((jsize)$2); (jenv)->SetByteArrayRegion(jb, 0, (jsize)$2, (jbyte *)$1); $input = jb; } %typemap(directorargout) (char *STRING, size_t LENGTH) %{(jenv)->GetByteArrayRegion($input, 0, (jsize)$2, (jbyte *)$1); (jenv)->DeleteLocalRef($input);%} %typemap(javadirectorin, descriptor="[B") (char *STRING, size_t LENGTH) "$jniinput" %apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) } /* java keywords */ %include // Default enum handling %include swig-3.0.8/Lib/java/std_wstring.i0000664000175000017500000001150512641054563016533 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_wstring.i * * Typemaps for std::wstring and const std::wstring& * * These are mapped to a Java String and are passed around by value. * Warning: Unicode / multibyte characters are handled differently on different * OSs so the std::wstring typemaps may not always work as intended. * * To use non-const std::wstring references use the following %apply. Note * that they are passed by value. * %apply const std::wstring & {std::wstring &}; * ----------------------------------------------------------------------------- */ namespace std { %naturalvar wstring; class wstring; // wstring %typemap(jni) wstring "jstring" %typemap(jtype) wstring "String" %typemap(jstype) wstring "String" %typemap(javadirectorin) wstring "$jniinput" %typemap(javadirectorout) wstring "$javacall" %typemap(in) wstring %{if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); return $null; } const jchar *$1_pstr = jenv->GetStringChars($input, 0); if (!$1_pstr) return $null; jsize $1_len = jenv->GetStringLength($input); if ($1_len) { $1.reserve($1_len); for (jsize i = 0; i < $1_len; ++i) { $1.push_back((wchar_t)$1_pstr[i]); } } jenv->ReleaseStringChars($input, $1_pstr); %} %typemap(directorout) wstring %{if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); return $null; } const jchar *$1_pstr = jenv->GetStringChars($input, 0); if (!$1_pstr) return $null; jsize $1_len = jenv->GetStringLength($input); if ($1_len) { $result.reserve($1_len); for (jsize i = 0; i < $1_len; ++i) { $result.push_back((wchar_t)$1_pstr[i]); } } jenv->ReleaseStringChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") wstring { jsize $1_len = $1.length(); jchar *conv_buf = new jchar[$1_len]; for (jsize i = 0; i < $1_len; ++i) { conv_buf[i] = (jchar)$1[i]; } $input = jenv->NewString(conv_buf, $1_len); delete [] conv_buf; } %typemap(out) wstring %{jsize $1_len = $1.length(); jchar *conv_buf = new jchar[$1_len]; for (jsize i = 0; i < $1_len; ++i) { conv_buf[i] = (jchar)$1[i]; } $result = jenv->NewString(conv_buf, $1_len); delete [] conv_buf; %} %typemap(javain) wstring "$javainput" %typemap(javaout) wstring { return $jnicall; } //%typemap(typecheck) wstring = wchar_t *; %typemap(throws) wstring %{ std::string message($1.begin(), $1.end()); SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, message.c_str()); return $null; %} // const wstring & %typemap(jni) const wstring & "jstring" %typemap(jtype) const wstring & "String" %typemap(jstype) const wstring & "String" %typemap(javadirectorin) const wstring & "$jniinput" %typemap(javadirectorout) const wstring & "$javacall" %typemap(in) const wstring & %{if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); return $null; } const jchar *$1_pstr = jenv->GetStringChars($input, 0); if (!$1_pstr) return $null; jsize $1_len = jenv->GetStringLength($input); std::wstring $1_str; if ($1_len) { $1_str.reserve($1_len); for (jsize i = 0; i < $1_len; ++i) { $1_str.push_back((wchar_t)$1_pstr[i]); } } $1 = &$1_str; jenv->ReleaseStringChars($input, $1_pstr); %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const wstring & %{if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); return $null; } const jchar *$1_pstr = jenv->GetStringChars($input, 0); if (!$1_pstr) return $null; jsize $1_len = jenv->GetStringLength($input); /* possible thread/reentrant code problem */ static std::wstring $1_str; if ($1_len) { $1_str.reserve($1_len); for (jsize i = 0; i < $1_len; ++i) { $1_str.push_back((wchar_t)$1_pstr[i]); } } $result = &$1_str; jenv->ReleaseStringChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") const wstring & { jsize $1_len = $1.length(); jchar *conv_buf = new jchar[$1_len]; for (jsize i = 0; i < $1_len; ++i) { conv_buf[i] = (jchar)($1)[i]; } $input = jenv->NewString(conv_buf, $1_len); delete [] conv_buf; } %typemap(out) const wstring & %{jsize $1_len = $1->length(); jchar *conv_buf = new jchar[$1_len]; for (jsize i = 0; i < $1_len; ++i) { conv_buf[i] = (jchar)(*$1)[i]; } $result = jenv->NewString(conv_buf, $1_len); delete [] conv_buf; %} %typemap(javain) const wstring & "$javainput" %typemap(javaout) const wstring & { return $jnicall; } //%typemap(typecheck) const wstring & = wchar_t *; %typemap(throws) const wstring & %{ std::string message($1.begin(), $1.end()); SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, message.c_str()); return $null; %} } swig-3.0.8/Lib/java/std_map.i0000664000175000017500000000444112641054563015614 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) #warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" %enddef %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) #warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" %enddef } swig-3.0.8/Lib/java/javakw.swg0000664000175000017500000000236612641054563016024 0ustar williamwilliam#ifndef JAVA_JAVAKW_SWG_ #define JAVA_JAVAKW_SWG_ /* Warnings for Java keywords */ #define JAVAKW(x) %keywordwarn("'" `x` "' is a java keyword, renaming to '_"`x`"'",rename="_%s") `x` /* from http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html */ JAVAKW(abstract); JAVAKW(double); JAVAKW(int); JAVAKW(strictfp); JAVAKW(boolean); JAVAKW(else); JAVAKW(interface); JAVAKW(super); JAVAKW(break); JAVAKW(extends); JAVAKW(long); JAVAKW(switch); JAVAKW(byte); JAVAKW(final); JAVAKW(native); JAVAKW(synchronized); JAVAKW(case); JAVAKW(finally); JAVAKW(new); JAVAKW(this); JAVAKW(catch); JAVAKW(float); JAVAKW(package); JAVAKW(throw); JAVAKW(char); JAVAKW(for); JAVAKW(private); JAVAKW(throws); JAVAKW(class); JAVAKW(goto); JAVAKW(protected); JAVAKW(transient); JAVAKW(const); JAVAKW(if); JAVAKW(public); JAVAKW(try); JAVAKW(continue); JAVAKW(implements); JAVAKW(return); JAVAKW(void); JAVAKW(default); JAVAKW(import); JAVAKW(short); JAVAKW(volatile); JAVAKW(do); JAVAKW(instanceof); JAVAKW(static); JAVAKW(while); /* others bad names */ /* Note here that only *::clone() is bad, and *::clone(int) is ok */ %namewarn("321:clone() is a java bad method name") *::clone(); #undef JAVAKW #endif //JAVA_JAVAKW_SWG_ swig-3.0.8/Lib/java/std_string.i0000664000175000017500000000673412641054563016354 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * Typemaps for std::string and const std::string& * These are mapped to a Java String and are passed around by value. * * To use non-const std::string references use the following %apply. Note * that they are passed by value. * %apply const std::string & {std::string &}; * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; class string; // string %typemap(jni) string "jstring" %typemap(jtype) string "String" %typemap(jstype) string "String" %typemap(javadirectorin) string "$jniinput" %typemap(javadirectorout) string "$javacall" %typemap(in) string %{ if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); return $null; } const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); if (!$1_pstr) return $null; $1.assign($1_pstr); jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorout) string %{ if(!$input) { if (!jenv->ExceptionCheck()) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); } return $null; } const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); if (!$1_pstr) return $null; $result.assign($1_pstr); jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") string %{ $input = jenv->NewStringUTF($1.c_str()); Swig::LocalRefGuard $1_refguard(jenv, $input); %} %typemap(out) string %{ $result = jenv->NewStringUTF($1.c_str()); %} %typemap(javain) string "$javainput" %typemap(javaout) string { return $jnicall; } %typemap(typecheck) string = char *; %typemap(throws) string %{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); return $null; %} // const string & %typemap(jni) const string & "jstring" %typemap(jtype) const string & "String" %typemap(jstype) const string & "String" %typemap(javadirectorin) const string & "$jniinput" %typemap(javadirectorout) const string & "$javacall" %typemap(in) const string & %{ if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); return $null; } const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); if (!$1_pstr) return $null; $*1_ltype $1_str($1_pstr); $1 = &$1_str; jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & %{ if(!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); return $null; } const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); if (!$1_pstr) return $null; /* possible thread/reentrant code problem */ static $*1_ltype $1_str; $1_str = $1_pstr; $result = &$1_str; jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") const string & %{ $input = jenv->NewStringUTF($1.c_str()); Swig::LocalRefGuard $1_refguard(jenv, $input); %} %typemap(out) const string & %{ $result = jenv->NewStringUTF($1->c_str()); %} %typemap(javain) const string & "$javainput" %typemap(javaout) const string & { return $jnicall; } %typemap(typecheck) const string & = char *; %typemap(throws) const string & %{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); return $null; %} } swig-3.0.8/Lib/java/javahead.swg0000664000175000017500000001012512641054563016274 0ustar williamwilliam/* ----------------------------------------------------------------------------- * javahead.swg * * Java support code * ----------------------------------------------------------------------------- */ /* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so * that the same typemaps can be used for generating code for both C and C++. The SWIG preprocessor can expand * the macros thereby generating the correct calling convention. It is thus essential that all typemaps that * use the macros are not within %{ %} brackets as they won't be run through the SWIG preprocessor. */ #ifdef __cplusplus # define JCALL0(func, jenv) jenv->func() # define JCALL1(func, jenv, ar1) jenv->func(ar1) # define JCALL2(func, jenv, ar1, ar2) jenv->func(ar1, ar2) # define JCALL3(func, jenv, ar1, ar2, ar3) jenv->func(ar1, ar2, ar3) # define JCALL4(func, jenv, ar1, ar2, ar3, ar4) jenv->func(ar1, ar2, ar3, ar4) # define JCALL5(func, jenv, ar1, ar2, ar3, ar4, ar5) jenv->func(ar1, ar2, ar3, ar4, ar5) # define JCALL6(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6) jenv->func(ar1, ar2, ar3, ar4, ar5, ar6) # define JCALL7(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) jenv->func(ar1, ar2, ar3, ar4, ar5, ar6, ar7) #else # define JCALL0(func, jenv) (*jenv)->func(jenv) # define JCALL1(func, jenv, ar1) (*jenv)->func(jenv, ar1) # define JCALL2(func, jenv, ar1, ar2) (*jenv)->func(jenv, ar1, ar2) # define JCALL3(func, jenv, ar1, ar2, ar3) (*jenv)->func(jenv, ar1, ar2, ar3) # define JCALL4(func, jenv, ar1, ar2, ar3, ar4) (*jenv)->func(jenv, ar1, ar2, ar3, ar4) # define JCALL5(func, jenv, ar1, ar2, ar3, ar4, ar5) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5) # define JCALL6(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5, ar6) # define JCALL7(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) #endif %insert(runtime) %{ /* Fix for jlong on some versions of gcc on Windows */ #if defined(__GNUC__) && !defined(__INTEL_COMPILER) typedef long long __int64; #endif /* Fix for jlong on 64-bit x86 Solaris */ #if defined(__x86_64) # ifdef _LP64 # undef _LP64 # endif #endif #include #include #include %} %insert(runtime) %{ /* Support for throwing Java exceptions */ typedef enum { SWIG_JavaOutOfMemoryError = 1, SWIG_JavaIOException, SWIG_JavaRuntimeException, SWIG_JavaIndexOutOfBoundsException, SWIG_JavaArithmeticException, SWIG_JavaIllegalArgumentException, SWIG_JavaNullPointerException, SWIG_JavaDirectorPureVirtual, SWIG_JavaUnknownError } SWIG_JavaExceptionCodes; typedef struct { SWIG_JavaExceptionCodes code; const char *java_exception; } SWIG_JavaExceptions_t; %} %insert(runtime) { static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { jclass excep; static const SWIG_JavaExceptions_t java_exceptions[] = { { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, { SWIG_JavaIOException, "java/io/IOException" }, { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, { SWIG_JavaUnknownError, "java/lang/UnknownError" }, { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; const SWIG_JavaExceptions_t *except_ptr = java_exceptions; while (except_ptr->code != code && except_ptr->code) except_ptr++; JCALL0(ExceptionClear, jenv); excep = JCALL1(FindClass, jenv, except_ptr->java_exception); if (excep) JCALL2(ThrowNew, jenv, excep, msg); } } %insert(runtime) %{ /* Contract support */ #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else %} swig-3.0.8/Lib/java/stl.i0000664000175000017500000000044312641054563014765 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/java/boost_shared_ptr.i0000664000175000017500000002115112641054563017523 0ustar williamwilliam// Users can provide their own SWIG_SHARED_PTR_TYPEMAPS macro before including this file to change the // visibility of the constructor and getCPtr method if desired to public if using multiple modules. #ifndef SWIG_SHARED_PTR_TYPEMAPS #define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE) #endif %include // Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" // Typemap customisations... // plain value %typemap(in) CONST TYPE ($&1_type argp = 0) %{ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; if (!argp) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } $1 = *argp; %} %typemap(out) CONST TYPE %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %} // plain reference %typemap(in) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} %typemap(out, fragment="SWIG_null_deleter") CONST TYPE & %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} // plain pointer by reference %typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{ temp = (TYPE *)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); $1 = &temp; %} %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (argp) $1 = *argp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ *($&1_ltype)&$result = *$1 ? new $*1_ltype(*$1) : 0; %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ *($&1_ltype)&$result = ($1 && *$1) ? new $*1_ltype(*$1) : 0; if ($owner) delete $1; %} // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0) %{ temp = $input ? *($1_ltype)&$input : &tempnull; $1 = &temp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ #error "typemaps for $1_type not available" %} %typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "jlong" %typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "long" %typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)" %typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)" %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) CONST TYPE { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE & { return new $typemap(jstype, TYPE)($jnicall, true); } %typemap(javaout) CONST TYPE * { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } %typemap(javaout) TYPE *CONST& { long cPtr = $jnicall; return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(javabody) TYPE %{ private transient long swigCPtr; private transient boolean swigCMemOwn; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} // Derived proxy classes %typemap(javabody_derived) TYPE %{ private transient long swigCPtr; private boolean swigCMemOwnDerived; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; $jnicall; } swigCPtr = 0; } } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { if (swigCPtr != 0) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $jnicall; } swigCPtr = 0; } super.delete(); } %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-3.0.8/Lib/java/director.swg0000664000175000017500000003202512641054563016347 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that Java proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) #include #endif #include namespace Swig { /* Java object wrapper */ class JObjectWrapper { public: JObjectWrapper() : jthis_(NULL), weak_global_(true) { } ~JObjectWrapper() { jthis_ = NULL; weak_global_ = true; } bool set(JNIEnv *jenv, jobject jobj, bool mem_own, bool weak_global) { if (!jthis_) { weak_global_ = weak_global || !mem_own; // hold as weak global if explicitly requested or not owned if (jobj) jthis_ = weak_global_ ? jenv->NewWeakGlobalRef(jobj) : jenv->NewGlobalRef(jobj); #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> " << jthis_ << std::endl; #endif return true; } else { #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> already set" << std::endl; #endif return false; } } jobject get(JNIEnv *jenv) const { #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "JObjectWrapper::get("; if (jthis_) std::cout << jthis_; else std::cout << "null"; std::cout << ") -> return new local ref" << std::endl; #endif return (jthis_ ? jenv->NewLocalRef(jthis_) : jthis_); } void release(JNIEnv *jenv) { #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "JObjectWrapper::release(" << jthis_ << "): " << (weak_global_ ? "weak global ref" : "global ref") << std::endl; #endif if (jthis_) { if (weak_global_) { if (jenv->IsSameObject(jthis_, NULL) == JNI_FALSE) jenv->DeleteWeakGlobalRef((jweak)jthis_); } else jenv->DeleteGlobalRef(jthis_); } jthis_ = NULL; weak_global_ = true; } /* Only call peek if you know what you are doing wrt to weak/global references */ jobject peek() { return jthis_; } /* Java proxy releases ownership of C++ object, C++ object is now responsible for destruction (creates NewGlobalRef to pin Java proxy) */ void java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) { if (take_or_release) { /* Java takes ownership of C++ object's lifetime. */ if (!weak_global_) { jenv->DeleteGlobalRef(jthis_); jthis_ = jenv->NewWeakGlobalRef(jself); weak_global_ = true; } } else { /* Java releases ownership of C++ object's lifetime */ if (weak_global_) { jenv->DeleteWeakGlobalRef((jweak)jthis_); jthis_ = jenv->NewGlobalRef(jself); weak_global_ = false; } } } private: /* pointer to Java object */ jobject jthis_; /* Local or global reference flag */ bool weak_global_; }; /* Local JNI reference deleter */ class LocalRefGuard { JNIEnv *jenv_; jobject jobj_; // non-copyable LocalRefGuard(const LocalRefGuard &); LocalRefGuard &operator=(const LocalRefGuard &); public: LocalRefGuard(JNIEnv *jenv, jobject jobj): jenv_(jenv), jobj_(jobj) {} ~LocalRefGuard() { if (jobj_) jenv_->DeleteLocalRef(jobj_); } }; /* director base class */ class Director { /* pointer to Java virtual machine */ JavaVM *swig_jvm_; protected: #if defined (_MSC_VER) && (_MSC_VER<1300) class JNIEnvWrapper; friend class JNIEnvWrapper; #endif /* Utility class for managing the JNI environment */ class JNIEnvWrapper { const Director *director_; JNIEnv *jenv_; int env_status; public: JNIEnvWrapper(const Director *director) : director_(director), jenv_(0), env_status(0) { #if defined(__ANDROID__) JNIEnv **jenv = &jenv_; #else void **jenv = (void **)&jenv_; #endif env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2); #if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) // Attach a daemon thread to the JVM. Useful when the JVM should not wait for // the thread to exit upon shutdown. Only for jdk-1.4 and later. director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL); #else director_->swig_jvm_->AttachCurrentThread(jenv, NULL); #endif } ~JNIEnvWrapper() { #if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD) // Some JVMs, eg jdk-1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call. // However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak. if (env_status == JNI_EDETACHED) director_->swig_jvm_->DetachCurrentThread(); #endif } JNIEnv *getJNIEnv() const { return jenv_; } }; /* Java object wrapper */ JObjectWrapper swig_self_; /* Disconnect director from Java object */ void swig_disconnect_director_self(const char *disconn_method) { JNIEnvWrapper jnienv(this) ; JNIEnv *jenv = jnienv.getJNIEnv() ; jobject jobj = swig_self_.get(jenv); LocalRefGuard ref_deleter(jenv, jobj); #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "Swig::Director::disconnect_director_self(" << jobj << ")" << std::endl; #endif if (jobj && jenv->IsSameObject(jobj, NULL) == JNI_FALSE) { jmethodID disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(jobj), disconn_method, "()V"); if (disconn_meth) { #if defined(DEBUG_DIRECTOR_OWNED) std::cout << "Swig::Director::disconnect_director_self upcall to " << disconn_method << std::endl; #endif jenv->CallVoidMethod(jobj, disconn_meth); } } } public: Director(JNIEnv *jenv) : swig_jvm_((JavaVM *) NULL), swig_self_() { /* Acquire the Java VM pointer */ jenv->GetJavaVM(&swig_jvm_); } virtual ~Director() { JNIEnvWrapper jnienv(this) ; JNIEnv *jenv = jnienv.getJNIEnv() ; swig_self_.release(jenv); } bool swig_set_self(JNIEnv *jenv, jobject jself, bool mem_own, bool weak_global) { return swig_self_.set(jenv, jself, mem_own, weak_global); } jobject swig_get_self(JNIEnv *jenv) const { return swig_self_.get(jenv); } // Change C++ object's ownership, relative to Java void swig_java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) { swig_self_.java_change_ownership(jenv, jself, take_or_release); } }; // Zero initialized bool array template class BoolArray { bool array_[N]; public: BoolArray() { memset(array_, 0, sizeof(array_)); } bool& operator[](size_t n) { return array_[n]; } bool operator[](size_t n) const { return array_[n]; } }; // Utility classes and functions for exception handling. // Simple holder for a Java string during exception handling, providing access to a c-style string class JavaString { public: JavaString(JNIEnv *jenv, jstring jstr) : jenv_(jenv), jstr_(jstr), cstr_(0) { if (jenv_ && jstr_) cstr_ = (const char *) jenv_->GetStringUTFChars(jstr_, NULL); } ~JavaString() { if (jenv_ && jstr_ && cstr_) jenv_->ReleaseStringUTFChars(jstr_, cstr_); } const char *c_str(const char *null_string = "null JavaString") const { return cstr_ ? cstr_ : null_string; } private: // non-copyable JavaString(const JavaString &); JavaString &operator=(const JavaString &); JNIEnv *jenv_; jstring jstr_; const char *cstr_; }; // Helper class to extract the exception message from a Java throwable class JavaExceptionMessage { public: JavaExceptionMessage(JNIEnv *jenv, jthrowable throwable) : message_(jenv, exceptionMessageFromThrowable(jenv, throwable)) { } const char *message() const { return message_.c_str("Could not get exception message in JavaExceptionMessage"); } private: // non-copyable JavaExceptionMessage(const JavaExceptionMessage &); JavaExceptionMessage &operator=(const JavaExceptionMessage &); // Get exception message by calling Java method Throwable.getMessage() static jstring exceptionMessageFromThrowable(JNIEnv *jenv, jthrowable throwable) { jstring jmsg = NULL; if (jenv && throwable) { jenv->ExceptionClear(); // Cannot invoke methods with any pending exceptions jclass throwclz = jenv->GetObjectClass(throwable); if (throwclz) { // All Throwable classes have a getMessage() method, so call it to extract the exception message jmethodID getMessageMethodID = jenv->GetMethodID(throwclz, "getMessage", "()Ljava/lang/String;"); if (getMessageMethodID) jmsg = (jstring)jenv->CallObjectMethod(throwable, getMessageMethodID); } if (jmsg == NULL && jenv->ExceptionCheck()) jenv->ExceptionClear(); } return jmsg; } JavaString message_; }; // C++ Exception class for handling Java exceptions thrown during a director method Java upcall class DirectorException : public std::exception { public: // Construct exception from a Java throwable DirectorException(JNIEnv *jenv, jthrowable throwable) : classname_(0), msg_(0) { // Call Java method Object.getClass().getName() to obtain the throwable's class name (delimited by '/') if (throwable) { jclass throwclz = jenv->GetObjectClass(throwable); if (throwclz) { jclass clzclz = jenv->GetObjectClass(throwclz); if (clzclz) { jmethodID getNameMethodID = jenv->GetMethodID(clzclz, "getName", "()Ljava/lang/String;"); if (getNameMethodID) { jstring jstr_classname = (jstring)(jenv->CallObjectMethod(throwclz, getNameMethodID)); // Copy strings, since there is no guarantee that jenv will be active when handled if (jstr_classname) { JavaString jsclassname(jenv, jstr_classname); const char *classname = jsclassname.c_str(0); if (classname) classname_ = copypath(classname); } } } } } JavaExceptionMessage exceptionmsg(jenv, throwable); msg_ = copystr(exceptionmsg.message()); } // More general constructor for handling as a java.lang.RuntimeException DirectorException(const char *msg) : classname_(0), msg_(copystr(msg ? msg : "Unspecified DirectorException message")) { } ~DirectorException() throw() { delete[] classname_; delete[] msg_; } const char *what() const throw() { return msg_; } // Reconstruct and raise/throw the Java Exception that caused the DirectorException // Note that any error in the JNI exception handling results in a Java RuntimeException void raiseJavaException(JNIEnv *jenv) const { if (jenv) { jenv->ExceptionClear(); jmethodID ctorMethodID = 0; jclass throwableclass = 0; if (classname_) { throwableclass = jenv->FindClass(classname_); if (throwableclass) ctorMethodID = jenv->GetMethodID(throwableclass, "", "(Ljava/lang/String;)V"); } if (ctorMethodID) { jenv->ThrowNew(throwableclass, what()); } else { SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, what()); } } } private: static char *copypath(const char *srcmsg) { char *target = copystr(srcmsg); for (char *c=target; *c; ++c) { if ('.' == *c) *c = '/'; } return target; } static char *copystr(const char *srcmsg) { char *target = 0; if (srcmsg) { size_t msglen = strlen(srcmsg) + 1; target = new char[msglen]; strncpy(target, srcmsg, msglen); } return target; } const char *classname_; const char *msg_; }; // Helper method to determine if a Java throwable matches a particular Java class type SWIGINTERN bool ExceptionMatches(JNIEnv *jenv, jthrowable throwable, const char *classname) { bool matches = false; if (throwable && jenv && classname) { // Exceptions need to be cleared for correct behavior. // The caller of ExceptionMatches should restore pending exceptions if desired - // the caller already has the throwable. jenv->ExceptionClear(); jclass clz = jenv->FindClass(classname); if (clz) { jclass classclz = jenv->GetObjectClass(clz); jmethodID isInstanceMethodID = jenv->GetMethodID(classclz, "isInstance", "(Ljava/lang/Object;)Z"); if (isInstanceMethodID) { matches = jenv->CallBooleanMethod(clz, isInstanceMethodID, throwable) != 0; } } #if defined(DEBUG_DIRECTOR_EXCEPTION) if (jenv->ExceptionCheck()) { // Typically occurs when an invalid classname argument is passed resulting in a ClassNotFoundException JavaExceptionMessage exc(jenv, jenv->ExceptionOccurred()); std::cout << "Error: ExceptionMatches: class '" << classname << "' : " << exc.message() << std::endl; } #endif } return matches; } } swig-3.0.8/Lib/java/std_shared_ptr.i0000664000175000017500000000010412641054563017162 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-3.0.8/Lib/java/typemaps.i0000664000175000017500000004122012641054563016023 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* INPUT typemaps -------------- These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is passed by value instead of reference. The following typemaps can be applied to turn a pointer or reference into a simple input value. That is, instead of passing a pointer or reference to an object, you would use a real value instead. bool *INPUT, bool &INPUT signed char *INPUT, signed char &INPUT unsigned char *INPUT, unsigned char &INPUT short *INPUT, short &INPUT unsigned short *INPUT, unsigned short &INPUT int *INPUT, int &INPUT unsigned int *INPUT, unsigned int &INPUT long *INPUT, long &INPUT unsigned long *INPUT, unsigned long &INPUT long long *INPUT, long long &INPUT unsigned long long *INPUT, unsigned long long &INPUT float *INPUT, float &INPUT double *INPUT, double &INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); In Java you could then use it like this: double answer = modulename.fadd(10.0, 20.0); There are no char *INPUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *INPUT {char *input}; void f(char *input); */ %define INPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JNIDESC) %typemap(jni) TYPE *INPUT, TYPE &INPUT "JNITYPE" %typemap(jtype) TYPE *INPUT, TYPE &INPUT "JTYPE" %typemap(jstype) TYPE *INPUT, TYPE &INPUT "JTYPE" %typemap(javain) TYPE *INPUT, TYPE &INPUT "$javainput" %typemap(in) TYPE *INPUT, TYPE &INPUT %{ $1 = ($1_ltype)&$input; %} %typemap(freearg) TYPE *INPUT, TYPE &INPUT "" %typemap(typecheck) TYPE *INPUT = TYPE; %typemap(typecheck) TYPE &INPUT = TYPE; %enddef INPUT_TYPEMAP(bool, jboolean, boolean, "Z"); INPUT_TYPEMAP(signed char, jbyte, byte, "B"); INPUT_TYPEMAP(unsigned char, jshort, short, "S"); INPUT_TYPEMAP(short, jshort, short, "S"); INPUT_TYPEMAP(unsigned short, jint, int, "I"); INPUT_TYPEMAP(int, jint, int, "I"); INPUT_TYPEMAP(unsigned int, jlong, long, "J"); INPUT_TYPEMAP(long, jint, int, "I"); INPUT_TYPEMAP(unsigned long, jlong, long, "J"); INPUT_TYPEMAP(long long, jlong, long, "J"); INPUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, "Ljava/math/BigInteger;"); INPUT_TYPEMAP(float, jfloat, float, "F"); INPUT_TYPEMAP(double, jdouble, double, "D"); #undef INPUT_TYPEMAP /* Convert from BigInteger using the toByteArray member function */ /* Overrides the typemap in the INPUT_TYPEMAP macro */ %typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { jclass clazz; jmethodID mid; jbyteArray ba; jbyte* bae; jsize sz; int i; if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); return $null; } clazz = JCALL1(GetObjectClass, jenv, $input); mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); bae = JCALL2(GetByteArrayElements, jenv, ba, 0); sz = JCALL1(GetArrayLength, jenv, ba); temp = 0; for(i=0; i double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Java output of the function would be the function return value and the value in the single element array. In Java you would use it like this: double[] ptr = {0.0}; double fraction = modulename.modf(5.0,ptr); There are no char *OUTPUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *OUTPUT {char *output}; void f(char *output); */ /* Java BigInteger[] */ %typecheck(SWIG_TYPECHECK_INT128_ARRAY) SWIGBIGINTEGERARRAY "" %define OUTPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE) %typemap(jni) TYPE *OUTPUT, TYPE &OUTPUT %{JNITYPE##Array%} %typemap(jtype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]" %typemap(jstype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]" %typemap(javain) TYPE *OUTPUT, TYPE &OUTPUT "$javainput" %typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp) { if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } temp = ($*1_ltype)0; $1 = &temp; } %typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT "" %typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT { JNITYPE jvalue = (JNITYPE)temp$argnum; JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue); } %typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE; %typemap(typecheck) TYPE &OUTPUT = TYPECHECKTYPE; %enddef OUTPUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); OUTPUT_TYPEMAP(signed char, jbyte, byte, Byte, "[Ljava/lang/Byte;", jbyteArray); OUTPUT_TYPEMAP(unsigned char, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); OUTPUT_TYPEMAP(short, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); OUTPUT_TYPEMAP(unsigned short, jint, int, Int, "[Ljava/lang/Integer;", jintArray); OUTPUT_TYPEMAP(int, jint, int, Int, "[Ljava/lang/Integer;", jintArray); OUTPUT_TYPEMAP(unsigned int, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); OUTPUT_TYPEMAP(long, jint, int, Int, "[Ljava/lang/Integer;", jintArray); OUTPUT_TYPEMAP(unsigned long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); OUTPUT_TYPEMAP(long long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); OUTPUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, NOTUSED, "[Ljava/lang/BigInteger;", SWIGBIGINTEGERARRAY); OUTPUT_TYPEMAP(float, jfloat, float, Float, "[Ljava/lang/Float;", jfloatArray); OUTPUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleArray); #undef OUTPUT_TYPEMAP %typemap(in) bool *OUTPUT($*1_ltype temp), bool &OUTPUT($*1_ltype temp) { if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } temp = false; $1 = &temp; } /* Convert to BigInteger - byte array holds number in 2's complement big endian format */ /* Use first element in BigInteger array for output */ /* Overrides the typemap in the OUTPUT_TYPEMAP macro */ %typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { jbyteArray ba = JCALL1(NewByteArray, jenv, 9); jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "", "([B)V"); jobject bigint; int i; bae[0] = 0; for(i=1; i<9; i++ ) { bae[i] = (jbyte)(temp$argnum>>8*(8-i)); } JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); bigint = JCALL3(NewObject, jenv, clazz, mid, ba); JCALL3(SetObjectArrayElement, jenv, $input, 0, bigint); } /* INOUT typemaps -------------- Mappings for a parameter that is both an input and an output parameter The following typemaps can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" typemaps described earlier. Output values are returned as an element in a Java array. bool *INOUT, bool &INOUT signed char *INOUT, signed char &INOUT unsigned char *INOUT, unsigned char &INOUT short *INOUT, short &INOUT unsigned short *INOUT, unsigned short &INOUT int *INOUT, int &INOUT unsigned int *INOUT, unsigned int &INOUT long *INOUT, long &INOUT unsigned long *INOUT, unsigned long &INOUT long long *INOUT, long long &INOUT unsigned long long *INOUT, unsigned long long &INOUT float *INOUT, float &INOUT double *INOUT, double &INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); This works similarly to C in that the mapping directly modifies the input value - the input must be an array with a minimum of one element. The element in the array is the input and the output is the element in the array. double x[] = {5.0}; neg(x); The implementation of the OUTPUT and INOUT typemaps is different to other languages in that other languages will return the output value as part of the function return value. This difference is due to Java being a typed language. There are no char *INOUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *INOUT {char *inout}; void f(char *inout); */ %define INOUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE) %typemap(jni) TYPE *INOUT, TYPE &INOUT %{JNITYPE##Array%} %typemap(jtype) TYPE *INOUT, TYPE &INOUT "JTYPE[]" %typemap(jstype) TYPE *INOUT, TYPE &INOUT "JTYPE[]" %typemap(javain) TYPE *INOUT, TYPE &INOUT "$javainput" %typemap(in) TYPE *INOUT, TYPE &INOUT { if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } $1 = ($1_ltype) JCALL2(Get##JAVATYPE##ArrayElements, jenv, $input, 0); } %typemap(freearg) TYPE *INOUT, TYPE &INOUT "" %typemap(argout) TYPE *INOUT, TYPE &INOUT { JCALL3(Release##JAVATYPE##ArrayElements, jenv, $input, (JNITYPE *)$1, 0); } %typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; %typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE; %enddef INOUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); INOUT_TYPEMAP(signed char, jbyte, byte, Byte, "[Ljava/lang/Byte;", jbyteArray); INOUT_TYPEMAP(unsigned char, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); INOUT_TYPEMAP(short, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); INOUT_TYPEMAP(unsigned short, jint, int, Int, "[Ljava/lang/Integer;", jintArray); INOUT_TYPEMAP(int, jint, int, Int, "[Ljava/lang/Integer;", jintArray); INOUT_TYPEMAP(unsigned int, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); INOUT_TYPEMAP(long, jint, int, Int, "[Ljava/lang/Integer;", jintArray); INOUT_TYPEMAP(unsigned long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); INOUT_TYPEMAP(long long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); INOUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, NOTUSED, "[Ljava.math.BigInteger;", SWIGBIGINTEGERARRAY); INOUT_TYPEMAP(float, jfloat, float, Float, "[Ljava/lang/Float;", jfloatArray); INOUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleArray); #undef INOUT_TYPEMAP /* Override typemaps in the INOUT_TYPEMAP macro for booleans to fix casts as a jboolean isn't always the same size as a bool */ %typemap(in) bool *INOUT (bool btemp, jboolean *jbtemp), bool &INOUT (bool btemp, jboolean *jbtemp) { if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } jbtemp = JCALL2(GetBooleanArrayElements, jenv, $input, 0); btemp = (*jbtemp) ? true : false; $1 = &btemp; } %typemap(argout) bool *INOUT, bool &INOUT { *jbtemp$argnum = btemp$argnum ? (jboolean)1 : (jboolean)0; JCALL3(ReleaseBooleanArrayElements, jenv, $input , (jboolean *)jbtemp$argnum, 0); } /* Override the typemap in the INOUT_TYPEMAP macro for unsigned long long */ %typemap(in) unsigned long long *INOUT ($*1_ltype temp), unsigned long long &INOUT ($*1_ltype temp) { jobject bigint; jclass clazz; jmethodID mid; jbyteArray ba; jbyte* bae; jsize sz; int i; if (!$input) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return $null; } if (JCALL1(GetArrayLength, jenv, $input) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return $null; } bigint = JCALL2(GetObjectArrayElement, jenv, $input, 0); if (!bigint) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array element null"); return $null; } clazz = JCALL1(GetObjectClass, jenv, bigint); mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, bigint, mid); bae = JCALL2(GetByteArrayElements, jenv, ba, 0); sz = JCALL1(GetArrayLength, jenv, ba); temp = 0; for(i=0; i %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i= 0 && swigValues[swigValue].swigValue == swigValue) return swigValues[swigValue]; for ($javaclassname swigEnum : swigValues) if (swigEnum.swigValue == swigValue) return swigEnum; throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue); } @SuppressWarnings("unused") private $javaclassname() { this.swigValue = SwigNext.next++; } @SuppressWarnings("unused") private $javaclassname(int swigValue) { this.swigValue = swigValue; SwigNext.next = swigValue+1; } @SuppressWarnings("unused") private $javaclassname($javaclassname swigEnum) { this.swigValue = swigEnum.swigValue; SwigNext.next = this.swigValue+1; } private final int swigValue; private static class SwigNext { private static int next = 0; } %} %javaenum(proper); swig-3.0.8/Lib/java/various.i0000664000175000017500000001336012641054563015655 0ustar williamwilliam/* ----------------------------------------------------------------------------- * various.i * * SWIG Typemap library for Java. * Various useful typemaps. * ----------------------------------------------------------------------------- */ /* * char **STRING_ARRAY typemaps. * These typemaps are for C String arrays which are NULL terminated. * char *values[] = { "one", "two", "three", NULL }; // note NULL * char ** is mapped to a Java String[]. * * Example usage wrapping: * %apply char **STRING_ARRAY { char **input }; * char ** foo(char **input); * * Java usage: * String numbers[] = { "one", "two", "three" }; * String[] ret = modulename.foo( numbers }; */ %typemap(jni) char **STRING_ARRAY "jobjectArray" %typemap(jtype) char **STRING_ARRAY "String[]" %typemap(jstype) char **STRING_ARRAY "String[]" %typemap(in) char **STRING_ARRAY (jint size) { int i = 0; if ($input) { size = JCALL1(GetArrayLength, jenv, $input); #ifdef __cplusplus $1 = new char*[size+1]; #else $1 = (char **)malloc((size+1) * sizeof(char *)); #endif for (i = 0; i %} /* %malloc(TYPE [, NAME = TYPE]) %calloc(TYPE [, NAME = TYPE]) %realloc(TYPE [, NAME = TYPE]) %free(TYPE [, NAME = TYPE]) %allocators(TYPE [,NAME = TYPE]) Creates functions for allocating/reallocating memory. TYPE *malloc_NAME(int nbytes = sizeof(TYPE); TYPE *calloc_NAME(int nobj=1, int size=sizeof(TYPE)); TYPE *realloc_NAME(TYPE *ptr, int nbytes); void free_NAME(TYPE *ptr); */ %define %malloc(TYPE,NAME...) #if #NAME != "" %rename(malloc_##NAME) ::malloc(int nbytes); #else %rename(malloc_##TYPE) ::malloc(int nbytes); #endif #if #TYPE != "void" %typemap(default) int nbytes "$1 = (int) sizeof(TYPE);" #endif TYPE *malloc(int nbytes); %typemap(default) int nbytes; %enddef %define %calloc(TYPE,NAME...) #if #NAME != "" %rename(calloc_##NAME) ::calloc(int nobj, int sz); #else %rename(calloc_##TYPE) ::calloc(int nobj, int sz); #endif #if #TYPE != "void" %typemap(default) int sz "$1 = (int) sizeof(TYPE);" #else %typemap(default) int sz "$1 = 1;" #endif %typemap(default) int nobj "$1 = 1;" TYPE *calloc(int nobj, int sz); %typemap(default) int sz; %typemap(default) int nobj; %enddef %define %realloc(TYPE,NAME...) %insert("header") { #if #NAME != "" TYPE *realloc_##NAME(TYPE *ptr, int nitems) #else TYPE *realloc_##TYPE(TYPE *ptr, int nitems) #endif { #if #TYPE != "void" return (TYPE *) realloc(ptr, nitems*sizeof(TYPE)); #else return (TYPE *) realloc(ptr, nitems); #endif } } #if #NAME != "" TYPE *realloc_##NAME(TYPE *ptr, int nitems); #else TYPE *realloc_##TYPE(TYPE *ptr, int nitems); #endif %enddef %define %free(TYPE,NAME...) #if #NAME != "" %rename(free_##NAME) ::free(TYPE *ptr); #else %rename(free_##TYPE) ::free(TYPE *ptr); #endif void free(TYPE *ptr); %enddef %define %sizeof(TYPE,NAME...) #if #NAME != "" %constant int sizeof_##NAME = sizeof(TYPE); #else %constant int sizeof_##TYPE = sizeof(TYPE); #endif %enddef %define %allocators(TYPE,NAME...) %malloc(TYPE,NAME) %calloc(TYPE,NAME) %realloc(TYPE,NAME) %free(TYPE,NAME) #if #TYPE != "void" %sizeof(TYPE,NAME) #endif %enddef swig-3.0.8/Lib/go/0000775000175000017500000000000012641054563013474 5ustar williamwilliamswig-3.0.8/Lib/go/std_pair.i0000664000175000017500000000131012641054563015446 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_pair.i * * SWIG typemaps for std::pair * ----------------------------------------------------------------------------- */ %include %include // ------------------------------------------------------------------------ // std::pair // ------------------------------------------------------------------------ %{ #include %} namespace std { template struct pair { pair(); pair(T first, U second); pair(const pair& p); template pair(const pair &p); T first; U second; }; // add specializations here } swig-3.0.8/Lib/go/std_except.i0000664000175000017500000000226712641054563016017 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. * These typemaps are used when methods are declared with an STL exception specification, such as * size_t at() const throw (std::out_of_range); * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %ignore exception; struct exception {}; } %typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%} %typemap(throws) std::domain_error %{_swig_gopanic($1.what());%} %typemap(throws) std::exception %{_swig_gopanic($1.what());%} %typemap(throws) std::invalid_argument %{_swig_gopanic($1.what());%} %typemap(throws) std::length_error %{_swig_gopanic($1.what());%} %typemap(throws) std::logic_error %{_swig_gopanic($1.what());%} %typemap(throws) std::out_of_range %{_swig_gopanic($1.what());%} %typemap(throws) std::overflow_error %{_swig_gopanic($1.what());%} %typemap(throws) std::range_error %{_swig_gopanic($1.what());%} %typemap(throws) std::runtime_error %{_swig_gopanic($1.what());%} %typemap(throws) std::underflow_error %{_swig_gopanic($1.what());%} swig-3.0.8/Lib/go/cdata.i0000664000175000017500000000444012641054563014724 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cdata.i * * SWIG library file containing macros for manipulating raw C data as strings. * ----------------------------------------------------------------------------- */ %{ typedef struct SWIGCDATA { char *data; intgo len; } SWIGCDATA; %} %fragment("cdata", "header") %{ struct swigcdata { intgo size; void *data; }; %} %typemap(gotype) SWIGCDATA "[]byte" %typemap(imtype) SWIGCDATA "uint64" %typemap(out, fragment="cdata") SWIGCDATA(struct swigcdata *swig_out) %{ swig_out = (struct swigcdata *)malloc(sizeof(*swig_out)); if (swig_out) { swig_out->size = $1.len; swig_out->data = malloc(swig_out->size); if (swig_out->data) { memcpy(swig_out->data, $1.data, swig_out->size); } } $result = *(long long *)(void **)&swig_out; %} %typemap(goout) SWIGCDATA %{ { type swigcdata struct { size int; data uintptr } p := (*swigcdata)(unsafe.Pointer(uintptr($1))) if p == nil || p.data == 0 { $result = nil } else { b := make([]byte, p.size) a := (*[0x7fffffff]byte)(unsafe.Pointer(p.data))[:p.size] copy(b, a) Swig_free(p.data) Swig_free(uintptr(unsafe.Pointer(p))) $result = b } } %} /* ----------------------------------------------------------------------------- * %cdata(TYPE [, NAME]) * * Convert raw C data to a binary string. * ----------------------------------------------------------------------------- */ %define %cdata(TYPE,NAME...) %insert("header") { #if #NAME == "" static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) { #else static SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements) { #endif SWIGCDATA d; d.data = (char *) ptr; #if #TYPE != "void" d.len = nelements*sizeof(TYPE); #else d.len = nelements; #endif return d; } } %typemap(default) int nelements "$1 = 1;" #if #NAME == "" SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements); #else SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements); #endif %enddef %typemap(default) int nelements; %rename(cdata) ::cdata_void(void *ptr, int nelements); %cdata(void); /* Memory move function. Due to multi-argument typemaps this appears to be wrapped as void memmove(void *data, const char *s); */ void memmove(void *data, char *indata, int inlen); swig-3.0.8/Lib/go/exception.i0000664000175000017500000000025512641054563015646 0ustar williamwilliam%typemap(throws,noblock=1) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } %insert("runtime") %{ #define SWIG_exception(code, msg) _swig_gopanic(msg) %} swig-3.0.8/Lib/go/std_deque.i0000664000175000017500000000003412641054563015620 0ustar williamwilliam%include swig-3.0.8/Lib/go/std_common.i0000664000175000017500000000014512641054563016010 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-3.0.8/Lib/go/gostring.swg0000664000175000017500000000152312641054563016053 0ustar williamwilliam/* ------------------------------------------------------------ * gostring.swg * * Support for returning strings from C to Go. * ------------------------------------------------------------ */ // C/C++ code to convert a memory buffer into a Go string allocated in // C/C++ memory. %fragment("AllocateString", "runtime") %{ static _gostring_ Swig_AllocateString(const char *p, size_t l) { _gostring_ ret; ret.p = (char*)malloc(l); memcpy(ret.p, p, l); ret.n = l; return ret; } %} // Go code to convert a string allocated in C++ memory to one // allocated in Go memory. %fragment("CopyString", "go_runtime") %{ type swig_gostring struct { p uintptr; n int } func swigCopyString(s string) string { p := *(*swig_gostring)(unsafe.Pointer(&s)) r := string((*[0x7fffffff]byte)(unsafe.Pointer(p.p))[:p.n]) Swig_free(p.p) return r } %} swig-3.0.8/Lib/go/goruntime.swg0000664000175000017500000002173112641054563016233 0ustar williamwilliam/* ------------------------------------------------------------ * goruntime.swg * * Go runtime code for the various generated files. * ------------------------------------------------------------ */ %inline %{ static void Swig_free(void* p) { free(p); } %} %insert(runtime) %{ #include #include #include #include #include %} #if SWIGGO_CGO %insert(cgo_comment_typedefs) %{ #include %} #endif #if SWIGGO_INTGO_SIZE == 32 %insert(runtime) %{ typedef int intgo; typedef unsigned int uintgo; %} #if SWIGGO_CGO %insert(cgo_comment_typedefs) %{ typedef int intgo; typedef unsigned int uintgo; %} #endif #elif SWIGGO_INTGO_SIZE == 64 %insert(runtime) %{ typedef long long intgo; typedef unsigned long long uintgo; %} #if SWIGGO_CGO %insert(cgo_comment_typedefs) %{ typedef long long intgo; typedef unsigned long long uintgo; %} #endif #else %insert(runtime) %{ typedef ptrdiff_t intgo; typedef size_t uintgo; %} #if SWIGGO_CGO %insert(cgo_comment_typedefs) %{ typedef ptrdiff_t intgo; typedef size_t uintgo; %} #endif #endif %insert(runtime) %{ typedef struct { char *p; intgo n; } _gostring_; typedef struct { void* array; intgo len; intgo cap; } _goslice_; %} #ifdef SWIGGO_CGO %insert(cgo_comment_typedefs) %{ typedef struct { char *p; intgo n; } _gostring_; typedef struct { void* array; intgo len; intgo cap; } _goslice_; %} #endif #ifndef SWIGGO_GCCGO /* Boilerplate for C/C++ code when using 6g/8g. This code is compiled with gcc. */ %insert(runtime) %{ #define swiggo_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1]; #define swiggo_size_assert(t, n) swiggo_size_assert_eq(sizeof(t), n, swiggo_sizeof_##t##_is_not_##n) swiggo_size_assert(char, 1) swiggo_size_assert(short, 2) swiggo_size_assert(int, 4) typedef long long swiggo_long_long; swiggo_size_assert(swiggo_long_long, 8) swiggo_size_assert(float, 4) swiggo_size_assert(double, 8) #ifdef __cplusplus extern "C" { #endif extern void crosscall2(void (*fn)(void *, int), void *, int); extern char* _cgo_topofstack(void) __attribute__ ((weak)); extern void _cgo_allocate(void *, int); extern void _cgo_panic(void *, int); #ifdef __cplusplus } #endif static char *_swig_topofstack() { if (_cgo_topofstack) { return _cgo_topofstack(); } else { return 0; } } static void _swig_gopanic(const char *p) { struct { const char *p; } a; a.p = p; crosscall2(_cgo_panic, &a, (int) sizeof a); } %} #if !SWIGGO_CGO /* This is here for backward compatibility, but it will not work with Go 1.5 or later. Do not use it in new code. */ %insert(runtime) %{ static void *_swig_goallocate(size_t len) { struct { size_t len; void *ret; } a; a.len = len; crosscall2(_cgo_allocate, &a, (int) sizeof a); return a.ret; } %} #endif #if !SWIGGO_CGO /* Boilerplate for C code when using 6g/8g. This code is compiled with 6c/8c. */ %insert(gc_header) %{ #include "runtime.h" #include "cgocall.h" #pragma dataflag 16 static void *cgocall = runtime·cgocall; #pragma dataflag 16 void *·_cgo_runtime_cgocall = &cgocall; %} #endif #else /* Boilerplate for C/C++ code when using gccgo. */ %insert(runtime) %{ #define SWIGGO_GCCGO #ifdef __cplusplus extern "C" { #endif extern void *_cgo_allocate(size_t); extern void _cgo_panic(const char *); #ifdef __cplusplus } #endif #define _swig_goallocate _cgo_allocate #define _swig_gopanic _cgo_panic %} #if !SWIGGO_CGO %insert(runtime) %{ /* Implementations of SwigCgocall and friends for different versions of gccgo. The Go code will call these functions using C names with a prefix of the module name. The implementations here call the routine in libgo. The routines to call vary depending on the gccgo version. We assume that the version of gcc used to compile this file is the same as the version of gccgo. */ #ifdef __cplusplus extern "C" { #endif #define SWIG_GCC_VERSION \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #if SWIG_GCC_VERSION < 40700 #define SwigDoCgocall() #define SwigDoCgocallDone() #define SwigDoCgocallBack() #define SwigDoCgocallBackDone() #elif SWIG_GCC_VERSION == 40700 void SwigDoCgocall(void) __asm__("libgo_syscall.syscall.Entersyscall"); void SwigDoCgocallDone(void) __asm__("libgo_syscall.syscall.Exitsyscall"); void SwigDoCgocallBack(void) __asm__("libgo_syscall.syscall.Exitsyscall"); void SwigDoCgocallBackDone(void) __asm__("libgo_syscall.syscall.Entersyscall"); #else void SwigDoCgocall(void) __asm__("syscall.Cgocall"); void SwigDoCgocallDone(void) __asm__("syscall.CgocallDone"); void SwigDoCgocallBack(void) __asm__("syscall.CgocallBack"); void SwigDoCgocallBackDone(void) __asm__("syscall.CgocallBackDone"); #endif #define SWIGSTRINGIFY2(s) #s #define SWIGSTRINGIFY(s) SWIGSTRINGIFY2(s) void SwigCgocall() __asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocall"); void SwigCgocall() { SwigDoCgocall(); } void SwigCgocallDone() __asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallDone"); void SwigCgocallDone() { SwigDoCgocallDone(); } void SwigCgocallBack() __asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallBack"); void SwigCgocallBack() { SwigDoCgocallBack(); } void SwigCgocallBackDone() __asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallBackDone"); void SwigCgocallBackDone() { SwigDoCgocallBackDone(); } #undef SWIGSTRINGIFY #undef SWIGSTRINGIFY2 #ifdef __cplusplus } #endif %} #endif #endif #if !SWIGGO_CGO %insert(runtime) %{ /* This is here for backward compatibility, but it will not work with Go 1.5 or later. Do not use it in new code. */ static _gostring_ _swig_makegostring(const char *p, size_t l) { _gostring_ ret; ret.p = (char*)_swig_goallocate(l + 1); memcpy(ret.p, p, l); ret.n = l; return ret; } %} #endif %insert(runtime) %{ #define SWIG_contract_assert(expr, msg) \ if (!(expr)) { _swig_gopanic(msg); } else %} #ifndef SWIGGO_GCCGO %go_import("unsafe", _ "runtime/cgo") #if !SWIGGO_CGO %insert(go_header) %{ var _cgo_runtime_cgocall func(unsafe.Pointer, uintptr) %} #endif #else %go_import("syscall", "unsafe") %insert(go_header) %{ type _ syscall.Sockaddr %} #endif %insert(go_header) %{ type _ unsafe.Pointer %} /* Swig_always_false is used to conditionally assign parameters to Swig_escape_val so that the compiler thinks that they escape. We only assign them if Swig_always_false is true, which it never is. We export the variable so that the compiler doesn't realize that it is never set. */ %insert(go_header) %{ var Swig_escape_always_false bool var Swig_escape_val interface{} %} /* Function pointers are translated by the code in go.cxx into _swig_fnptr. Member pointers are translated to _swig_memberptr. */ %insert(go_header) %{ type _swig_fnptr *byte type _swig_memberptr *byte %} /* Handle memory management for directors. */ %insert(director) %{ #include namespace { struct GCItem { virtual ~GCItem() {} }; struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) { } GCItem_var& operator=(GCItem *item) { GCItem *tmp = _item; _item = item; delete tmp; return *this; } ~GCItem_var() { delete _item; } GCItem* operator->() { return _item; } private: GCItem *_item; }; template struct GCItem_T : GCItem { GCItem_T(Type *ptr) : _ptr(ptr) { } virtual ~GCItem_T() { delete _ptr; } private: Type *_ptr; }; } class Swig_memory { public: template void swig_acquire_pointer(Type* vptr) { if (vptr) { swig_owner[vptr] = new GCItem_T(vptr); } } private: typedef std::map swig_ownership_map; swig_ownership_map swig_owner; }; template static void swig_acquire_pointer(Swig_memory** pmem, Type* ptr) { if (!pmem) { *pmem = new Swig_memory; } (*pmem)->swig_acquire_pointer(ptr); } %} /* For directors we need C++ to track a Go pointer. Since we can't pass a Go pointer into C++, we use a map to track the pointers on the Go side. */ %go_import("sync") %insert(go_header) %{ type _ sync.Mutex %} %insert(go_director) %{ var swigDirectorTrack struct { sync.Mutex m map[int]interface{} c int } func swigDirectorAdd(v interface{}) int { swigDirectorTrack.Lock() defer swigDirectorTrack.Unlock() if swigDirectorTrack.m == nil { swigDirectorTrack.m = make(map[int]interface{}) } swigDirectorTrack.c++ ret := swigDirectorTrack.c swigDirectorTrack.m[ret] = v return ret } func swigDirectorLookup(c int) interface{} { swigDirectorTrack.Lock() defer swigDirectorTrack.Unlock() ret := swigDirectorTrack.m[c] if ret == nil { panic("C++ director pointer not found (possible use-after-free)") } return ret } func swigDirectorDelete(c int) { swigDirectorTrack.Lock() defer swigDirectorTrack.Unlock() if swigDirectorTrack.m[c] == nil { if c > swigDirectorTrack.c { panic("C++ director pointer invalid (possible memory corruption") } else { panic("C++ director pointer not found (possible use-after-free)") } } delete(swigDirectorTrack.m, c) } %} swig-3.0.8/Lib/go/std_list.i0000664000175000017500000000170312641054563015474 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %{ #include #include %} namespace std { template > class list { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef Alloc allocator_type; list(); size_type size() const; bool empty() const; %rename(isEmpty) empty; void clear(); void push_front(const value_type& x); void pop_front(); void push_back(const value_type& x); void pop_back(); void remove(value_type x); void reverse(); void unique(); void sort(); void merge(list& x); }; } swig-3.0.8/Lib/go/std_map.i0000664000175000017500000000333212641054563015276 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_map.i * * SWIG typemaps for std::map * ----------------------------------------------------------------------------- */ %include // ------------------------------------------------------------------------ // std::map // ------------------------------------------------------------------------ %{ #include #include #include %} // exported class namespace std { template class map { // add typemaps here public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } void set(const K& key, const T& x) { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { std::map::iterator i = self->find(key); return i != self->end(); } } }; } swig-3.0.8/Lib/go/std_string.i0000664000175000017500000000343212641054563016030 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_string.i * * Typemaps for std::string and const std::string& * These are mapped to a Go string and are passed around by value. * * To use non-const std::string references use the following %apply. Note * that they are passed by value. * %apply const std::string & {std::string &}; * ----------------------------------------------------------------------------- */ %{ #include %} namespace std { %naturalvar string; class string; %typemap(gotype) string, const string & "string" %typemap(in) string %{ $1.assign($input.p, $input.n); %} %typemap(directorout) string %{ $result.assign($input.p, $input.n); %} %typemap(out,fragment="AllocateString") string %{ $result = Swig_AllocateString($1.data(), $1.length()); %} %typemap(goout,fragment="CopyString") string %{ $result = swigCopyString($1) %} %typemap(directorin,fragment="AllocateString") string %{ $input = Swig_AllocateString($1.data(), $1.length()); %} %typemap(godirectorin,fragment="CopyString") string %{ $result = swigCopyString($input) %} %typemap(in) const string & %{ $*1_ltype $1_str($input.p, $input.n); $1 = &$1_str; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & %{ static $*1_ltype $1_str; $1_str.assign($input.p, $input.n); $result = &$1_str; %} %typemap(out,fragment="AllocateString") const string & %{ $result = Swig_AllocateString((*$1).data(), (*$1).length()); %} %typemap(goout,fragment="CopyString") const string & %{ $result = swigCopyString($1) %} %typemap(directorin,fragment="AllocateString") const string & %{ $input = Swig_AllocateString($1.data(), $1.length()); %} %typemap(godirectorin,fragment="CopyString") const string & %{ $result = swigCopyString($input) %} } swig-3.0.8/Lib/go/stl.i0000664000175000017500000000044212641054563014450 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-3.0.8/Lib/go/typemaps.i0000664000175000017500000002333512641054563015516 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Pointer and reference handling typemap library * * These mappings provide support for input/output arguments and common * uses for C/C++ pointers and C++ references. * ----------------------------------------------------------------------------- */ /* INPUT typemaps -------------- These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is passed by value instead of reference. The following typemaps can be applied to turn a pointer or reference into a simple input value. That is, instead of passing a pointer or reference to an object, you would use a real value instead. bool *INPUT, bool &INPUT signed char *INPUT, signed char &INPUT unsigned char *INPUT, unsigned char &INPUT short *INPUT, short &INPUT unsigned short *INPUT, unsigned short &INPUT int *INPUT, int &INPUT unsigned int *INPUT, unsigned int &INPUT long *INPUT, long &INPUT unsigned long *INPUT, unsigned long &INPUT long long *INPUT, long long &INPUT unsigned long long *INPUT, unsigned long long &INPUT float *INPUT, float &INPUT double *INPUT, double &INPUT To use these, suppose you had a C function like this : double fadd(double *a, double *b) { return *a+*b; } You could wrap it with SWIG as follows : %include double fadd(double *INPUT, double *INPUT); or you can use the %apply directive : %include %apply double *INPUT { double *a, double *b }; double fadd(double *a, double *b); In Go you could then use it like this: answer := modulename.Fadd(10.0, 20.0) There are no char *INPUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *INPUT {char *input}; void f(char *input); */ %define INPUT_TYPEMAP(TYPE, GOTYPE) %typemap(gotype) TYPE *INPUT, TYPE &INPUT "GOTYPE" %typemap(in) TYPE *INPUT, TYPE &INPUT %{ $1 = ($1_ltype)&$input; %} %typemap(out) TYPE *INPUT, TYPE &INPUT "" %typemap(goout) TYPE *INPUT, TYPE &INPUT "" %typemap(freearg) TYPE *INPUT, TYPE &INPUT "" %typemap(argout) TYPE *INPUT, TYPE &INPUT "" // %typemap(typecheck) TYPE *INPUT = TYPE; // %typemap(typecheck) TYPE &INPUT = TYPE; %enddef INPUT_TYPEMAP(bool, bool); INPUT_TYPEMAP(signed char, int8); INPUT_TYPEMAP(char, byte); INPUT_TYPEMAP(unsigned char, byte); INPUT_TYPEMAP(short, int16); INPUT_TYPEMAP(unsigned short, uint16); INPUT_TYPEMAP(int, int); INPUT_TYPEMAP(unsigned int, uint); INPUT_TYPEMAP(long, int64); INPUT_TYPEMAP(unsigned long, uint64); INPUT_TYPEMAP(long long, int64); INPUT_TYPEMAP(unsigned long long, uint64); INPUT_TYPEMAP(float, float32); INPUT_TYPEMAP(double, float64); #undef INPUT_TYPEMAP // OUTPUT typemaps. These typemaps are used for parameters that // are output only. An array replaces the c pointer or reference parameter. // The output value is returned in this array passed in. /* OUTPUT typemaps --------------- The following typemaps can be applied to turn a pointer or reference into an "output" value. When calling a function, no input value would be given for a parameter, but an output value would be returned. This works by a Go slice being passed as a parameter where a c pointer or reference is required. As with any Go function, the array is passed by reference so that any modifications to the array will be picked up in the calling function. Note that the array passed in MUST have at least one element, but as the c function does not require any input, the value can be set to anything. bool *OUTPUT, bool &OUTPUT signed char *OUTPUT, signed char &OUTPUT unsigned char *OUTPUT, unsigned char &OUTPUT short *OUTPUT, short &OUTPUT unsigned short *OUTPUT, unsigned short &OUTPUT int *OUTPUT, int &OUTPUT unsigned int *OUTPUT, unsigned int &OUTPUT long *OUTPUT, long &OUTPUT unsigned long *OUTPUT, unsigned long &OUTPUT long long *OUTPUT, long long &OUTPUT unsigned long long *OUTPUT, unsigned long long &OUTPUT float *OUTPUT, float &OUTPUT double *OUTPUT, double &OUTPUT For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and returns the integer part in one of its parameters): double modf(double x, double *ip); You could wrap it with SWIG as follows : %include double modf(double x, double *OUTPUT); or you can use the %apply directive : %include %apply double *OUTPUT { double *ip }; double modf(double x, double *ip); The Go output of the function would be the function return value and the value in the single element array. In Go you would use it like this: ptr := []float64{0.0} fraction := modulename.Modf(5.0,ptr) There are no char *OUTPUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *OUTPUT {char *output}; void f(char *output); */ %define OUTPUT_TYPEMAP(TYPE, GOTYPE) %typemap(gotype) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%} %typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp) { if ($input.len == 0) { _swig_gopanic("array must contain at least 1 element"); } $1 = &temp; } %typemap(out) TYPE *OUTPUT, TYPE &OUTPUT "" %typemap(goout) TYPE *INPUT, TYPE &INPUT "" %typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT "" %typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT { TYPE* a = (TYPE *) $input.array; a[0] = temp$argnum; } %enddef OUTPUT_TYPEMAP(bool, bool); OUTPUT_TYPEMAP(signed char, int8); OUTPUT_TYPEMAP(char, byte); OUTPUT_TYPEMAP(unsigned char, byte); OUTPUT_TYPEMAP(short, int16); OUTPUT_TYPEMAP(unsigned short, uint16); OUTPUT_TYPEMAP(int, int); OUTPUT_TYPEMAP(unsigned int, uint); OUTPUT_TYPEMAP(long, int64); OUTPUT_TYPEMAP(unsigned long, uint64); OUTPUT_TYPEMAP(long long, int64); OUTPUT_TYPEMAP(unsigned long long, uint64); OUTPUT_TYPEMAP(float, float32); OUTPUT_TYPEMAP(double, float64); #undef OUTPUT_TYPEMAP /* INOUT typemaps -------------- Mappings for a parameter that is both an input and an output parameter The following typemaps can be applied to make a function parameter both an input and output value. This combines the behavior of both the "INPUT" and "OUTPUT" typemaps described earlier. Output values are returned as an element in a Go slice. bool *INOUT, bool &INOUT signed char *INOUT, signed char &INOUT unsigned char *INOUT, unsigned char &INOUT short *INOUT, short &INOUT unsigned short *INOUT, unsigned short &INOUT int *INOUT, int &INOUT unsigned int *INOUT, unsigned int &INOUT long *INOUT, long &INOUT unsigned long *INOUT, unsigned long &INOUT long long *INOUT, long long &INOUT unsigned long long *INOUT, unsigned long long &INOUT float *INOUT, float &INOUT double *INOUT, double &INOUT For example, suppose you were trying to wrap the following function : void neg(double *x) { *x = -(*x); } You could wrap it with SWIG as follows : %include void neg(double *INOUT); or you can use the %apply directive : %include %apply double *INOUT { double *x }; void neg(double *x); This works similarly to C in that the mapping directly modifies the input value - the input must be an array with a minimum of one element. The element in the array is the input and the output is the element in the array. x := []float64{5.0} Neg(x); The implementation of the OUTPUT and INOUT typemaps is different to other languages in that other languages will return the output value as part of the function return value. This difference is due to Go being a typed language. There are no char *INOUT typemaps, however you can apply the signed char * typemaps instead: %include %apply signed char *INOUT {char *inout}; void f(char *inout); */ %define INOUT_TYPEMAP(TYPE, GOTYPE) %typemap(gotype) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%} %typemap(in) TYPE *INOUT, TYPE &INOUT { if ($input.len == 0) { _swig_gopanic("array must contain at least 1 element"); } $1 = ($1_ltype) $input.array; } %typemap(out) TYPE *INOUT, TYPE &INOUT "" %typemap(goout) TYPE *INOUT, TYPE &INOUT "" %typemap(freearg) TYPE *INOUT, TYPE &INOUT "" %typemap(argout) TYPE *INOUT, TYPE &INOUT "" %enddef INOUT_TYPEMAP(bool, bool); INOUT_TYPEMAP(signed char, int8); INOUT_TYPEMAP(char, byte); INOUT_TYPEMAP(unsigned char, byte); INOUT_TYPEMAP(short, int16); INOUT_TYPEMAP(unsigned short, uint16); INOUT_TYPEMAP(int, int); INOUT_TYPEMAP(unsigned int, uint); INOUT_TYPEMAP(long, int64); INOUT_TYPEMAP(unsigned long, uint64); INOUT_TYPEMAP(long long, int64); INOUT_TYPEMAP(unsigned long long, uint64); INOUT_TYPEMAP(float, float32); INOUT_TYPEMAP(double, float64); #undef INOUT_TYPEMAP swig-3.0.8/Lib/go/std_vector.i0000664000175000017500000000466712641054563016037 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_vector.i * ----------------------------------------------------------------------------- */ %{ #include #include %} namespace std { template class vector { public: typedef size_t size_type; typedef T value_type; typedef const value_type& const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { const_reference get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i class vector { public: typedef size_t size_type; typedef bool value_type; typedef bool const_reference; vector(); vector(size_type n); size_type size() const; size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; bool empty() const; void clear(); %rename(add) push_back; void push_back(const value_type& x); %extend { bool get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i /* Code insertion directives */ #define %go_import(...) %insert(go_imports) %{__VA_ARGS__%} /* Basic types */ %typemap(gotype) bool, const bool & "bool" %typemap(gotype) char, const char & "byte" %typemap(gotype) signed char, const signed char & "int8" %typemap(gotype) unsigned char, const unsigned char & "byte" %typemap(gotype) short, const short & "int16" %typemap(gotype) unsigned short, const unsigned short & "uint16" %typemap(gotype) int, const int & "int" %typemap(gotype) unsigned int, const unsigned int & "uint" %typemap(gotype) long, const long & "int64" %typemap(gotype) unsigned long, const unsigned long & "uint64" %typemap(gotype) long long, const long long & "int64" %typemap(gotype) unsigned long long, const unsigned long long & "uint64" %typemap(gotype) float, const float & "float32" %typemap(gotype) double, const double & "float64" %typemap(in) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $1 = ($1_ltype)$input; %} %typemap(in) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long long &, const unsigned long long &, const float &, const double & %{ $1 = ($1_ltype)&$input; %} %typemap(in) const long & ($*1_ltype temp), const unsigned long & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = ($1_ltype)&temp; %} %typemap(out) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $result = $1; %} %typemap(goout) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double "" %typemap(out) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ $result = ($*1_ltype)*$1; %} %typemap(goout) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & "" %typemap(out) void "" %typemap(goout) void "" %typemap(directorin) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $input = ($1_ltype)$1; %} %typemap(godirectorin) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double "" %typemap(directorin) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ $input = ($*1_ltype)$1; %} %typemap(godirectorin) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & "" %typemap(directorout) bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double %{ $result = ($1_ltype)$input; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const bool &, const char &, const signed char &, const unsigned char &, const short &, const unsigned short &, const int &, const unsigned int &, const long &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ $result = new $*1_ltype($input); swig_acquire_pointer(&swig_mem, $result); %} /* The size_t type. */ %typemap(gotype) size_t, const size_t & %{int64%} %typemap(in) size_t %{ $1 = (size_t)$input; %} %typemap(in) const size_t & %{ $1 = ($1_ltype)&$input; %} %typemap(out) size_t %{ $result = $1; %} %typemap(goout) size_t "" %typemap(out) const size_t & %{ $result = ($*1_ltype)*$1; %} %typemap(goout) const size_t & "" %typemap(directorin) size_t %{ $input = (size_t)$1; %} %typemap(godirectorin) size_t "" %typemap(directorin) const size_t & %{ $input = ($*1_ltype)$1; %} %typemap(godirectorin) const size_t & "" %typemap(directorout) size_t %{ $result = ($1_ltype)$input; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const size_t & %{ $result = new $*1_ltype($input); swig_acquire_pointer(&swig_mem, $result); %} /* Member pointers. */ %typemap(gotype) SWIGTYPE (CLASS::*) %{$gotypename%} %typemap(in) SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)$input; %} %typemap(out) SWIGTYPE (CLASS::*) %{ struct swig_out_type { intgo size; void* val; } *swig_out; swig_out = (struct swig_out_type*)malloc(sizeof(*swig_out)); if (swig_out) { swig_out->size = sizeof($1_ltype); swig_out->val = malloc(swig_out->size); if (swig_out->val) { *($&1_ltype)(swig_out->val) = $1; } } $result = swig_out; %} %typemap(goout) SWIGTYPE (CLASS::*) %{ { type swig_out_type struct { size int; val uintptr } p := (*swig_out_type)(unsafe.Pointer($1)) if p == nil || p.val == 0 { $result = nil } else { m := make([]byte, p.size) a := (*[1024]byte)(unsafe.Pointer(p.val))[:p.size] copy(m, a) Swig_free(p.val) Swig_free(uintptr(unsafe.Pointer(p))) $result = &m[0] } } %} %typemap(directorin) SWIGTYPE (CLASS::*) %{ $input = *($&1_ltype)$1; %} %typemap(godirectorin) SWIGTYPE (CLASS::*) "" %typemap(directorout) SWIGTYPE (CLASS::*) %{ $result = new $1_ltype($input); swig_acquire_pointer(&swig_mem, $result); %} /* Pointers. */ /* We can't translate pointers using a typemap, so that is handled in the C++ code. */ %typemap(gotype) SWIGTYPE * %{$gotypename%} %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE * %{ *($&1_ltype)&$result = ($1_ltype)$1; %} %typemap(goout) SWIGTYPE * "" %typemap(directorin) SWIGTYPE * %{ *($&1_ltype)&$input = ($1_ltype)$1; %} %typemap(godirectorin) SWIGTYPE * "" %typemap(directorout) SWIGTYPE * %{ $result = *($&1_ltype)&$input; %} %apply SWIGTYPE * { SWIGTYPE *const } /* Pointer references. */ %typemap(gotype) SWIGTYPE *const& %{$gotypename%} %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) %{ temp = *($1_ltype)&$input; $1 = ($1_ltype)&temp; %} %typemap(out) SWIGTYPE *const& %{ *($1_ltype)&$result = *$1; %} %typemap(goout) SWIGTYPE *const& "" /* References. */ /* Converting a C++ reference to Go has to be handled in the C++ code. */ %typemap(gotype) SWIGTYPE & %{$gotypename%} %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE & %{ *($&1_ltype)&$result = $1; %} %typemap(goout) SWIGTYPE & "" %typemap(directorin) SWIGTYPE & %{ $input = ($1_ltype)&$1; %} %typemap(godirectorin) SWIGTYPE & "" %typemap(directorout) SWIGTYPE & %{ *($&1_ltype)&$result = $input; %} %typemap(gotype) SWIGTYPE && %{$gotypename%} %typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE && %{ *($&1_ltype)&$result = $1; %} %typemap(goout) SWIGTYPE && "" %typemap(directorin) SWIGTYPE && %{ $input = ($1_ltype)&$1_name; %} %typemap(godirectorin) SWIGTYPE && "" %typemap(directorout) SWIGTYPE && %{ *($&1_ltype)&$result = $input; %} /* C arrays turn into Go pointers. If we know the length we can use a slice. */ %typemap(gotype) SWIGTYPE [] %{$gotypename%} %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %} %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} %typemap(goout) SWIGTYPE [] "" %typemap(directorin) SWIGTYPE [] %{ $input = *($1_ltype)&$1; %} %typemap(godirectorin) SWIGTYPE [] "" %typemap(directorout) SWIGTYPE [] %{ *($&1_ltype)&$result = $input; %} /* Strings. */ %typemap(gotype) char *, char *&, char[ANY], char[] "string" /* Needed to avoid confusion with the way the go module handles references. */ %typemap(gotype) char&, unsigned char& "*byte" %typemap(gotype) signed char& "*int8" %typemap(in) char *, char[ANY], char[] %{ $1 = ($1_ltype)$input.p; %} %typemap(in) char *& %{ $1 = ($1_ltype)$input.p; %} %typemap(out,fragment="AllocateString") char *, char *&, char[ANY], char[] %{ $result = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %} %typemap(goout,fragment="CopyString") char *, char *&, char[ANY], char[] %{ $result = swigCopyString($1) %} %typemap(directorin,fragment="AllocateString") char *, char *&, char[ANY], char[] %{ $input = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %} %typemap(godirectorin,fragment="CopyString") char *, char *&, char[ANY], char[] %{ $result = swigCopyString($input) %} %typemap(directorout) char *, char *&, char[ANY], char[] %{ $result = ($1_ltype)$input.p; %} /* String & length */ %typemap(gotype) (char *STRING, size_t LENGTH) "string" %typemap(in) (char *STRING, size_t LENGTH) %{ $1 = ($1_ltype)$input.p; $2 = ($2_ltype)$input.n; %} %typemap(out,fragment="AllocateString") (char *STRING, size_t LENGTH) %{ $result = Swig_AllocateString((char*)$1, (size_t)$2); %} %typemap(goout,fragment="CopyString") (char *STRING, size_t LENGTH) %{ $result = swigCopyString($1) %} %typemap(directorin,fragment="AllocateString") (char *STRING, size_t LENGTH) %{ $input = Swig_AllocateString((char*)$1, $2); %} %typemap(godirectorin,fragment="CopyString") (char *STRING, size_t LENGTH) %{ $result = swigCopyString($input) %} %typemap(directorout) (char *STRING, size_t LENGTH) %{ $1 = ($1_ltype)$input.p; $2 = ($2_ltype)$input.n; %} /* Enums. We can't do the right thing for enums in typemap(gotype) so we deliberately don't define them. The right thing would be to capitalize the name. This is instead done in go.cxx. */ %typemap(gotype) enum SWIGTYPE %{$gotypename%} %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} %typemap(out) enum SWIGTYPE %{ $result = (intgo)$1; %} %typemap(goout) enum SWIGTYPE "" %typemap(directorin) enum SWIGTYPE %{ $input = (intgo)$1; %} %typemap(godirectorin) enum SWIGTYPE "" %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} %typemap(directorin) enum SWIGTYPE & (intgo e) %{ e = (intgo)$1; $input = ($1_ltype)&e; %} %typemap(godirectorin) enum SWIGTYPE & "" %typemap(directorout) enum SWIGTYPE & %{ $*1_ltype f = ($*1_ltype)*$input; $result = ($1_ltype)&f; %} /* Arbitrary type. This is a type passed by value in the C/C++ code. We convert it to a pointer for the Go code. Note that all basic types are explicitly handled above. */ %typemap(gotype) SWIGTYPE %{$gotypename%} %typemap(in) SWIGTYPE ($&1_type argp) %{ argp = ($&1_ltype)$input; if (argp == NULL) { _swig_gopanic("Attempt to dereference null $1_type"); } $1 = ($1_ltype)*argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus %{ *($&1_ltype*)&$result = new $1_ltype($1); %} #else { $&1_ltype $1ptr = ($&1_ltype)malloc(sizeof($1_ltype)); memmove($1ptr, &$1, sizeof($1_type)); *($&1_ltype*)&$result = $1ptr; } #endif %typemap(goout) SWIGTYPE "" %typemap(directorin) SWIGTYPE %{ $input = ($&1_ltype)&$1; %} %typemap(godirectorin) SWIGTYPE "" %typemap(directorout) SWIGTYPE %{ $result = *($&1_ltype)$input; %} /* Exception handling */ %typemap(throws) char * %{ _swig_gopanic($1); %} %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ (void)$1; _swig_gopanic("C++ $1_type exception thrown"); %} /* Typecheck typemaps. The purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in Go as more than one C++ type maps to a single Go type. */ %typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */ bool, const bool & "" %typecheck(SWIG_TYPECHECK_CHAR) /* Go byte */ char, const char &, unsigned char, const unsigned char & "" %typecheck(SWIG_TYPECHECK_INT8) /* Go int8 */ signed char, const signed char & "" %typecheck(SWIG_TYPECHECK_INT16) /* Go int16 */ short, const short & "" %typecheck(SWIG_TYPECHECK_INT16) /* Go uint16 */ unsigned short, const unsigned short & "" %typecheck(SWIG_TYPECHECK_INT32) /* Go int */ int, const int & "" %typecheck(SWIG_TYPECHECK_INT32) /* Go uint */ unsigned int, const unsigned int & "" %typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */ long, const long &, long long, const long long & "" %typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */ unsigned long, const unsigned long &, unsigned long long, const unsigned long long & "" %typecheck(SWIG_TYPECHECK_FLOAT) /* Go float32 */ float, const float & "" %typecheck(SWIG_TYPECHECK_DOUBLE) /* Go float64 */ double, const double & "" %typecheck(SWIG_TYPECHECK_STRING) /* Go string */ char *, char *&, char[ANY], char [], signed char *, signed char *&, signed char[ANY], signed char [], unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char [] "" %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Go keywords. */ %include %include swig-3.0.8/Lib/go/gokw.swg0000664000175000017500000000105312641054563015164 0ustar williamwilliam/* Rename keywords. */ #define GOKW(x) %keywordwarn("'" `x` "' is a Go keyword, renaming to 'X"`x`"'",rename="X%s") `x` #define GOBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in Go") "::"`x` GOKW(break); GOKW(case); GOKW(chan); GOKW(const); GOKW(continue); GOKW(default); GOKW(defer); GOKW(else); GOKW(fallthrough); GOKW(for); GOKW(func); GOKW(go); GOKW(goto); GOKW(if); GOKW(import); GOKW(interface); GOKW(package); GOKW(range); GOKW(return); GOKW(select); GOKW(struct); GOKW(switch); GOKW(type); GOKW(var); GOBN(map); #undef GOKW swig-3.0.8/Lib/cstring.i0000664000175000017500000000050412641054563014711 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cstring.i * ----------------------------------------------------------------------------- */ %echo "cstring.i not implemented for this target" #define SWIG_CSTRING_UNIMPL /* old name keep for compatibility */ #define _CSTRING_UNIMPL swig-3.0.8/Lib/cffi/0000775000175000017500000000000012641054563013776 5ustar williamwilliamswig-3.0.8/Lib/cffi/cffi.swg0000664000175000017500000002306412641054563015434 0ustar williamwilliam/* Define a C preprocessor symbol that can be used in interface files to distinguish between the SWIG language modules. */ #define SWIG_CFFI /* Typespecs for basic types. */ %typemap(cin) void ":void"; %typemap(cin) char ":char"; %typemap(cin) char * ":string"; %typemap(cin) unsigned char ":unsigned-char"; %typemap(cin) signed char ":char"; %typemap(cin) short ":short"; %typemap(cin) signed short ":short"; %typemap(cin) unsigned short ":unsigned-short"; %typemap(cin) int ":int"; %typemap(cin) signed int ":int"; %typemap(cin) unsigned int ":unsigned-int"; %typemap(cin) long ":long"; %typemap(cin) signed long ":long"; %typemap(cin) unsigned long ":unsigned-long"; %typemap(cin) long long ":long-long"; %typemap(cin) signed long long ":long-long"; %typemap(cin) unsigned long long ":unsigned-long-long"; %typemap(cin) float ":float"; %typemap(cin) double ":double"; %typemap(cin) SWIGTYPE ":pointer"; %typemap(cout) void ":void"; %typemap(cout) char ":char"; %typemap(cout) char * ":string"; %typemap(cout) unsigned char ":unsigned-char"; %typemap(cout) signed char ":char"; %typemap(cout) short ":short"; %typemap(cout) signed short ":short"; %typemap(cout) unsigned short ":unsigned-short"; %typemap(cout) int ":int"; %typemap(cout) signed int ":int"; %typemap(cout) unsigned int ":unsigned-int"; %typemap(cout) long ":long"; %typemap(cout) signed long ":long"; %typemap(cout) unsigned long ":unsigned-long"; %typemap(cout) long long ":long-long"; %typemap(cout) signed long long ":long-long"; %typemap(cout) unsigned long long ":unsigned-long-long"; %typemap(cout) float ":float"; %typemap(cout) double ":double"; %typemap(cout) SWIGTYPE ":pointer"; %typemap(ctype) bool "int"; %typemap(ctype) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1_ltype"; %typemap(ctype) SWIGTYPE "$&1_type"; %typemap(in) bool "$1 = (bool)$input;"; %typemap(in) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1 = $input;"; %typemap(in) SWIGTYPE "$1 = *$input;"; %typemap(out) void ""; %typemap(out) bool "$result = (int)$1;"; %typemap(out) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;"; #ifdef __cplusplus %typemap(out) SWIGTYPE "$result = new $1_type($1);"; #else %typemap(out) SWIGTYPE { $result = ($&1_ltype) malloc(sizeof($1_type)); memmove($result, &$1, sizeof($1_type)); } #endif %typecheck(SWIG_TYPECHECK_BOOL) bool { $1 = 1; }; %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = 1; }; %typecheck(SWIG_TYPECHECK_FLOAT) float { $1 = 1; }; %typecheck(SWIG_TYPECHECK_DOUBLE) double { $1 = 1; }; %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = 1; }; %typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE { $1 = 1; }; %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[ANY], SWIGTYPE { $1 = 1; }; /* This maps C/C++ types to Lisp classes for overload dispatch */ %typemap(lisptype) bool "cl:boolean"; %typemap(lisptype) char "cl:character"; %typemap(lisptype) unsigned char "cl:integer"; %typemap(lisptype) signed char "cl:integer"; %typemap(lispclass) bool "t"; %typemap(lispclass) char "cl:character"; %typemap(lispclass) unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE "cl:integer"; /* CLOS methods can't be specialized on single-float or double-float */ %typemap(lispclass) float "cl:number"; %typemap(lispclass) double "cl:number"; %typemap(lispclass) char * "cl:string"; /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } %{ #ifdef __cplusplus # define EXTERN extern "C" #else # define EXTERN extern #endif #define EXPORT EXTERN SWIGEXPORT #include %} %insert("swiglisp") %{ ;;;SWIG wrapper code starts here (cl:defmacro defanonenum (cl:&body enums) "Converts anonymous enums to defconstants." `(cl:progn ,@(cl:loop for value in enums for index = 0 then (cl:1+ index) when (cl:listp value) do (cl:setf index (cl:second value) value (cl:first value)) collect `(cl:defconstant ,value ,index)))) (cl:eval-when (:compile-toplevel :load-toplevel) (cl:unless (cl:fboundp 'swig-lispify) (cl:defun swig-lispify (name flag cl:&optional (package cl:*package*)) (cl:labels ((helper (lst last rest cl:&aux (c (cl:car lst))) (cl:cond ((cl:null lst) rest) ((cl:upper-case-p c) (helper (cl:cdr lst) 'upper (cl:case last ((lower digit) (cl:list* c #\- rest)) (cl:t (cl:cons c rest))))) ((cl:lower-case-p c) (helper (cl:cdr lst) 'lower (cl:cons (cl:char-upcase c) rest))) ((cl:digit-char-p c) (helper (cl:cdr lst) 'digit (cl:case last ((upper lower) (cl:list* c #\- rest)) (cl:t (cl:cons c rest))))) ((cl:char-equal c #\_) (helper (cl:cdr lst) '_ (cl:cons #\- rest))) (cl:t (cl:error "Invalid character: ~A" c))))) (cl:let ((fix (cl:case flag ((constant enumvalue) "+") (variable "*") (cl:t "")))) (cl:intern (cl:concatenate 'cl:string fix (cl:nreverse (helper (cl:concatenate 'cl:list name) cl:nil cl:nil)) fix) package)))))) ;;;SWIG wrapper code ends here %} #ifdef __cplusplus %typemap(out) SWIGTYPE "$result = new $1_type($1);"; #else %typemap(out) SWIGTYPE { $result = ($&1_ltype) malloc(sizeof($1_type)); memmove($result, &$1, sizeof($1_type)); } #endif ////////////////////////////////////////////////////////////// /* name conversion for overloaded operators. */ #ifdef __cplusplus %rename(__add__) *::operator+; %rename(__pos__) *::operator+(); %rename(__pos__) *::operator+() const; %rename(__sub__) *::operator-; %rename(__neg__) *::operator-() const; %rename(__neg__) *::operator-(); %rename(__mul__) *::operator*; %rename(__deref__) *::operator*(); %rename(__deref__) *::operator*() const; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; %rename(__logxor__) *::operator^; %rename(__logand__) *::operator&; %rename(__logior__) *::operator|; %rename(__lognot__) *::operator~(); %rename(__lognot__) *::operator~() const; %rename(__not__) *::operator!(); %rename(__not__) *::operator!() const; %rename(__assign__) *::operator=; %rename(__add_assign__) *::operator+=; %rename(__sub_assign__) *::operator-=; %rename(__mul_assign__) *::operator*=; %rename(__div_assign__) *::operator/=; %rename(__mod_assign__) *::operator%=; %rename(__logxor_assign__) *::operator^=; %rename(__logand_assign__) *::operator&=; %rename(__logior_assign__) *::operator|=; %rename(__lshift__) *::operator<<; %rename(__lshift_assign__) *::operator<<=; %rename(__rshift__) *::operator>>; %rename(__rshift_assign__) *::operator>>=; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__lt__) *::operator<; %rename(__gt__) *::operator>; %rename(__lte__) *::operator<=; %rename(__gte__) *::operator>=; %rename(__and__) *::operator&&; %rename(__or__) *::operator||; %rename(__preincr__) *::operator++(); %rename(__postincr__) *::operator++(int); %rename(__predecr__) *::operator--(); %rename(__postdecr__) *::operator--(int); %rename(__comma__) *::operator,(); %rename(__comma__) *::operator,() const; %rename(__member_ref__) *::operator->; %rename(__member_func_ref__) *::operator->*; %rename(__funcall__) *::operator(); %rename(__aref__) *::operator[]; #endif %{ #ifdef __cplusplus # define EXTERN extern "C" #else # define EXTERN extern #endif #define EXPORT EXTERN SWIGEXPORT #include #include %} swig-3.0.8/Lib/cpointer.i0000664000175000017500000000673712641054563015101 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cpointer.i * * SWIG library file containing macros that can be used to manipulate simple * pointer objects. * ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * %pointer_class(type,name) * * Places a simple proxy around a simple type like 'int', 'float', or whatever. * The proxy provides this interface: * * class type { * public: * type(); * ~type(); * type value(); * void assign(type value); * }; * * Example: * * %pointer_class(int, intp); * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = intp() * >>> a.assign(10) * >>> a.value() * 10 * >>> b = intp() * >>> b.assign(20) * >>> print add(a,b) * 30 * * As a general rule, this macro should not be used on class/structures that * are already defined in the interface. * ----------------------------------------------------------------------------- */ %define %pointer_class(TYPE, NAME) %{ typedef TYPE NAME; %} typedef struct { } NAME; %extend NAME { #ifdef __cplusplus NAME() { return new TYPE(); } ~NAME() { if ($self) delete $self; } #else NAME() { return (TYPE *) calloc(1,sizeof(TYPE)); } ~NAME() { if ($self) free($self); } #endif } %extend NAME { void assign(TYPE value) { *$self = value; } TYPE value() { return *$self; } TYPE * cast() { return $self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; } } %types(NAME = TYPE); %enddef /* ----------------------------------------------------------------------------- * %pointer_functions(type,name) * * Create functions for allocating/deallocating pointers. This can be used * if you don't want to create a proxy class or if the pointer is complex. * * %pointer_functions(int, intp) * * int add(int *x, int *y) { return *x + *y; } * * In python (with proxies) * * >>> a = copy_intp(10) * >>> intp_value(a) * 10 * >>> b = new_intp() * >>> intp_assign(b,20) * >>> print add(a,b) * 30 * >>> delete_intp(a) * >>> delete_intp(b) * * ----------------------------------------------------------------------------- */ %define %pointer_functions(TYPE,NAME) %{ static TYPE *new_##NAME() { %} #ifdef __cplusplus %{ return new TYPE(); %} #else %{ return (TYPE *) calloc(1,sizeof(TYPE)); %} #endif %{} static TYPE *copy_##NAME(TYPE value) { %} #ifdef __cplusplus %{ return new TYPE(value); %} #else %{ TYPE *obj = (TYPE *) calloc(1,sizeof(TYPE)); *obj = value; return obj; %} #endif %{} static void delete_##NAME(TYPE *obj) { %} #ifdef __cplusplus %{ if (obj) delete obj; %} #else %{ if (obj) free(obj); %} #endif %{} static void NAME ##_assign(TYPE *obj, TYPE value) { *obj = value; } static TYPE NAME ##_value(TYPE *obj) { return *obj; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); void delete_##NAME(TYPE *obj); void NAME##_assign(TYPE *obj, TYPE value); TYPE NAME##_value(TYPE *obj); %enddef /* ----------------------------------------------------------------------------- * %pointer_cast(type1,type2,name) * * Generates a pointer casting function. * ----------------------------------------------------------------------------- */ %define %pointer_cast(TYPE1,TYPE2,NAME) %inline %{ TYPE2 NAME(TYPE1 x) { return (TYPE2) x; } %} %enddef swig-3.0.8/CHANGES0000664000175000017500000350551512641054563013372 0ustar williamwilliamSWIG (Simplified Wrapper and Interface Generator) See the CHANGES.current file for changes in the current version. See the RELEASENOTES file for a summary of changes in each release. Version 3.0.7 (3 Aug 2015) ========================== 2015-08-02: wsfulton [Java] Fix potential security exploit in generated Java classes. The swigCPtr and swigCMemOwn member variables in the generated Java classes are now declared 'transient' by default. Further details of the exploit in Android is being published in an academic paper as part of USENIX WOOT '15: https://www.usenix.org/conference/woot15/workshop-program/presentation/peles. In the unlikely event that you are relying on these members being serializable, then you will need to override the default javabody and javabody_derived typemaps to generate the old generated code. The relevant typemaps are in the Lib directory in the java.swg, boost_shared_ptr.i and boost_intrusive_ptr.i files. Copy the relevant default typemaps into your interface file and remove the 'transient' keyword. *** POTENTIAL INCOMPATIBILITY *** 2015-08-01: vadz Make configure --without-alllang option more useful: it can now be overridden by the following --with-xxx options, allowing to easily enable just one or two languages. 2015-07-30: wsfulton Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class in the carrays.i library - bug is only relevant when using C++. 2015-07-29: wsfulton [Python] Improve indentation warning and error messages for code in the following directives: %pythonprepend %pythonappend %pythoncode %pythonbegin %feature("shadow") Old error example: Error: Line indented less than expected (line 3 of pythoncode) New error example: Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block) as no line should be indented less than the indentation in line 1 Old warning example: Warning 740: Whitespace prefix doesn't match (line 2 of %pythoncode or %insert("python") block) New warning example: Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of %pythoncode or %insert("python") block) 2015-07-28: wsfulton [Python] Fix #475. Improve docstring indentation handling. SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring feature. This occurred when the indentation (whitespace) in the docstring was less in the second or later lines when compared to the first line. SWIG-3.0.6 gave a 'Line indented less than expected' error instead of truncating the docstring text. Now the indentation for the 'docstring' feature is smarter and is appropriately adjusted so that no truncation occurs. 2015-07-22: wsfulton Support for special variable expansion in typemap attributes. Example usage expansion in the 'out' attribute (C# specific): %typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype" is equivalent to the following as $*1_ltype expands to 'unsigned int': %typemap(ctype, out="unsigned int") unsigned int& "unsigned int" Special variables can be used within special variable macros too. Example usage expansion: %typemap(cstype) unsigned int "uint" %typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)" Special variables are expanded first and hence the above is equivalent to: %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)" which then expands to: %typemap(cstype, out="uint") unsigned int& "uint" 2015-07-22: lindleyf Apply patch #439 - support for $typemap() (aka embedded typemaps or special variable macros) in typemap attributes. A simple example where $typemap() is expanded in the 'out' attribute (C# specific): %typemap(cstype) unsigned int "uint" %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)" is equivalent to: %typemap(cstype, out="uint") unsigned int& "uint" 2015-07-18: m7thon [Python] Docstrings provided via %feature("docstring") are now quoted and added to the tp_doc slot when using python builtin classes (-builtin). When no docstring is provided, the tp_doc slot is set to the fully qualified C/C++ class name. Github issues #445 and #461. 2015-07-17: kwwette [octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski). 2015-07-07: wsfulton SWIG no longer generates a wrapper for a class' constructor if that class has any base class with a private destructor. This is because your compiler should not allow a class to be instantiated if a base has a private destructor. Some compilers do, so if you need the old behaviour, use the "notabstract" feature, eg: %feature("notabstract") Derived; class Base { ~Base() {} }; struct Derived : Base {}; Version 3.0.6 (5 Jul 2015) ========================== 2015-07-02: wsfulton Fix syntax error when the template keyword is used in types, eg: std::template vector v; 2015-07-02: ngladitz [Lua] Push characters as unformatted 1-character strings to avoid unprintable characters such as (char)127 being converted to "<\127>" with Lua 5.3 and later. (github PR #452) 2015-06-29: olly [Python] Improve handling of whitespace in %pythoncode. Previously SWIG looked at the indentation of the first line and removed that many characters from each subsequent line, regardless of what those characters were. This was made worse because SWIG's preprocessor removes any whitespace before a '#'. Fixes github issue #379, reported by Joe Orton. 2015-06-12: wsfulton [R] Fix #430 - call to SWIG_createNewRef in copyToC was incorrectly named. 2015-06-11: sghirate [C#] Patch #427 adds in new command line option -outfile to combine all the generated C# code into a single file. 2015-06-09: wsfulton Fix seg fault processing C++11 type aliasing. Issue #424. 2015-05-28: wsfulton [Python] Add new feature "python:cdefaultargs" to control default argument code generation. By default, SWIG attempts to convert C/C++ default argument values into Python values and generates code into the Python layer with these values. Recent versions of SWIG are able to convert more of these values, however, the new behaviour can be circumvented if desired via this new feature, such that the default argument values are obtained from the C layer and not the Python layer. For example: struct CDA { int fff(int a = 1, bool b = false); }; The default code generation in the Python layer is: class CDA(_object): ... def fff(self, a=1, b=False): return _default_args.CDA_fff(self, a, b) Adding the feature: %feature("python:cdefaultargs") CDA::fff; Results in: class CDA(_object): ... def fff(self, *args): return _default_args.CDA_fff(self, *args) Some code generation modes, eg -builtin and -fastproxy, are unaffected by this as the default values are always obtained from the C layer. 2015-05-27: wsfulton [Python] Deal with an integer as the default value of a typedef to bool parameter in the C++ prototype. See #327. Regression from 3.0.0 onwards. 2015-05-19: olly [Python] Fix warning when compiling generated code with MSVC. (Fixes https://sourceforge.net/p/swig/patches/351/ reported by Mateusz Szyma¿ski). 2015-05-14: wsfulton Fix seg fault wrapping shared_ptr of classes with private constructors and destructors. This also fixes the "unref" feature when used on classes with private destructors. 2015-05-10: wsfulton [Java] Fix multi-argument typemaps (char *STRING, size_t LENGTH) so that they can be applied to a wider range of types. Fixes #385. 2015-05-07: olly [Python] Deal with an integer as the default value of a bool parameter in the C++ prototype. Fixes github #327, reported by Greg Allen. 2015-05-07: LindleyF [Java] Allow feature("director") and feature("ref") to be used together. Github PR#403. 2015-05-05: olly Suppress warning 325 "Nested class not currently supported (Foo ignored)" when Foo has already been explicitly ignored with "%ignore". 2015-05-04: wsfulton Add support for friend templates, including operator overloading - fixes #196. Considering the example below, previously the operator gave a syntax error and friendfunc incorrectly warned with: "Warning 503: Can't wrap 'friendfunc<(Type)>' unless renamed to a valid identifier." template class MyClass { friend int friendfunc (double is, MyClass & x); friend int operator<< (double un, const MyClass &x); }; The following also previously incorrectly warned with: "Warning 302: Identifier 'template_friend' redefined (ignored)," template T template_friend(T); struct MyTemplate { template friend T template_friend(T); }; 2015-05-01: wsfulton Fix handling of conversion operators where the operator is split over multiple lines or has comments within the operator type. Fixes #401. Also fix similar problem with normal operators which gave a syntax error if split over multiple lines or had a comment within the operator declaration. 2015-04-30: olly Ignore unknown preprocessor directives which are inside an inactive conditional (github issue #394, reported by Dan Wilcox). Regression introduced in 3.0.3. 2015-04-27: vadz [Python] Fix "default" typemap used after an argument with "numinputs=0" (#377). 2015-04-24: wsfulton [Python] Fix #256. Code generated with '-builtin -modernargs' segfaults for any method taking zero arguments. Also fixes: "SystemError: error return without exception set" during error checking when using just -builtin and the incorrect number of arguments is passed to a class method expecting zero arguments. 2015-04-23: wsfulton [Java] Bug #386 - Memory leak fix in (char *STRING, size_t LENGTH) typemaps. 2015-04-23: vadz [Python] Make "default" typemap work again (#330, #377). 2015-04-23: vadz [Python] Fix the use of default values for the pointer types (#365, #376). 2015-04-23: wsfulton Fix 'make check-ccache' which is part of 'make check' when one of the CCACHE_ environment variables, for example CCACHE_DISABLE, is set. 2015-04-14: wsfulton Clearer warning message for badly constructed typecheck typemaps. For example, was: example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking rule for 'int'). Now: example.i:3: Warning 467: Overloaded foo(int) not supported (incomplete type checking rule - no precedence level in typecheck typemap for 'int'). 2015-04-11: wsfulton [Java] Fix #353 - Linker multiple definition of 'ExceptionMatches' when using directors and multiple modules. 2015-04-11: wsfulton Merge #320 - Make __dict__ accessible for Python builtin classes. 2015-04-07: wsfulton Fix #375 - parsing of extern "C" and typedef for example: extern "C" typedef void (*Hook2_t)(int, const char *); extern "C" typedef int Integer; 2015-03-12: olly -DSWIG_DIRECTOR_STATIC is now supported for all languages with director support, not only Python and PHP. 2015-03-02: ianlancetaylor [Go] Add -cgo option, required for Go versions 1.5 and later. 2015-02-26: olly Fix segmentation fault when top==NULL, introduced by nested class handling (reported in issue#346 by Pawe¿ Tomulik). 2015-02-09: wsfulton [Guile] Fix generated code for static const char member variables when defined and declared inline. 2015-02-09: mishas [Go] Fix %import of files in sub directories. 2015-02-05: ianlancetaylor [Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty. 2015-02-05: ianlancetaylor [Go] Generated Go code no longer calls _swig_goallocate or _swig_makegostring, as they will no longer work as of Go 1.5. Version 3.0.5 (31 Jan 2015) =========================== 2015-01-30: wsfulton [Python] Fix Python -classic and property setting. Setting properties on classic classes was broken in swig-3.0.3 by attempting to use __setattr__. This regression is fixed now by using __dict__ again when using -classic. Fixes patch #232. 2015-01-27: smarchetto [Scilab] Support for the Scilab language has been added 2015-01-23: olly [PHP] When wrapping a returned resource as an object, check if all cases wrap it in the same class, and if so eliminate the pointless switch statement wrapper we previously generated. 2015-01-22: wsfulton [Octave] Merge patch #297 for SF bug #1277 - Octave shared_ptr support 2015-01-15: wsfulton [Python] Merge patch #250 - Fixes for using %constant and objects (non-primitive types) 2015-01-15: wsfulton [C# Go] Merge patch #308 and fix #307 - C++11 strongly typed enum support in directors 2015-01-15: wsfulton [Python] Second fix for #294 #296 - Regression introduced in SWIG-3.0.3 when wrapping functions with default arguments, this time when using kwargs. Version 3.0.4 (14 Jan 2015) =========================== 2015-01-12: olly [PHP] Fix segfault in director upcall check when using PHP built with ZTS enabled. Fixes #155, reported by Pierre Labastie. 2015-01-12: vadz [Python] Fix #294 #296 - Regression introduced in SWIG-3.0.3 when wrapping functions with default arguments. Invalid or missing default arguments were sometimes being generated into the python layer. 2015-01-08: olly Allow C++11 "explicit constexpr". Fixes github issue #284 reported by Pawel Tomulik. Also handle "constexpr explicit" and "constexpr static". 2015-01-08: olly When reporting an error for a construct which hasn't been terminated when the end of the file is reached, report it at the start line rather than "EOF" as then tools like editors and IDEs will take you to a generally more useful place for fixing the problem. 2015-01-08: olly Improve error messages for a few cases which previously gave the one of the cryptic catch-all errors "Syntax error in input". 2015-01-08: olly Provide -cppext as a general command line option for setting the extension used for generated C++ files (previously it was specific to the PHP backend). Deprecate the equivalent -suffix option provided by the Ocaml backend, but continue to support that for now. Version 3.0.3 (30 Dec 2014) =========================== 2014-12-27: wsfulton Fix #280 - abort using all default template parameters within other template parameters. 2014-12-27: talby [Perl] Issue #282 perl5 archlib vs archlibexp [Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code under clang 2014-12-18: wsfulton Add support for %constant and structs/classes - issue #272 2014-12-09: wsfulton Fix #245 - regression (since swig-3.0.0) in templated constructors. Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504: "Function: xyz must have a return type. Ignored." 2014-12-07: wsfulton Add support for C++11 strongly typed enumerations. 2014-11-21: wsfulton [Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum" wrappers. 2014-10-28: vadz [Python] Patch #201 The generated .py file no longer uses *args for all Python parameters. Instead, the parameters are named using the C++ parameter names. "compactdefaultargs" feature can be enabled to restore the old behaviour. *** POTENTIAL INCOMPATIBILITY *** 2014-10-24: timotheecour [D] Patch #204 Use core.atomic.atomicOp to mutate shared variables 2014-10-21: wsfulton Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the "compactdefaultargs" feature if the target language does not support kwargs. Only Java and Python support kwargs, so this affects all the other languages. *** POTENTIAL INCOMPATIBILITY *** 2014-10-10: diorcety [Python] Patch #232 Fix property access using directors 2014-10-06: wsfulton [Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion of single elements, such as 'del vec[0]'. 2014-09-30: oliverb [Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript. 2014-09-30: oliverb [Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one. 2014-09-30: ianlancetaylor [Go] In configure script, require Go 1.1 or later. 2014-09-30: wsfulton [Python] Patch #207 - Fix No module error with -relativeimport when using single header file import. 2014-09-27: wsfulton Patch #208 - Initialise newly created array when using array_functions in the carrays.i library (C++ usage). 2014-09-27: wsfulton [Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one module was loaded at a time when data is being shared between modules. 2014-09-27: wsfulton [Java] Patch #168 - Fix leak in Java director string handling after the Java upcall when called from a native thread. 2014-09-25: ianlancetaylor [Go] Adjust generated code to work with upcoming Go 1.4 release. 2014-09-23: wsfulton [Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in the STL iterators (SwigPyIterator destructor). 2014-09-17: wsfulton [C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i 2014-09-12: olly [PHP] Add support for specifying any PHP interfaces a wrapped class implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator"; 2014-09-11: olly [PHP] Fix throwing a PHP exception through C++ from a subclassed director method - PHP NULL gets returned by the subclassed method in this case, so the directorout typemap needs to allow that (at least if an exception is active). 2014-09-09: ianlancetaylor [Go] Add goargout typemap. 2014-09-09: olly [PHP] Fix segmentation faults with directors in PHP >= 5.4, and reenable runme tests for director_basic testcase. Fix from pavel-charvat in issue#164. 2014-09-05: ianlancetaylor [Go] Add imtype, goin, goout, godirectorin, and godirectorout typemaps, to support writing Go code to convert between types. 2014-09-02: olly [Python] Fix regression in indentation of python code produced with -modern, introduced by changes in #188. Reported by fabiencastan in #218. 2014-09-01: olly Issue an error for unknown SWIG preprocessor directives, rather than quietly ignoring them. Reported by jrhelsey in issue#217. *** POTENTIAL INCOMPATIBILITY *** 2014-08-15: talby [Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350). 2014-08-04: wsfulton [C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated tag so that StyleCop ignores the files. 2014-08-04: wsfulton [Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to unsigned char * in various.i in NIOBUFFER typemaps. 2014-07-14: ianlancetaylor [Go] Change struct definition to use void *, not uint8, so that the type is recorded as possibly containing pointers. This ensures that the 1.3 garbage collector does not collect pointers passed to C++ code. 2014-07-01: wsfulton Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains brackets in the expanded name. Version 3.0.2 (4 Jun 2014) ========================== 2014-06-02: v-for-vandal [Lua] Pull request #176: If class has no __eq implemented, then default __eq is generated. Default __eq compares actual pointers stored inside Lua userdata. 2014-06-02: vkalinin Fix #183 - %extend and unnamed nested structs 2014-05-28: kwwette Fix install failure when using an 'out of source' build using the shipped tarball - regression introduced in swig-3.0.1. 2014-05-24: kwwette [Octave] Remove deprecated -global/-noglobal command-line arguments *** POTENTIAL INCOMPATIBILITY *** Version 3.0.1 (27 May 2014) =========================== 2014-05-25: hfalcic [Python] Python 3 byte string output: use errors="surrogateescape" if available on the version of Python that's in use. This allows obtaining the original byte string (and potentially trying a fallback encoding) if the bytes can't be decoded as UTF-8. Previously, a UnicodeDecodeError would be raised with no way to treat the data as bytes or try another codec. 2014-05-18: vkalinin Bug #175 - Restore %extend to work for unnamed nested structures by using a C symbol comprising the outer structure name and unnamed variable instance name. 2014-05-15: kwwette Add #166 - 'make check' now works out of source. This required the examples to build out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript, Lua, Octave, Perl, PHP, Python, Ruby and Tcl. 2014-05-01: Oliver Buchtala Javascript support added, see Javascript chapter in the documentation. 2014-05-01: olly [PHP] The generated __isset() method now returns true for read-only properties. 2014-04-24: kwwette [Go] Fix go ./configure parsing of gccgo --version, and goruntime.swg typo in __GNUC_PATCHLEVEL__ (SF Bug #1298) 2014-04-24: kwwette Fix {python|perl5|ruby|tcl}/java examples In Lib/gcj/cni.i, for compatibility with newer gcj versions: - remove JvAllocObject() which gcj no longer defines, from gcj Changelog: 2004-04-16 Bryce McKinlay * gcj/cni.h (JvAllocObject): Remove these obsolete, undocumented CNI calls. - change JvCreateJavaVM() argument from void* to JvVMInitArgs*, from gcj Changelog: 2005-02-23 Thomas Fitzsimmons PR libgcj/16923 ... (JvCreateJavaVM): Declare vm_args as JvVMInitArgs* rather than void*. *** POTENTIAL INCOMPATIBILITY *** 2014-04-08: wsfulton SF Bug #1366 - Remove duplicate declarations of strtoimax and strtoumax in inttypes.i 2014-04-08: wsfulton [Java C#] Enums which have been ignored via %ignore and are subsequently used are handled slightly differently. Type wrapper classes are now generated which are effectively a wrapper of an empty enum. Previously in Java uncompilable code was generated and in C# an int was used. 2014-04-04: wsfulton Fix regression in 3.0.0 where legal code following an operator<< definition might give a syntax error. SF Bug #1365. 2014-04-03: olly [PHP] Fix wrapping director constructors with default parameters with a ZTS-enabled build of PHP. 2014-04-02: olly [PHP] Pass the ZTS context we already have to avoid needing to call TSRMLS_FETCH, which is relatively expensive. 2014-04-02: olly [PHP] Pass ZTS context through to t_output_helper() so it works with a ZTS-enabled build of PHP. Reported by Pierre Labastie in github PR#155. 2014-03-28: wsfulton [Java C# D Go] Fixes for C enums used in an API and the definition of the enum has not been parsed. For D, this fixes a segfault in SWIG. The other languages now produce code that compiles, although the definition of the enum is needed in order to use the enum properly from the target language. 2014-03-23: v-for-vandal [Lua] Fix for usage of snprintf in Lua runtime which Visual Studio does not have. Version 3.0.0 (16 Mar 2014) =========================== 2014-03-16: wsfulton C++11 support initially developed as C++0x support by Matevz Jekovec as a Google Summer of Code project has been further extended. The C++11 support is comprehensive, but by no means complete or without limitations. Full details for each new feature in C++11 is covered in the CPlusPlus11.html chapter in the documentation which is included in SWIG and also available online at http://www.swig.org/Doc3.0/CPlusPlus11.html. 2014-03-14: v-for-vandal [Lua] Numerous Lua improvements: 1. %nspace support has been added. Namespaces are mapped to tables in the module, with the same name as the C++ namespace. 2. Inheritance is now handled differently. Each class metatable keeps a list of class bases instead of merging all members of all bases into the derived class. 3. The new metatables result in differences in accessing class members. For example: %module example struct Test { enum { TEST1 = 10, TEST2 = 20 }; static const int ICONST = 12; }; Now this can be used as follows: print(example.Test.TEST1) print(example.Test.ICONST) The old way was: print(example.Test_TEST1) print(example.Test_ICONST) 4. The special class metatable member ".constructor" was removed. Now SWIG generates the proxy function by itself and assigns it directly to the class table "__call" method. 5. eLua should also now support inheritance. 6. 'const' subtable in eLua is considered deprecated. Changes in behaviour: a. You can no longer assign to non-existing class members in classes without a __setitem__ method. It will cause a Lua error. b. You can no longer iterate over a module table and copy everything into the global namespace. Actually, this was never the case, but it is now explicitly prohibited. c. Now changing a base class will immediately affect all derived classes. d. There might be some issues with inheritance. Although the bases iteration scheme is the same as was used for merging base classes into derived one, some unknown issues may arise. The old metatable behaviour can be restored by using the -no-old-metatable-bindings option. *** POTENTIAL INCOMPATIBILITY *** 2014-03-06: wsfulton [Python] Change in default behaviour wrapping C++ bool. Only a Python True or False will now work for C++ bool parameters. This fixes overloading bool with other types. Python 2.3 minimum is now required for wrapping bool. When wrapping: const char* overloaded(bool value) { return "bool"; } const char* overloaded(int value) { return "int"; } Previous behaviour: >>> overloaded(False) 'int' >>> overloaded(True) 'int' >>> overloaded(0) 'int' Now we get the expected behaviour: >>> overloaded(False) 'bool' >>> overloaded(0) 'int' The consequence is when wrapping bool in non-overloaded functions: const char* boolfunction(bool value) { return value ? "true" : "false"; } The previous behaviour was very Pythonic: >>> boolfunction("") 'false' >>> boolfunction("hi") 'true' >>> boolfunction(12.34) 'true' >>> boolfunction(0) 'false' >>> boolfunction(1) 'true' Now the new behaviour more along the lines of C++ due to stricter type checking. The above calls result in an exception and need to be explicitly converted into a bool as follows: >>> boolfunction(0) Traceback (most recent call last): File "", line 1, in TypeError: in method 'boolfunction', argument 1 of type 'bool' >>> boolfunction(bool(0)) 'false' The old behaviour can be resurrected by passing the -DSWIG_PYTHON_LEGACY_BOOL command line parameter when executing SWIG. Typemaps can of course be written to customise the behaviour for specific parameters. *** POTENTIAL INCOMPATIBILITY *** 2014-03-06: wsfulton Fix SF Bug #1363 - Problem with method overloading when some methods are added by %extend and others are real methods and using template default parameters with smart pointers. This is noticeable as a regression since 2.0.12 when using the default smart pointer handling for some languages when the smart pointer wraps std::map and other STL containers. 2014-03-02: wsfulton [Python] SF Patch #346 from Jens Krueger. Correct exception thrown attempting to access a non-existent C/C++ global variable on the 'cvar' object. The exception thrown used to be a NameError. However, as this access is via a primary, an AttributeError is more correct and so the exception thrown now is an AttributeError. Reference: http://docs.python.org/2/reference/expressions.html#attribute-references *** POTENTIAL INCOMPATIBILITY *** 2014-03-01: wsfulton [Python] Patch #143 Fix type shown when using type() to include the module and package name when using -builtin. 2014-03-01: wsfulton [Python] SF patch #347 Fix missing argument count checking with -modern. Fixes regression introduced when builtin changes were introduced in SWIG-2.0.3. 2014-02-21: wsfulton [PHP] Fix warning suppression using %warnfilter for PHP reserved class names. 2014-02-19: olly [Lua] Add keyword warnings for Lua keywords and Basic Functions. 2014-02-19: olly -Wallkw now includes keywords for all languages with keyword warnings (previously Go and R were missing). 2014-02-19: olly [PHP] Update the lists of PHP keywords with new ones from PHP 5.4 and newer (and some missing ones from 5.3). Reserved PHP constants names are now checked against enum values and constants, instead of against function and method names. Built-in PHP function names no longer match methods added by %extend. Functions and methods named '__sleep', '__wakeup', 'not', 'parent', or 'virtual' are no longer needlessly renamed. 2014-02-15: wsfulton Fix the %$ismember %rename predicates to also apply to members added via %extend. Add %$isextendmember for %rename of members added via %extend. This can be used to distinguish between normal class/struct members and %extend members. For example '%$ismember, %$not %$isextendmember' will now identify just class/struct members. *** POTENTIAL INCOMPATIBILITY *** 2014-02-16: hfalcic [Python] Patch #137 - fix crashes/exceptions in exception handling in Python 3.3 2014-02-15: wsfulton [Java] Add support for the cdata library. 2014-02-08: vkalinin Nested class support added. This primarily allows SWIG to properly parse nested classes and keep the nested class information in the parse tree. Java and C# have utilised this information wrapping the C++ nested classes as Java/C# nested classes. The remaining target languages ignore nested classes as in previous versions. Help is needed by users of these remaining languages to design how C++ nested classes can be best wrapped. Please talk to us on the swig-devel mailing list if you think you can help. Previously, there was limited nested class support. Nested classes were treated as opaque pointers. However, the "nestedworkaround" feature provided a way to wrap a nested class as if it was a global class. This feature no longer exists and is replaced by the new "flatnested" feature. This effectively does the same thing with less manual code to be written. Please see the 'Nested classes' section in the documentation in SWIGPlus.html if you were previously using this feature. SWIG now parses the contents of nested classes where previously it did not. You may find that you will need to make adjustments to your interface file as effectively extra code is being wrapped. *** POTENTIAL INCOMPATIBILITY *** 2014-02-06: gjanssens [Guile] Patch #133. Make scm to string conversion work with non-ascii strings. Guile 2 has a completely rewritten string implementation. SWIG made some assumptions that are no longer valid as to the internals of guile's string representation. 2014-01-30: wsfulton [C#] Add new swigtype_inout.i library containing SWIGTYPE *& OUTPUT typemaps. Example usage wrapping: void f(XXX *& x) { x = new XXX(111); } would be: XXX x = null; f(out x); // use x x.Dispose(); // manually clear memory or otherwise leave out and leave it to the garbage collector 2014-01-21: ianlancetaylor [Go] Add %go_import directive. 2014-01-21: ianlancetaylor [Go] Add support for Go 1.3, not yet released. 2014-01-20: wsfulton Director exceptions (Swig::DirectorException) now derive from std::exception and hence provide the what() method. In Python and Ruby, this replaces the now deprecated DirectorException::getMessage() method. 2014-01-14: diorcety Patch #112 - Fix symbol resolution involving scopes that have multiple levels of typedefs - fixes some template resolutions as well as some typemap searches. 2014-01-11: wsfulton Fix and document the naturalvar feature override behaviour - the naturalvar feature attached to a variable name has precedence over the naturalvar feature attached to the variable's type. The overriding was not working when turning the feature off on the variable's name. Fix so that any use of the naturalvar feature will override the global setting. Previously when set globally by -naturalvar or %module(naturalvar=1), use of the naturalvar feature was not always honoured. 2014-01-06: ianlancetaylor [Go] Fix bug that broke using directors from a thread not created by Go. 2013-12-24: ptomulik [Python] SF Bug #1297 Resolve several issues related to python imports. For example, it's now possible to import modules having the same module names, but belonging in different packages. From the user's viewpoint, this patch gives a little bit more control on import statements generated by SWIG. The user may choose to use relative or absolute imports. Some details: - we (still) generate import statements in the form 'import a.b.c' which corresponds to absolute imports in python3 and (the only available) ambiguous one in python2. - added -relativeimport option to use explicit relative import syntax (python3), The "Python Packages" section in the documentation discusses how to work with importing packages including the new -relativeimport command line option. 2013-12-23: vadz [Octave, Perl, Python, R, Ruby, Tcl] Change the length of strings created from fixed-size char buffers in C code. This is a potential backwards compatibility break: a "char buf[5]" containing "ho\0la" was returned as a string of length 5 before, but is returned as a string of length 2 now. Also, it was possible to assign a (non-NUL-terminated) string "hello" to such a buffer before but now this fails and only "helo" can fit. Apply "char FIXSIZE[ANY]" typemaps to explicitly choose the old behaviour. *** POTENTIAL INCOMPATIBILITY *** 2013-12-23: talby [Perl] Add support for directors. 2013-12-18: ianlancetaylor [Go] Don't require that Go environment variables be set when running examples or testsuite when using Go 1 or later. 2013-12-17: ianlancetaylor [Go] Remove -longsize option (for backward compatibility, ignore it if seen). 2013-12-17: ianlancetaylor [Go] Add -go-pkgpath option. 2013-12-16: ianlancetaylor [Go] Update for Go 1.2 release. Add support for linking SWIG code directly into executable, rather than using a shared library. 2013-12-13: ianlancetaylor [Go] Add SWIG source file name as comments in generated files. This can be used by Go documentation tools. 2013-12-12: jleveque [Lua] Fix typo (wchar instead of wchar_t) which made wchar.i for Lua useless. 2013-12-12: vmiklos [PHP] PHP's peculiar call-time pass-by-reference feature was deprecated in PHP 5.3 and removed in PHP 5.4, so update the REF typemaps in phppointers.i to specify pass-by-reference in the function definition. Examples/php/pointer has been updated accordingly. 2013-12-12: olly [PHP] The usage of $input in PHP directorout typemaps has been changed to be consistent with other languages. The typemaps provided by SWIG have been updated accordingly, but if you have written your own directorout typemaps, you'll need to update $input to &$input (or make equivalent changes). *** POTENTIAL INCOMPATIBILITY *** 2013-11-27: vadz [C#, Java, Python] Add std_auto_ptr.i defining typemaps for returning std::auto_ptr<>. 2013-11-09: wsfulton [C#] Apply patch #79 from Brant Kyser - Remove using directives from the generated C# code and fully qualify the use of all .NET framework types in order to minimize potential name collisions from input files defining types, namespace, etc with the same name as .NET framework members. - Globally qualify the use of .NET framework types in the System namespace - Remove .NET 1.1 support, .NET 2 is the minimum for the C# module This is a potential backwards compatibility break if code has been added relying on these using statements that used to be generated: using System; using System.Runtime.InteropServices; The quick fix to add these back in is to add the -DSWIG2_CSHARP command line option when executing SWIG. See CSharp.html documentation for more info. *** POTENTIAL INCOMPATIBILITY *** 2013-11-05: wsfulton [Java] Fix some corner cases for the $packagepath/$javaclassname special variable substitution. 2013-11-05: wsfulton [Java] Apply patch #91 from Marvin Greenberg - Add director:except feature for improved exception handling in director methods for Java. 2013-10-15: vadz Allow using \l, \L, \u, \U and \E in the substitution part of %(regex:/pattern/subst/) inside %rename to change the case of the text being replaced. 2013-10-12: wsfulton [CFFI] Apply #96 - superclass not lispify 2013-10-12: wsfulton Merge in C++11 support from the gsoc2009-matevz branch where Matevz Jekovec first started the C++0x additions. Documentation of the C++11 features supported is in a new Chapter of the documentation, "SWIG and C++11" in Doc/Manual/CPlusPlus11.html. 2013-10-04: wsfulton Fix %naturalvar not having any affect on templated classes instantiated with an enum as the template parameter type. Problem reported by Vadim Zeitlin. 2013-09-20: wsfulton [Java] Fix a memory leak for the java char **STRING_ARRAY typemaps. Version 2.0.12 (9 Feb 2014) =========================== 2014-01-16: wsfulton [PHP] Fix compilation error in ZTS mode (64 bit windows) due to incorrect placement of TSRMLS_FETCH() in SWIG_Php_GetModule() as reported by Mark Dawson-Butterworth. 2014-01-13: kwwette [Octave] update support to Octave version 3.8.0 - Octave 3.8.0 no longer defines OCTAVE_API_VERSION_NUMBER, but 3.8.1 will define OCTAVE_{MAJOR,MINOR,PATCH}_VERSION instead: see http://hg.savannah.gnu.org/hgweb/octave/rev/b6b6e0dc700e So we now use a new macro SWIG_OCTAVE_PREREQ(major,minor,patch) to enable features requiring Octave version major.minor.patch or later. For Octave versions prior to 3.8.1, we reconstruct values for OCTAVE_{MAJOR,MINOR,PATCH}_VERSION based on OCTAVE_API_VERSION_NUMBER, extracted from Octave's ChangeLogs. An additional hack is needed to distinguish between Octave <= 3.2.x and 3.8.0, neither of which define OCTAVE_API_VERSION_NUMBER. - Octave 3.8.0 deprecates symbol_table::varref(), so remove its use for this and future versions of Octave. - Octave 3.8.0 removes octave_value::is_real_nd_array(), used in octave_swig_type::dims(). Its use is not required here, so remove it. - Retested against Octave versions 3.0.5, 3.2.4, 3.4.3, 3.6.4, and 3.8.0. - Updated Octave documentation with tested Octave versions, and added a warning against using versions <= 3.x.x, which are no longer tested. 2013-12-22: wsfulton C++11 support for new versions of erase and insert in the STL containers. The erase and insert methods in the containers use const_iterator instead of iterator in C++11. There are times when the methods wrapped must match the parameters exactly. Specifically when full type information for template types is missing or SWIG fails to look up the type correctly, for example: %include typedef float Real; %template(RealVector) std::vector; SWIG does not find std::vector::iterator because %template using typedefs does not always work and so SWIG doesn't know if the type is copyable and so uses SwigValueWrapper which does not support conversion to another type (const_iterator). This resulted in compilation errors when using the C++11 version of the containers. Closes #73 2013-10-17: wsfulton [R] Fix SF #1340 - Visual Studio compile error in C++ wrappers due to #include within extern "C" block. 2013-10-17: wsfulton [Python] Fix SF #1345 - Missing #include for offsetof when using -builtin. 2013-10-12: wsfulton [Lua] Apply #92 - missing return statements for SWIG_Lua_add_namespace_details() and SWIG_Lua_namespace_register(). Version 2.0.11 (15 Sep 2013) ============================ 2013-09-15: wsfulton [R] Fix attempt to free a non-heap object in OUTPUT typemaps for: unsigned short *OUTPUT unsigned long *OUTPUT signed long long *OUTPUT char *OUTPUT signed char*OUTPUT unsigned char*OUTPUT 2013-09-12: wsfulton [Lua] Pull Git patch #62. 1) Static members and static functions inside class can be accessed as ModuleName.ClassName.FunctionName (MemberName respectively). Old way such as ModuleName.ClassName_FunctionName still works. 2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc. 2013-09-12: wsfulton [UTL] Infinity is now by default an acceptable value for type 'float'. This fix makes the handling of type 'float' and 'double' the same. The implementation requires the C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available. Users requiring the old behaviour of not accepting infinity, can define a 'check' typemap wherever a float is used, such as: %typemap(check,fragment="") float, const float & %{ if ($1 < -FLT_MAX || $1 > FLT_MAX) { SWIG_exception_fail(SWIG_TypeError, "Overflow in type float"); } %} *** POTENTIAL INCOMPATIBILITY *** 2013-08-30: wsfulton [Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages. This is standard information in Lua error messages, and makes it much easier to find bugs. 2013-08-29: wsfulton Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an 'Illegal token' syntax error. 2013-08-29: wsfulton [C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function. 2013-08-28: wsfulton [Python] %implicitconv is improved for overloaded functions. Like in C++, the methods with the actual types are considered before trying implicit conversions. Example: %implicitconv A; struct A { A(int i); }; class CCC { public: int xx(int i) { return 11; } int xx(const A& i) { return 22; } }; The following python code: CCC().xx(-1) will now return 11 instead of 22 - the implicit conversion is not done. 2013-08-23: olly [Python] Fix clang++ warning in generated wrapper code. 2013-08-16: wsfulton [Python] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer. Problem highlighted by Bo Peng. Closes SF patch #230. 2013-08-07: wsfulton [Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and make the generated wrapper use the default python implementations, which will fall back to repr (for -builtin option). Advantages: - it avoids the swig user having to jump through hoops to get print to work as expected when redefining repr/str slots. - typing the name of a variable on the python prompt now prints the result of a (possibly redefined) repr, without the swig user having to do any extra work. - when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the redefined repr - the behaviour is exactly the same as without the -builtin option while requiring no extra work by the user (aside from adding the %feature("python:slot...) statements of course) Disadvantage: - default str() will give different (but clearer?) output on swigged classes 2013-07-30: wsfulton [Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation of a std::map was erroneously required in addition to an instantiation of std::multimap with the same template parameters to prevent compilation errors for the wrappers of a std::multimap. 2013-07-14: joequant [R] Change types file to allow for SEXP return values 2013-07-05: wsfulton [Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is added at the beginning of the generated .py file. This is primarily needed for importing from __future__ statements required to be at the very beginning of the file. Example: %pythonbegin %{ from __future__ import print_function print("Loading", "Whizz", "Bang", sep=' ... ') %} 2013-07-01: wsfulton [Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr when using -builtin. 2013-07-01: wsfulton [Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating a <:: digraph when using the unary scope operator (::) (global scope) in a template type. 2013-07-01: wsfulton [Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on object deletion when using -builtin. Fixes SF bug #1301. 2013-06-11: wsfulton [Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example files have been modified to use this so that Debug builds will now work without having to install or build a Debug build of the interpreter. 2013-06-07: wsfulton [Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. Also fix the Complex helper functions external visibility (to static by default). 2013-06-04: olly [PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL if the type lookup fails. Version 2.0.10 (27 May 2013) ============================ 2013-05-25: wsfulton [Python] Fix Python 3 inconsistency when negative numbers are passed where a parameter expects an unsigned C type. An OverFlow error is now consistently thrown instead of a TypeError. 2013-05-25: Artem Serebriyskiy SVN Patch ticket #338 - fixes to %attribute macros for template usage with %arg. 2013-05-19: wsfulton Fix ccache-swig internal error bug due to premature file cleanup. Fixes SF bug 1319 which shows up as a failure in the ccache tests on Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined. This is a corner case which will be hit when the maximum number of files in the cache is set to be quite low (-F option), resulting in a cache miss. 2013-05-09: kwwette [Octave] Fix bugs in Octave module loading: - fix a memory leak in setting of global variables - install functions only once, to speed up module loads 2013-04-28: gjanssens [Guile] Updates in guile module: - Add support for guile 2.0 - Drop support for guile 1.6 - Drop support for generating wrappers using guile's gh interface. All generated wrappers will use the scm interface from now on. - Deprecate -gh and -scm options. They are no longer needed. A warning will be issued when these options are still used. - Fix all tests and examples to have a successful travis test 2013-04-18: wsfulton Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion in fragments. For example: %fragment("nameDescriptor", "header") %{ static const char *nameDescriptor = "$descriptor(Name)"; %} which will generate into the wrapper if the fragment is used: static const char *nameDescriptor = "SWIGTYPE_Name"; 2013-04-18: wsfulton Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as: typedef enum { eZero = 0 #define ONE 1 } EFoo; The macros are silently ignored. 2013-04-17: wsfulton [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjunction with directors. 2013-04-15: kwwette [Octave] Fix bugs in output of cleanup code. - Cleanup code is now written also after the "fail:" label, so it will be called if a SWIG_exception is raised by the wrapping function, consistent with other modules. - Octave module now also recognises the "$cleanup" special variable, if needed. 2013-04-08: kwwette Add -MP option to SWIG for generating phony targets for all dependencies. - Prevents make from complaining if header files have been deleted before the dependency file has been updated. - Modelled on similar option in GCC. 2013-04-09: olly [PHP] Add missing directorin typemap for char* and char[] which fixes director_string testcase failure. 2013-04-05: wsfulton [Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL wrappers that override the default predicate, such as: %template(Map) std::map >; 2013-04-05: wsfulton [Ruby] SF Bug #1159 - Correctly check rb_respond_to call return values to fix some further 1.9 problems with functors and use of Complex wrappers. 2013-04-02: wsfulton [Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used. 2013-03-30: wsfulton [Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, on exit of the Ruby interpreter. More frequently observed in ruby-1.9. 2013-03-29: wsfulton [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would sometimes seg fault or not work. 2013-03-25: wsfulton [Python] Fix some undefined behaviour deleting slices in the STL containers. 2013-03-19: wsfulton [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are the same except being in different namespaces when the %nspace feature is not being used. 2013-02-19: kwwette Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef a(7).q(volatile).double myarray // typedef volatile double[7] myarray; the type q(const).myarray // const myarray becomes a(7).q(const volatile).double // const volatile double[7] Previously, SwigType_typedef_resolve() produces the type q(const).a(7).q(volatile).double // non-sensical type which would never match %typemap declarations, whose types were parsed correctly. Add typemap_array_qualifiers.i to the test suite which checks for the correct behaviour. 2013-02-18: wsfulton Deprecate typedef names used as constructor and destructor names in %extend. The real class/struct name should be used. typedef struct tagEStruct { int ivar; } EStruct; %extend tagEStruct { EStruct() // illegal name, should be tagEStruct() { EStruct *s = new EStruct(); s->ivar = ivar0; return s; } ~EStruct() // illegal name, should be ~tagEStruct() { delete $self; } } For now these trigger a warning: extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in %extend is deprecated, the constructor name should be 'tagEStruct'. extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in %extend is deprecated, the destructor name should be 'tagEStruct'. These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been restored for now, but is officially deprecated. This does not apply to anonymously defined typedef classes/structs such as: typedef struct {...} X; 2013-02-17: kwwette When generating functions provided by %extend, use "(void)" for no-argument functions instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". 2013-02-17: kwwette [Octave] Minor fix to autodoc generation: get the right type for functions returning structs. 2013-02-15: wsfulton Deprecate typedef names used in %extend that are not the real class/struct name. For example: typedef struct StructBName { int myint; } StructB; %extend StructB { void method() {} } will now trigger a warning: swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name StructBName should be used instead of the typedef name StructB. This is only partially working anyway (the %extend only worked if placed after the class definition). 2013-02-09: wsfulton [CFFI] Apply patch #22 - Fix missing package before &body 2013-01-29: wsfulton [Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5. 2013-01-28: wsfulton [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. 2013-01-28: wsfulton [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. 2013-01-18: Brant Kyser [Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option. This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class into a package and the nspace feature is used to place all exposed types into a package. 2013-01-15: wsfulton Fix Visual Studio examples to work when SWIG is unzipped into a directory containing spaces. 2013-01-15: wsfulton [C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name matches. For example: %typemap(cstype) bool MVar::mvar "MyBool" struct MVar { bool mvar; }; 2013-01-11: Brant Kyser [Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on classes with the same name in two different namespaces. 2013-01-11: Vladimir Kalinin [C#] Add support for csdirectorin 'pre', 'post' and 'terminator' attributes. 2013-01-08: olly [PHP] Fix to work with a ZTS build of PHP (broken in 2.0.7). 2013-01-07: olly Fix bashism in configure, introduced in 2.0.9. 2013-01-06: wsfulton Pull patch #4 from ptomulik to fix SF Bug #1296 - Fix incorrect warning for virtual destructors in templates, such as: Warning 521: Illegal destructor name B< A >::~B(). Ignored. 2013-01-05: wsfulton [Python] Pull patch #3 from ptomulik to fix SF Bug #1295 - standard exceptions as classes using the SWIG_STD_EXCEPTIONS_AS_CLASSES macro. 2013-01-04: wsfulton [Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction with directors. 2013-01-03: wsfulton [Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when multilevel namespaces are used. Version 2.0.9 (16 December 2012) ================================ 2012-12-16: wsfulton Fix garbage line number / empty file name reporting for some missing '}' or ')' error messages. 2012-12-15: kkaempf [Ruby] Apply patch 3530444, Class#methods and Class#constants returns array of symbols in Ruby 1.9+ 2012-12-14: kkaempf [Ruby] Apply patch 3530439 and finally replace all occurrences of the STR2CSTR() macro with StringValuePtr(). STR2CSTR was deprecated since years and got removed in Ruby 1.9 2012-12-14: kkaempf [Ruby] Applied patches #3530442 and 3530443 to adapt compile and runtime include paths to match Ruby 1.9+ 2012-12-14: wsfulton [CFFI] Fix #3161614 - Some string constants are incorrect 2012-12-13: wsfulton [CFFI] Fix #3529690 - Fix incorrect constant names. 2012-12-12: drjoe [R] add fix to finalizer that was missed earlier 2012-12-11: wsfulton [Python] Apply patch #3590522 - fully qualified package paths for Python 3 even if a module is in the same package. 2012-12-08: wsfulton [Python] Bug #3563647 - PyInt_FromSize_t unavailable prior to Python 2.5 for unsigned int types. 2012-12-08: wsfulton [Perl] Fix bug #3571361 - C++ comment in C wrappers. 2012-12-07: wsfulton [C#] Apply patch #3571029 which adds missing director support for const unsigned long long &. 2012-11-28: kwwette [Octave] Simplified module loading: now just the syntax $ example; is accepted, which loads functions globally but constants and variables relative to the current scope. This make module loading behaviour reliably consistent, and reduces problems when loading modules which depend on other modules which may not have been previously loaded. 2012-11-27: wsfulton [cffi] Fix junk output when wrapping single character literal constants. 2012-11-17: wsfulton [Tcl, Modula3] Add missing support for -outdir. 2012-11-17: wsfulton Fix segfaults when using filename paths greater than 1024 characters in length. 2012-11-14: wsfulton [ccache-swig] Apply patch #3586392 from Frederik Deweerdt to fix some error cases - incorrectly using memory after it has been deleted. 2012-11-09: vzeitlin [Python] Fix overflow when passing values greater than LONG_MAX from Python 3 for parameters with unsigned long C type. 2012-11-09: wsfulton Fix some feature matching issues for implicit destructors and implicit constructors and implicit copy constructors added with %copyctor. Previously a feature for these had to be fully qualified in order to match. Now the following will also match: %feature("xyz") ~XXX(); struct XXX {}; 2012-11-09: wsfulton Further consistency in named output typemap lookups for implicit constructors and destructors and implicit copy constructors added with %copyctor. Previously only the fully qualified name was being used, now the unqualified name will also be used. For example, previously: example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More Looking for: void Space::More::~More Looking for: void Now the unqualified name is also used: example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More Looking for: void Space::More::~More Looking for: void ~More Looking for: void 2012-11-02: wsfulton Fix some subtle named output typemap lookup misses, the fully qualified name was not always being used for variables, for example: struct Glob { int MyVar; }; Previously the search rules (as shown by -debug-tmsearch) for the getter wrapper were: example.i:44: Searching for a suitable 'out' typemap for: int MyVar Looking for: int MyVar Looking for: int Now the scope is named correctly: example.i:44: Searching for a suitable 'out' typemap for: int Glob::MyVar Looking for: int Glob::MyVar Looking for: int MyVar Looking for: int 2012-10-26: wsfulton Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously the name was ignored during the typemap search. Applies to the following list of typemaps: directorout, csdirectorout, cstype, imtype, ctype, ddirectorout, dtype, gotype, jtype, jni, javadirectorout. 2012-10-11: wsfulton Most of the special variables available for use in %exception are now also available for expansion in %extend blocks. These are: $name $symname $overname $decl $fulldecl $parentclassname $parentclasssymname, see docs on "Class extension" in SWIGPlus.html. Patch based on submission from Kris Thielemans. 2012-10-10: wsfulton Additional new special variables in %exception are expanded as follows: $parentclassname - The parent class name (if any) for a method. $parentclasssymname - The target language parent class name (if any) for a method. 2012-10-08: iant [Go] Generating Go code now requires using the -intgosize option to indicate the size of the 'int' type in Go. This is because the size of the type is changing from Go 1.0 to Go 1.1 for x86_64. 2012-09-14: wsfulton Add new warning if the empty template instantiation is used as a base class, for example: template class Base {}; %template() Base; class Derived : public Base {}; gives the following warning instead of silently ignoring the base: cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored. cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name. 2012-09-11: wsfulton [Java] Fix #3535304 - Direct use of a weak global reference in directors sometimes causing seg faults especially on Android. 2012-09-06: wsfulton [Java] Fix (char *STRING, size_t LENGTH) typemaps to accept NULL string. 2012-08-26: drjoe [R] make ExternalReference slot ref to contain reference 2012-08-26: drjoe [R] fix Examples/Makefile to use C in $(CC) rather than $(CXX) Version 2.0.8 (20 August 2012) ============================== 2012-08-15: wsfulton [Perl] Add size_type, value_type, const_reference to the STL containers. 2012-08-15: wsfulton [Python] Add discard and add methods to std::set wrappers so that pyabc.i can be used ensuring MutableSet is a valid abstract base class for std::set. As reported by Alexey Sokolov. Similarly for std::multiset. 2012-08-15: wsfulton [Python] Fix #3541744 - Missing PyInt_FromSize_t calls for Python 3. 2012-08-13: wsfulton [Java] Patch from David Baum to add the assumeoverride feature for Java directors to improve performance when all overridden methods can be assumed to be overridden. 2012-08-05: wsfulton [Python] #3530021 Fix unused variable warning. 2012-08-05: wsfulton [C#] Fix #3536360 - Invalid code sometimes being generated for director methods with many arguments. 2012-08-05: wsfulton [Perl] #3545877 - Don't undefine bool if defined by C99 stdbool.h - problem using Perl 5.16 and later. 2012-08-04: wsfulton Remove incorrect warning (314) about target language keywords which were triggered by using declarations and using directives. For example 'string' is a keyword in C#: namespace std { class string; } using std::string; 2012-07-21: wsfulton Fix display of pointers in various places on 64 bit systems - only 32 bits were being shown. 2012-07-21: wsfulton Fix gdb debugger functions 'swigprint' and 'locswigprint' to display to the gdb output window rather than stdout. This fixes display problems in gdbtui and the ensures the output appears where expected in other gdb based debuggers such as Eclipse CDT. 2012-07-20: kwwette [Octave] segfault-on-exit prevention hack now preserves exit status, and uses C99 _Exit(). 2012-07-02: wsfulton Fix Debian bug http://bugs.debian.org/672035, typemap copy failure - regression introduced in swig-2.0.5: %include using std::pair; %template(StrPair) pair; 2012-07-02: wsfulton Fix using declarations combined with using directives with forward class declarations so that types are correctly found in scope for templates. Example: namespace Outer2 { namespace Space2 { template class Thing2; } } using namespace Outer2; using Space2::Thing2; template class Thing2 {}; // STILL BROKEN void useit2(Thing2 t) {} void useit2a(Outer2::Space2::Thing2 t) {} void useit2b(::Outer2::Space2::Thing2 t) {} void useit2c(Space2::Thing2 t) {} namespace Outer2 { void useit2d(Space2::Thing2 t) {} } %template(Thing2Int) Thing2; 2012-06-30: wsfulton Fix template namespace problems for symbols declared with a forward class declarations, such as: namespace Space1 { namespace Space2 { template struct YYY; } template struct Space2::YYY { T yyy(T h) { return h; } }; void testYYY1(Space1::Space2::YYY yy) {} void testYYY2(Space2::YYY yy) {} void testYYY3(::Space1::Space2::YYY yy) {} } %template(YYYInt) Space1::Space2::YYY; 2012-06-30: wsfulton Fix namespace problems for symbols declared with a forward class declarations, such as: namespace Space1 { namespace Space2 { struct XXX; struct YYY; } struct Space2::YYY {}; struct Space1::Space2::XXX {}; void testXXX2(Space2::XXX xx) {} void testYYY2(Space2::YYY yy) {} } where xx and yy were not recognised as the proxy classes XXX and YYY. 2012-06-30: wsfulton Fix using declarations combined with using directives with forward class declarations so that types are correctly found in scope. namespace Outer2 { namespace Space2 { class Thing2; } } using namespace Outer2; using Space2::Thing2; class Thing2 {}; // None of the methods below correctly used the Thing2 proxy class void useit2(Thing2 t) {} void useit2a(Outer2::Space2::Thing2 t) {} void useit2b(::Outer2::Space2::Thing2 t) {} void useit2c(Space2::Thing2 t) {} namespace Outer2 { void useit2d(Space2::Thing2 t) {} } 2012-06-25: wsfulton Fix using declarations combined with using directives so that types are correctly found in scope. Example: namespace Outer2 { namespace Space2 { class Thing2 {}; } } using namespace Outer2; // using directive using Space2::Thing2; // using declaration void useit2(Thing2 t) {} Similarly for templated classes. 2012-05-29: wsfulton Fix #3529601 - seg fault when a protected method has the "director" feature but the parent class does not. Also fix similar problems with the allprotected feature. 2012-05-28: wsfulton Fix seg fault when attempting to warn about an illegal destructor - #3530055, 3530078 and #3530118. Version 2.0.7 (26 May 2012) =========================== 2012-05-26: wsfulton std::string typemap modifications so they can be used with %apply for other string classes. 2012-05-25: wsfulton [Lua] Fixes for -external-runtime to work again. 2012-05-22: szager [python] Disambiguate SWIG_From_unsigned_SS_int and SWIG_From_unsigned_SS_long. 2012-05-18: olly [PHP] Fix getters for template members. (SF#3428833, SF#3528035) 2012-05-14: wsfulton Fix some language's std::map wrappers to recognise difference_type, size_type, key_type and mapped_type. 2012-05-14: kwwette (signed off by xavier98) [Octave] Prevent Octave from seg-faulting at exit when SWIG modules are loaded, due to bugs in Octave's cleanup code: * Wrapping functions now declared with Octave DEFUN_DLD macro, and loaded through Octave's dynamic module loader * Global variables of swigref type are now assigned a new() copy of the swigref class, to prevent double-free errors * SWIG module at-exit cleanup function now created in Octave through eval(), so not dependent on loaded .oct library * For Octave versions 3.1.* to 3.3.*, register C-level at-exit function which terminates Octave immediately (with correct status code) without performing memory cleanup. This function can be controlled with macros in Lib/octave/octruntime.swg [Octave] New syntax for determing whether SWIG module should be loaded globally or non-globally. To load module "example" globally, type the module name $ example; as before; to load module non-globally, assign it to a variable: $ example = example; or $ ex = example; for a shorter (local) module name. -global/-noglobal command-line options and module command line are deprecated. Added usage info to module, so typing $ help example or incorrect usage should display proper usage, with examples. *** POTENTIAL INCOMPATIBILITY *** 2012-05-12: olly [PHP] Fix memory leak in code generated for a callback. Patch from SF bug #3510806. 2012-05-12: olly [PHP] Avoid using zend_error_noreturn() as it doesn't work with all builds of PHP (SF bug #3166423). Instead we now wrap it in a SWIG_FAIL() function which we annotate as "noreturn" for GCC to avoids warnings. This also reduces the size of the compiled wrapper (e.g. the stripped size is reduced by 6% for Xapian's PHP bindings). 2012-05-11: wsfulton [Java] SF patch #3522855 Fix unintended uninitialised memory access in OUTPUT typemaps. 2012-05-11: wsfulton [Java] SF patch #3522674 Fix possible uninitialised memory access in char **STRING_OUT typemap. 2012-05-11: wsfulton [Java] SF patch #3522611 Fix uninitialised size regression in char **STRING_ARRAY introduced in swig-2.0.6. 2012-05-11: wsfulton SF bug #3525050 - Fix regression introduced in swig-2.0.5 whereby defining one typemap method such as an 'out' typemap may hide another typemap method such as an 'in' typemap - only occurs when the type is a template type where the template parameters are the same via a typedef. 2012-05-10: olly [PHP] Fix the constant typemaps for SWIGTYPE, etc - previously these used the wrong name for renamed constants. Add autodoc_runme.php to the testsuite as a regression test for this. 2012-05-02: ianlancetaylor [Go] Remove compatibility support for gccgo 4.6. Using SWIG with gccgo will now require gccgo 4.7. Using SWIG with the more commonly used gc compiler is unaffected. 2012-05-01: wsfulton Fix generated code for C forward enum declarations in some languages. Version 2.0.6 (30 April 2012) ============================= 2012-04-25: wsfulton [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. 2012-04-28: wsfulton [Python] Fix compilation errors when wrapping STL containers on Mac OS X and possibly other systems. 2012-04-28: wsfulton [Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle null pointers. Version 2.0.5 (19 April 2012) ============================= 2012-04-14: wsfulton [Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable 2012-04-14: wsfulton [Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR. 2012-04-13: wsfulton Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers. 2012-04-13: wsfulton [Lua] Apply #3219676 from Shane Liesegang which adds: - support for %factory - a __tostring method - a __disown method 2012-04-13: wsfulton [Xml] Apply #3513569 which adds a catchlist to the xml output. 2012-04-05: olly [Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader) 2012-03-26: xavier98 [octave] Apply patch #3425993 from jgillis: add extra logic to the octave_swig_type::dims(void) method: it checks if the user has defined a __dims__ method and uses this in stead of returning (1,1) [octave] Apply patch #3424833 from jgillis: make is_object return true for swig types 2012-03-24: wsfulton [D] Apply #3502431 to fix duplicate symbols in multiple modules. 2012-03-21: wsfulton Fix #3494791 - %$isglobal for %rename matching. 2012-03-20: wsfulton Fix #3487706 and #3391906 - missing stddef.h include for ptrdiff_t when using %import for STL containers and compiling with g++-4.6. An include of stddef.h is now only generated when SWIG generates STL helper templates which require ptrdiff_t. If you were previously relying on "#include " always being generated when using a %include of an STL header, you may now need to add this in manually. 2012-03-16: wsfulton Apply patch #3392264 from Sebastien Bine to parse (unsigned) long long types in enum value assignment. 2012-03-16: wsfulton Apply patch #3505530 from Karl Wette to allow custom allocators in STL string classes for the UTL languages. 2012-03-13: wsfulton Apply patch #3468362 from Karl Wette to fix %include inside %define. 2012-03-13: wsfulton [Python, Ruby, Octave, R] Fix #3475492 - iterating through std::vector wrappers of enumerations. 2012-02-27: xavier98 (patches from Karl Wette) [Octave] Use -globals . to load global variables in module namespace [Octave] Comment declaration of unimplemented function swig_register_director [Octave] Fix OCTAVE_PATH in octave Makefiles [Octave] Add support for std::list - fix li_std_containers_int test [Octave] Fix imports test 2012-02-16: wsfulton [Java] Make generated support functions in arrays_java.i static so that generated code from multiple instances of SWIG can be compiled and linked together - problem reported by Evan Krause. 2012-01-24: wsfulton Fix crash with bad regex - bug #3474250. 2012-01-24: wsfulton [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list). Assigning to a slice, reading a slice and deleting a slice with steps now work. For example: %template(vector_i) std::vector vi = vector_i(range(10)) print list(vi) vi[1:4:2] = [111, 333] print list(vi) del vi[3:10:3] print list(vi) print list(vi[::-1]) gives (same behaviour as native Python sequences such as list): [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [0, 111, 2, 333, 4, 5, 6, 7, 8, 9] [0, 111, 2, 4, 5, 7, 8] [8, 7, 5, 4, 2, 111, 0] 2012-01-23: klickverbot [D] Correctly annotate function pointers with C linkage. [D] Exception and Error have become blessed names; removed d_exception_name test case. 2012-01-20: wsfulton [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg: %template(vector_i) std::vector iv=vector_i([0,1,2,3,4,5]) iv[-7:] now returns [0, 1, 2, 3, 4, 5] instead of [5]. vv[7:9] = [22,33] now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error. Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper: il[0:2] = [11] 2012-01-17: wsfulton [Go] Fix forward class declaration within a class when used as a base. 2012-01-07: wsfulton [C#] Add support for %nspace when using directors. 2012-01-06: wsfulton [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors. 2011-12-21: wsfulton The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds - $1_name, $2_name etc. 2011-12-20: wsfulton [Java] Add (char *STRING, size_t LENGTH) director typemaps. 2011-12-20: wsfulton [C#, Go, Java, D] Add support for the 'directorargout' typemap. 2011-12-20: wsfulton [Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap. This change will break any 'directorargout' typemaps you may have written. Please change: $result to $1 $input to $result Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't previously compile and add in $1, $2 etc expansion. *** POTENTIAL INCOMPATIBILITY *** 2011-12-10: talby [perl5] SWIG_error() now gets decorated with perl source file/line number. [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue). 2011-12-10: wsfulton [Android/Java] Fix directors to compile on Android. Added documentation and examples for Android. 2011-12-08: vadz Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes (they could be sometimes mysteriously not renamed or ignored there before). 2011-12-03: klickverbot [D] Fix exception glue code for newer DMD 2 versions. [D] Do not default to 32 bit glue code for DMD anymore. [D] Use stdc.config.c_long/c_ulong to represent C long types. 2011-12-01: szager [python] Fixed bug 3447426: memory leak in vector.__getitem__. 2011-11-30: wsfulton [R] Remove C++ comments from generated C code. 2011-11-27: olly [Python] Fix some warnings when compiling generated wrappers with certain GCC warning options (Debian bug #650246). 2011-11-28: wsfulton Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. 2011-11-28: olly [Perl] Fix warnings when compiling generated wrappers with certain GCC warning options (Debian bug #436711). 2011-11-28: olly [PHP] Update keyword list to include keywords added in PHP releases up to 5.3. 2011-11-25: wsfulton [C#] Provide an easy way to override the default visibility for the proxy class pointer constructors and getCPtr() method. The visibility is 'internal' by default and if multiple SWIG modules are being used and compiled into different assemblies, then they need to be 'public' in order to use the constructor or getCPtr() method from a different assembly. Use the following macros to change the visibilities in the proxy and type wrapper class: SWIG_CSBODY_PROXY(public, public, SWIGTYPE) SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE) [Java] Provide an easy way to override the default visibility for the proxy class pointer constructors and getCPtr() method. The visibility is 'protected' by default and if multiple SWIG modules are being used and compiled into different packages, then they need to be 'public' in order to use the constructor or getCPtr() method from a different package. Use the following macros to change the visibilities in the proxy and type wrapper class: SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) The default for Java has changed from public to protected for the proxy classes. Use the SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities. *** POTENTIAL INCOMPATIBILITY *** 2011-11-22: szager [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin isn't being used, to avoid unnecessary binary incompatibilities between python installations. 2011-11-17: wsfulton Bug fix: Remove root directory from directory search list in Windows. 2011-11-13: wsfulton [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in different namespaces confusion when using multiple modules. 2011-11-11: wsfulton Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. 2011-11-03: wsfulton Expand special variables in typemap warnings, eg: %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..." 2011-11-01: wsfulton Fix named output typemaps not being used when the symbol uses a qualifier and contains a number, eg: %typemap(out) double ABC::m1 "..." 2011-10-24: talby [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research is needed on a stable path for tail calls in XS. Also, fix for large long longs in 32 bit perl. 2011-10-13: xavier98 [octave] Allow Octave modules to be re-loaded after a "clear all". 2011-09-19: wsfulton Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code when using typedef and function pointer references, for example: typedef int FN(const int &a, int b); void *typedef_call1(FN *& precallback, FN * postcallback); 2011-09-14: wsfulton [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) including options for targeting Lua Tiny RAM (LTR). 2011-09-14: wsfulton [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571. 2011-09-13: wsfulton Add warnings for badly named destructors, eg: struct KStruct { ~NOT_KStruct() {} }; cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored. 2011-09-13: wsfulton Fix %extend and destructors for templates. The destructor in %extend was not always wrapped, for example: %extend FooT { ~FooT() { delete $self; } // was not wrapped as expected }; template class FooT {}; %template(FooTi) FooT; 2011-09-13: wsfulton Fix special variables such as "$decl" and "$fulldecl" in destructors to include the ~ character. 2011-09-10: talby [perl5] SF bug #1481958 - Improve range checking for integer types. Enhance li_typemaps_runme.pl 2011-09-08: wsfulton Fix %extend on typedef classes in a namespace using the typedef name, for example: namespace Space { %extend CStruct { ... } typedef struct tagCStruct { ... } CStruct; } 2011-08-31: xavier98 [octave] patches from Karl Wette: improvements to module loading behavior; added example of friend operator to operator example; fixed octave panic/crash in 3.0.5; documentation improvements 2011-08-30: szager [python] Bug 3400486, fix error signalling for built-in constructors. 2011-08-26: wsfulton [Go] Fix file/line number display for "gotype" when using typemap debugging options -tmsearch and -tmused. 2011-08-26: wsfulton [C#, D] Fix %callback which was generating uncompilable code. 2011-08-25: wsfulton Fix constructors in named typedef class declarations as reported by Gregory Bronner: typedef struct A { A(){} // Constructor which was not accepted by SWIG B(){} // NOT a constructor --illegal, but was accepted by SWIG } B; For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in the generated code when wrapping members in A, but ultimately this does not matter, as they are the same thing. 2011-08-23: wsfulton Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The code from the "ref" feature was not always being generated for the function specified by %newobject. Documentation for "ref" and "unref" moved from Python to the C++ chapter. 2011-08-22: szager [python] Fixed memory leak with --builtin option (bug 3385089). 2011-08-22: wsfulton [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing the module table into the global namespace. Require call also returns the module table instead of a string. 2011-08-09: xavier98 Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) 2011-08-04: wsfulton Add in $symname expansion for director methods. 2011-07-29: olly [PHP] Don't generate "return $r;" in cases where $r hasn't been set. This was basically harmless, except it generated a PHP E_NOTICE if the calling code had enabled them. 2011-07-26: wsfulton Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol was incorrectly put into the outer namespace, eg namespace std { template struct map { class iterator; }; } iterator was scoped as std::iterator, but now it is correctly std::map::iterator; Also fixed is %template and template parameters that are a typedef when the template contains default template parameters, eg: namespace Std { template struct Map { typedef Key key_type; typedef T mapped_type; }; } typedef double DOUBLE; %template(MM) Std::Map; All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the wrapped code uses Std::Map or std::Map or Std::Map Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits. 2011-07-20 szager [python] Fix closure for tp_call slot. 2011-07-16: wsfulton [python] Fix director typemap using PyObject *. 2011-07-13: szager [python] SF patch #3365908 - Add all template parameters to map support code in std_map.i 2011-07-13: szager [python] Fix for bug 3324753: %rename member variables with -builtin. 2011-07-01: wsfulton Fix some scope and symbol lookup problems when template default parameters are being used with typedef. For example: template struct Foo { typedef XX X; typedef TT T; }; template struct UsesFoo { void x(typename Foo::T, typename Foo::X); }; Also fixes use of std::vector::size_type for Python as reported by Aubrey Barnard. 2011-06-23: olly [PHP] Fix director code to work when PHP is built with ZTS enabled, which is the standard configuration on Microsoft Windows. 2011-06-21: mutandiz [allegrocl] - various small tweaks and bug fixes. - Avoid name conflicts between smart pointer wrappers and the wrappers for the actual class. - Fix default typemaps for C bindings, which were incorrectly attempting to call non-existent destructors on user-defined types. - New feature, feature:aclmixins, for adding superclass to the foreign class wrappers. - Improve longlong typemaps. 2011-06-19: wsfulton Fix incorrect typemaps being used for a symbol within a templated type, eg: A::value_type would incorrectly use a typemap for type A. 2011-06-18: olly [Tcl] Fix variable declarations in middle of blocks which isn't permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). Reported by Paul Obermeier in SF#3288586. 2011-06-17: wsfulton [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[] using arrays_java.i. 2011-06-13: wsfulton [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python. 2011-06-10: wsfulton [Python] Few subtle bugfixes in autodoc documentation generation, - Unnamed argument names fix for autodoc levels > 0. - Display of template types fixed for autodoc levels > 1. - Fix SF #3310528 - display of typedef structs for autodoc levels > 1. - Add missing type for self for autodoc levels 1 and 3. - autodoc levels 2 and 3 documented. - Minor tweaks to autodoc style to conform with PEP8. 2011-05-30: olly [PHP] Fix handling of directors when -prefix is used. 2011-05-24: olly [PHP] Fix handling of methods of classes with a virtual base class (SF#3124665). Version 2.0.4 (21 May 2011) =========================== 2011-05-19: wsfulton [Guile] Patch #3191625 fixing overloading of integer types. 2011-05-19: wsfulton [Perl] Patch #3260265 fixing overloading of non-primitive types and integers in Perl 5.12 and later. 2011-05-19: wsfulton [Ruby] Fix %import where one of the imported files %include one of the STL include files such as std_vector.i. 2011-05-17: wsfulton [Java] Apply #3289851 from Alan Harder to fix memory leak in directors when checking for pending exceptions. 2011-05-17: wsfulton [Tcl] Apply #3300072 from Christian Delbaere to fix multiple module loading not always sharing variables across modules. 2011-05-16: xavier98 [octave] Fix an incompatibility with never versions of Octave. Case on Octave API >= 40 to handle rename of Octave_map to octave_map. [octave] Add support for y.__rop__(x) operators when x.__op__(y) doesn't exist. [octave] Allow global operators to be defined by SWIG-wrapped functions. [octave] Fix several bugs around module namespaces; add -global, -noglobal, -globals command line options to the module. 2011-05-14: wsfulton %varargs when used with a numeric argument used to create an additional argument which was intended to provide a guaranteed sentinel value. This never worked and now the additional argument is not generated. 2011-05-13: wsfulton [python] Additional fixes for python3.2 support. 2011-05-07: szager [python] Fixed PyGetSetDescr for python3.2. 2011-05-05: wsfulton [Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded method with incorrect arguments improved to show always show fully qualified name and if a const method. Also fixed other Lua error messages in generated code which weren't consistently using the fully qualified C++ name - requested by Gedalia Pasternak. 2011-04-29: szager Bug 2635919: Convenience method to convert std::map to a python dict. 2011-04-29: szager [Python] Fixed bug 2811549: return non-const iterators from STL methods begin(), end(), rbegin(), rend(). 2011-04-25: szager [Python] Fixed bug 1498929: Access to member fields in map elements 2011-04-23: klickverbot [D] nspace: Correctly generate identifiers for base classes when not in split proxy mode. 2011-04-13: szager Fixed bug 3286333: infinite recursion with mutual 'using namespace' clauses. 2011-04-12: szager Fixed bug 1163440: vararg typemaps. 2011-04-12: szager Fixed bug #3285386: parse error from 'operator T*&()'. Added operator_pointer_ref test case to demonstrate. 2011-04-11: szager [Python] Fixed PyVarObject_HEAD_INIT to eliminate VC++ compiler errors about static initialization of struct members with pointers. 2011-04-11: wsfulton [Tcl] Apply patch #3284326 from Colin McDonald to fix some compiler warnings. 2011-04-11: szager [Python] Fixed PyVarObject_HEAD_INIT to eliminate VC++ compiler errors about static initialization of struct members with pointers. 2011-04-10: klickverbot [D] Fixed wrapping of enums that are type char, for example: enum { X = 'X'; } (this was already in 2.0.3 for C# and Java) 2011-04-10: klickverbot [D] nspace: Fixed referencing types in the root namespace when not in split proxy mode. 2011-04-09: szager [Python] Applied patch #1932484: migrate PyCObject to PyCapsule. 2011-04-09: szager [Python] Added preprocessor guards for python functions PyUnicode_AsWideChar and PySlice_GetIndices, which changed signatures in python3.2. 2011-04-07: wsfulton Fix wrapping of const array typedefs which were generating uncompilable code as reported by Karl Wette. 2011-04-03: szager [Python] Fixed the behavior of %pythonnondynamic to conform to the spec in Lib/pyuserdir.swg. 2011-04-03: szager [Python] Merged in the szager-python-builtin branch, adding the -builtin feature for python. The -builtin option may provide a significant performance gain in python wrappers. For full details and limitations, refer to Doc/Manual/Python.html. A small test suite designed to demonstrate the performance gain is in Examples/python/performance. 2011-04-01: wsfulton Add in missing wrappers for friend functions for some target languages, mostly the non-scripting languages like Java and C#. Version 2.0.3 (29 March 2011) ============================= 2011-03-29: wsfulton [R] Apply patch #3239076 from Marie White fixing strings for R >= 2.7.0 2011-03-29: wsfulton [Tcl] Apply patch #3248280 from Christian Delbaere which adds better error messages when the incorrect number or type of arguments are passed to overloaded methods. 2011-03-29: wsfulton [Tcl] Apply patch #3224663 from Christian Delbaere. 1. Fix when function returns a NULL value, a "NULL" command will be created in the Tcl interpreter and calling this command will cause a segmentation fault. 2. Previous implementation searches for class methods using a linear search causing performance issues in wrappers for classes with many member functions. The patch adds a method hash table to classes and changes method name lookup to use the hash table instead of doing a linear search. 2011-03-26: wsfulton [C#, Java] SF bug #3195112 - fix wrapping of enums that are type char, for example: enum { X = 'X'; } 2011-03-21: vadz Allow setting PCRE_CFLAGS and PCRE_LIBS during configuration to override the values returned by pcre-config, e.g. to allow using a static version of PCRE library. 2011-03-17: wsfulton [UTL] Add missing headers in generated STL wrappers to fix compilation with gcc-4.6. 2011-03-17: wsfulton Fix regression introduced in swig-2.0.2 where filenames with spaces were not found when used with %include and %import. Reported by Shane Liesegang. 2011-03-15: wsfulton [UTL] Fix overloading when using const char[], problem reported by David Maxwell. Similarly for char[ANY] and const char[ANY]. 2011-03-15: wsfulton [C#] Apply patch #3212624 fixing std::map Keys property. 2011-03-14: olly [PHP] Fix handling of overloaded methods/functions where some return void and others don't - whether this worked or not depended on the order they were encountered in (SF#3208299). 2011-03-13: klickverbot [D] Extended support for C++ namespaces (nspace feature). 2011-03-12: olly [PHP] Fix sharing of type information between multiple SWIG-wrapped modules (SF#3202463). 2011-03-09: wsfulton [Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value for a primitive type parameter in a method declaration. 2011-03-07: olly [PHP] Don't use zend_error_noreturn() for cases where the function returns void - now this issue can only matter if you have a function or method which is directed and returns non-void. 2011-03-06: olly [PHP] Add casts to the typemaps for long long and unsigned long long to avoid issues when they are used with shorter types via %apply. 2011-03-02: wsfulton Templated smart pointers overloaded with both const and non const operator-> generated uncompilable code when the pointee was a class with either public member variables or static methods. Regression in 2.0.x reported as working in 1.3.40 by xantares on swig-user mailing list. Version 2.0.2 (20 February 2011) ================================ 2011-02-19: wsfulton [PHP] Add missing INPUT, OUTPUT and INOUT typemaps in the typemaps.i library for primitive reference types as well as signed char * and bool *. 2011-02-19: olly [PHP] Address bug in PHP on some platforms/architectures which results in zend_error_noreturn() not being available using SWIG_ZEND_ERROR_NORETURN which defaults to zend_error_noreturn but can be overridden when building the module by passing -DSWIG_ZEND_ERROR_NORETURN=zend_error to the compiler. This may result in compiler warnings, but should at least allow a module to be built on those platforms/architectures (SF#3166423). 2011-02-18: wsfulton Fix #3184549 - vararg functions and function overloading when using the -fastdispatch option. 2011-02-18: olly [PHP] An overloaded method which can return an object or a primitive type no longer causes SWIG to segfault. Reported by Paul Colby in SF#3168531. 2011-02-18: olly [PHP] Fix invalid erase during iteration of std::map in generated director code. Reported by Cory Bennett in SF#3175820. 2011-02-17: wsfulton Preprocessing now warns if extra tokens appear after #else and #end. 2011-02-16: wsfulton Fix #1653092 Preprocessor does not error out when #elif is missing an expression. This and other cases of missing preprocessor expressions now result in an error. 2011-02-14: wsfulton [Ocaml] Apply patch #3151788 from Joel Reymont. Brings Ocaml support up to date (ver 3.11 and 3.12), including std::string. 2011-02-13: wsfulton [Ruby] Apply patch #3176274 from James Masters - typecheck typemap for time_t. 2011-02-13: wsfulton Apply patch #3171793 from szager - protected director methods failing when -fvirtual is used. 2011-02-13: wsfulton Fix #1927852 - #include directives don't preprocess the file passed to it. The fix is for #include with -importall or -includeall, %include and %import, for example: #define FILENAME "abc.h" %include FILENAME 2011-02-12: wsfulton Fix #1940536, overactive preprocessor which was expanding defined(...) outside of #if and #elif preprocessor directives. 2011-02-05: wsfulton [MzScheme] SF #2942899 Add user supplied documentation to help getting started with MzScheme. Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket. 2011-02-05: wsfulton [C#] SF #3085906 - Possible fix running test-suite on Mac OS X. 2011-02-05: wsfulton SF #3173367 Better information during configure about Boost prerequisite for running the test-suite. 2011-02-05: wsfulton SF #3127633 Fix infinite loop in recursive typedef resolution. 2011-02-04: wsfulton [R] SF #3168676 Fix %rename not working for member variables and methods. 2011-02-04: wsfulton [clisp] SF #3148200 Fix segfault parsing nested unions. 2011-02-01: wsfulton [C#] Directors - a call to a method being defined in the base class, not overridden in a subclass, but again overridden in a class derived from the first subclass was not being dispatched correctly to the most derived class. See director_alternating.i for an example. 2011-02-01: wsfulton [C#, Java] Any 'using' statements in the protected section of a class were previously ignored with director protected (dirprot) mode. 2011-01-30: wsfulton Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a number of scripting languages. 2011-01-17: wsfulton New warning for smart pointers if only some of the classes in the inheritance chain are marked as smart pointer, eg, %shared_ptr should be used for all classes in an inheritance hierarchy, so this new warning highlights code where this is not the case. example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer. example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer. 2011-01-14: wsfulton Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and (char *STRING, int LENGTH). Documentation for this updated. Java patch from Volker Grabsch. 2011-01-11: iant Require Go version 7077 or later. 2010-12-30: klickverbot [C#, D, Java] Check for collision of parameter names with target language keywords when generating the director glue code. The situation in which the generated could would previously be invalid is illustrated in the new 'director_keywords' test case. 2010-12-23: wsfulton [C#] Fix $csinput special variable not being expanded for csvarin typemaps when used for global variables. Reported by Vadim Zeitlin. 2010-12-14: wsfulton Fix $basemangle expansion in array typemaps. For example if type is int *[3], $basemangle expands to _p_int. 2010-12-07: iant Check that we are using a sufficiently new version of the 6g or 8g Go compiler during configure time. If not, disable Go. Minimum version is now 6707. *** POTENTIAL INCOMPATIBILITY *** 2010-12-06: wsfulton Fix #3127394 - use of network paths on Windows/MSys. 2010-11-18: klickverbot [D] Added the D language module. 2010-11-12: vadz Fix handling of multiple regex-using %renames attached to the same declaration. For example, now %rename("%(regex:/^Set(.*)/put\\1/)s") ""; %rename("%(regex:/^Get(.*)/get\\1/)s") ""; works as expected whereas before only the last anonymous rename was taken into account. 2010-10-17: drjoe [R] Fix failure in overloaded functions which was breaking QuantLib-SWIG 2010-10-14: olly [PHP] Allow compilation on non-conforming Microsoft C++ compilers which don't accept: return function_returning_void(); Reported by Frank Vanden Berghen on the SWIG mailing list. 2010-10-12: wsfulton Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being incorrectly treated as opaque types. Also fixes #2958781 and some other type problems due to better typedef resolution, eg std::vector::value_type didn't resolve to T * when it should have. The mangled type was incorrectly SWIGTYPE_std__vectorT_Test_p_std__allocatorT_Test_p_t_t__value_type and now it is correctly SWIGTYPE_p_Test. Version 2.0.1 (4 October 2010) ============================== 2010-10-03: wsfulton Apply patch #3066958 from Mikael Johansson to fix default smart pointer handling when the smart pointer contains both a const and non-const operator->. 2010-10-01: wsfulton Add -pcreversion option to display PCRE version information. 2010-10-01: olly [Ruby] Avoid segfault when a method node has no parentNode (SF#3034054). 2010-10-01: olly [Python] Allow reinitialisation to work with an embedded Python interpreter (patch from Jim Carroll in SF#3075178). 2010-09-28: wsfulton [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid throwing exceptions with normal usage of iterators. 2010-09-27: olly [Python] Improve error message given when a parameter of the wrong type is passed to an overloaded method (SF#3027355). 2010-09-25: wsfulton Apply SF patch #3075150 - Java directors using static variables in named namespace. 2010-09-24: wsfulton More file and line error/warning reporting fixes where SWIG macros are used within {} braces (where the preprocessor expands macros), for example macros within %inline {...} and %fragment(...) {...} and nested structs. 2010-09-18: wsfulton More file and line error/warning reporting fixes for various inherited class problems. 2010-09-15: wsfulton A much improved debugging of SWIG source experience is now available and documented in the "Debugging SWIG" section in the Doc/Devel/internals.html file, including a swig.dbg support file for the gdb debugger. 2010-09-11: wsfulton Fix incorrect line number reporting in errors/warnings when a macro definition ends with '/' and it is not the end of a C comment. 2010-09-11: wsfulton Fix incorrect line number reporting in errors/warnings after parsing macro invocations with parameters given over more than one line. 2010-09-10: wsfulton Remove extraneous extra line in preprocessed output after including files which would sometimes lead to error/warning messages two lines after the end of the file. 2010-09-10: wsfulton Fix #2149523 - Incorrect line number reporting in errors after parsing macros containing C++ comments. 2010-09-08: olly [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394). 2010-09-03: wsfulton Fix erroneous line numbers in error messages for macro expansions, for example, the error message now points to instantiation of the macro, ie the last line here: #define MACRO2(a, b) #define MACRO1(NAME) MACRO2(NAME,2,3) MACRO1(abc) 2010-09-02: wsfulton Fix line numbers in error and warning messages for preprocessor messages within %inline, for example: %inline %{ #define FOOBAR 1 #define FOOBAR "hi" %} 2010-09-02: wsfulton Fix line numbers in error and warning messages which were cumulatively one less than they should have been after parsing each %include/%import - bug introduced in swig-1.3.32. Also fix line numbers in error and warning messages when new line characters appear between the %include / %import statement and the filename. 2010-08-30: wsfulton Fix line number and file name reporting for some macro preprocessor warnings. The line number of the macro argument has been corrected and the line number of the start of the macro instead of one past the end of the macro is used. Some examples: file.h:11: Error: Illegal macro argument name '..' file.h:19: Error: Macro 'DUPLICATE' redefined, file.h:15: Error: previous definition of 'DUPLICATE'. file.h:25: Error: Variable-length macro argument must be last parameter file.h:32: Error: Illegal character in macro argument name file.i:37: Error: Macro 'SIT' expects 2 arguments 2010-08-26: wsfulton Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this did not work at all. Also fixes SF #2822822. 2010-08-17: wsfulton [Perl] Fix corner case marshalling of doubles - errno was not being correctly set before calling strtod - patch from Justin Vallon - SF Bug #3038936. 2010-08-17: wsfulton Fix make distclean when some of the more obscure languages are detected by configure - fixes from Torsten Landschoff. 2010-07-28: wsfulton Restore configuring out of source for the test-suite since it broke in 1.3.37. As previously, if running 'make check-test-suite' out of source, it needs to be done by invoking configure with a relative path. Invoking configure with an absolute path will not work. Running the full 'make check' still needs to be done in the source tree. 2010-07-16: wsfulton Fix wrapping of function pointers and member function pointers when the function returns by reference. 2010-07-13: vadz Removed support for the old experimental "rxspencer" encoder and "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and officially supported "regex" encoder and "[not]regexmatch" checks should be used instead (see the two previous entries). Please replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s" when upgrading. Notice that you will also need to replace the back- references of form "@1" with the more standard "\\1" and may need to adjust your regular expressions syntax as the new regex encoder uses Perl-compatible syntax and not (extended) POSIX syntax as the old one. *** POTENTIAL INCOMPATIBILITY *** 2010-07-13: vadz Add "regexmatch", "regextarget" and "notregexmatch" which can be used to apply %rename directives to the declarations matching the specified regular expression only. The first two can be used interchangeably, both of the %renames below do the same thing: %rename("$ignore", regexmatch$name="Old$") ""; %rename("$ignore", regextarget=1) "Old$"; (namely ignore the declarations having "Old" suffix). "notregexmatch" restricts the match to only the declarations which do not match the regular expression, e.g. here is how to rename to lower case versions all declarations except those consisting from capital letters only: %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") ""; 2010-07-13: vadz Add the new "regex" encoder that can be used in %rename, e.g. %rename("regex:/(\\w+)_(.*)/\\2/") ""; to remove any alphabetical prefix from all identifiers. The syntax of the regular expressions is Perl-like and PCRE library (http://www.pcre.org/) is used to implement this feature but notice that backslashes need to be escaped as usual inside C strings. Original patch from Torsten Landschoff. 2010-07-08: wsfulton Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes the "unref" feature when used on classes with non-public destructors. 2010-06-17: ianlancetaylor [Go] Add the Go language module. 2010-06-10: wsfulton [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple modules and wrapping strings. Patch from 'Number Cruncher'. 2010-06-10: olly [PHP] Fix directors to correctly call a method with has a different name in PHP to C++ (we were always using the C++ name in this case). 2010-06-03: wsfulton Fix uncompilable code when %rename results in two enum items with the same name. Reported by Vadim Zeitlin. Version 2.0.0 (2 June 2010) =========================== 2010-06-02: wsfulton [C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with types containing commas, for example: SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >) 2010-06-01: wsfulton Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be wrapped if the following macro is defined: #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 %include shared_ptr is also documented in Library.html now. 2010-05-27: wsfulton Add the ability for $typemap special variable macros to call other $typemap special variable macros, for example: %typemap(cstype) CC "CC" %typemap(cstype) BB "$typemap(cstype, CC)" %typemap(cstype) AA "$typemap(cstype, BB)" void hah(AA aa); This also fixes C# std::vector containers of shared_ptr and %shared_ptr. Also added diagnostics for $typemap with -debug-tmsearch, for example, the above displays additional diagnostic lines starting "Containing: ": example.i:34: Searching for a suitable 'cstype' typemap for: AA aa Looking for: AA aa Looking for: AA Using: %typemap(cstype) AA Containing: $typemap(cstype, BB) example.i:31: Searching for a suitable 'cstype' typemap for: BB Looking for: BB Using: %typemap(cstype) BB Containing: $typemap(cstype, CC) example.i:29: Searching for a suitable 'cstype' typemap for: CC Looking for: CC Using: %typemap(cstype) CC 2010-05-26: olly Fix %attribute2ref not to produce a syntax error if the last argument (AccessorMethod) is omitted. Patch from David Piepgras in SF#2235756. 2010-05-26: olly [PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers now throw PHP Exception objects instead of giving a PHP error of type E_ERROR. This change shouldn't cause incompatibility issues, since you can't set an error handler for E_ERROR, so previously PHP would just exit which also happens for unhandled exceptions. The benefit is you can now catch them if you want to. Fixes SF#2545578 and SF#2955522. 2010-05-25: olly [PHP] Add missing directorin typemap for const std::string &. Fixes SF#3006404 reported by t-Legiaw. 2010-05-23: wsfulton [C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being initialized before use in .NET 4 as the classes were not marked beforefieldinit. A static constructor has been added to the intermediary class like this: %pragma(csharp) imclasscode=%{ static $imclassname() { } %} If you had added your own custom static constructor to the intermediary class in the same way as above, you will have to modify your approach to use static variable initialization or define SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR - See csharphead.swg. *** POTENTIAL INCOMPATIBILITY *** 2010-05-23: wsfulton Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an inheritance hierarchy. No special treatment is needed for derived classes. The proxy class also no longer needs to be specified, it is automatically deduced. The following macros are deprecated: SWIG_SHARED_PTR(PROXYCLASS, TYPE) SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) and have been replaced by %shared_ptr(TYPE) Similarly for intrusive_ptr wrappers, the following macro is deprecated: SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) and have been replaced by %intrusive_ptr(TYPE) 2010-05-21: olly [PHP] Stop generating a bogus line of code in certain constructors. This was mostly harmless, but caused a PHP notice to be issued, if enabled (SF#2985684). 2010-05-18: wsfulton [Java] Fix member pointers on 64 bit platforms. 2010-05-14: wsfulton Fix wrapping of C++ enum boolean values reported by Torsten Landschoff: typedef enum { PLAY = true, STOP = false } play_state; 2010-05-14: olly [PHP] Fix wrapping of global variables which was producing uncompilable code in some cases. 2010-05-12: drjoe [R] Add two more changes from Wil Nolan. Get garbage collection to work. Implement newfree 2010-05-09: drjoe Fix bug reported by Wil Nolan change creation of string so that R 2.7.0+ can use char hashes 2010-05-07: wsfulton Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by operator in constructor initialization lists. 2010-05-05: wsfulton [R] Memory leak fix handling const std::string & inputs, reported by Will Nolan. 2010-05-01: wsfulton Typemap matching enhancement for non-default typemaps. Previously all qualifiers were stripped in one step, now they are stripped one at a time starting with the left most qualifier. For example, int const*const is first stripped to int *const then int *. *** POTENTIAL INCOMPATIBILITY *** 2010-04-25: bhy [Python] Fix #2985655 - broken constructor renaming. 2010-04-14: wsfulton Typemap fragments are now official and documented in Typemaps.html. 2010-04-09: wsfulton [Ruby] Fix #2048064 and #2408020. Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit. https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/522874 2010-04-09: wsfulton [Mzscheme] Apply Ubuntu patch to fix std::map wrappers: https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/203876 2010-04-09: wsfulton [Python] Apply patch #2952374 - fix directors and the -nortti option. 2010-04-09: wsfulton [Lua] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index. 2010-04-03: wsfulton [Python] Fix exceptions being thrown with the -threads option based on patch from Arto Vuori. Fixes bug #2818499. 2010-04-03: wsfulton Fix Makefile targets: distclean and maintainer-clean 2010-04-02: wsfulton [Lua] Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a valid value. Bug reported by Gedalia Pasternak. 2010-04-01: wsfulton Numerous subtle typemap matching rule fixes when using the default type. The typemap matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc), then look for the next best match by reducing the chosen default type. The type deduction now follows C++ class template partial specialization matching rules. Below are the set of changes made showing the default type deduction along with the old reduced type and the new version of the reduced type: SWIGTYPE const &[ANY] new: SWIGTYPE const &[] old: SWIGTYPE (&)[ANY] SWIGTYPE *const [ANY] new: SWIGTYPE const [ANY] old: SWIGTYPE *[ANY] SWIGTYPE const *const [ANY] new: SWIGTYPE *const [ANY] old: SWIGTYPE const *[ANY] SWIGTYPE const *const & new: SWIGTYPE *const & old: SWIGTYPE const *& SWIGTYPE *const * new: SWIGTYPE const * old: SWIGTYPE ** SWIGTYPE *const & new: SWIGTYPE const & old: SWIGTYPE *& Additionally, a const SWIGTYPE lookup is used now for any constant type. Some examples, where T is some reduced type, eg int, struct Foo: T const new: SWIGTYPE const old: SWIGTYPE T *const new: SWIGTYPE *const old: SWIGTYPE * T const[] new: SWIGTYPE const[] old: SWIGTYPE[] enum T const new: enum SWIGTYPE const old: enum SWIGTYPE T (*const )[] new: SWIGTYPE (*const )[] old: SWIGTYPE (*)[] Reminder: the typemap matching rules can now be seen for any types being wrapped by using either the -debug-tmsearch or -debug-tmused options. In practice this leads to some subtle matching rule changes and the majority of users won't notice any changes, except in the prime area of motivation for this change: Improve STL containers of const pointers and passing const pointers by reference. This is fixed because many of the STL containers use a type 'T const&' as parameters and when T is a const pointer, for example, 'K const*', then the full type is 'K const*const&'. This means that the 'SWIGTYPE *const&' typemaps now match when T is either a non-const or const pointer. Furthermore, some target languages incorrectly had 'SWIGTYPE *&' typemaps when these should have been 'SWIGTYPE *const&'. These have been corrected (Java, C#, Lua, PHP). *** POTENTIAL INCOMPATIBILITY *** 2010-03-13: wsfulton [Java] Some very old deprecated pragma warnings are now errors. 2010-03-13: wsfulton Improve handling of file names and directories containing double/multiple path separators. 2010-03-10: mutandiz (Mikel Bancroft) [allegrocl] Use fully qualified symbol name of cl::identity in emit_defun(). 2010-03-06: wsfulton [Java] The intermediary JNI class modifiers are now public by default meaning these intermediary low level functions are now accessible by default from outside any package used. The proxy class pointer constructor and getCPtr() methods are also now public. These are needed in order for the nspace option to work without any other mods. The previous default of protected access can be restored using: SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE) %pragma(java) jniclassclassmodifiers = "class" 2010-03-06: wsfulton [C#] Added the nspace feature for C#. Documentation for the nspace feature is now available. 2010-03-04: wsfulton Added the nspace feature. This adds some improved namespace support. Currently only Java is supported for target languages, where C++ namespaces are automatically translated into Java packages. The feature only applies to classes,struct,unions and enums declared within a namespace. Methods and variables declared in namespaces still effectively have their namespaces flattened. Example usage: %feature(nspace) Outer::Inner1::Color; %feature(nspace) Outer::Inner2::Color; namespace Outer { namespace Inner1 { struct Color { ... }; } namespace Inner2 { struct Color { ... }; } } For Java, the -package option is also required when using the nspace feature. Say we use -package com.myco, the two classes can then be accessed as follows from Java: com.myco.Outer.Inner1.Color and com.myco.Outer.Inner2.Color. 2010-02-27: wsfulton [Python] Remove -dirvtable from the optimizations included by -O as it this option currently leads to memory leaks as reported by Johan Blake. 2010-02-27: wsfulton License code changes: SWIG Source is GPL-v3 and library code license is now clearer and is provided under a very permissive license. See http://www.swig.org/legal.html. 2010-02-13: wsfulton [Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'. 2010-02-13: wsfulton [Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x used in various STL wrappers. 2010-02-13: wsfulton [C#, Java] Fix incorrect multiply defined symbol name error when an enum item and class name have the same name, as reported by Nathan Krieger. Example: class Vector {}; namespace Text { enum Preference { Vector }; } This also fixes other incorrect corner case target language symbol name clashes. 2010-02-11: wsfulton Add the -debug-lsymbols option for displaying the target language layer symbols. 2010-02-09: wsfulton Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as they should be. 2010-02-08: wsfulton Fix #1807329 - When Makefile dependencies are being generated using the -M family of options on Windows, the file paths have been corrected to use single backslashes rather than double backslashes as path separators. 2010-02-06: wsfulton Fix #2918902 - language specific files not being generated in correct directory on Windows when using forward slashes for -o, for example: swig -python -c++ -o subdirectory/theinterface_wrap.cpp subdirectory/theinterface.i 2010-02-05: wsfulton Fix #2894405 - assertion when using -xmlout. 2010-01-28: wsfulton Fix typemap matching bug when a templated type has a typemap both specialized and not specialized. For example: template struct XX { ... }; %typemap(in) const XX & "..." %typemap(in) const XX< int > & "..." resulted in the 2nd typemap being applied for all T in XX< T >. 2010-01-22: wsfulton Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote global scope, the typemap is now used in situations like this: struct X {}; %typemap(in) const X & "..." void m(const ::X &); and this: struct X {}; %typemap(in) const ::X & "..." void m(const X &); 2010-01-20: wsfulton Fix some unary scope operator (::) denoting global scope problems in the types generated into the C++ layer. Previously the unary scope operator was dropped in the generated code if the type had any sort of qualifier, for example when using pointers, references, like ::foo*, ::foo&, bar< ::foo* >. 2010-01-13: olly [PHP] Add datetime to the list of PHP predefined classes (patch from David Fletcher in SF#2931042). 2010-01-11: wsfulton Slight change to warning, error and diagnostic reporting. The warning number is no longer shown within brackets. This is to help default parsing of warning messages by other tools, vim on Unix in particular. Example original display using -Fstandard: example.i:20: Warning(401): Nothing known about base class 'B'. Ignored. New display: example.i:20: Warning 401: Nothing known about base class 'B'. Ignored. Also subtle fix to -Fmicrosoft format adding in missing space. Example original display: example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored. New display: example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored. 2010-01-10: wsfulton Fix a few inconsistencies in reporting of file/line numberings including modifying the overload warnings 509, 512, 516, 474, 475 to now be two line warnings. 2010-01-10: wsfulton Modify -debug-tags output to use standard file name/line reporting so that editors can easily navigate to the appropriate lines. Was typically: . top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312) . top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39) now: /usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include /usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include 2010-01-03: wsfulton Fix missing file/line numbers for typemap warnings and in output from the -debug-tmsearch/-debug-tmused options. 2010-01-03: wsfulton Add typemaps used debugging option (-debug-tmused). When used each line displays the typemap used for each type for which code is being generated including the file and line number related to the type. This is effectively a condensed form of the -debug-tmsearch option. Documented in Typemaps.html. 2009-12-23: wsfulton Fix for %javaexception and directors so that all the appropriate throws clauses are generated. Problem reported by Peter Greenwood. 2009-12-20: wsfulton Add -debug-tmsearch option for debugging the typemap pattern matching rules. Documented in Typemaps.html. 2009-12-12: wsfulton [Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER macro provided in the octave headers for determining the api version instead. 2009-12-04: olly [Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of SF#2859614. 2009-12-04: olly Fix handling of modulo operator (%) in constant expressions (SF#2818562). 2009-12-04: olly [PHP] "empty" is a reserved word in PHP, so rename empty() method on STL classes to "is_empty()" (previously this was automatically renamed to "c_empty()"). *** POTENTIAL INCOMPATIBILITY *** 2009-12-03: olly [PHP] Add typemaps for long long and unsigned long long, and for pointer to method. 2009-12-02: olly [PHP] Fix warning and rename of reserved class name to be case insensitive. 2009-12-01: wsfulton Revert support for %extend and memberin typemaps added in swig-1.3.39. The memberin typemaps are ignored again for member variables within a %extend block. Documentation inconsistency reported by Torsten Landschoff. 2009-11-29: wsfulton [Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for static const char member variables. %javaconst(1) A; %csconst(1) A; struct X { static const char A = 'A'; }; 2009-11-26: wsfulton [Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to use the actual constant value if it is specified, rather than the C++ code to access the member. %javaconst(1) EN; %csconst(1) EN; struct X { static const int EN = 2; }; 2009-11-23: wsfulton C++ nested typedef classes can now be handled too, for example: struct Outer { typedef Foo { } FooTypedef1, FooTypedef2; }; 2009-11-18: wsfulton The wrappers for C nested structs are now generated in the same order as declared in the parsed code. 2009-11-18: wsfulton Fix #491476 - multiple declarations of nested structs, for example: struct Outer { struct { int val; } inner1, inner2, *inner3, inner4[1]; } outer; 2009-11-17: wsfulton Fix parsing of enum declaration and initialization, for example: enum ABC { a, b, c } A = a, *pC = &C, array[3] = {a, b, c}; 2009-11-17: wsfulton Fix parsing of struct declaration and initialization, for example: struct S { int x; } instance = { 10 }; 2009-11-15: wsfulton Fix #1960977 - Syntax error parsing derived nested class declaration and member variable instance. 2009-11-14: wsfulton Fix #2310483 - function pointer typedef within extern "C" block. 2009-11-13: wsfulton Fix usage of nested template classes within templated classes so that compilable code is generated. 2009-11-13: olly [php] Fix place where class prefix (as specified with -prefix) wasn't being used. Patch from gverbruggen in SF#2892647. 2009-11-12: wsfulton Fix usage of nested template classes so that compilable code is generated - the nested template class is now treated like a normal nested classes, that is, as an opaque type unless the nestedworkaround feature is used. 2009-11-12: wsfulton Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively. Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg: %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner; but clearly unnamed nested classes cannot and the global suppression is still required, eg: #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS 2009-11-11: wsfulton Added the nestedworkaround feature as a way to use the full functionality of a nested class (C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG had never parsed the nested class. The documented nested class workarounds using a global fake class stopped working when SWIG treated the nested class as an opaque pointer, and this feature reverts this behaviour. The documentation has been updated with details of how to use and implement it, see the "Nested classes" section in SWIGPlus.html. 2009-11-11: wsfulton There were a number of C++ cases where nested classes/structs/unions were being handled as if C code was being parsed which would oftentimes lead to uncompilable code as an attempt was made to wrap the nested structs like it is documented for C code. Now all nested structs/classes/unions are ignored in C++ mode, as was always documented. However, there is an improvement as usage of nested structs/classes/unions is now always treated as an opaque type by default, resulting in generated code that should always compile. *** POTENTIAL INCOMPATIBILITY *** 2009-11-09: drjoe Fix R for -fcompact and add std_map.i 2009-11-08: wsfulton Fix inconsistency for nested structs/unions/classes. Uncompilable code was being generated when inner struct and union declarations were used as types within the inner struct. The inner struct/union is now treated as a forward declaration making the behaviour the same as an inner class. (C++ code), eg: struct Outer { struct InnerStruct { int x; }; InnerStruct* getInnerStruct(); }; 2009-11-08: wsfulton Ignored nested class/struct warnings now display the name of the ignored class/struct. 2009-11-07: wsfulton Bug #1514681 - Fix nested template classes within a namespace generated uncompilable code and introduced strange side effects to other wrapper code especially code after the nested template class. Note that nested template classes are still ignored. 2009-11-07: wsfulton Add new debug options: -debug-symtabs - Display symbol tables information -debug-symbols - Display target language symbols in the symbol tables -debug-csymbols - Display C symbols in the symbol tables 2009-11-03: wsfulton Fix some usage of unary scope operator (::) denoting global scope, for example: namespace AA { /* ... */ } using namespace ::AA; and bug #1816802 - SwigValueWrapper should be used: struct CC { CC(int); // no default constructor }; ::CC x(); and in template parameter specializations: struct S {}; template struct X { void a() {} }; template <> struct X { void b() {} }; %template(MyTConcrete) X< ::S >; plus probably some other corner case usage of ::. 2009-11-02: olly [Python] Fix potential memory leak in initialisation code for the generated module. 2009-10-23: wsfulton Fix seg fault when using a named nested template instantiation using %template(name) within a class. A warning that these are not supported is now issued plus processing continues as if no name was given. 2009-10-20: wsfulton [Python] Fix std::vector. This would previously compile, but not run correctly. 2009-10-20: wsfulton Fixed previously fairly poor template partial specialization and explicit specialization support. Numerous bugs in this area have been fixed including: - Template argument deduction implemented for template type arguments, eg this now works: template class X {}; template class X {}; %template(X1) X; // Chooses T * specialization and more complex cases with multiple parameters and a mix of template argument deduction and explicitly specialised parameters, eg: template struct TwoParm { void a() {} }; template struct TwoParm { void e() {} }; %template(E) TwoParm; Note that the primary template must now be in scope, like in C++, when an explicit or partial specialization is instantiated with %template. *** POTENTIAL INCOMPATIBILITY *** 2009-09-14: wsfulton [C#] Add %csattributes for adding C# attributes to enum values, see docs for example. 2009-09-11: wsfulton Fix memmove regression in cdata.i as reported by Adriaan Renting. 2009-09-07: wsfulton Fix constant expressions containing <= or >=. 2009-09-02: wsfulton The following operators in constant expressions now result in type bool for C++ wrappers and remain as type int for C wrappers, as per each standard: && || == != < > <= >= (Actually the last 4 are still broken). For example: #define A 10 #define B 10 #define A_EQ_B A == B // now wrapped as type bool for C++ #define A_AND_B A && B // now wrapped as type bool for C++ 2009-09-02: wsfulton Fix #2845746. true and false are now recognised keywords (only when wrapping C++). Constants such as the following are now wrapped (as type bool): #define FOO true #define BAR FOO && false Version 1.3.40 (18 August 2009) =============================== 2009-08-17: olly [Perl] Add "#undef do_exec" to our clean up of Perl global namespace pollution. 2009-08-17: olly [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217). 2009-08-17: wsfulton Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html is not available. 2009-08-16: wsfulton [Octave] Caught exceptions display the type of the C++ exception instead of the generic "c++-side threw an exception" message. 2009-08-16: wsfulton [Java] When %catches is used, fix so that any classes specified in the "throws" attribute of the "throws" typemap are generated into the Java method's throws clause. 2009-08-16: wsfulton [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez. 2009-08-15: wsfulton Fix %template seg fault on some cases of overloading the templated method. Bug reported by Jan Kupec. 2009-08-15: wsfulton [Ruby] Add numerous missing wrapped methods for std::vector specialization as reported by Youssef Jones. 2009-08-14: wsfulton [Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer memory ownership control. shared_ptr support still to be added. Patch from David Fletcher. 2009-08-14: olly [PHP] PHP5 now wraps static member variables as documented. 2009-08-14: olly [PHP] Update the PHP "class" example to work with PHP5 and use modern wrapping features. 2009-08-13: wsfulton [PHP] std::vector wrappers overhaul. They no longer require the specialize_std_vector() macro. Added wrappers for capacity() and reserve(). 2009-08-13: wsfulton [PHP] Add const reference typemaps. const reference primitive types are now passed by value rather than pointer like the other target languages. Fixes SF#2524029. 2009-08-08: wsfulton [Python] More user friendly AttributeError is raised when there are no constructors generated for the proxy class in the event that the class is abstract - the error message is now "No constructor defined - class is abstract" whereas if there are no public constructors for any other reason and the class is not abstract, the message remains "No constructor defined". [tcl] Similarly for tcl when using -itcl. 2009-08-04: olly [PHP] Fix generated code to work with PHP 5.3. 2009-08-04: vmiklos [PHP] Various mathematical functions (which would conflict with the built-in PHP ones) are now automatically handled by adding a 'c_' prefix. 2009-08-03: wsfulton [C#] The std::vector implementation is improved and now uses $typemap such that the proxy class for T no longer has to be specified in some macros for correct C# compilation; the following macros are deprecated, where CSTYPE was the C# type for the C++ class CTYPE: SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE) usage should be removed altogether SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE) should be replaced with: SWIG_STD_VECTOR_ENHANCED(CTYPE) Some more details in csharp/std_vector.i *** POTENTIAL INCOMPATIBILITY *** 2009-07-31: olly [Python] Fix indentation so that we give a useful error if the module can't be loaded. Patch from Gaetan Lehmann in SF#2829853. 2009-07-29: wsfulton Add $typemap(method, typelist) special variable macro. This allows the contents of a typemap to be inserted within another typemap. Fully documented in Typemaps.html. 2009-07-29: vmiklos [PHP] Static member variables are now prefixed with the class name. This allows static member variables with the same name in different classes. 2009-07-29: olly [Python] Add missing locks to std::map wrappers. Patch from Paul Hampson in SF#2813836. 2009-07-29: olly [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi Amano in SF#2826322. 2009-07-29: olly [PHP] Fix memory leak in PHP resource destructor for classes without a destructor and non-class types. Patch from Hitoshi Amano in SF#2825303. 2009-07-28: olly [PHP] Update warnings about clashes between identifiers and PHP keywords and automatic renaming to work with the PHP5 class wrappers. Fixes SF#1613679. 2009-07-28: vmiklos [PHP] If a member function is not public but it has a base which is public, then now a warning is issued and the member function will be public, as PHP requires this. 2009-07-21: vmiklos [PHP] Director support added. 2009-07-15: olly [Perl] Don't specify Perl prototype "()" for a constructor with a different name to the class, as such constructors can still take parameters. 2009-07-12: xavier98 [Octave] Add support for Octave 3.2 API 2009-07-05: olly [PHP] Update the list of PHP keywords - "cfunction" is no longer a keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__", and "__NAMESPACE__". 2009-07-03: olly [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter of the manual. Based on patch from SF#2810380 by Christian Gollwitzer. 2009-07-02: vmiklos [PHP] Added factory.i for PHP, see the li_factory testcase for more info on how to use it. 2009-07-02: wsfulton Fix -Wallkw option as reported by Solomon Gibbs. 2009-07-02: wsfulton Fix syntax error when a nested struct contains a comment containing a * followed eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs. 2009-07-01: vmiklos [PHP] Unknown properties are no longer ignored in proxy classes. 2009-07-01: vmiklos [PHP] Fixed %newobject behaviour, previously any method marked with %newobject was handled as a constructor. 2009-06-30: olly [Ruby] Undefine close and connect macros defined by Ruby API headers as we don't need them and they can clash with C++ methods being wrapped. Patch from Vit Ondruch in SF#2814430. 2009-06-26: olly [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a double parameter. 2009-06-24: wsfulton Fix wrapping methods with default arguments and the compactdefaultargs feature where a class is passed by value and is assigned a default value. The SwigValueWrapper template workaround for a missing default constructor is no longer used as the code generated does not call the default constructor. 2009-06-16: wsfulton [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items. Incorrect enum values were being passed to the C++ layer or compilation errors resulted. 2009-06-02: talby [Perl] Resolved reference.i overload support problem identified by John Potowsky. 2009-05-26: wsfulton [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy now implements System.Collections.Generic.IDictionary<>. These std:map wrappers have a non-backwards compatible overhaul to make them like a .NET IDictionary. Some method names have changed as following: set -> setitem (use this[] property now) get -> getitem (use this[] property now) has_key -> ContainsKey del -> Remove clear -> Clear The following macros used for std::map wrappers are deprecated and will no longer work: specialize_std_map_on_key specialize_std_map_on_value specialize_std_map_on_both *** POTENTIAL INCOMPATIBILITY *** 2009-05-20: vmiklos [PHP] Add the 'thisown' member to classes. The usage of it is the same as the Python thisown one: it's 1 by default and you can set it to 0 if you want to prevent freeing it. (For example to prevent a double free.) 2009-05-14: bhy [Python] Fix the wrong pointer value returned by SwigPyObject_repr(). 2009-05-13: mutandiz (Mikel Bancroft) [allegrocl] Minor tweak when wrapping in -nocwrap mode. 2009-05-11: wsfulton [C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These implement IList<> instead of IEnumerable<> where possible. 2009-04-29: wsfulton [Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps. When this attribute is set, the typemap will not apply to classes that are derived from a C++ base class, eg %typemap(csbase, notderived="1") SWIGTYPE "CommonBase" 2009-04-29: olly [Python] Don't attempt to acquire the GIL in situations where we know that it will already be locked. This avoids some dead-locks with mod_python (due to mod_python bugs which are apparently unlikely to ever be fixed), and results in smaller wrappers which run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04, the stripped wrapper library was 11% smaller and ran 2.7% faster). 2009-04-21: wsfulton [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation. 2009-04-09: wsfulton Fix #2746858 - C macro expression using floating point numbers 2009-03-30: olly [PHP] The default out typemap for char[ANY] now returns the string up to a zero byte, or the end of the array if there is no zero byte. This is the same as Python does, and seems more generally useful than the previous behaviour of returning the whole contents of the array including any zero bytes. If you want the old behaviour, you can provide your own typemap to do this: %typemap(out) char [ANY] %{ RETVAL_STRINGL($1, $1_dim0, 1); %} Version 1.3.39 (21 March 2009) ============================== 2009-03-19: bhy [Python] Fix the memory leak related to Python 3 unicode and C char* conversion, which can be shown in the following example before this fix: from li_cstring import * i=0 while True: i += 1 n = str(i)*10 test3(n) This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with a null alloc and non-null cptr argument in Python 3, otherwise a runtime error will be raised. 2009-03-18: wsfulton [C#] std::vector wrapper improvements for .NET 2 and also providing the necessary machinery to use the std::vector wrappers with more advanced features such as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to generate code requiring .NET 2 as a minimum, although the C# code can be compiled for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the std_vector.i file for more details. *** POTENTIAL INCOMPATIBILITY *** 2009-03-12: wsfulton [Ruby] Fix #2676738 SWIG generated symbol name clashes. 2009-03-01: bhy [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement. Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect the drop of tp_compare and nb_long. 2009-03-01: bhy [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the case that module already imported at other place. 2009-02-28: bhy [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before the method calls, since some C compiler don't allow declaration in middle of function body. 2009-02-21: wsfulton [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types. 2009-02-20: wsfulton [CFFI] Fix seg faults when for %extend and using statements. 2009-02-20: wsfulton Fix SF #2605955: -co option which broke in 1.3.37. 2009-02-20: wsfulton New %insert("begin") section added. Also can be used as %begin. This is a new code section reserved entirely for users and the code within the section is generated at the top of the C/C++ wrapper file and so provides a means to put custom code into the wrapper file before anything else that SWIG generates. 2009-02-17: wsfulton 'make clean-test-suite' will now run clean on ALL languages. Previously it only ran the correctly configured languages. This way it is now possible to clean up properly after running 'make partialcheck-test-suite'. 2009-02-14: wsfulton Extend attribute library support for structs/classes and the accessor functions use pass/return by value semantics. Two new macros are available and usage is identical to %attribute. These are %attributeval for structs/classes and %attributestring for string classes, like std::string. See attribute.swg for more details. 2009-02-13: wsfulton Add support for %extend and memberin typemaps. Previously the memberin typemaps were ignored for member variables within a %extend block. 2009-02-12: wsfulton Remove unnecessary temporary variable when wrapping return values that are references. Example of generated code for wrapping: struct XYZ { std::string& refReturn(); }; used to be: std::string *result = 0 ; ... { std::string &_result_ref = (arg1)->refReturn(); result = (std::string *) &_result_ref; } Now it is: std::string *result = 0 ; ... result = (std::string *) &(arg1)->refReturn(); 2009-02-08: bhy Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from the length of the buffer to the number of items in the buffer. 2009-02-08: wsfulton Fix %feature not working for conversion operators, reported by Matt Sprague, for example: %feature("cs:methodmodifiers") operator bool "protected"; 2009-02-07: wsfulton [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions. Also fixes Makefile errors building SWIG executable when mzscheme package is installed (version 3.72 approx and later). 2009-02-04: talby [Perl] Fix SF#2564192 reported by David Kolovratnk. SWIG_AsCharPtrAndSize() now handles "get" magic. Version 1.3.38 (31 January 2009) ================================ 2009-01-31: bhy [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend and %pythonappend have correct indentation. 2009-01-31: bhy [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list of static member function in generated proxy code should not have the 'self' parameter. 2009-01-29: wsfulton Fix regression introduced in 1.3.37 where the default output directory for target language specific files (in the absence of -outdir) was no longer the same directory as the generated c/c++ file. 2009-01-28: wsfulton [Java, C#] Fix proxy class not being used when the global scope operator was used for parameters passed by value. Reported by David Piepgrass. 2009-01-15: wsfulton [Perl] Fix seg fault when running with -v option, reported by John Ky. Version 1.3.37 (13 January 2009) ================================ 2009-01-13: mgossage [Lua] Added contract support for requiring that unsigned numbers are >=0 Rewrote much of Examples/Lua/embed3. Added a lot to the Lua documentation. 2009-01-13: wsfulton Fix compilation error when using directors on protected virtual overloaded methods reported by Sam Hendley. 2009-01-12: drjoe [R] Fixed handling of integer arrays 2009-01-10: drjoe [R] Fix integer handling in r to deal correctly with signed and unsigned issues 2009-01-10: wsfulton Patch #1992756 from Colin McDonald - %contract not working for classes in namespace 2009-01-05: olly Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source code and remove documentation of them. 2008-12-30: wsfulton Bug #2430756. All the languages now define a macro in the generated C/C++ wrapper file indicating which language is being wrapped. The macro name is the same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc and are listed in the "Conditional Compilation" section in the documentation. 2008-12-23: wsfulton [Java] Fix #2153773 - %nojavaexception was clearing the exception feature instead of disabling it. Clearing checked Java exceptions also didn't work. The new %clearjavaexception can be used for clearing the exception feature. 2008-12-22: wsfulton Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors throw exceptions. 2008-12-21: wsfulton Apply patch #2440046 which fixes possible seg faults for member and global variable char arrays when the strings are larger than the string array size. 2008-12-20: wsfulton The ccache compiler cache has been adapted to work with SWIG and named ccache-swig. It now works with C/C++ compilers as well as SWIG and can result in impressive speedups when used to recompile unchanged code with either a C/C++ compiler or SWIG. Documentation is in CCache.html or the installed ccache-swig man page. 2008-12-12: wsfulton Apply patch from Kalyanov Dmitry which fixes parsing of nested structs containing comments. 2008-12-12: wsfulton Fix error message in some nested struct and %inline parsing error situations such as unterminated strings and comments. 2008-12-07: olly [PHP] Fix warnings when compiling generated wrapper with GCC 4.3. 2008-12-06: wsfulton [PHP] Deprecate %pragma(php4). Please use %pragma(php) instead. The following two warnings have been renamed: WARN_PHP4_MULTIPLE_INHERITANCE -> WARN_PHP_MULTIPLE_INHERITANCE WARN_PHP4_UNKNOWN_PRAGMA -> WARN_PHP_UNKNOWN_PRAGMA *** POTENTIAL INCOMPATIBILITY *** 2008-12-04: bhy [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py are changed, since they are inappropriate and discouraged in Python documentation (from http://www.python.org/doc/2.5.2/api/includes.html): "All user visible names defined by Python.h (except those defined by the included standard headers) have one of the prefixes "Py" or "_Py". Names beginning with "_Py" are for internal use by the Python implementation and should not be used by extension writers. Structure member names do not have a reserved prefix. Important: user code should never define names that begin with "Py" or "_Py". This confuses the reader, and jeopardizes the portability of the user code to future Python versions, which may define additional names beginning with one of these prefixes." Here is a brief list of what changed: PySwig* -> SwigPy* PyObject_ptr -> SwigPtr_PyObject PyObject_var -> SwigVar_PyObject PySequence_Base, PySequence_Cont, PySequence_Ref -> SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref PyMap* -> SwigPyMap* We provided a pyname_compat.i for backward compatibility. Users whose code having these symbols and do not want to change it could simply include this file at front of your code. A better solution is to run the converting tool on your code, which has been put in SWIG's SVN trunk (Tools/pyname_patch.py) and you can download it here: https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py *** POTENTIAL INCOMPATIBILITY *** 2008-12-02: wsfulton [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes when the package option is specified in %module and that module is %import'ed. 2008-11-28: wsfulton [UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element passed into a vector constructor would be accepted, but the ensuing behaviour was undefined. Now the type conversion correctly raises an exception. 2008-11-24: wsfulton Add -outcurrentdir option. This sets the default output directory to the current directory instead of the path specified by the input file. This option enables behaviour similar to c/c++ compilers. Note that this controls the output directory, but only in the absence of the -o and/or -outdir options. 2008-11-23: wsfulton [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in ruby 1.9. 2008-11-23: wsfulton Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. 2008-11-21: wsfulton The use of the include path to find the input file is now deprecated. This makes the behaviour of SWIG the same as C/C++ compilers in preparation for use with ccache. 2008-11-16: wsfulton Fix -nopreprocess option to: - correctly report file names in warning and error messages. - use the original input filename that created the preprocessed output when determining the C++ wrapper file name (in the absence of -o). Previously the name of the input file containing the preprocessed output was used. 2008-11-11: wsfulton [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the Intel compiler 2008-11-01: wsfulton Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy class being reported for Python docstrings when %rename is used. 2008-11-01: wsfulton Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an easy way to rename symbols by stripping a commonly used prefix in all the function/struct names. It works in the same way as the other encoders, such as title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to DoSomething: %rename("%(strip:[wx])s") ""; struct wxAnotherWidget { void wxDoSomething(); }; 2008-09-26: mutandiz [allegrocl] Lots of test-suite work. - Fix ordering of wrapper output and %{ %} header output. - Fix declarations of local vars in C wrappers. - Fix declaration of defined constants in C wrappers. - Fix declaration of EnumValues in C wrappers. - add some const typemaps to allegrocl.swg - add rename for operator bool() overloads. 2008-09-25: olly [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). 2008-09-22: mutandiz (Mikel Bancroft) [allegrocl] - Support wrapping of types whose definitions are not seen by SWIG. They are treated as forward-referenced classes and if a definition is not seen are treated as (* :void). - Don't wrap the contents of unnamed namespaces. - More code cleanup. Removed some extraneous warnings. - start work on having the allegrocl mod pass the cpp test-suite. 2008-09-19: olly [PHP5] Add typemaps for long long and unsigned long long. 2008-09-18: wsfulton [C#] Added C# array typemaps provided by Antti Karanta. The arrays provide a way to use MarshalAs(UnmanagedType.LPArray) and pinning the array using 'fixed'. See arrays_csharp.i library file for details. 2008-09-18: wsfulton Document the optional module attribute in the %import directive, see Modules.html. Add a warning for Python wrappers when the module name for an imported base class is missing, requiring the module attribute to be added to %import, eg %import(module="FooModule") foo.h 2008-09-18: olly [PHP5] Change the default input typemap for char * to turn PHP Null into C NULL (previously it was converted to an empty string). The new behaviour is consistent with how the corresponding output typemap works (SF#2025719). If you want to keep the old behaviour, add the following typemap to your interface file (PHP's convert_to_string_ex() function does the converting from PHP Null to an empty string): %typemap(in) char * { convert_to_string_ex($input); $1 = Z_STRVAL_PP($input); } 2008-09-18: olly [PHP5] Fix extra code added to proxy class constructors in the case where the only constructor takes no arguments. 2008-09-18: olly [PHP5] Fix wrapping of a renamed enumerated value of an enum class member (SF#2095273). 2008-09-17: mutandiz (Mikel Bancroft) [allegrocl] - Fix how forward reference typedefs are handled, so as not to conflict with other legit typedefs. - Don't (for now) perform an ffitype typemap lookup when trying to when calling compose_foreign_type(). This is actually a useful thing to do in certain cases, the test cases for which I can't currently locate :/. It's breaking some wrapping behavior that is more commonly seen, however. I'll readd in a more appropriate way when I can recreate the needed test case, or a user complains (which means they probably have a test case). - document the -isolate command-line arg in the 'swig -help' output. It was in the html docs, but not there. - small amount of code cleanup, removed some unused code. - some minor aesthetic changes. 2008-09-12: bhy [Python] Python 3.0 support branch merged into SWIG trunk. Thanks to Google Summer of Code 2008 for supporting this project! By default SWIG will generate interface files compatible with both Python 2.x and 3.0. And there's also some Python 3 new features that can be enabled by passing a "-py3" command line option to SWIG. These features are: - Function annotation support Also, the parameter list of proxy function will be generated, even without the "-py3" option. However, the parameter list will fallback to *args if the function (or method) is overloaded. - Buffer interface support - Abstract base class support For details of Python 3 support and these features, please see the "Python 3 Support" section in the "SWIG and Python" chapter of the SWIG documentation. The "-apply" command line option and support of generating codes using apply() is removed. Since this is only required by very old Python. This merge also patched SWIG's parser to solve a bug. By this patch, SWIG features able to be correctly applied on C++ conversion operator, such like this: %feature("shadow") *::operator bool %{ ... %} 2008-09-02: richardb [Python] Commit patch #2089149: Director exception handling mangles returned exception. Exceptions raised by Python code in directors are now passed through to the caller without change. Also, remove the ": " prefix which used to be added to other director exceptions (eg, those due to incorrect return types). 2008-09-02: wsfulton [Python] Commit patch #1988296 GCItem multiple module linking issue when using directors. 2008-09-02: wsfulton [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now possible through the use of the pre attribute and the new terminator attribute, eg %typemap(csin, pre=" using (CDate temp$csinput = new CDate($csinput)) {", terminator=" } // terminate temp$csinput using block", ) const CDate & "$csclassname.getCPtr(temp$csinput)" See CSharp.html for more info. 2008-09-01: wsfulton [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into no-eval context in DEFCENUM 2008-08-02: wuzzeb [Chicken,Allegro] Commit Patch 2019314 Fixes a build error in chicken, and several build errors and other errors in Allegro CL 2008-07-19: wsfulton Fix building of Tcl examples/test-suite on Mac OS X reported by Gideon Simpson. 2008-07-17: wsfulton Fix SF #2019156 Configuring with --without-octave or --without-alllang did not disable octave. 2008-07-14: wsfulton [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly marshalled to C#/Java null in director methods. 2008-07-04: olly [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() since "empty" is a PHP reserved word. Based on patch from Mark Klein in SF#1943417. 2008-07-04: olly [PHP] The deprecated command line option "-make" has been removed. Searches on Google codesearch suggest that nobody is using it now anyway. 2008-07-04: olly [PHP] The SWIG cdata.i library module is now supported. 2008-07-03: olly [PHP] The deprecated command line option "-phpfull" has been removed. We recommend building your extension as a dynamically loadable module. 2008-07-02: olly [PHP4] Support for PHP4 has been removed. The PHP developers are no longer making new PHP4 releases, and won't even be providing patches for critical security issues after 2008-08-08. 2008-07-02: olly [Python] Import the C extension differently for Python 2.6 and later so that an implicit relative import doesn't produce a deprecation warning for 2.6 and a failure for 2.7 and later. Patch from Richard Boulton in SF#2008229, plus follow-up patches from Richard and Haoyu Bai. Version 1.3.36 (24 June 2008) ============================= 06/24/2008: wsfulton Remove deprecated -c commandline option (runtime library generation). 06/24/2008: olly [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) (testcase ignore_parameter). 06/24/2008: olly [PHP] Fix segfault when wrapping a non-class function marked with %newobject (testcase char_strings). 06/22/2008: wsfulton [Java] Add a way to use AttachCurrentThreadAsDaemon instead of AttachCurrentThread in director code. Define the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro, see Lib/java/director.swg. 06/21/2008: wsfulton [Ruby] Fix crashing in the STL wrappers (reject! and delete_if methods) 06/19/2008: wsfulton [Java, C#] C# and Java keywords will be renamed instead of just issuing a warning and then generating uncompilable code. Warning 314 gives the new name when a keyword is found. 06/19/2008: wsfulton [R] Keyword handling added. R Keywords will be renamed as necessary. Warning 314 gives the new name when a keyword is found. 06/17/2008: mgossage [Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase. (Bug #1938142) 06/07/2008: bhy Added test case keyword_rename, then made the keyword renaming works properly by fixing Swig_name_make() for a incomplete condition checking. 06/02/2008: wsfulton [Java, C#] Fix enum wrappers when using -noproxy. 05/30/2008: bhy Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive type in SWIG - fixed SF #1976978. 05/29/2008: wsfulton [Java, C#] Fix variable wrappers when using -noproxy. 05/29/2008: bhy [Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related to -extranative SWIG option - SF #1971977. 05/20/2008: wsfulton New partialcheck makefile targets for partial testing of the test-suite. These just invoke SWIG, ie no compilation and no runtime testing. It can be faster when developing by just doing a directory diff of the files SWIG generates against those from a previous run. Example usage from the top level directory: make partialcheck-test-suite make partialcheck-java-test-suite This change also encompasses more flexibility in running the test-suite, eg it is possible to prefix the command line which runs any target language test with a tool. See the RUNTOOL, COMPILETOOL and SWIGTOOL targets in the common.mk file and makefiles in the test-suite directory. For example it is possible to run the runtime tests through valgrind using: make check RUNTOOL="valgrind --leak-check=full" or invoke SWIG under valgrind using: make check SWIGTOOL="valgrind --tool=memcheck" 05/19/2008: drjoe [R] Fixed define that was breaking pre-2.7. Checked in patch from Soren Sonnenburg that creates strings in version independent way 05/15/2008: wsfulton [Java] Fix variable name clash in directors - SF #1963316 reported by Tristan. 05/14/2008: wsfulton Add an optimisation for functions that return objects by value, reducing the number of copies of the object that are made. Implemented using an optional attribute in the "out" typemap called "optimal". Details in Typemaps.html. 05/11/2008: olly [PHP] Check for %feature("notabstract") when generating PHP5 class wrapper. 05/11/2008: wsfulton Fix SF #1943608 - $self substitution in %contract, patch submitted by Toon Verstraelen. 05/09/2008: olly [PHP] Fix char * typemaps to work when applied to signed char * and unsigned char * (uncovered by testcase apply_strings). 05/09/2008: wsfulton Fix wrapping of char * member variables when using allprotected mode. Bug reported by Warren Wang. 05/09/2008: olly [PHP] Fix bad PHP code generated when wrapping an enum in a namespace (uncovered by testcase arrays_scope). 05/09/2008: olly [PHP] SWIG now runs the PHP testsuite using PHP5, not PHP4. PHP4 is essentially obsolete now, so we care much more about solid PHP5 support. 05/07/2008: wsfulton STL fixes when using %import rather than %include and the Solaris Workshop compiler and the Roguewave STL. 05/07/2008: wsfulton Fix wrapping of overloaded protected methods when using allprotected mode. Bug reported by Warren Wang. 05/03/2008: wsfulton Commit patch #1956607 to add -MT support from Richard Boulton. This patch mirrors the gcc -MT option which allows one to change the default Makefile target being generated when generating makefiles with the -M family of options. For example: $ swig -java -MM -MT overriddenname -c++ example.i overriddenname: \ example.i \ example.h 04/30/2008: mgossage [Lua] Removed generation of _wrap_delete_XXXXX (wrappered destructor) which was unused and causing warning with g++ -Wall. Removed other unused warning in typemaps.i and other places. Added Examples/lua/embed3, and run tests a few test cases. 04/24/2008: olly [Python] Fix generated code for IBM's C++ compiler on AIX (patch from Goeran Uddeborg in SF#1928048). 04/24/2008: olly Rename BSIZE in Examples/test-suite/arrays_scope.i to BBSIZE to avoid a clash with BSIZE defined by headers on AIX with Perl (reported in SF#1928048). 04/20/2008: wsfulton Add the ability to wrap all protected members when using directors. Previously only the virtual methods were available to the target language. Now all protected members, (static and non-static variables, non-virtual methods and static methods) are wrapped when using the allprotected mode. The allprotected mode is turned on in the module declaration: %module(directors="1", allprotected="1") modulename Version 1.3.35 (7 April 2008) ============================= 04/07/2008: wsfulton [Lua] Add missing pointer reference typemaps 04/06/2008: wsfulton Fix stack overflow when using typemap warning suppression, eg %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) 04/05/2008: wsfulton [Python] Fix shared_ptr typemaps so that %pythonnondynamic can be used. Also corrects display of the proxy class type. Reported by Robert Lupton. 04/04/2008: olly [Python] Add %newobject reference to python memory management subsection of manual (patch from mdbeachy in SF#1894610). 03/27/2008: wsfulton [Python] Fix shared_ptr typemaps where the pointer type is a templated type with with more than one parameter. Reported by Robert Lupton. 03/27/2008: mgossage [Lua] Added a typemap DISOWN for SWIGTYPE* and SWIGTYPE[], and support for %delobject feature. Added Examples/lua/owner which demonstrates the use of the memory management. 03/26/2008: wsfulton [Java] Apply patch #1844301 from Monty Taylor to suppress enum constructor unused warnings. 03/26/2008: wsfulton [Python] Apply patch #1924524 from Casey Raymondson which ensures the "No constructor defined" message is displayed when attempting to call a constructor on a class that doesn't have a constructor wrapper, eg if the C++ class is abstract. 03/26/2008: wsfulton [Python] Apply patch #1925702 from Casey Raymondson which removes warning 512 for std::vector wrappers. 03/26/2008: olly [Python] Apply GCC 4.3 warnings patch from Philipp Thomas (SF#1925122). 03/21/2008: wsfulton [Python] Thread safety patch for STL iterators from Abhinandan Jain. 03/17/2008: mgossage [Lua] Added %luacode feature to add source code into wrappers. Updated documentation to document this. Added Examples/lua/arrays to show its use (and typemaps) 03/17/2008: olly Fix nonportable sed usage which failed on Mac OS X (and probably other platforms). Fixes SF#1903612. 03/17/2008: olly Fix memory leak in SWIG's parser (based on patch from Russell Bryant in SF#1914023). 03/12/2008: wsfulton Fix bug #1878285 - unnecessary cast for C struct creation wrappers. 03/12/2008: wsfulton [Python] Remove debugging info when using shared_ptr support 03/06/2008: mgossage [Lua] Updated documentation for Lua exceptions. Added Examples/lua/exception and Examples/lua/embed2. Small updates to the typemaps. 03/04/2008: wsfulton [Java, C#] Add char *& typemaps. 03/04/2008: wsfulton Fix occasional seg fault when attempting to report overloaded methods as being ignored. 02/29/2008: wsfulton [Perl] Fix #1904537 Swig causes a Perl warning "x used only once" in Perl 5.10 reported by Ari Jolma 02/29/2008: wsfulton [Python] Add shared_ptr varin/varout typemaps for wrapping global variables. 02/25/2008: wsfulton Fix $wrapname to work in %exception (fixes some wrap:name assertions) Version 1.3.34 (27 February 2008) ================================= 02/13/2008: wsfulton [R] Fix wrapping of global function pointer variables. 02/13/2008: wsfulton Add new special variables for use within %exception: $wrapname - language specific wrapper name $overname - if a method is overloaded this contains the extra mangling used on the overloaded method $decl - the fully qualified C/C++ declaration of the method being wrapped without the return type $fulldecl - the fully qualified C/C++ declaration of the method being wrapped including the return type 02/12/2008: drjoe [R] Now setting S4 flag in SWIG created objects. This fixes R-SWIG for 2.6 and warning for 2.6 failure has been removed. 02/11/2008: mgossage [Lua] Added a patch by Torsten Landschoff to fix the unary minus issue Ran 'astyle --style=kr -2' across lua.cxx to neaten it up 02/10/2008: wsfulton Bump SWIG_RUNTIME_VERSION to 4. This is because of the recently introduced API change in the conversion functions, ie change in definition of swig_converter_func. Anyone calling SWIG_TypeCast must pass in a valid value for the new additional (third) parameter and then handle the newly created memory if the returned value is set to SWIG_CAST_NEW_MEMORY else a memory leak will ensue. 02/09/2008: wsfulton [Python] Experimental shared_ptr typemaps added. Usage is the same as the recently added Java and C# shared_ptr typemaps. Two macros are available, although these may well change in a future version: For base classes or classes not in an inheritance chain: SWIG_SHARED_PTR(PROXYCLASS, TYPE) For derived classes: SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) The PROXYCLASS is the name of the proxy class, but is only required for Java/C#. Example usage: %include "boost_shared_ptr.i" SWIG_SHARED_PTR(Klass, Space::Klass) SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived) namespace Space { struct Klass { ... }; struct KlassDerived : Klass { ... }; } Further details to follow in future documentation, but the following features should be noted: - Not restricted to boost::shared_ptr, eg std::tr1::shared_ptr can also be used. - Available typemap groups: (a) Typemaps for shared_ptr passed by value, reference, pointer and pointer reference. - (b) Typemaps for passing by raw value, raw pointer, raw reference, raw pointer reference. - The code being wrapped does not even have to use shared_ptr, SWIG can use shared_ptr as the underlying storage mechanism instead of a raw pointer due to the typemaps in group (b) above. - No array support as shared_ptr does not support arrays. - This works quite differently to the usual SWIG smart pointer support when operator-> is parsed by SWIG: - An additional smart pointer class is not generated reducing code bloat in the wrappers. - Using smart pointers and raw pointers can be mixed seamlessly. - Missing constructors for the smart pointers is no longer a problem and so separate factory type functions do not have to be written and wrapped. - The implicit C++ shared_ptr< derived class > to shared_ptr< base class > cast also works in the target language. This negates the necessity to write an explicit helper cast function providing the upcast which would need calling prior to passing a derived class to a method taking a shared_ptr to a base class. 02/09/2008: wsfulton [Python] Add support for overriding the class registration function via a new "smartptr" feature. This is a very low level of customisation most users would never need to know. The feature will typically be used for intrusive smart pointers along with additional typemaps. Example usage of the feature: %feature("smartptr", noblock=1) Foo { boost::shared_ptr< Foo > } class Foo {}; The generated Foo_swigregister function will then register boost::shared < Foo > (SWIGTYPE_p_boost__shared_ptrTFoo_t instead of SWIGTYPE_p_Foo) as the underlying type for instantiations of Foo. 02/09/2008: wsfulton Features now supports the optional 'noblock' attribute for all usage of %feature. When specified, the { } braces are removed from the feature code. This is identical in behaviour to usage of 'noblock' in typemaps and is used when the preprocessor is required to operate on the code in the feature and the enclosing { } braces are not required. Example: #define FOO foo %feature("smartptr", noblock="1") { FOO::bar } The preprocessor then reduces this as if this had been used instead: %feature("smartptr") "foo::bar" 02/01/2008: olly [Python] Fix format string bug (SF#1882220). 01/31/2008: wsfulton Additions to the %types directive. Now the conversion / casting code can be overridden to some custom code in the %types directive, like so: %types(fromtype = totype) %{ ... code to convert fromtype to totype and return ... %} The special variable $from will be replaced by the name of the parameter of the type being converted from. The code must return the totype cast to void *. Example: class Time; class Date; Date &Time::dateFromTime(); %types(Time = Date) %{ Time *t = (Time *)$from; Date &d = t->dateFromTime(); return (void *) &d; %} resulting in the conversion / casting code looking something like: static void *_p_TimeTo_p_Date(void *x) { Time *t = (Time *)x; Date &d = t->dateFromTime(); return (void *) &d; } This is advanced usage, please use only if you understand the runtime type system. 01/30/2008: mgossage Small update to documentation in Typemaps.html, to warn about use of local variables in typemaps for multiple types. 01/25/2008: wsfulton [Java] Fix bug reported by Kevin Mills in ARRAYSOFCLASSES typemaps where any changes made to an array element passed from Java to C are not reflected back into Java. 01/24/2008: mgossage More updates to the configure script for detecting lua. Also looks in /usr/include/lua* Also changed typemaps.i not to check for NULL before freeing a pointer 01/21/2008: wsfulton [Python] For STL containers, SWIG no longer attempts to convert from one STL container to another, eg from std::vector to std::vector or std::list to std::vector or even std::vector to std::vector as it previously did. In fact SWIG no longer attempts to convert any SWIG wrapped C++ proxy class that is also a Python sequence, whereas previously it would. Any non-SWIG Python sequence will still be accepted wherever an STL container is accepted. Overloaded methods using containers should be faster. 01/18/2008: wsfulton [C#] Add 'directorinattributes' and 'directoroutattributes' typemap attributes for the imtype typemap. These should contain C# attributes which will be generated into the C# director delegate methods. 01/18/2008: olly Fix handling of byte value 255 in input files on platforms where char is signed (it was getting mapped to EOF). Fixes SF#1518219. 01/16/2008: wsfulton Fix template member variables wrapped by a smart pointer. Bug reported by Robert Lupton. 01/14/2008: mgossage Substantial changes to configure script for detecting lua. Code can now link to liblua.a, liblua50.a or liblua51.a It's also a lot neater now. 12/16/2007: wsfulton [Perl] Backed out #1798728 - numbers can be passed to functions taking char * 12/16/2007: wsfulton Fix #1832613 - Templates and some typedefs involving pointers or function pointers 12/12/2007: wsfulton [Java] Fix #1632625 - Compilation errors on Visual C++ 6 when using directors. 12/12/2007: wsfulton [Perl] Fix #1798728 - numbers can be passed to functions taking char *. 12/12/2007: wsfulton Fix #1819847 %template with just one default template parameter template class Foo {...}; %template(FooDefault) Foo<>; 12/12/2007: mgossage [Lua] Small correction on Lua.html 12/09/2007: wsfulton Apply patch #1838248 from Monty Taylor for vpath builds of SWIG. 12/08/2007: wsfulton [Lua] Fixes to remove gcc-4.2 warnings 12/06/2007: wsfulton Fix #1734415 - template template parameters with default arguments such as: template class t_alloc = pfc::alloc_fast > class list_t : public list_impl_t > { ... }; 12/04/2007: mgossage [lua] Fix a bug in the class hierachy code, where the methods were not propagated, if the name ordering was in a certain order. Added new example programs (dual, embed) and runtime tests for test-suite. 11/30/2007: wsfulton Fix using statements using a base class method where the methods were overloaded. Depending on the order of the using statements and method declarations, these were previously generating uncompilable wrappers, eg: struct Derived : Base { virtual void funk(); using Base::funk; }; Version 1.3.33 (November 23, 2007) ================================== 11/21/2007: mikel [allegrocl] omit private slot type info in the classes/types defined on the lisp side. Fix bug in mapping of C/++ types to lisp types. Fix typo in modules generated defpackage form. Have std::string *'s automatically marshalled between foreign and lisp strings. 11/20/2007: olly [Python] Fill in Python Dictionary functions list (patch from Jelmer Vernooij posted to swig-devel). 11/20/2007: beazley Fixed a bug in the C scanner related to backslash characters. 11/19/2007: wsfulton [Perl] Fix broken compilation of C++ wrappers on some compilers. 11/16/2007: olly [Python] Don't pass Py_ssize_t for a %d printf-like format as that's undefined behaviour when sizeof(Py_ssize_t) != sizeof(int). Version 1.3.32 (November 15, 2007) ================================== 11/14/2007: wsfulton [R] Package name and dll name is now the same as the SWIG module name. It used to be the module name with _wrap as a suffix. The package and dll names can be modified using the -package and -dll commandline options. *** POTENTIAL INCOMPATIBILITY *** 11/11/2007: wsfulton [R] Add support for Windows (Visual C++ 8 tested) 11/10/2007: olly [php] Fix makefile generated by -make (SF#1633679). Update documentation to mark "-make" as deprecated (none of the other SWIG backends seem to offer such a feature, it can't realistically generate a fully portable makefile, and the commands to build an extension are easy enough to write for the user's preferred build tool). Also recommend against the use of "-phpfull" (it's only really useful when static linking, and a dynamically loadable module is virtually always the better approach). 11/09/2007: olly Fix --help output to note that `export SWIG_FEATURES' is required. 10/29/2007: wsfulton [R] Fix seg fault on Windows [R] Examples R scripts are now platform independent 10/30/2007: mgossage [lua] fixed bug in template classes which cases template_default2 and template_specialization_defarg to fail. Added several warning filters into the overload's test cases. Added runtime tests for several codes. You can now make check-lua-test-suite with no errors and only a few warnings. 10/30/2007: olly [guile] Fix the configure test to put GUILELINK in LIBS not LDFLAGS (SF#1822430). 10/30/2007: olly [guile] Fix the guile examples on 64-bit platforms. 10/29/2007: wsfulton [C#] Fix member pointers on 64 bit platforms. 10/28/2007: olly [lua] Fix swig_lua_class instances to be static to allow multiple SWIG wrappers to be compiled into the same executable statically. Patch from Andreas Fredriksson (posted to the swig mailing list). 10/28/2007: olly [lua] Fix Examples/lua to pass SRCS for C tests rather than CXXSRCS. The code as it was happened to work on x86, but broke on x86_64 (and probably any other platforms which require -fPIC). 10/28/2007: wsfulton [Java, C#] New approach for fixing uninitialised variable usage on error in director methods using the new templated initialisation function SwigValueInit(). 10/28/2007: wsfulton [Perl] Use more efficient SvPV_nolen(x) instead of SvPV(x,PL_na) if SvPV_nolen is supported. 10/26/2007: wuzzeb [Chicken] Fix global variables of class member function pointers. Other minor fixes, so all tests in the chicken test suite now pass 10/25/2007: olly Fix UTL typecheck macro for a function taking char[] or const char[] (SF#1820132). 10/22/2007: mkoeppe [Guile] Filter out -ansi -pedantic from CFLAGS while compiling test programs for Guile in configure. This enables running the test suite for Guile if it is installed and usable. 10/22/2007: mkoeppe [Guile -scm] Fix testcases apply_signed_char and apply_strings by adding explicit casts to the appropriate $ltype. 10/22/2007: wsfulton [Java, C#] Fix uninitialised variable usage on error in director methods. 10/19/2007: wsfulton [Java, C#] Bug #1794247 - fix generated code for derived classes when csbase or javabase typemaps are used with the replace="1" attribute. 10/19/2007: wsfulton [Python] Docs updated to suggest using distutils. Patch #1796681 from Christopher Barker. 10/19/2007: olly [perl5] Clear errno before calls to strtol(), strtoul(), strtoll() and strtoull() which we check errno after to avoid seeing a junk value of errno if there isn't an error in the call. 10/16/2007: wsfulton Deprecate %attribute_ref and replace with %attributeref. There is just an argument order change in order to maintain consistency with %attribute, from: %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName) to %attributeref(Class, AttributeType, AttributeName, AccessorMethod) 10/16/2007: olly [Tcl] Fix several occurrences of "warning: deprecated conversion from string constant to 'char*'" from GCC 4.2 in generated C/C++ code. 10/16/2007: olly [PHP] Fix many occurrences of "warning: deprecated conversion from string constant to 'char*'" from GCC 4.2 in generated C/C++ code when compiling with a new enough version of PHP 5 (tested with PHP 5.2.3, but PHP 5.2.1 is probably the minimum requirement). 10/15/2007: wsfulton Patch #1797133 from David Piepgrass fixes %attribute when the getter has the same name as the attribute name and no longer generate non-functional setter for read-only attributes. 10/15/2007: olly [Tcl] Prevent SWIG_Tcl_ConvertPtr from calling the unknown proc. Add Examples/tcl/std_vector/ which this change fixes. Patch is from "Cliff C" in SF#1809819. 10/12/2007: wsfulton [Java] Add DetachCurrentThread back in for directors. See entry dated 08/11/2006 and search for DetachCurrentThread on the mailing lists for details. The crashes on Solaris seem to be only present in jdk-1.4.2 and lower (jdk-1.5.0 and jdk-1.6.0 are okay), so anyone using directors should use a recent jdk on Solaris, or define (see director.swg) SWIG_JAVA_NO_DETACH_CURRENT_THREAD to the C++ compiler to get old behaviour. 10/12/2007: wsfulton [Java] Ensure the premature garbage collection prevention parameter (pgcpp) is generated when there are C comments in the jtype and jstype typemaps. 10/12/2007: wuzzeb Added a testsuite entry for Bug #1735931 10/09/2007: olly Automatically rerun autogen.sh if configure.in is modified. 10/09/2007: olly Enhance check-%-test-suite rule and friends to give a more helpful error message if you try them for a language which doesn't exist (e.g. "make check-php-test-suite" rather than the correct "make check-php4-test-suite"). 10/09/2007: olly Add make rule to regenerate Makefile from Makefile.in if it has changed. 10/09/2007: olly [php] Fix long-standing memory leak in wrapped constructors and wrapped functions/methods which return an object. 10/08/2007: olly Fix Makefile.in to read check.list files correctly in a VPATH build. 10/07/2007: wsfulton [C#, Java] Experimental shared_ptr typemaps added 09/27/2007: mgossage [lua] added more verbose error messages for incorrect typechecks. Added a routine which checks the exact number of parameters passed to a function (breaks operator_overloading for unary minus operator, currently disabled). Reorganised the luatypemaps.swg to tidy it up. Added a lot of %ignores on the operators not supported by lua. Added support for constant member function pointers & runtest for member_pointer.i Added first version of wchar.i 09/25/2007: wsfulton [C#, Java] throws typemaps for std::wstring using C# patch #1799064 from David Piepgrass 09/24/2007: wsfulton [Tcl] Apply #1771313 to fix bug #1650229 - fixes long long and unsigned long long handling. 09/20/2007: olly [Java] Eliminate some unnecessary uses of a temporary buffer allocated using new[]. SF#1796609. 09/19/2007: wsfulton [C#] The $csinput special variable can be used in the csvarin typemap where it is always expanded to 'value'. 09/19/2007: wsfulton [C#] Fix bug reported by Glenn A Watson and #1795260 where the cstype typemap used the 'ref' keyword in the typemap body, it produced uncompilable C# properties (variable wrappers). The type for the property now correctly comes from the 'out' attribute in the cstype typemap. 09/19/2007: wsfulton [Java] Fix const std::wstring& typemaps 09/19/2007: wsfulton [Java] Ensure the premature garbage collection prevention parameter (pgcpp) is generated where a parameter is passed by pointer reference, eg in the std::vector wrappers. The pgcpp is also generated now when user's custom typemaps use a proxy class in the jstype typemap and a 'long' in the jtype typemap. 09/18/2007: olly [php] Add typemaps for handling parameters of type std::string & which are modified by the wrapped function. 09/17/2007: olly [python] Split potentially long string literals to avoid hitting MSVC's low fixed limit on string literal length - patch from SF#1723770, also reported as SF#1630855. 09/17/2007: olly [ocaml] Fix renaming of overloaded methods in the method_table - my patch from SF#940399. 09/17/2007: olly [python] Simpler code for SWIG_AsVal_bool() which fixes a "strict aliasing" warning from GCC - patch from SF#1724581 by Andrew Baumann. 09/17/2007: olly [perl5] Use sv_setpvn() to set a scalar from a pointer and length - patch from SF#174460 by "matsubaray". 09/17/2007: olly When wrapping C++ code, generate code which uses std::string::assign(PTR, LEN) rather than assigning std::string(PTR, LEN). Using assign generates more efficient code (tested with GCC 4.1.2). 09/07/2007: wsfulton Fix %ignore on constructors which are not explicitly declared [SF #1777712] 09/05/2007: wuzzeb (John Lenz) - Change r_ltype in typesys.c to store a hashtable instead of a single value. several very subtle bugs were being caused by multiple ltypes being mapped to a single mangled type, mostly when using typedefed template parameters. Now, r_ltype stores a hashtable of possible ltypes, and when generating the type table, all the ltypes are added into the swig_type_info structure. 08/31/2007: wsfulton SF #1754967 from James Bigler. - Fix bug in turning on warnings that were turned off by default. Eg 'swig -w+309' will now turn on the normally suppressed warning 309. - New -Wextra commandline option which enables the extra warning numbers: 202,309,403,512,321,322 (this is the list of warnings that have always been suppressed by default). By specifying -Wextra, all warnings will be turned on, but unlike -Wall, warnings can still be selectively turned on/off using %warnfilter, #pragma SWIG nowarn or further -w commandline options, eg: swig -Wextra -w309 will turn on all warnings except 309. 08/28/2007: wsfulton - New debugging options, -debug-module and -debug-top to display the parse tree at various stages, where is a comma separated list of stages 1-4.For example, to display top of parse tree at stages 1 and 3: swig -debug-top 1,3 - Deprecate the following options which have equivalents below: -dump_parse_module => -debug-module 1 -dump_module => -debug-module 4 -dump_parse_top => -debug-top 1 -dump_top => -debug-top 4 - Renamed some commandline options for naming consistency across all options: -debug_template => -debug-template -debug_typemap => -debug-typemap -dump_classes => -debug-classes -dump_tags => -debug-tags -dump_typedef => -debug-typedef -dump_memory => -debug-memory 08/25/2007: olly [PHP5] Fix handling of double or float parameters with an integer default value. 08/25/2007: olly [PHP5] Generate __isset() methods for setters for PHP 5.1 and later. 08/20/2007: wsfulton [Java C#] Fix director bug #1776651 reported by Stephane Routelous which occurred when the director class name is the same as the start of some other symbols used within the director class. 08/17/2007: wsfulton Correct behaviour for templated methods used with %rename or %ignore and the empty template declaration - %template(). A warning is issued if the method has not been renamed. 08/16/2007: mutandiz (Mikel Bancroft) [allegrocl] Name generated cl file based on input file rather than by module name. It was possible to end up with a mypackage.cl and a test_wrap.c when parsing a test.i input file. Confusing. Also, include external-format templates for :fat and :fat-le automatically to avoid these being compiled at runtime. 08/15/2007: efuzzyone [cffi] Apply patch #1766076 from Leigh Smith adding support for newly introduced in cffi :long-long and :unsigned-long-long. 08/10/2007: wsfulton [Java] Add documentation patch #1743573 from Jeffrey Sorensen. It contains a neat idea with respect to better memory management by the JVM of C++ allocated memory. 08/10/2007: wsfulton [Perl] Apply patch #1771410 from Wade Brainerd to fix typedef XS(SwigPerlWrapper) in perlrun.swg for ActiveState Perl build 822 and Perl 5.8.9 and 5.10 branches. 08/10/2007: wsfulton [Lua] const enum reference typemaps fixed. 08/09/2007: wsfulton [C#] Added missing support for C++ class member pointers. 08/09/2007: wsfulton [C#, Java] Add support for $owner in the "out" typemaps like in the scripting language modules. Note that $owner has always been supported in the "javaout" / "csout" typemaps. 08/01/2007: wsfulton Fix smart pointer handling for classes that have templated methods within the smart pointer type. Problem reported by craigdo at ee.washington.edu. 07/31/2007: efuzzyone [cffi] fixed memory access after being freed bug. thanks to Martin Percossi. package name clos changed to cl. thanks to Ralf Mattes 07/24/2007: wsfulton Parallel make support added for the examples and test-suite for developers who have more than one CPU. Now parallel make can be used for checking in addition to building the SWIG executable. Some typical checking examples: make -j8 -k check make -j4 check-java-test-suite make -j2 check-java-examples 07/19/2007: mgossage Fixed bug that stopped configure working on mingw (applied dos2unix to configure.in) 07/10/2007: mgossage [lua] Extra compatibility with Lua 5.1 (updated SWIG_init, docs, examples, test suite) Removed name clash for static link of multiple modules 07/05/2007: mgossage [lua] Fix a bug in SWIG_ALLOC_ARRAY() improved the error messages for incorrect arguments. Changed the output of swig_type() to use the human readable form of the type, rather than the raw swig type. 07/03/2007: wsfulton [C#] Fix directors for some overloaded methods where the imtype resulted in identical methods being generated in the C# director class, eg void foo(int *) and void foo(double *) used to generated two of these: private void SwigDirectorfoo(IntPtr p) { ... } 06/25/2007: wsfulton [Java, C#] Some parameter name changes in std_vector.i allowing better targeting of typemaps for method parameters (for memory management of containers of pointers). 06/07/2007: mutandiz (Mikel Bancroft) [allegrocl] fix foreign-type constructor to properly look for ffitype typemap bindings. fix inout_typemaps.i for strings. 06/06/2007: olly [Ruby] Use whichever of "long" or "long long" is the same size as "void*" to hold pointers as integers, rather than whichever matches off_t. Fixes compilation on OS X and GCC warnings on platforms where sizeof(void*) < sizeof(off_t) (SF patch #1731979). 06/06/2007: olly [PHP5] Fix handling of a particular case involving overloaded functions with default parameters. 06/05/2007: mutandiz (Mikel Bancroft) [allegrocl] Fix case where we'd pass fully qualified identifiers (i.e. NS1::NS2::FOO) to swig-insert-id. All namespaces should be stripped. Fix bug in TypedefHandler introduced by last fix. 06/05/2007: olly Fix reporting of filenames in errors after %include (patch from Leigh Smith in #1731040; also reported as #1699940). 05/31/2007: olly [Python] Fix "missing initialiser" warning when compiling generated C/C++ wrapper code with Python 2.5 with warnings enabled (patch from bug#1727668 from Luke Moore). 05/29/2007: olly [Python] Split docstrings into separate string literals at each newline when generating C/C++ wrapper code (the C/C++ compiler will just combine them back into a single string literal). This avoids MSVC complaining that the strings are too long (problem reported by Bo Peng on the mailing list). 05/28/2007: olly [Python] Escape backslashes in docstrings. 05/26/2007: olly [Python] Fix autodoc generation of enums to be more consistent with how the enums are wrapped - patch #1697226 from Josh Cherry. 05/26/2007: olly [PHP5] Fix wrapping of methods and functions which return a pointer to a class (bug#1700788) and those which have overloaded forms returning both classes and non-classes (bug#1712717, thanks to Simon Berthiaume for the patch). 05/25/2007: wsfulton Fixed %rename inconsistency in conversion operators as reported by Zhong Ren. The matching is now done on the operator name in the same way as it is done for parameters. For example: %rename(opABC) Space::ABC::operator ABC() const; %rename(methodABC) Space::ABC::method(ABC a) const; namespace Space { class ABC { public: void method(ABC a) const {} operator ABC() const { ABC a; return a; } }; } Note that qualifying the conversion operator previously may or may not have matched. Now it definitely won't, so this will not match: %rename(opABC) Space::ABC::operator Space::ABC() const; in the same way that this does not match: %rename(methodABC) Space::ABC::method(Space::ABC a) const; The documentation has been improved with respect to %rename, namespaces and templates. Conversion operators documentation too. *** POTENTIAL INCOMPATIBILITY *** 05/16/2007: mutandiz [allegrocl] Fix bad generation of local var ltype's in functionWrapper(). Try to work better with the backward order in which swig unrolls nested class definitions. cleaned up a little unnecessary code/debug printf's. Remove warning when replacing $ldestructor for ff:foreign-pointer 05/12/2007: olly [Python] swig -python -threads now generates C/C++ code which uses Python's own threading abstraction (from pythread.h) rather than OS specific code. The old code failed to compile on MS Windows. (See SF patch tracker #1710341). 05/04/2007: gga [Ruby] Changed STL renames to be global renames. This fixes STL functions not being renamed when autorename is on. This is a not a totally perfect work-around, but better. Someone really needs to fix the template renaming code. (See bug #1545634) 05/04/2007 gga [All] Changed %rename("%(undercase)s") a little so that single numbers at the end of a function are not undercased. That is: getSomething -> get_something get2D -> get_2d get234 -> get_234 BUT: asFloat2 -> as_float2 (Bug #1699714) 05/03/2007: gga [Ruby] Made __swigtype__ => @__swigtype__ so it can be accessed from the scripting language (and follows Ruby's official documentation, just in case). Made tracking => @__trackings__ for same reason. Currently storing ivars without the @ seems valid, but the PickAxe says this is not correct, so just in case... 05/03/2007: gga [Ruby] Applied patch for -minherit bug and exception classes. This issue should be revisited more closely, as Multiple Inheritance in Ruby is still problematic. (patch/bug #1604878) 05/03/2007: gga [Ruby] Overloaded functions in ruby will now report to the user the possible prototypes when the user mistypes the number or type of a parameter. 05/03/2007: gga [Ruby] Forgot to document the bug fixing of an old bug regarding exceptions. (bug #1458247) 05/03/2007: gga [Ruby] Fixed Ruby documentation to use the proper css styles for each section. Added autodoc section to Ruby's docs to document the features supported by Ruby in documenting its modules. Made rdoc documentation spit out the full name of the class + method name. Albeit this will make the current rdoc not recognize the method, this is still needed to disambiguate between different classes with similar methods (rdoc was created to document the ruby source which only contains one class per c file, unlike swig) I have patched rdoc to make it more friendly to swig. This patch needs to be merged in the ruby std library now. 05/03/2007: gga [Ruby] Changed flag -feature to be -init_name to better reflect its purpose and avoid confusion with -features. 05/03/2007: gga [Ruby] Improved autodoc generation. Added autodoc .swg files to Ruby library for easily adding documentation to common Ruby methods and STL methods. Fixed autodoc documenting of getters and setters and module. Made test suite always generate autodocs. 05/03/2007: gga [Ruby] Removed some warnings from STL and test suite. 05/02/2007: mgossage [Lua] Fixed issues with C++ classes and hierachies across multiple source files. Fixed imports test case & added run test. Added Examples/imports. Added typename for raw lua_State* Added documentation on native functions. 05/02/2007: gga [Ruby] Docstrings are now supported. %feature("autodoc") and %feature("docstring") are now properly supported in Ruby. These features will generate a _wrap.cxx file with rdoc comments in them. 05/02/2007: gga [Ruby] STL files have been upgraded to follow the new swig/python Lib/std conventions. This means std::vector, std::set, std::map, set::multimap, std::multiset, std::deque and std::string are now properly supported, including their iterators, support for containing ruby objects (swig::GC_VALUE) and several other ruby enhancements. std::complex, std::ios, std::iostream, std::iostreambuf and std::sstream are now also supported. std::wstring, std::wios, std::wiostream, std::wiostreambuf and std::wsstream are supported verbatim with no unicode conversion. std_vector.i now mimics the behavior of Ruby Arrays much more closely, supporting slicing, shifting, unshifting, multiple indexing and proper return values on assignment. COMPATABILITY NOTE: this changes the older api a little bit in that improper indexing would previously (incorrectly) raise exceptions. Now, nil is returned instead, following ruby's standard Array behavior. 05/02/2007: gga [Ruby] Changed the value of SWIG_TYPECHECK_BOOL to be 10000 (ie. higher than that of all integers). This is because Ruby allows typecasting integers down to booleans which can make overloaded functions on bools and integers to fail. (bug# 1488142) 05/02/2007: gga [Ruby] Fixed a subtle bug in multiple argouts that could get triggered if the user returned two or more arguments and the first one was an array. 05/01/2007: gga [Ruby] Improved the documentation to document the new features added, add directorin/out/argout typemaps, etc. 05/01/2007: gga [Ruby] Added %initstack and %ignorestack directives for director functions. These allow you to control whether a director function should re-init the Ruby stack. This is sometimes needed for an embedded Ruby where the director method is used as a C++ callback and not called by the user from ruby code. Explanation: Ruby's GC needs to be aware of the running OS stack in order to mark any VALUE (Ruby objects) it finds there to avoid collection of them. This allows the ruby API to be very simple and allows you to write code like "VALUE a = sth" anywhere without needing to do things like refcounting like python. By default, the start of the stack is set when ruby_init() is called. If ruby is inited within main(), as it usually is the case with the main ruby executable, ruby will be able to calculate its stack properly. However, when this is not possible, as when ruby is embedded as a plugin to an application where main is not available, ruby_init() will be called in the wrong place, and ruby will be incorrectly tracking the stack from the function that called ruby_init() forwards only, which can lead to all sorts of weird crashes or to ruby thinking it has run out of stack space incorrectly. To avoid this, director (callback) functions can now be tagged to try to reset the ruby stack, which will solve the issues. NOTE: ruby1.8.6 still contains a bug in it in that its function to reset the stack will not always do so. This bug is triggered very rarely, when ruby is called from two very distinct places in memory, like a branch of main() and another dso. This bug has now been reported to ruby-core and is pending further investigation. (bug #1700535 and patch #1702907) 04/30/2007: wsfulton Fix #1707582 - Restore building from read-only source directories. 04/30/2007: gga [Ruby] Ruby will now report the parameter index properly on type errors as well as the class and value of the incorrect argument passed. (feature request #1699670) 04/30/2007: gga [Ruby] Ruby no longer creates the free_Class function if the class contains its own user defined free function (%freefunc). (bug #1702882) 04/30/2007: gga [Ruby] Made directors raise a ruby exception for incorrect argout returned values if RUBY_EMBEDDED is set, instead of throwing an actual SwigDirector exception. This will prevent crashes when ruby is embedded and unaware of the SwigDirector exception. 04/30/2007: gga [Ruby] Removed the need for -DSWIGEXTERN. Changed swig_ruby_trackings to be a static variable, but also be kept within a hidden instance variable in the SWIG module. This allows properly dealing with trackings across multiple DSOs, which was previously broken. (bug #1700535 and improvement to patch #1702907) 04/29/2007: gga [Ruby] Fixed GC memory issues with trackings that could lead to segfaults when dealing, mainly, with static variables. (bug #1700535 and patch #1702907) 04/29/2007: gga [Ruby] Fixed String conversion using old ruby1.6 macros. Now StringValuePtr() is used if available. This removes warnings when converting strings with \0 in them. (bug #1700535 and patch #1702907) 04/29/2007: gga [Ruby] Fixed the argout count in directors for Ruby. Previously, ignored or "numinputs=0" typemaps would incorrectly not get counted towards the argout count. (bug/patch #1545585) 04/29/2007: gga [Ruby] Upgraded Ruby converter to recognize "numinputs=0". Previously, only the old "ignore" flag was checked (which would currently still work properly, but is deprecated). 04/29/2007: gga [Ruby - but should be made generic] %feature("numoutputs","0") added. This feature allows you to ignore the output of a function so that it is not added to a list of output values ( ie. argouts ). This should also become a feature of %typemap(directorout) as "numoutputs"=0, just like "numinputs"=0 exists. %feature("directors"=1) %include %feature("numoutputs","0") { Class::member_function1 }; %typemap(out) MStatus { // some code, like check mstatus // and raise exception if wrong }; %inline %{ typedef int MStatus; class Class { // one argument returned, but director out code added // MStatus is discarded as a return (out) parameter. virtual MStatus member_function1( int& OUTPUT ); // two arguments returned, director out code added // MStatus is not discarded virtual MStatus member_function2( int& OUTPUT ); }; %} 04/21/2007: olly Fix parsing of float constants with an exponent (e.g. 1e-02f) (bug #1699646). 04/20/2007: olly [Python] Fix lack of generation of docstrings when -O is used. Also, fix generation of docstrings containing a double quote character. Patch from Richard Boulton in bug#1700146. 04/17/2007: wsfulton [Java, C#] Support for adding in Java/C# code before and after the intermediary call, specifically related to the marshalling of the proxy type to the intermediary type. The javain/csin typemap now supports the 'pre' and 'post' attributes to achieve this. The javain typemap also supports an optional 'pgcppname' attribute for premature garbage collection prevention parameter naming and the csin typemap supports an optional 'cshin' attribute for the parameter type used in a constructor helper generated when the type is used in a constructor. Details in the Java.html and CSharp.html documentation. 04/16/2007: olly Don't treat `restrict' as a reserved identifier in C++ mode (bug#1685534). 04/16/2007: olly [PHP5] Fix how zend_throw_exception() is called (bug #1700785). 04/10/2007: olly Define SWIGTEMPLATEDISAMBIGUATOR to template for aCC (reported on swig-user that this is needed). 04/04/2007: olly [PHP5] If ZTS is enabled, release _globals_id in MSHUTDOWN to avoid PHP interpreter crash on shutdown. This solution was suggested here: http://bugs.php.net/bug.php?id=40985 04/03/2007: olly [PHP4] Add missing ZTS annotations to generated C++ wrapper code to fix compilation failures when using ZTS enabled SWIG (Linux distributions tend to disable ZTS, but notably the Windows build uses it by default). 04/01/2007: efuzzyone [CFFI] Patch #1684261: fixes handling of unsigned int literals, thanks Leigh Smith. Also, improved documentation. 03/30/2007: olly Avoid generating '<:' token when using SwigValueWrapper<> on a type which starts with '::' (patch #1690948). 03/25/2007: wuzzeb (John Lenz) [perl5] Add SWIG_fail to the SWIG_exception macro. Fixes a few problems reported on the mailing list. 03/23/2007: wsfulton String copying patch from Josh Cherry reducing memory consumption by about 25%. 03/21/2007: wsfulton [Java] Apply patch #1631987 from Ulrik Peterson - bool INOUT typemaps fail on big endian machines. 03/16/2007: wsfulton Fix seg fault given dodgy C++ code: namespace abc::def { } 03/16/2007: wsfulton [Java] Fixes so that ARRAYSOFCLASSES and ARRAYSOFENUMS in arrays_java.i can be applied to pointer types. 03/03/2007: olly [PHP5] When we know the literal numeric value for a constant, use that to initialise the const member in the PHP wrapper class. 03/02/2007: olly [PHP5] Fix PHP wrapper code generated for certain cases of overloaded forms with default arguments. 02/26/2007: efuzzyone [CFFI] Patch #1656395: fixed hex and octal values bug, thanks to Arthur Smyles. 02/22/2007: mgossage [Lua] Fixed bug in typemaps which caused derived_byvalue and rname test cases to fail. Updated derived_byvalue.i to explain how to find and fix the problem 01/25/2007: wsfulton Fix #1538522 and #1338527, forward templated class declarations without a name for the templated class parameters, such as: template class X; 01/23/2007: mgossage [Lua] Patch #1640862: replaced by Patch #1598063 Typo in typemaps.i 01/22/2007: mgossage [Lua] Added a lua specific carrays.i which adds the operator[] support. modified the main code to make it not emit all the class member functions & accessors Note: C structs are created using new_XXX() while C++ classes use XXX() (should be standardised) Updated test case: li_carrays Updated the documentation. 01/12/2007: wsfulton [Php] Add support for newfree typemaps (sometimes used by %newobject) 01/12/2007: beazley New command line option -macroerrors. When supplied, this will force the C scanner/parser to report proper location information for code contained inside SWIG macros (defined with %define). By default, SWIG merely reports errors on the line at which a macro is used. With this option, you can expand the error back to its source---something which may simplify debugging. 01/12/2007: beazley [Internals] Major overhaul of C/C++ scanning implementation. For quite some time, SWIG contained two completely independent C/C++ tokenizers-- the legacy scanner in CParse/cscanner.c and a general purpose scanner in Swig/scanner.c. SWIG still has two scanning modules, but the C parser scanner (CParse/cscanner.c) now relies upon the general purpose scanner found in Swig/scanner.c. As a result, it is much smaller and less complicated. This change also makes it possible to maintain all of the low-level C tokenizing in one central location instead of two places as before. ***POTENTIAL FLAKINESS*** This change may cause problems with accurate line number reporting as well as error reporting more generally. I have tried to resolve this as much as possible, but there might be some corner cases. 01/12/2007: mgossage [Lua] Added typemap throws for std::string*, typemap for SWIGTYPE DYNAMIC, changed the existing throws typemap to throw a string instead of making a copy of the object (updating a few test cases to deal with the change). fixed test case: dynamic_casts, exception_partial_info, li_std_string, size_t 01/03/2007: beazley [Internals]. Use of swigkeys.c/.h variables is revoked. Please use simple strings for attribute names. 12/30/2006: beazley Internal API functions HashGetAttr() and HashCheckAttr() have been revoked. Please use Getattr() to retrieve attributes. The function Checkattr() can be used to check attributes. Note: These functions have been revoked because they only added a marginal performance improvement at the expense code clarity. 12/26/2006: mgossage [Lua] Added more STL (more exceptions, map, size_t), fixed test case: conversion_ns_template. 12/21/2006: mgossage [Lua] Update to throw errors when setting immutables, and allowing user addition of module variables. 12/20/2006: wsfulton Fix typedef'd variable wrappers that use %naturalvar, eg, std::string. 12/14/2006: wsfulton [C#] Add std::wstring and wchar_t typemaps 12/14/2006: olly [php] Fix bug #1613673 (bad PHP5 code generated for getters and setters). 12/02/2006: wsfulton, John Lenz, Dave Beazley Move from cvs to Subversion for source control 11/30/2006: beazley Cleaned up swigwarnings.swg file not to use nested macro definitions. 11/12/2006: wsfulton [Java, C#] Fix for %extend to work for static member variables. Version 1.3.31 (November 20, 2006) ================================== 11/12/2006: Luigi Ballabio [Python] Alternate fix for Python exceptions bug #1578346 (the previous one broke Python properties in modern classes) 11/12/2006: wsfulton -fakeversion commandline option now generates the fake version into the generated wrappers as well as displaying it when the -version commandline option is used. 14/11/2006: mgossage [lua] update to typemap for object by value, to make it c89 compliant Version 1.3.30 (November 13, 2006) ================================== 11/12/2006: wsfulton [java] Remove DetachCurrentThread patch from 08/11/2006 - it causes segfaults on some systems. 11/12/2006: wsfulton [python] Fix #1578346 - Python exceptions with -modern 11/10/2006: wsfulton Fix #1593291 - Smart pointers and inheriting from templates 11/09/2006: wsfulton Fix director operator pointer/reference casts - #1592173. 11/07/2006: wsfulton Add $self special variable for %extend methods. Please use this instead of just 'self' as the C++ 'this' pointer. 11/07/2006: mutandiz [allegrocl] allegrocl.swg: swig-defvar updated to allow specifying of non-default foreign type (via :ftype keyword arg). allegrocl.cxx: Specify proper access type for enum values. 11/03/2006: wsfulton [Java/C#] Fix const std::string& return types for directors as reported by Mark Donselzmann 10/29/2006: wsfulton [Java] Remove DeleteLocalRef from end of director methods for now as it is causing a seg fault when run on Solaris 8. 10/29/2006: wuzzeb (John Lenz) [Guile] Patch from Chris Shoemaker to clean up some warnings in the generated code. 10/29/2006: wsfulton [Java] Important fix to prevent early garbage collection of the Java proxy class while it is being used in a native method. The finalizer could destroy the underlying C++ object while it was being used. The problem occurs when the proxy class is no longer strongly reachable after a native call. The problem seems to occur in memory stress situations on some JVMs. It does not seem to occur on the Sun client JVM up to jdk 1.5. However the 1.6 client jdk has a more aggressive garbage collector and so the problem does occur. It does occur on the Sun server JVMs (certainly 1.4 onwards). The fix entails passing the proxy class into the native method in addition to the C++ pointer in the long parameter, as Java classes are not collected when they are passed into JNI methods. The extra parameter can be suppressed by setting the nopgcpp attribute in the jtype typemap to "1" or using the new -nopgcpp commandline option. See Java.html#java_pgcpp for further details on this topic. 10/24/2006: wsfulton [C#] Fix smart pointer wrappers. The virtual/override/new keyword is not generated for each method as the smart pointer class does not mirror the underlying pointer class inheritance hierarchy. SF #1496535 10/24/2006: mgossage [lua] added support for native methods & member function pointers. fixed test cases arrays_dimensionless & cpp_basic. Added new example (functor). tidied up a little of the code (around classHandler). 10/17/2006: wsfulton [C#, Java] directorout typemap changes to fall in line with the other director languages. $result is now used where $1 used to be used. Please change your typemaps if you have a custom directorout typemap. 10/18/2006: wsfulton Some fixes for applying the char array typemaps to unsigned char arrays. 10/17/2006: wsfulton [C#, Java] Add in const size_t& and const std::size_t& typemaps. 10/15/2006: efuzzyone [CFFI] Suppress generating defctype for enums, thanks to Arthur Smyles. Patch 1560983. 10/14/2006: wuzzeb (John Lenz) [Chicken] Minor fix to make SWIG work with the (as yet unreleased) chicken 2.5 [Guile,Chicken] Fix SF Bug 1573892. Added an ext_test to the test suite to test this bug, but this test can not really be made generic because the external code must plug into the target language interpreter directly. See Examples/test-suite/chicken/ext_test.i and ext_test_external.cxx Added a %.externaltest to common.mk, and any interested language modules can copy and slightly modify either the chicken or the guile ext_test.i 10/14/2006: mgossage [Lua] added OUTPUT& for all number types, added a long long type fixed several test cases. update: changed typemaps to use SWIG_ConvertPtr rather than SWIG_MustGetPointer started spliting lua.swg into smaller parts to make it neater 10/13/2006: wsfulton [C#, Java] Marginally better support for multiple inheritance only in that you can control what the base class is. This is done using the new 'replace' attribute in the javabase/csbase typemap, eg in the following, 'Me' will be the base class, no matter what Foo is really derived from in the C++ layer. %typemap(javabase, replace="1") Foo "Me"; %typemap(csbase, replace="1") Foo "Me"; Previously it was not possible for the javabase/csbase typemaps to override the C++ base. 10/12/2006: wsfulton [Java] Remove potential race condition on the proxy class' delete() method (it is now a synchronized method, but is now customisable by changing the methodmodifiers attribute in the javadestruct or javadestruct_derived typemap) [C#] Remove potential race condition on the proxy class' Dispose() method, similar to Java's delete() above. *** POTENTIAL INCOMPATIBILITY *** 10/12/2006: wsfulton [Ruby, Python] Remove redundant director code in %extend methods (%extend methods cannot be director methods) 10/12/2006: wsfulton [Ruby, Python] Fix #1505594 - director objects not returned as director objects in %extend methods. 10/11/2006: wsfulton [Java] Fix #1238798 - Directors using unsigned long long or any other type marshalled across the JNI boundary using a Java class (where the jni typemap contains jobject). 10/06/2006: wsfulton Fix #1162194 - #include/%include within a structure 10/06/2006: wsfulton Fix #1450661, string truncation in String_seek truncating Java/C# enums. 10/06/2006: mgossage [Lua] Fix #1569587. The name is now correct. 10/04/2006: wsfulton Director fixes for virtual conversion operators 10/04/2006: olly [php] Fix #1569587 for PHP. Don't use sizeof() except with string literals. Change some "//" comments to "/* */" for portability. 10/04/2006: mgossage [Lua] Partial Fix #1569587. The type is now correct, but the name is still not correct. 10/03/2006: wsfulton [Ruby] Fix #1527885 - Overloaded director virtual methods sometimes produced uncompilable code when used with the director:except feature. 10/03/2006: wsfulton Directors: Directors are output in the order in which they are declared in the C++ class rather than in some pseudo-random order. 10/03/2006: mmatus Fix #1486281 and #1471039. 10/03/2006: olly [Perl] Fix for handling strings with zero bytes from Stephen Hutsal. 09/30/2006: efuzzyone [CFFI] Bitfield support and vararg support due to Arthur Smyles. C expression to Lisp conversion, thanks to Arthur Smyles for the initial idea, it now supports conversion for a whole range of C expressions. 09/28/2006: wsfulton Fix #1508327 - Overloaded methods are hidden when using -fvirtual optimisation. Overloaded methods are no longer candidates for elimination - this mimics C++ behaviour where all overloaded methods must be defined and implemented in a derived class in order for them to be available. 09/25/2006: wsfulton [Ruby, Python, Ocaml] Fix #1505591 Throwing exceptions in extended directors 09/25/2006: wsfulton Fix #1056100 - virtual operators. 09/24/2006: olly Don't accidentally create a "<:" token (which is the same as "[" in C++). Fixes bug # 1521788. 09/23/2006: olly [Ruby] Support building with recent versions of the Ruby 1.9 development branch. Fixes bug #1560092. 09/23/2006: olly Templates can now be instantiated using negative numbers and constant expressions, e.g.: template class x {}; %template(x_minus1) x<-1>; %template(x_1plus2) x<1+2>; Also, constant expressions can now include comparisons (>, <, >=, <=, !=, ==), modulus (%), and ternary conditionals (a ? b : c). Fixes bugs #646275, #925555, #956282, #994301. 09/22/2006: wsfulton Fix %ignore on director methods - Bugs #1546254, #1543533 09/20/2006: wsfulton Fix %ignore on director constructors 09/20/2006: wsfulton Fix seg faults and asserts when director methods are ignored (#1543533) 09/20/2006: wsfulton Fix out of source builds - bug #1544718 09/20/2006: olly Treat a nested class definition as a forward declaration rather than ignoring it completely, so that we generate correct code for passing opaque pointers to the nested class (fixes SF bug #909387). 09/20/2006: olly *** POTENTIAL INCOMPATIBILITY *** [php] Overload resolution now works. However to allow this, SWIG generated wrappers no longer coerce PHP types (which reverts a change made in 1.3.26). So for example, if a method takes a string, you can no longer pass a number without explicitly converting it to a string in PHP using: (string)x 09/18/2006: mgossage [ALL] fix on swiginit.swg, has been reported to crash on several test cases found and fixed problem in imports under python (mingw) 09/16/2006: wsfulton [Python] Patch from Michal Marek for Python 2.5 to fix 64 bit array indexes on 64 bit machines. 09/13/2006: wsfulton The explicitcall feature has been scrapped. This feature was introduced primarily to solve recursive director method calls. Director upcall improvements made instead: [Python, Ruby, Ocaml] The swig_up flag is no longer used. The required mutexes wrapping this flag are also no longer needed. The recursive calls going from C++ to the target language and back again etc are now avoided by a subtlely different approach. Instead of using the swig_up flag in each director method to indicate whether the explicit C++ call to the appropriate base class method or a normal polymorphic C++ call should be made, the new approach makes one of these calls directly from the wrapper method. [Java, C#] The recursive call problem when calling a C++ base class method from Java/C# is now fixed. The implementation is slightly different to the other languages as the detection as to whether the explicit call or a normal polymorphic call is made in the Java/C# layer rather than in the C++ layer. 09/11/2006: mgossage [ALL] updated swiginit.swg to allow multiple interpreters to use multiple swig modules at once. This has been tested in Lua (mingw & linux), perl5 & python (linux) only. 09/11/2006: mgossage [lua] added support for passing function pointers as well as native lua object into wrappered function. Added example funcptr3 to demonstrate this feature 09/05/2006: olly [php] Rename ErrorCode and ErrorMsg #define-s to SWIG_ErrorCode and SWIG_ErrorMsg to avoid clashes with code the user might be wrapping (patch from Darren Warner in SF bug #1466086). Any user typemaps which use ErrorCode and/or ErrorMsg directly will need adjusting - you can easily fix them to work with both old and new SWIG by changing to use SWIG_ErrorMsg and adding: #ifndef SWIG_ErrorMsg #define SWIG_ErrorMsg() ErrorMsg() #endif 08/29/2006: olly [php] Move constant initialisation from RINIT to MINIT to fix a warning when using Apache and mod_php. We only need to create PHP constants once when we're first initialised, not for every HTTP request. 08/21/2006: mgossage [Lua] Bugfix #1542466 added code to allow mapping Lua nil's <-> C/C++ NULL's updated various typemaps to work correctly with the changes added voidtest_runme.lua to show the features working 08/19/2006: wuzzeb (John Lenz) [Guile] Add feature:constasvar to export constants as variables instead of functions that return the constant value. 08/11/2006: wsfulton [Java] DetachCurrentThread calls have been added so that natively created threads no longer prevent the JVM from exiting. Bug reported by Thomas Dudziak and Paul Noll. 08/10/2006: wsfulton [C#] Fix director protected methods so they work 07/25/2006: mutandiz [allegrocl] more additions to std::string, some tweaks and small bug fixes -nocwrap mode. 07/21/2006: mgossage [Lua] Bugfix #1526022 pdated std::string to support strings with '\0' inside them updated typemaps.i to add support for pointer to pointers 07/19/2006: mutandiz [allegrocl] - Add std_string.i support. - Add newobject patch submitted by mkoeppe (thanks!) - Fix type name mismatch issue for nested type definitions. specifically typedefs in templated class defns. 07/18/2006: mgossage Bugfix #1522858 updated lua.cxx to support -external-runtime command 07/14/2006: wuzzeb (John Lenz) Increment the SWIG_RUNTIME_VERSION to 3, because of the addition of the owndata member in swig_type_info. Reported by: Prabhu Ramachandran 07/05/2006: wsfulton Search path fixes: - Fix search path for library files to behave as documented in Library.html. - Fix mingw/msys builds which did not find the SWIG library when installed. - Windows builds also output the mingw/msys install location when running swig -swiglib. - The non-existent and undocumented config directory in the search path has been removed. 07/05/2006: wsfulton Fix $symname special variable expansion. 07/04/2006: wuzzeb (John Lenz) [Chicken] Add %feature("constasvar"), which instead of exporting a constant as a scheme function, exports the constant as a scheme variable. Update the documentation as well. 07/04/2006: wsfulton [See entry of 09/13/2006 - explicitcall feature and documentation to it removed] New explicitcall feature which generates additional wrappers for virtual methods that call the method explicitly, not relying on polymorphism to make the method call. The feature is a feature flag and is enabled like any other feature flag. It also recognises an attribute, "suffix" for mangling the feature name, see SWIGPlus.html#SWIGPlus_explicitcall documentation for more details. [Java, C#] The explicitcall feature is also a workaround for solving the recursive calls problem when a director method makes a call to a base class method. See Java.html#java_directors_explicitcall for updated documentation. 06/28/2006: joe (Joseph Wang) [r] Initial support for R 06/20/2006: wuzzeb (John Lenz) [Chicken] Minor fixes to get apply_strings.i testsuite to pass Remove integers_runme.scm from the testsuite, because SWIG and Chicken does handle overflows. 06/19/2005: olly [php] Add support for generating PHP5 class wrappers for C++ classes (use "swig -php5"). 06/17/2006: olly [php] Added some missing keywords to the PHP4 keyword list, and fixed __LINE__ and __FILE__ which were in the wrong category. Also added all the keywords new in PHP5, and added comments noting the PHP4 keywords which aren't keywords in PHP5. 06/17/2006: olly [php] Don't segfault if PHP Null is passed as this pointer (e.g. Class_method(Null)) - give a PHP Error instead. 06/15/2006: mutandiz [allegrocl] Add initial support for std::list container class. Fix a few bugs in helper functions. 05/13/2006: wsfulton [Java] Replace JNIEXPORT with SWIGEXPORT, thereby enabling the possibility of using gcc -fvisibility=hidden for potentially smaller faster loading wrappers. 05/13/2006: wsfulton Fix for Makefiles for autoconf-2.60 beta 05/13/2006: wsfulton Vladimir Menshakov patch for compiling wrappers with python-2.5 alpha. 05/12/2006: wsfulton Fix buffer overflow error when using large %feature(docstring) reported by Joseph Winston. 05/12/2006: wsfulton [Perl] Operator overload fix from Daniel Moore. 05/25/2006: mutandiz [allegrocl] Fix bug in generation of CLOS type declarations for unions and equivalent types. 05/24/2006: mutandiz [allegrocl] Don't require a full class definition to generate a CLOS wrapper. 05/20/2006: olly [php] GCC Visibility support now works with PHP. 05/19/2006: olly [php] Removed support for -dlname (use -module instead). Fixed naming of PHP extension module to be consistent with PHP conventions (no "php_" prefix on Unix; on PHP >= 4.3.0, handle Unix platforms which use something other than ".so" as the extension.) 05/13/2006: wsfulton [C#] Director support added 05/07/2006: olly [php] Don't segfault if PHP Null is passed where a C++ reference is wanted. 05/05/2006: olly [php] Fix wrappers generated for global 'char' variables to not include a terminating zero byte in the PHP string. 05/03/2006: wsfulton Modify typemaps so that char * can be applied to unsigned char * or signed char * types and visa versa. 05/03/2006: efuzzyone [cffi]Thanks to Luke J Crook for this idea. - a struct/enum/union is replaced with :pointer only if that slot is actually a pointer to that type. So,: struct a_struct { int x; } and struct b_struct { a_struct struct_1; }; will be converted as: (cffi:defcstruct b_struct (struct_1 a_struct)) - Other minor fixes in lispifying names. 05/02/2006: wsfulton Fix possible redefinition of _CRT_SECURE_NO_DEPRECATE for VC++. 04/14/2006: efuzzyone [cffi] Thanks to Thomas Weidner for the patch. - when feature export is set (export 'foo) is generated for every symbol - when feature inline is set (declaim (inline foo)) is generated before every function definition - when feature intern_function is set #.(value-of-intern-function "name" "nodeType" package) is emitted instead of the plain symbol. A sample swig-lispify is provided. - every symbol is prefixed by it's package. 04/13/2006: efuzzyone [cffi] Fixed the generation of wrappers for global variables. Added the option [no]swig-lisp which turns on/off generation of code for swig helper lisp macro, functions, etc. Version 1.3.29 (March 21, 2006) =============================== 04/05/2006: mutandiz [allegrocl] Fix output typemap of char so it produces a character instead of an integer. Also adds input/output typemaps for 'char *'. add command-line argument -isolate to generate an interface file that won't interfere with other SWIG generated files that may be used in the same application. 03/20/2005: mutandiz [allegrocl] More tweaks to INPUT/OUTPUT typemaps for bool. Fix constantWrapper for char and string literals. find-definition keybindings should work in ELI/SLIME. Output (in-package ) to lisp wrapper instead of (in-package #.*swig-module-name*). slight rework of multiple return values. doc updates. 03/17/2005: mutandiz [allegrocl] mangle names of constants generated via constantWrapper. When using OUTPUT typemaps and the function has a non-void return value, it should be first in the values-list, followed by the OUTPUT mapped values. Fix bug with boolean parameters, which needed to be passed in as int values, rather than T or NIL. 03/15/2006: mutandiz [allegrocl] Generate wrappers for constants when in C++ or -cwrap mode. Make -cwrap the default, since it is most correct. Users can use the -nocwrap option to avoid the creation of a .cxx file when interfacing to C code. When in -nocwrap mode, improve the handling of converting infix literals to prefix notation for lisp. This is very basic and not likely to be improved upon since this only applies to the -nocwrap case. Literals we can't figure out will result in a warning and be included in the generated code. validIdentifier now more closely approximates what may be a legal common lisp symbol. Fix typemap error in allegrocl.swg 03/12/2006: mutandiz [allegrocl] fix up INPUT/OUTPUT typemaps for bool. Generate c++ style wrapper functions for struct/union members when -cwrap option specified. 03/10/2006: mutandiz [allegrocl] Fix bug in C wrapper generation introduced by last allegrocl commit. 03/10/2006: wsfulton [Java] Commit #1447337 - Delete LocalRefs at the end of director methods to fix potential leak 03/10/2006: wsfulton Fix #1444949 - configure does not honor --program-prefix. Removed non-standard configure option --with-release-suffix. Fix the autoconf standard options --program-prefix and --program-suffix which were being shown in the help, but were being ignored. Use --program-suffix instead of --with-release-suffix now. 03/10/2006: wsfulton [Java] Fix #1446319 with patch from andreasth - more than one wstring parameter in director methods 03/07/2006: mkoeppe [Guile] Fix for module names containing a "-" in non-"shadow" mode. Patch from Aaron VanDevender (#1441474). 03/04/2006: mmatus - Add -O to the main program, which now enables -fastdispatch [Python] - Add the -fastinit option to enable faster __init__ methods. Setting 'this' as 'self.this.append(this)' in the python code confuses PyLucene. Now the initialization is done in the the C++ side, as reported by Andi and Robin. - Add the -fastquery option to enable faster SWIG_TypeQuery via a python dict cache, as proposed by Andi Vajda - Avoid to call PyObject_GetAttr inside SWIG_Python_GetSwigThis, since this confuses PyLucene, as reported by Andi Vajda. 03/02/2006: wsfulton [Java] Removed extra (void *) cast when casting pointers to and from jlong as this was suppressing gcc's "dereferencing type-punned pointer will break strict-aliasing rules" warning. This warning could be ignored in versions of gcc prior to 4.0, but now the warning is useful as gcc -O2 and higher optimisation levels includes -fstrict-aliasing which generates code that doesn't work with these casts. The assignment is simply never made. Please use -fno-strict-aliasing to both suppress the warning and fix the bad assembly code generated. Note that the warning is only generated by the C compiler, but not the C++ compiler, yet the C++ compiler will also generate broken code. Alternatively use -Wno-strict-aliasing to suppress the warning for gcc-3.x. The typemaps affected are the "in" and "out" typemaps in java.swg and arrays_java.swg. Users ought to fix their own typemaps to do the same. Note that removal of the void * cast simply prevents suppression of the warning for the C compiler and nothing else. Typical change: From: %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)(void *)&$input; %} To: %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %} From: %typemap(out) SWIGTYPE * %{ *($&1_ltype)(void *)&$result = $1; %} To: %typemap(out) SWIGTYPE * %{ *($&1_ltype)&$result = $1; %} 03/02/2006: mkoeppe [Guile -scm] Add typemaps for "long long"; whether the generated code compiles, however, depends on the version and configuration of Guile. 03/02/2006: wsfulton [C#] Add support for inner exceptions. If any of the delegates are called which construct a pending exception and there is already a pending exception, it will create the new exception with the pending exception as an inner exception. 03/02/2006: wsfulton [Php] Added support for Php5 exceptions if compiling against Php5 (patch from Olly Betts). 03/01/2006: mmatus Use the GCC visibility attribute in SWIGEXPORT. Now you can compile (with gcc 3.4 or later) using CFLAGS="-fvisibility=hidden". Check the difference for the 'std_containers.i' python test case: Sizes: 3305432 _std_containers.so 2383992 _std_containers.so.hidden Exported symbols (nm -D .so | wc -l): 6146 _std_containers.so 174 _std_containers.so.hidden Execution times: real 0m0.050s user 0m0.039s sys 0m0.005s _std_containers.so real 0m0.039s user 0m0.026s sys 0m0.007s _std_containers.so.hidden Read http://gcc.gnu.org/wiki/Visibility for more details. 02/27/2006: mutandiz [allegrocl] Add support for INPUT, OUTPUT, and INOUT typemaps. For OUTPUT variables, the lisp wrapper returns multiple values. 02/26/2006: mmatus [Ruby] add argcargv.i library file. Use it as follow: %include argcargv.i %apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) } %inline { int mainApp(size_t argc, const char **argv) { return argc; } } then in the ruby side: args = ["asdf", "asdf2"] n = mainApp(args); This is the similar to the python version Lib/python/argcargv.i 02/24/2006: mgossage Small update Lua documents on troubleshooting problems 02/22/2006: mmatus Fix all the errors reported for 1.3.28. - fix bug #1158178 - fix bug #1060789 - fix bug #1263457 - fix 'const char*&' typemap in the UTL, reported by Geoff Hutchison - fixes for python 2.1 and the runtime library - fix copyctor + template bug #1432125 - fix [ 1432152 ] %rename friend operators in namespace - fix gcc warning reported by R. Bernstein - avoid assert when finding a recursive scope inheritance, emit a warning in the worst case, reported by Nitro - fix premature object deletion reported by Paul in tcl3d - fix warning reported by Nitro in VC7 - more fixes for old Solaris compiler - fix for python 2.3 and gc_refs issue reported by Luigi - fix fastproxy for methods using kwargs - fix overload + protected member issue reported by Colin McDonald - fix seterrormsg as reported by Colin McDonald - fix directors, now the test-suite runs again using -directors - fix for friend operator and Visual studio and bug 1432152 - fix bug #1435090 - fix using + %extend as reported by William - fix bug #1094964 - fix for Py_NotImplemented as reported by Olly and Amaury - fix nested namespace issue reported by Charlie and also: - allow director protected members by default - delete extra new lines in swigmacros[UTL] - cosmetic for generated python code - add the factory.i library for UTL - add swigregister proxy method and move __repr__ to a single global module [python] 02/22/2006: mmatus When using directors, now swig will emit all the virtual protected methods by default. In previous releases, you needed to use the 'dirprot' option to achieve the same. If you want, you can disable the new default behaviour, use the 'nodirprot' option: swig -nodirprot ... and/or the %nodirector feature for specific methods, i.e.: %nodirector Foo::bar; struct Foo { virtual ~Foo(); protected: virtual void bar(); }; As before, pure abstract protected members are allways emitted, independent of the 'dirprot/nodirprot' options. 02/22/2006: mmatus Add the factory.i library for languages using the UTL (python,tcl,ruby,perl). factory.i implements a more natural wrap for factory methods. For example, if you have: ---- geometry.h -------- struct Geometry { enum GeomType{ POINT, CIRCLE }; virtual ~Geometry() {} virtual int draw() = 0; // // Factory method for all the Geometry objects // static Geometry *create(GeomType i); }; struct Point : Geometry { int draw() { return 1; } double width() { return 1.0; } }; struct Circle : Geometry { int draw() { return 2; } double radius() { return 1.5; } }; // // Factory method for all the Geometry objects // Geometry *Geometry::create(GeomType type) { switch (type) { case POINT: return new Point(); case CIRCLE: return new Circle(); default: return 0; } } ---- geometry.h -------- You can use the %factory with the Geometry::create method as follows: %newobject Geometry::create; %factory(Geometry *Geometry::create, Point, Circle); %include "geometry.h" and Geometry::create will return a 'Point' or 'Circle' instance instead of the plain 'Geometry' type. For example, in python: circle = Geometry.create(Geometry.CIRCLE) r = circle.radius() where 'circle' now is a Circle proxy instance. 02/17/2006: mkoeppe [MzScheme] Typemaps for all integral types now accept the full range of integral values, and they signal an error when a value outside the valid range is passed. [Guile] Typemaps for all integral types now signal an error when a value outside the valid range is passed. 02/13/2006: mgossage [Documents] updated the extending documents to give a skeleton swigging code with a few typemaps. [Lua] added an extra typemap for void* [in], so a function which requires a void* can take any kind of pointer Version 1.3.28 (February 12, 2006) ================================== 02/11/2006: mmatus Fix many issues with line counting and error reports. 02/11/2006: mmatus [Python] Better static data member support, if you have struct Foo { static int bar; }; then now is valid to access the static data member, ie: f = Foo() f.bar = 3 just as in C++. 02/11/2006: wsfulton [Perl] Fixed code generation to work again with old versions of Perl (5.004 and later tested) 02/04/2006: mmatus [Python] Add the %extend_smart_pointer() directive to extend SWIG smart pointer support in python. For example, if you have a smart pointer as: template class RCPtr { public: ... RCPtr(Type *p); Type * operator->() const; ... }; you use the %extend_smart_pointer directive as: %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; then, if you have something like: RCPtr make_ptr(); int foo(A *); you can do the following: a = make_ptr(); b = foo(a); ie, swig will accept a RCPtr object where a 'A *' is expected. Also, when using vectors %extend_smart_pointer(RCPtr); %template(RCPtr_A) RCPtr; %template(vector_A) std::vector >; you can type a = A(); v = vector_A(2) v[0] = a ie, an 'A *' object is accepted, via implicit conversion, where a RCPtr object is expected. Additionally x = v[0] returns (and sets 'x' as) a copy of v[0], making reference counting possible and consistent. %extend_smart_pointer is just a collections of new/old tricks, including %typemaps and the new %implicitconv directive. 02/02/2006: mgossage bugfix #1356577, changed double=>lua_number in a few places. added the std::pair wrapping 01/30/2006: wsfulton std::string and std::wstring member variables and global variables now use %naturalvar by default, meaning they will now be wrapped as expected in all languages. Previously these were wrapped as a pointer rather than a target language string. It is no longer necessary to add the following workaround to wrap these as strings: %apply const std::string & { std::string *} *** POTENTIAL INCOMPATIBILITY *** 01/28/2006: mkoeppe [Guile -scm] Add typemaps for handling of member function pointers. 01/24/2006: mmatus - Better support for the %naturalvar directive, now it works with the scripting languages as well as Java/C#. Now, it can also be applied to class types: %naturalvar std::string; %include that will tell swig to use the 'natural' wrapping mechanism to all std::string global and member variables. - Add support for the %allowexcept feature along the scripting languages, which allows the %exception feature to be applied to the variable access methods. Also, add the %exceptionvar directive to specify a distintic exception mechanism only for variables. - Add more docs for the %delobject directive to mark a method as a destructor, 'disowning' the first argument. For example: %newobject create_foo; %delobject destroy_foo; Foo *create_foo() { return new Foo(); } void destroy_foo(Foo *foo) { delete foo; } or in a member method as: %delobject Foo::destroy; class Foo { public: void destroy() { delete this;} private: ~Foo(); }; 01/24/2006: mgossage [Lua] - Removed the type swig_lua_command_info & replace with luaL_reg (which then broke the code), fixed this - added an additional cast in the typemaps for enum's due to the issue that VC.Net will not allow casting of a double to an enum directly. Therefore cast to int then to enum (thanks to Jason Rego for this observation) 01/16/2006: mmatus (Change disabled... will be back in CVS soon) Add initial support for regexp via the external library RxSpencer. SWIG doesn't require this library to compile and/or run. But if you specify --with-rxspencer, and the library is found during installation, then swig will use it in three places: - In %renames rules, via the new rxsmatch rules, for example: %rename("%(lowercase)",rxsmatch$name="GSL_.*") ""; %rename("%(lowercase)",rxsmatch$nodeType="enum GSL_.*") ""; rxsmatch is similar to the match rule, it just uses the RxSpencer regexp library to decide if there is a match with the provided regexp. As with the match rule, you can also use the negate rule notrxsmatch. - In the %rename target name via the rxstarget option, for example: %rename("%(lowercase)",rxstarget=1) "GSL_.*"; where the target name "GSL.*" is now understood as a regexp to be matched. - In the new encoder "rxspencer", which looks like: %(rxspencer:[regexp][replace])s where "regexp" is the regular expression and "replace" is a string used as a replacement, where the @0,@1,...,@9 pseudo arguments are used to represent the corresponding matching items in the reg expression. For example: %(rxspencer:[GSL.*][@0])s <- Hello -> %(rxspencer:[GSL.*][@0])s <- GSLHello -> GSLHello %(rxspencer:[GSL(.*)][@1])s <- GSLHello -> Hello %(rxspencer:[GSL(.*)][gsl@1])s <- GSLHello -> gslHello Another example could be: %rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][@1])s",%$isfunction) ""; which take out the prefix "GSL_" and returns all the function names in lower cases, as following: void GSL_Hello(); -> hello(); void GSL_Hi(); -> hi(); const int GSL_MAX; -> GSL_MAX; // no change, is not a function We use the RxSpencer as an initial test bed to implemention while we decide which library will be finally added to swig. You can obtain the RxSpencer library from http://arglist.com/regex (Unix) or http://gnuwin32.sourceforge.net/packages.html (Windows) Once installed, use "man rxspencer" to get more info about the regexp format, or just google rxspencer. Since now you can enable the rxsmatch rules (see above), the simple or '|' support for the match rules (01/12/2006: mmatus) is disabled. Still, if you have problems with the rxspencer library, you can re-enable the simple 'match or' support using -DSWIG_USE_SIMPLE_MATCHOR. 01/16/2006: mmatus Change the %rename predicates to use the prefix '%$', as in: %rename("%(utitle)s",%$isfunction,%$ismember) ""; to avoid clashes with other swig macros/directives. 01/14/2006: cfisavage [Ruby] Added support for Ruby bang! methods via a new %bang feature. Bang methods end in exclamation points and indicate that the object being processed will be modified in-place as opposed to being copied. 01/12/2006: cfisavage [Ruby] Updated the Ruby module to automatically convert method names to lower_case_with_underscores using the new %rename functionality. 01/12/2006: mmatus - Add aliases for 'case' encoders used with %rename/%namewarn %(uppercase)s hello_world -> HELLO_WORLD %(lowercase)s HelloWorld -> helloworld %(camelcase)s hello_world -> HelloWorld %(undercase)s HelloWorld -> hello_world 01/12/2006: mmatus - Add the -dump_parse_module and -dump_parse_top options, which are similar to -dump_module and -dump_top, but they dump the node trees just after parsing, showing only the attributes visible at the parsing stage, and not the added later in typemap.cxx, allocate.cxx, lang.cxx or elsewhere. Besides debugging porpuses, these options are very useful if you plan to use %rename in an "advance way", since it shows only and all the node's attributes you can use inside the match rules. 01/12/2006: mmatus - Add predicates to %rename, so, you don't need to remember, for example, how to match a member function. Now it is easy, for example to use the 'utitle' encoder in all the member methods, you type: %rename("%(utitle)s",%isfunction,%ismember) ""; or to ignore all the enumitems in a given class: %rename("$ignore", %isenumitem, %classname="MyClass") ""; Available predicates are (see swig.swg): %isenum %isenumitem %isaccess %isclass %isextend %isextend %isconstructor %isdestructor %isnamespace %istemplate %isconstant %isunion %isfunction %isvariable %isimmutable %isstatic %isfriend %istypedef %isvirtual %isexplicit %isextern %ismember %isglobal %innamespace %ispublic %isprotected %isprivate %classname These predicates correspond to specific 'match' declarations, which sometimes are not as evident as the predicates names. - Add the or '|' operation in %rename match, for example to capitalize all the constants (%constant or const cdecl): %rename("%(upper)s",match="cdecl|constant",%isimmutable) ""; 01/12/2006: mgossage - Partial fixed of errors under C89, bug #1356574 (converted C++ style comments to C style) - Added patches from neomantra@users.sf.net #1379988 and #1388343 missing a 'return' statement for error conditions also updated the %init block bug #1356586 01/10/2006: mmatus - Add the 'utitle' encoder, as an example of how to add your own encoder. I added the encoder method in misc.c but developers can add others, the same way, inside any target language. Well, 'utitle' is the reverse of 'ctitle', ie: %rename("%(ctitle)s") camel_case; -> CamelCase; %rename("%(utitle)s") CamelCase; -> camel_case; 01/10/2006: cfisavage [Ruby] Updated Ruby Exception handling. Classes that are specified in throws clauses, or are marked as %exceptionclass, are now inherited from rb_eRuntimeError. This allows instances of these classes to be returned to Ruby as exceptions. Thus if a C++ method throws an instance of MyException, the calling Ruby method will get back a MyException object. To see an example, look at ruby/examples/exception_class. 01/10/2006: mmatus - Add the %catches directive, which complements the %exception directive in a more automatic way. For example, if you have int foo() throw(E1); swig generates the proper try/catch code to dispatch E1. But if you have: int barfoo(int i) { if (i == 1) { throw E1(); } else { throw E2(); } return 0; } ie, where there is no explicit exception specification in the decl, you end up doing: %exception barfoo { try { $action } catch(E1) { ... } } catch(E2) { ... } } which is very tedious. Well, the %catches directive defines the list of exceptions to catch, and from swig: %catches(E1,E2) barfoo(int i); int barfoo(int i); is equivalent to int barfoo(int i) throw(E1,E2); Note, however, that the %catches list doesn't have to correspond to the C++ exception specification. For example, if you have: struct E {}; struct E1 : E {}; struct E2 : E {}; int barfoo(int i) throw(E1,E2); you can define %catches(E) barfoo(int i); and swig will generate an action code equivalent to try { $action } catch(E &_e) { ; } Of course, you still have to satisfy the C++ restrictions, and the catches list must be compatible (not the same) as the original list of types in the exception specification. Also, you can now specify that you want to catch the unknown exception '...', for example: %catches(E1,E2,...) barfoo(int); In any case, the %catches directive will emit the code to convert into the target language error/exception using the 'throws' typemap. For the '...' case to work, you need to write the proper typemap in your target language. In the UTL, this looks like: %typemap(throws) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } 01/09/2006: mutandiz [Allegrocl] Fixes a number of SEGVs primarily in the handling of various anonymous types. Found in a pass through the swig test-suite. Still more to do here, but this is a good checkpoint. Adds -cwrap and -nocwrap as an allegrocl specific command-line argument. Controls generating of a C wrapper file when wrapping C code. By default only a lisp file is created for C code wrapping. Doc updates for the command-line arguments and fixes as pointed out on swig-devel 01/05/2006: wsfulton [Java] Fix unsigned long long and const unsigned long long & typemaps - Bug #1398394 with patch from Dries Decock 01/06/2006: mmatus Add 'named' warning codes, now in addition to: %warnfilter(813); you can use %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE); just use the same code name found in Source/Include/swigwarn.h plus the 'SWIG' prefix. If a developer adds a new warning code, the Lib/swigwarn.swg file will be generated when running the top level make. 01/05/2006: cfisavage [Ruby] Reimplemented object tracking for Ruby. The new implementation works by expanding the swig_class structure for Ruby by adding a trackObjects field. This field can be set/unset via %trackobjects as explained in the Ruby documentation. The new implementation is more robust and takes less code to implement. 01/05/2006: wsfulton Fix for %extend and static const integral types, eg: class Foo { public: %extend { static const int bar = 42; } }; 12/30/2005: mmatus - Add info for old and new debug options: -dump_top - Print information of the entire node tree, including system nodes -dump_module - Print information of the module node tree, avoiding system nodes -dump_classes - Print information about the classes found in the interface -dump_typedef - Print information about the types and typedefs found in the interface -dump_tags - Print information about the tags found in the interface -debug_typemap - Print information for debugging typemaps -debug_template - Print information for debugging templates - Add the fakeversion. If you have a project that uses configure/setup.py, or another automatic building system and requires a specific swig version, let say 1.3.22 you can use: SWIG_FEATURES="-fakeversion 1.3.22" or swig -fakeversion 1.3.22 and then swig -version will report 1.3.22 instead of the current version. Typical use would be SWIG_FEATURES="-fakeversion 1.3.22" ./configure 12/30/2005: mmatus - Add option/format support to %rename and %namewarn. Now %namewarn can force renaming, for example: %namewarn("314: import is a keyword",rename="_%s") "import"; and rename can also support format forms: %rename("swig_%s") import; Now, since the format is processed via swig Printf, you can use encoders as follows: %rename("%(title)s") import; -> Import %rename("%(upper)s") import; -> IMPORT %rename("%(lower)s") Import; -> import %rename("%(ctitle)s") camel_case; -> CamelCase This will allow us to add more encoders, as the expected one for regular expressions. - Add the above 'ctitle' encoder, which does the camel case: camel_case -> CamelCase - Also, while we get the regexp support, add the 'command' encoder, you can use it as follows %rename("%(command:sed -e 's/\([a-z]\)/\U\\1/' <<< )s") import; then swig will popen the command "sed -e 's/\([a-z]\)/\U\\1/' <<< import" see below for anonymous renames for better examples. - The rename directive now also allows: - simple match: only apply the rename if a type match happen, for example %rename(%(title)s,match="enumitem") hello; enum Hello { hi, hello -> hi, Hello }; int hello() -> hello; - extended match: only apply the rename if the 'extended attribute' match occurred, for example: // same as simple match %rename(%(title)s,match$nodeType="enumitem") hello; enum Hello { hi, hello -> hi, Hello }; Note that the symbol '$' is used to define the attribute name in a 'recursive' way, for example: // match only hello in 'enum Hello' %rename(%(title)s,match$parentNode$type="enum Hello") hello; enum Hello { hi, hello -> hi, Hello // match }; enum Hi { hi, hello -> hi, hello // no match }; here, for Hello::hi, the "parentNode" is "Hello", and its "type" is "enum Hello". - Anonymous renames: you can use 'anonymous' rename directives, for example: // rename all the enum items in Hello %rename(%(title)s,match$parentNode$type="enum Hello") ""; enum Hello { hi, hello -> Hi, Hello // match both }; enum Hi { hi, hello -> hi, hello // no match }; // rename all the enum items %rename(%(title)s,match$nodeType="enumitem") ""; // rename all the items in given command (sloooow, but...) %rename(%(command:)s) ""; Anonymous renames with commands can be very powerful, since you can 'outsource' all the renaming mechanism (or part of it) to an external program: // Uppercase all (and only) the names that start with 'i' %rename("%(command:awk '/^i/{print toupper($1)}' <<<)s") ""; int imported() -> IMPORTED; int hello() -> hello Note that if the 'command' encoder returns an empty string, swig understands that no rename is necessary. Also note that %rename 'passes' the matched name. For example, in this case namespace ns1 { int foo(); } namespace ns2 { int bar(); } the external program only receives "foo" and "bar". If needed, however, you can request the 'fullname' %rename("%(command:awk 'awk '/ns1::/{l=split($1,a,"::"); print toupper(a[l])}'' <<<)s",fullname=1) ""; ns1::foo -> FOO ns2::bar -> bar - Mixing encoders and matching: of course, you can do mix commands and match fields, for example: %rename("%()",match="cdecl") ""; %rename("%()",match="enumitem") ""; %rename("%()",match="enumitem", match$parentNode$parentNode$nodeType="class") ""; Use "swig -dump_parse_module" to see the attribute names you can use to match a specific case. - 'sourcefmt' and 'targetfmt': sometimes you need to process the 'source' name before comparing, for example %namewarn("314: empty is a keyword",sourcefmt="%(lower)s") "empty"; then if you have int Empty(); // "Empty" is the source you will get the keyword warning since 'Empty' will be lower cased, via the sourcefmt="%(lower)s" option, before been compared to the 'target' "empty". There is an additional 'targetfmt' option to process the 'target' before comparing. - complementing 'match': you can use 'notmatch', for example %namewarn("314: empty is a keyword",sourcefmt="%(lower)s",notmatch="namespace") "empty"; here, the name warning will be applied to all the symbols except namespaces. 12/30/2005: mmatus - Add initial support for gcj and Java -> mechanism. See examples in: Examples/python/java Examples/ruby/java Examples/tcl/java to see how to use gcj+swig to export java classes into python/ruby/tcl. The idea is to put all the common code for gcj inside Lib/gcj and localize specific types such as jstring, as can be found in Lib/python/jstring.i Lib/ruby/jstring.i Lib/tcl/jstring.i Using the UTL, this is very easy, and the perl version for jstring.i will be next. 12/29/2005: mmatus - Add the copyctor feature/directive/option to enable the automatic generation of copy constructors. Use as in: %copyctor A; struct A { }; then this will work a1 = A(); a2 = A(a1); Also, since it is a feature, if you just type %copyctor; that will enable the automatic generation for all the classes. It is also equivalent to swig -copyctor -c++ ... Notes: 1.- The feature only works in C++ mode. 2.- The automatic creation of the copy constructor will usually produce overloading. Hence, if the target language doesn't support overloading, a special name will be used (A_copy). 3.- For the overloading reasons above, it is probably not a good idea to use the flag when, for example, you are using keywords in Python. 4.- The copyctor automatic mechanism follows more or less the same rules as the default constructor mechanism, i.e., a copy constructor will not be added if the class is abstract or if there is a pertinent non-public copy ctor in the class or its hierarchy. Hence, it might be necessary for you to complete the class declaration with the proper non-public copy ctor to avoid a wrong constructor addition. - Fix features/rename for templates ctor/dtor and other things around while adding the copyctor mechanism. 12/27/2005: mmatus - Add the 'match' option to typemaps. Assume you have: %typemap(in) SWIGTYPE * (int res) {..} %typemap(freearg) SWIGTYPE * { if (res$argnum) ...} then if you do %typemap(in) A * {...} swig will 'overload the 'in' typemap, but the 'freearg' typemap will be also applied, even when this is wrong. The old solutions is to write: %typemap(in) A * {...} %typemap(freeag) A * ""; overload 'freearg' with an empty definition. The problem is, however, there is no way to know you need to do that until you start getting broken C++ code, or worse, broken runtime code. The same applies to the infamous 'typecheck' typemap, which always confuses people, since the first thing you do is to just write the 'in' typemap. The 'match' option solves the problem, and if instead you write: %typemap(in) SWIGTYPE * (int res) {..} %typemap(freearg,match="in") SWIGTYPE * { if (res$argnum) ...} %typemap(typecheck,match="in",precedence...) SWIGTYPE * {...} it will tell swig to apply the 'freearg/typecheck' typemaps only if they 'match' the type of the 'in' typemap. The same can be done with other typemaps as: %typemap(directorout) SWIGTYPE * {...} %typemap(directorfree,match="directorout") SWIGTYPE * {...} 12/27/2005: mmatus - Add the 'naturalvar' option/mode/feature to treat member variables in a more natural way, ie, similar to the global variable behavior. You can use it in a global way via the command line swig -naturalvar ... or the module mode option %module(naturalvar=1) both forms make swig treat all the member variables in the same way it treats global variables. Also, you can use it in a case by case approach for specific member variables using the directive form: %naturalvar Bar::s; Then, in the following case for example: std::string s; struct Bar { std::string s; }; you can do: b = Bar() b.s ="hello" cvar.s = "hello" if (b.s != cvar.s): raise RuntimeError This is valid for all the languages, and the implementation is based on forcing the use of the const SWIGTYPE& (C++)/SWIGTYPE (C) typemaps for the get/set methods instead of the SWIGTYPE * typemaps. Hence, for 'naturalvar' to work, each target language must implement 'typemap(in/out) const Type&' properly. The 'naturalvar' option replaces or makes workarounds such as: %apply const std::string & { std::string *} unnecessary. Note1: If your interface has other kinds of workarounds to deal with the old 'unnatural' way to deal with member variables (returning/expecting pointers), the 'naturalvar' option could break them. Note2: the option has no effect on unnamed types, such as unnamed nested unions. 12/27/2005: mmatus - Add more 'expressive' result states for the typemap libraries. In the past, for scripting languages, you would do checking something like: if (ConvertPtr(obj,&vptr,ty,flags) != -1) { // success } else { // error } Now the result state can carry more information, including: - Error state: like the old -1/0, but with error codes from swigerrors.swg. int res = ConvertPtr(obj,&vptr,ty,flags); if (SWIG_IsOK(res)) { // success code } else { SWIG_Error(res); // res carries the error code } - Cast rank: when returning a simple successful conversion, you just return SWIG_OK, but if you need to do a 'cast', you can add the casting rank, ie: if (PyFloat_Check(obj)) { value = PyFloat_AsDouble(obj); return SWIG_OK; } else if (PyInt_Check(obj)) { value = (double) PyInt_AsLong(obj); return SWIG_AddCast(SWIG_OK); } later, the casting rank is used to properly dispatch the overloaded function, for example. This of course requires your language to support and use the new dispatch cast/rank mechanism (Now mainly supported in perl and python, and easily expandable to ruby and tcl). - [UTL] Add support for the new 'expressive' result states. 12/27/2005: mmatus - Add support for the C++ implicit conversion mechanism, which required some modifications in parser.y (to recognize 'explicit') and overload.cxx (to replace $implicitconv as needed). Still, real support in each target language requires each target language to be modified. Python provides an example, see below. - Add support for native C++ implicit conversions, ie, if you have %implicitconv A; struct A { int ii; A() {ii = 1;} A(int) {ii = 2;} A(double) {ii = 3;} explicit A(char *s) {ii = 4;} }; int get(const A& a) {return a.ii;} you can call: a = A() ai = A(1) ad = A(1.0) as = A("hello") # old forms get(a) -> 1 get(ai) -> 2 get(ad) -> 3 get(as) -> 4 #implicit conversions get(1) -> 2 get(1.0) -> 3 get("hello") -> Error, explicit constructor Also, as in C++, now implicit conversions are supported in variable assigments, and if you have: A ga; struct Bar { A a; }; you can do: cvar.ga = A(1) cvar.ga = 1 cvar.ga = 1.0 cvar.ga = A("hello") cvar.ga = "hello" -> error, explicit constructor b = Bar() b.a = A("hello") b.a = 1 b.a = 1.0 b.a = "hello" -> error, explicit constructor Note that the last case, assigning a member var directly, also requires the 'naturalvar' option. This support now makes the old '%implicit' macro, which was found in 'implicit.i' and it was fragile in many ways, obsolete, and you should use the new '%implicitconv' directive instead. Note that we follow the C++ conventions, ie, in the following the implicit conversion is allowed: int get(A a) {return a.ii;} int get(const A& a) {return a.ii;} but not in these cases: int get(A *a) {return a->ii;} int get(A& a) {return a.ii;} Also, it works for director methods that return a by value result, ie, the following will work: virtual A get_a() = 0; def get_a(self): return 1 but not in this case: virtual const A& get_a() = 0; virtual A& get_a() = 0; virtual A* get_a() = 0; Notes: - the implicitconv mechanism is implemented by directly calling/dispatching the python constructor, triggering a call to the __init__method. Hence, if you expanded the __init__ method, like in: class A: def __init__(self,args): then 'my code' will also be executed. - Since the %implicitconv directive is a SWIG feature, if you type: %implicitconv; that will enable implicit conversion for all the classes in your module. But if you are worried about performance, maybe that will be too much, especially if you have overloaded methods, since to resolve the dispatching problem, python will efectively try to call all the implicit constructors as needed. - For the same reason, it is highly recommended that you use the new 'castmode' when mixing implicit conversion and overloading. - [python] The %implicit directive is declared obsolete, and you should use %implicitconv instead. If you include the implicit.i file, a warning will remind you of this. Note: Since %implicit is fragile, just replacing it by %implicitconv could lead to different behavior. Hence, we don't automatically switch from to the other, and the user must migrate to the new %implicitconv directive manually. 12/26/2005: wsfulton [C#] Modify std::vector wrappers to use std::vector::value_type as this is closer to the real STL declarations for some methods, eg for push_back(). Fixes some compilation errors for some compilers eg when the templated type is a pointer. [Java] std::vector improvements - a few more methods are wrapped and specializations are no longer required. The specialize_std_vector macro is no longer needed (a warning is issued if an attempt is made to use it). 12/26/2005: wsfulton [Java, C#] Add in pointer reference typemaps. This also enables one to easily wrap std::vector where T is a pointer. 12/24/2005: efuzzyone [CFFI] The cffi module for SWIG: - Fully supports C, but provides limited supports for C++, in particular C++ support for templates and overloading needs to be worked upon. 12/23/2005: mmatus [python] Add the castmode that allows the python type casting to occur. For example, if you have 'int foo(int)', now class Ai(): def __init__(self,x): self.x = x def __int__(self): return self.x foo(1) // Ok foo(1.0) // Ok foo(1.3) // Error a = Ai(4) foo(ai) // Ok The castmode, which can be enabled either with the '-castmode' option or the %module("castmode") option, uses the new cast/rank dispatch mechanism. Hence, now if you have 'int foo(int); int foo(double);', the following works as expected: foo(1) -> foo(int) foo(1.0) -> foo(double) ai = Ai(4) foo(ai) -> foo(int) Note1: the 'castmode' could disrupt some specialized typemaps. In particular, the "implicit.i" library seems to have problem with the castmode. But besides that one, the entire test-suite compiles fine with and without the castmode. Note2: the cast mode can't be combined with the fast dispatch mode, ie, the -fastdispatch option has no effect when the cast mode is selected. The penalties, however, are minimum since the cast dispatch code is already based on the same fast dispatch mechanism. See the file overload_dispatch_cast_runme.py file for new cases and examples. 12/22/2005: mmatus Add the cast and rank mechanism to dispatch overloading functions. The UTF supports it now, but for each language it must be decided how to implement and/or when to use it. [perl] Now perl uses the new cast and rank dispatch mechanism, which solves all the past problems known in perl, such as the old '+ 1' problem: int foo(int); $n = 1 $n = $n + 1 $r = foo(n) also works: foo(1); foo("1"); foo(1.0); foo("1.0"); but fails foo("l"); and when overloading foo(int) and foo(double); foo(1) -> foo(int) foo(1.0) -> foo(double) foo("1") -> foo(int) foo("1.0") -> foo(double) foo("l") -> error foo($n) -> foo(int) for good perl versions foo($n) -> foo(double) for old bad perl versions when overloading foo(int), foo(char*) and foo(double): foo(1) -> foo(int) foo(1.0) -> foo(double) foo("1") -> foo(char*) foo("1.0") -> foo(char*) foo("l") -> foo(char*) Note: In perl the old dispatch mechanism was broken, so, we don't provide an option to enable the old one since, again, it was really really broken. See 'overload_simple_runme.pl' for more cases and tests. PS: all the old known issues are declared resolved, any new "problem" that could be discovered is declared, a priori, as "features" of the new dispatch mechanism (until we find another solution at least). *** POTENTIAL INCOMPATIBILITY *** As with the introduction of the UTF, some things could now start to work as expected, and people used to deal or workaround previous bugs related to the dispatch mechanism, could see now a difference in perl behavior. 12/21/2005: mmatus - The '-nodefault' flag (pragma and feature) now generates a warning, and recommends to use the explicit -nodefaultctor and -nodefaultdtor options. The reason to split the 'nodefault' behavior is that, in general, ignoring the default destructor generates memory leaks in the target language. Hence, is too risky just to disable both the default constructor and destructor at the same time. If you need to disable the default destructor, it is also recommended you use the directive form: %nodefaultdtor MyVerySpecialClass; for specific classes, and always avoid using the global -nodefault and -nodefaultdtor options. 12/21/2005: wsfulton [Java, C#] Fix incorrect code generation when the intermediary classname is changed in the module directive from its default. For example: %module(jniclassname="myimclassnewname") "mymodule" // Java %module(imclassname="myimclassnewname") "mymodule" // C# Add in new special variable $imclassname. See docs. 12/17/2005: mmatus [Python] - Add the -aliasobj0/-noaliasobj0 options to use with -fastunpack and/or -O and old typemaps that use 'obj0' directly. So, if you compile your code using -O and get errors about the undeclared 'obj0' variable, run again using swig -O -aliasobj0 -python .... For new typemaps, never use 'obj0' directly, if needed, use the '$self' name that will be properly expanded to 'obj0' (nofastunpack) or 'swig_obj[0]' (fastunpack). If you have no idea what I am talking about, better, that means you have no typemap with this problem. 12/14/2005: mmatus [Python] - Add the -fastunpack/-nofastunpack options to enable/disable the use of the internal UnpackTuple method, instead of calling the one from the python C API. The option -O now also implies -fastunpack. 12/11/2005: mmatus [Python] - Add the -proxydel/-noproxydel options to enable/disable the generation of proxy/shadow __del__ methods, even when now they are redundant, since they are empty. However, old interfaces could rely on calling them. The default behavior is to generate the __del__ methods as in 1.3.27 or older swig versions. The option -O now also implies -noproxydel. 12/10/2005: mmatus [UTF] - Fix unneccessary calls to SWIG_TypeQuery for 'char *' and 'wchar_t *', problem found by Clay Culver while profiling the PyOgre project. [Python] - Add the -dirvtable/-nodirvtable to enable/disable a pseudo virtual table used for directors, avoiding the need to resolve the python method at each call. - Add the -safecstrings/-nosafecstrings options to enable/disable the use of safe conversions from PyString to char *. Python requires you to never change the internal buffer directly, and hence 'safectrings' warranties that but returning a copy of the internal python string buffer. The default, as in previous releases, is to return a pointer to the buffer (nosafecstrings), so, it is the user's responsibility to avoid its modification. - Add the -O option to enable all the optimization options at once, initially equivalent to -modern -fastdispatch -dirvtable -nosafecstrings -fvirtual 12/08/2005: mmatus - Add the -fastdispatch option (fastdispatch feature). This enables the "fast dispatch" mechanism for overloaded methods provided by Salvador Fandi~no Garc'ia (#930586). The resulting code is smaller and faster since less type checking is performed. However, the error messages you get when the overloading is not resolved could be different from what the traditional method returns. With the old method you always get an error such as "No matching function for overloaded ..." with the new method you can also get errors such as "Type error in argument 1 of type ..." See bug report #930586 for more details. So, this optimization must be explicitly enabled by users. The new mechanism can be used as: swig -fastdispatch or using the feature form %feature("fastdispatch") method; or %fastdispatch method; 12/06/2005: mmatus - Several memory and speed improvements, specially for templates. Now swig is up to 20 faster than before for large template interfaces, such as the std_containers.i and template_matrix.i files in the python test-suite. Memory footprint is also reduced in consideration of small pcs/architectures. - add commandline options -cpperraswarn and -nocpperraswarn" to force the swig preprocessor to treat the #error directive as a #warning. the pragmas #pragma SWIG cpperraswarn=1 #pragma SWIG cpperraswarn=0 are equivalent to the command line options, respectively. 12/06/2005: mmatus [Python] The generated code is now more portable, especially for Windows. Following http://www.python.org/doc/faq/windows.html Py_None is never accessed as a structure, plus other tricks mentioned there. 12/06/2005: mmatus [Python] Added initial support for threads based in the proposal by Joseph Winston. The user interface is as follows: 1.- the module thread support is enable via the "threads" module option, i.e. %module("threads"=1) 2.- Equivalent to that, is the new '-threads' swig option swig -threads -python ... 3.- You can partially disable thread support for a given method using: %feature("nothread") method; or %nothread method; also, you can disable sections of the thread support, for example %feature("nothreadblock") method; or %nothreadblock method; %feature("nothreadallow") method; or %nothreadallow method; the first disables the C++/python thread protection, and the second disables the python/C++ thread protection. 4.- The current thread support is based in the PyGIL extension present in python version 2.3 or later, but you can provide the thread code for older versions by defining the macros in pythreads.swg. If you get a working implementation for older versions, please send us a patch. For the curious about performance, here are some numbers for the profiletest.i test, which is used to check the speed of the wrapped code: nothread 9.6s (no thread code) nothreadblock 12.2s (only 'allow' code) nothreadallow 13.6s (only 'block' code) full thread 15.5s ('allow' + 'block' code) i.e., full thread code decreases the wrapping performance by around 60%. If that is important to your application, you can tune each method using the different 'nothread', 'nothreadblock' or 'nothreadallow' features as needed. Note that for some methods deactivating the 'thread block' or 'thread allow' code is not an option, so, be careful. 11/26/2005: wsfulton SWIG library files use system angle brackets everywhere for %include, eg %include "std_common.i" becomes %include 11/26/2005: wsfulton [Java, C#] Typesafe enums and proper enums have an extra constructor so that enum item values that are initialised by another enum item value can be wrapped without having to use %javaconstvalue/ %csconstvalue for when using %javaconst(1)/%csconst(1). Suggestion by Bob Marinier/Douglas Pearson. For example: typedef enum { xyz, last = xyz } repeat; 11/21/2005: mmatus [ruby + python] Fixes for directors + pointers. This is an ugly problem without an easy solution. Before we identified this case as problematic: virtual const MyClass& my_method(); but it turns out that all the cases where a pointer, array or reference is returned, are problematic, even for primitive types (as int, double, char*, etc). To try to fix the issue, a new typemap was added, 'directorfree', which is used to 'free' the resources allocated during the 'directorout' phase. At the same time, a primitive garbage collector engine was added to deal with orphaned addresses, when needed. The situation is much better now, but still it is possible to have memory exhaustation if recursion is used. So, still you need to avoid returning pointers, arrays or references when using director methods. - Added stdint.i - typemaps for latest C99 integral types found in stdint.h. 11/14/2005: wsfulton More types added to windows.i, eg UINT8, WORD, BYTE etc. Including windows.i will also enable SWIG to parse the __declspec Microsoft extension, eg __declspec(dllimport). Also other Windows calling conventions such as __stdcall. 11/10/2005: wsfulton New library file for Windows - windows.i. This file will contain useful type information for users who include windows.h. Initial support is for the non ISO integral types: __int8, __int16, __int32, __int64 and unsigned versions. The unsigned versions previously could not be parsed by SWIG. SF #872013. 11/09/2005: wsfulton [Java, C#] Portability warning for files which will overwrite each other on case insensitive file systems such as FAT32/NTFS. This will occur, for example, when two class names are the same barring case. The warning is issued on all platforms and can be suppressed with the usual warning suppression techniques. SF bug #1084507. 11/09/2005: wsfulton ./configure --with-python --with-ruby --with-perl5 etc enable these languages, ie the --with-xxxx options, where no path is specified, work the same as if the option was not specified at all. Based on patches #1335042 #1329048 #1329047. 11/09/2005: dancy [Allegrocl] Add C++ support to the Allegrocl module. Further enhances the C support as well. Some of the features: - MUCH better generation of foreign types based on the C/C++ types for use in defining the FFI on the lisp side. We don't pass everything as a (* :void) any longer. - Uses typemaps for better control of type conversions and code generation in the generated lisp and c++ wrapper code. - CLOS wrapping of pointers returned from foreign space makes it easier to differentiate pointers in user code. The wrapping objects can be passed directly to FF calls. - Defun wrapping of FF calls, allowing for more lispy interface. Conversion, GCing, of lisp objects to foreign objects can be done in the wrapping defun via the use of typemaps. - overload dispatching implemented on the lisp side using generic functions. - Templates and synonymous types supported. 11/07/2005: mmatus [Python] Adding proper support for multi-inheritance in the python side, ie, if you have two C++ wrapped class, Foo and Bar, now: class MyPythonClass(Foo,Bar): .... will properly work, even with directors, and the deallocation of Foo.this and Bar.this will follow correctly. Before, a class could only have one 'this' instance (unlike C++), only the last base class was properly deleted, or detected with directors. Now 'self.this' can be a list, which will contain the C++ instance pointers for all the base classes. Also, swig.this is responsible for deallocating the C++ instance(s), and the __del__ method is not emitted unless the user preppend/append some code to it. - Swig can now detect memory leaks, ie, if you still don't use proxy/shadow classes, and type something like import _example f = _example.new_Foo() and forget to call _example.delete_Foo(f), then swig will tell you that there is a memory leak. Otherwise, if you always use the proxy classes, you probably you will never ever see this warning unless there is something wrong inside the swig wrapping code. *** POTENTIAL INCOMPATIBILITY *** If you overloaded the __del__ method, and call the base one without a try block, as in class MyClass(SwigClass): def __del__(self): SwigClass.__del__(self) python could complain that the method SwigClass.__del__ is undefined. Try to use instead: def __del__(self): try: SwigClass.__del__(self) except: pass or simply def __del__(self): 11/02/2005: mmatus [Python] Adding more fun to STL/STD containers, now you can do %template(pyset) std::set; %template(pyvector) std::vector; %template() std::pair; %template(pyvector) std::map; .... The same applies to std::list, std::deque, std::multiset, etc. Then, at the python side you can do now: # C++ std::vector as native python sequence v = pyvector([1,"hello",(1,2)]) print v[1] >> 'hello' print v[2] >> (1,2) # C++ std::set as native python sequence s = pyset() s.insert((1,2)) s.insert(1) s.insert("hello") sum=() for i in s: sum +=(i,) print sum >>> (1, 'hello', (1, 2)) # C++ std::map as native python sequence m = pymap() m["foo"] = "hello" m[1] = (1,2) pm = {} for k in m: pm[k] = m[k] print pm >>> {1: (1, 2), 'foo': 'hello'} ie, the STD/STL containers work as real native python container, with arbitrary item types and so. But since normal C++ containers do not properly ref/unref their items, you should use the safer versions: %template(pyset) std::set; %template(pyvector) std::vector; %template() std::pair; %template(pyvector) std::map; .... where swig::PyObject_ptr is a PyObject * envelope class provided to safely incref/decref the python object. So, now you can use all the STL/STD containers as native Python containers. Note 1: std::map, std::set and the other 'ordered' containers will properly use PyObject_Compare for sorting, when needed. Note 2: all the STL/STD containers have a limit size of SIZE_MAX, ie, you can have manage containers larger than INT_MAX, the python limit. 11/02/2005: mmatus [Python] - add 'iterator()' method for all sequences and additionally 'key_iterator()' for maps. 'iterator()' will always return the native C++ iterator. Additionally, in maps, 'key_iterator()' will return a python iterator using only the map keys. In general the sequence method __iter__ will call 'iterator()', returning the native C++ iterator, but in maps it will call 'key_iterator()', maintaining backward compatibility. Hence, for std::maps, you can play then with the native C++ iterator, which value is a (key, value) pair, by calling map.iterator(), as with map.begin(), map.end(), etc. The difference is that map.iterator() returns a safe 'closed' iterator, while map.begin() and map.end() are 'open' iterators. A 'closed' iterator knows the begin and the end of the sequence, and it never can seg. fault. An 'open' iterator, as in C++, can seg. fault at the C++ side. # a closed iterator is safe in the following example. # the next() method will throw a StopIteration # exception as needed i = seq.iterator() try: while True: sum += i.next() except: pass # an open iterator always need to be checked, # or it will crash at the C++ side current = seq.begin() end = seq.end() while (current != end): sum += current.next() [Python] - Finally, when we call f = Foo() the construction is 'one-way'. Before construction was done something like Foo() (python) -> _new_Foo() (C++) new_Foo() (C++) -> FooPtr() (python) FooPtr() (python) -> Foo() (python) and returning a pointer was done like NewPointerObj() (C++) -> FooPtr() (python) FooPtr(python) -> Foo() (python) ie, we when going back and forward between the C++ and python side. Now since there is no FooPtr the construction process is Foo() (python) -> _new_Foo() (C++) _new_Foo() (C++) -> NewPointerObj() (C++) (no shadow class) and returning a pointer is done NewPointerObj() (C++) (with shadow class) -> NewInstaceObj() (C++) where NewInstanceObj creates a new instance without calling __init__ and it doesn't go 'back' to python, is 'pure' C API. - With this change, and the other ones in the PySwigObject type, which now carries the thisown and swig_type_info pointer, the generated code should be as fast as boost::Python and/or the other python wrappers based in pure Python/C API calls. As a reference, the profiletest_runme.py example, which does a simple call function many times, such as this code: import profiletest a = profiletest.A() b = profiletest.B() for i in range(0,1000000) a = b.fn(a) where fn is defined as 'A* B::fn(A *a) {return a;}', produces the following times nomodern modern swig-1.3.26 19.70s 5.98s swig-CVS 0.99s 0.98s Clearly, there is a large improvement for the python 'nomodern' mode. Still, the 'modern' mode is around 6 times faster than before. For the same test, but using the non-shadow version of the module, we get _profiletest (non-shadow) swig-1.3.26 0.80s swig-CVS 0.60s Hence, now for practical purposes, the proxy overhead is insignificant. Note that the performance numbers we are showing is for a simple module (two types) and a simple function (one argument). For real situations, for modules with many more types and/or functions with many more parameters, you will see even better results. 10/31/2005: mmatus [Python] - Finally, no more ClassPtr proxy classes. You will see only a clean Class proxy class in the .py file. - No more 'real' thisown attribute either, the PySwigObject now carries the ownership info. You can also do something like print self.this.own() >>> True self.this.disown() self.this.own(0) print self.this.own() >>> False self.this.acquire() self.this.own(1) print self.this.own() >>> True Still the old way, print self.thisown >>> True self.thisown = 0 print self.thisown >>> False self.thisown = 1 print self.thisown >>> True is supported, and python dispatches the proper method calls as needed. - Support for iterators in STL/STD containers, for example, if you have %template std::set; you can use the C++ iterators as: s = set_string() s.append("c") s.append("a") s.append("b") b = s.begin() e = s.end() sum = "" while (b != e): sum += b.next() print sum >>> "abc" advance the iterator as in C++ current = s.begin() current += 1 print current.value() >>> "b" now using the reverse operators b = s.rbegin() e = s.rend() sum = "" while (b != e): sum += b.next() print sum >>> "cba" or the 'previous' method b = s.begin() e = s.end() sum = "" while (b != e): sum += e.previous() print sum >>> "cba" or just as in a python fashion for i in s: sum += i Note 1: Iterators in C++ are very powerful, but dangerous too. And in python you can shoot yourself in the foot just like in C++, so, be careful. Note 2: the iterators are 'light', ie, they do not convert sequence elements until you request to do so, via next(), value() or previous(). If you just increment/decrement one no conversion is performed, for example: b = s.begin() b += 1 b.incr() b.incr(2) b.decr(2) b.decr() b -= 1 only the iterator is modified, and not value wrapper is generated. Other typical C++ operations are also available, such as: print s.end() - s.begin() >>> 3 f = s.begin() + 1 print f.value() >>> "b" l = s.end() - 1 print l.value() >>> "c" etc. Of course, the 'find', 'insert', 'erase', and so on methods also supports iterators now, ie: i = s.begin() i += 1 s.erase(i) for i in s: sum += i print sum >>> "ac" *** POTENTIAL INCOMPATIBILITY *** There is no more 'thisown' attribute. If you use it, python will translate the following code as follows: if (self.thisown): ==> if (self.this.own()): self.thisown = 1 ==> self.this.own(1) self.thisown = 0 ==> self.this.own(0) Still, maybe in some unusual cases the translation will not be 100% correct, so if you have a problem, please report it and/or use the new 'self.this.own()' accessor. *** POTENTIAL INCOMPATIBILITY *** There is no more ClassPtr classes in the python code. Hence, if in the past you needed to resort to some kind of trickery with them, or overcome their presence, it is no longer required, but the extra code you added could now break things. If needed, you can use the option -classptr, i.e., swig -classptr -python ... to generate the old ClassPtr classes. 10/30/2005: mkoeppe [Guile] Make declared and defined linkage of SWIG_init consistent. Reported by Steven G. Johnson (SF patch 1315498). 10/26/2005: mmatus - Added the attribute.i file to the global library director. Now it can be used from other languages that do not use the unified typemap library as well. So, if you have something like: %include attribute.i %attribute(A, int, a, get_a, set_a); struct A { int get_a() const; void set_a(int aa); }; %attribute_ref(B, int, c); struct B { int& c(); }; then in the target language the 'A.a' and 'B.c' attributes will be visible, ie, you can access them as plain variables: f = A() f.a = 3 g = B() g.c = 3 h = f.a + g.c and the proper get/set methods will be dispatched. See attribute.i for more info. - More cleanups around and adding more test-cases. The DISOWN typemap now is tested and working in all the languages that use the unified typemap library, ie, tcl, ruby, perl and python. 10/25/2005: mmatus - Perl, complete the DISOWN typemap. - added the attribute.i file to the unified typemap library (before was only usable from python). - unify the names for the setter and getter methods in perl,tcl,ruby and python, so, the attribute.i library can work across them. - see the li_attribute.i test-case or the library file Lib/typemaps/attribute.swg for more info about how to use it. 10/24/2005: mmatus - Perl now uses the unified typemap library. - Changes in ruby to use the $track option in typemaps. - Changes in the unified typemap library to follow the convention that all macros that are not used in the C/C++ side starts with %, such as %delete %new_array etc. - Documenting fragments, see fragments.swg. - Cleaner way to use the unified typemap library, include just . Check some of the supported languages: perl, tcl, ruby, python. Always start with the head file, such as python/python.swg tcl/tcl8.swg ruby/ruby.swg perl5/perl5.swg and the principal file that invokes the unified library, such as python/pytypemaps.swg tcl/tcltypemaps.swg ruby/rubytypemaps.swg perl/perltypemaps.swg The file that provide the specialization for each language are the one that provides the basic types: python/pyprimtypes.swg ruby/rubyprimtypes.swg tcl/tclprimtypes.swg perl5/perlprimtypes.swg and the string manipulation: python/pystrings.swg ruby/rubystrings.swg tcl/tclstrings.swg perl5/perlstrings.swg The rest of the files, such as carray.i, are mostly one line files that include the proper typemap library version. *** POTENTIAL INCOMPATIBILITY in Perl *** Some missing/wrong typemaps could start working properly, and change the old expected behavior in Perl. 10/23/2005: wuzzeb Chicken: + pointers to member functions finally work properly + add test of member function pointers to cpp_basic.i 10/20/2005: dancy [allegrocl] Added C++ support. Large update, many changes. See newly added Allegro Common Lisp section in lisp.html 10/20/2005: mmatus Ruby, Tcl, Python: - Uniform way to fail (label fail:), now finally SWIG_exception works across the three languages and all the typemaps. - Add proper cleanup code to ruby - More valgrind fixes - Simplify the inline use, it seems a small interface of 20,000 lines (plus many many templates) can break gcc -O3 easily. - Finalize the typemaps library. All the old *.i files (carray.i, cpointer.i, exception.i) had been implemented in the new typemaps library. 10/19/2005: wuzzeb Update the Runtime Typemap documentation in Typemaps.html 10/18/2005: wuzzeb Chicken: - Correctly handle %ignored classes - Correctly convert long, long long, unsigned long, etc to chicken primitives. (Thanks to Felix Winkelmann) - Using argout parameters when the return value was a wrapped pointer caused a memory corruption. The chicken garbage collector moved a pointer out from under us. This is now fixed by running all the proxy creation functions as continuations after the wrapper function returns. As part of this, we no longer need the chickenfastproxy flag on output typemaps. - using -proxy and -nocollection together works now Before, it was not exporting the destructor in the proxy wrapper. 10/18/2005: mmatus Added the Unified Typemap Library (UTL). It unifies the typemaps for python, ruby, tcl and in the process, fixes several problems in each of the three languages to work in a "canonical" way now established in the typemap library SWIG/Lib/typempas The current status of the unification is that everything compiles and runs inside the test-suite and examples directories. And for the first time we have three languages than pass the primitive_types.i case. Also, we have a uniform way to treat the errors, for example if you do something like >>> from primitive_types import * >>> print val_uchar(10) 10 >>> print val_uchar(1000) Traceback (most recent call last): File "", line 1, in ? OverflowError: in argument 1 of type 'unsigned char' you get the same exception in all the three languages. And well, many more good things will come from this unification, for example, proper support of the STL/STD classes for all the languages, and hopefully, we can keep adding other languages. The hardest part, writing a common typemap library that suites the three different languages, is done, and adding another language should now be easy. Still the global unification is not complete, the STL/STD part is next, and probably as well as adding one or two more languages. If you are curious, look at the python, ruby and/or tcl directories to see what is needed to support the new common typemaps library. Still, the final way to integrate a new language could change as we move to integrate the STD/STL. *** POTENTIAL INCOMPATIBILITY in Ruby/Tcl *** Some missing/wrong typemaps could start working properly, and change the old behavior, specially in ruby and tcl. Version 1.3.27 (October 15, 2005) ================================= 10/15/2005: wsfulton [Java] Fix for typesafe enum wrapping so that it is possible to overload a method with 2 different enum types. 10/15/2005: wsfulton Fix for %feature("immutable","0") attempting to generate setters for constants. Restored %immutable and %makedefault to clear the feature as it behaved in SWIG-1.3.25 and earlier. 10/14/2005: mmatus Fix bug in anonymous typedef structures which was leading to strange behaviour. 10/13/2005: mmatus Several minor changes: - Improve the wchar_t type support - Add a warning for when you define the 'in' typemap but you don't define the 'typecheck' one. Very common mistake. - Add proper default rule for function pointers, now you can define a typemap such as: %typemap(in) SWIGTYPE ((*)(ANY)) {...} That will apply to all the pointer to functions. The rule in C++ also apply to the function 'reference', ie, in both cases typedef int (*fptr)(int a); typedef int (func)(int a); This was needed since it seems to be 'illegal' in C++ to do something like: void *ptr = static_cast(fptr); and probably, as for member functions, it is not warrantied that the pointer sizes will match. - Add the #error/#warning directives to swig's cpp. - Add the noblock option for typemaps, which is used as follows: supposed you a typemap, like this %typemap(in,noblock=1) Hello { .... } then the typemap will be inserted without the block imposed by the brackets, similar to %typemap(in) Hello "..."; So, why you don't just use the quote style?, because: 1.- The quote style doesn't get preprocessed, for example %typemap(in) Hello "$1= SWIG_macro($1);"; here, SWIG_macro doesn't get expanded 2.- Inside a quote typemap, you have to use quotes carefully %typemap(in) Hello "$1 = \"hello\" "; 3.- You can't make emacs and/or other editors to indent inside a string!. So, why do you want to remove the block?, because an extra block when not needed (no local variables in it): 1.- makes the code harder to read 2.- makes the code larger 3.- or in short, for the same reason we have the quote style. Version 1.3.26 (October 9, 2005) ================================ 10/08/2005: wsfulton [Php] Added 'throws' typemaps. 10/08/2005: wsfulton Fixes for languages that don't support multiple inheritance. The first non-ignored class in the public base class list is used for inheritance. by the proxy class. Previously, if the first class in the list was ignored, then the proxy class wouldn't have any base classes. 10/07/2005: mmatus Update more features to follow new convention, including: callback ref/unref except All of them use not only the feature as a flag, but also as code value. To deal with those features, we use now GetFlagAttr, which is similar to GetFlag, but instead or returning 1 or 0, it returns the attr value, if happens to be different of "0" of course. Now there are also more uniform directive names for the ones based in features, for example, for the old %newobject directive now we have tree directives defined: #define %newobject %feature("new") #define %nonewobject %feature("new","0") #define %clearnewobject %feature("new","") and so on for all the other feature directives. *** POTENTIAL INCOMPATIBILITY *** 09/30/2005: wsfulton Subtle change to some features. Previously it was not possible to disable many features once they had been enabled. This was for most features that behave as flags. These features now work as follows: %feature("name") // enables the feature %feature("name", "1") // enables the feature %feature("name", "0") // disables the feature %feature("name", "") // clears the feature In fact any non-empty value other than "0" will enable the feature (like C boolean logic). Previously "1", "0" or any other non-empty value would enable the feature and it would only be possible to disable the feature by clearing it (assuming there was no global enable). The following features are affected: allowexcept compactdefaultargs classic (Python) cs:const (C#) director exceptionclass (Python) ignore immutable java:const (Java) java:downcast (Java) kwargs modern (Python) new noautodoc (Python) nodefault nodirector noref notabstract nounref novaluewrapper python:maybecall (Python) python:nondynamic (Python) modula3:multiretval (Modula3) predicate (Ruby) trackobjects (Ruby) valuewrapper It is now possible, for example to ignore all methods/classes in a header file, except for a few targetted methods, for example: %feature("ignore"); // ignore all methods/classes %feature("ignore","0") some_function(int, double); // do not ignore this function %feature("ignore","0") SomeClass; // do not ignore this Class %feature("ignore","0") SomeClass::method; // do not ignore this method %include "bigheader.h" Removed %pythondynamic - it never worked properly. Use %pythonnondynamic instead. Removed %feature("nokwargs") - it wasn't fully implemented - use %feature("kwargs","0") instead. *** POTENTIAL INCOMPATIBILITY *** 09/25/2005: mkoeppe [Guile] Add "throws" typemaps. 09/24/2005: cfisavage [Ruby] Adds new %trackobjects functionality that maps C++ objects to Ruby objects. This functionality makes it much easier to implement mark functions for the garbage collector. For more information refer to the update documentation and examples. 09/20/2005: wsfulton [Perl] Patch 1116431 from Josh Cherry. Fixes non member functions inadvertently being called instead of member functions. 09/20/2005: wsfulton [Lua] Patch from Mark Gossage to add support for Lua-5.1, std::string, std::vector, std::exception and documentation. 09/14/2005: mmatus [Python] Add -nocppcast. Now the default behavior is to always use the cppcast operators. Before that was the case only when you used the -cppcast option. If this seems to break your code... your welcome!, it means it was broken before, and you never notice. If you thing the error is due to one of the SWIG typemaps, send us an example. Use -nocppcast only with very old C++ compilers that do not support the cppcast operations. So, here applies: This change doesn't break compatibility, it was broken before. 09/13/2005: wsfulton [Java] Fix for director methods when a class is passed by value as a parameter. 09/11/2005: mmatus Adding the module option to the %import directive. Now you can use it as %import(module="BigModule") foo.i where subfile could (or not) define the module name via the %module directive. The module option take precedence and it has the same effects than having the directive %module BigModule inside the imported file foo.i. You can use the option in mainly two cases: 1.- You used the -module option when you generated the module to be imported, and hence the module name in the imported %module directive is not really useful. 2.- The module you want to import is very large, and it has several .i/.h files. Then, if you just one to import a class or so from the module, says 'foo', and not the entire module via importing the main BigModule.i file, then you just do: %import(module="BigModule") foo.h or %import(module="BigModule") foo.i where foo.i contains the 'foo' declaration and maybe a couple of extra %include directives, as needed. 09/11/2005: mmatus Fix bug #1282637, about the -module option not having effect in places where it was needed. 09/11/2005: wsfulton When wrapping variables, ensure that none of the typemaps used for the set wrappers are used when generating the get wrappers. I doubt this was a problem for any languages except for the recently introduced null attribute in the out typemap (C# only). 09/08/2005: wsfulton More descriptive error messages when files fail to open. 09/06/2005: mmatus Allow a %define a macro inside another %define macro, for example %define hello(name, Type) %define name ## a(Type) %typemap(in) Type "hello;"; %enddef %enddef To learn how to use this new features in your own typemaps library, see python/cstring.i, python/cwstring.i and python/cwstrbase.i. [Python] Normalize the cstring.i implementation to use fragments, and add cwstring.i, which implements the same typemaps but for wchar_t strings. [Python] Bug fixed: 1247477, 1245591, 1249878 and others. 08/18/2005: wsfulton [Ruby] Implement support for SWIGTYPE* DISOWN typemap (like in Python) for better control of memory management, eg when adding an object created in Ruby to a C++ container. Patch #1261692 from Charlie Savage. 08/18/2005: wsfulton [Tcl] 64 bit platform fixes for the varargs handling in SWIG_GetArgs. This is an improved fix for bug #1011604 as suggested by Jeremy Lin. 08/18/2005: wsfulton [Tcl] Bug #1240469 - %newobject support for Tcl. Patch from Bob Marinier. 08/16/2005: wsfulton [Perl] Bug #1254494 - Fix for global namespace pollution by perl header files (bool define) prevented STL headers from being used on some systems, eg Windows with Visual Studio. 08/16/2005: wsfulton [Java] Bug #1240937 - Redefinition of __int64 typedef for Intel compilers. 08/15/2005: wsfulton [Xml] Bug #1251832 - C++ template may generate invalid XML file 08/15/2005: wsfulton [Lua] Support added for Lua. Patch #1242772 from Mark Gossage. It supports most C/C++ features (functions, struct, classes, arrays, pointers, exceptions), as well as lots of documentation and a few test cases & examples. 08/14/2005: wsfulton [Xml] Fix incorrect xml escaping in base class name when base class is a template. 08/13/2005: efuzzyone [CLISP] Added support for handling enums. Does not adds the return type declaration to the function definition, if a function returns void. 08/09/2005: mkoeppe New language module, Common Lisp with UFFI, from Utz-Uwe Haus. 08/09/2005: mkoeppe Fix the Lisp s-expression output module; it no longer complains about "unknown targets". 07/27/2005: wsfulton Modifications to STL wrappers so that it is possible for a user's %exception directive to be applied to the STL wrapper methods. Previously the following global %exception directive would not be used on the wrapper methods: %exception { try { $action } catch (...) { // handle uncaught exceptions } } This has been implemented by replacing %exception directives for specific STL wrapper methods with an exception specification declared on the wrapper methods. throws typemaps are now supplied for handling the STL exception specification. These can also be easily overridden, for example the std::out_of_range exception, which is used a lot in the STL wrappers, can be customised easily: %include "std_vector.i" %typemap(throws) std::out_of_range { // custom exception handler } %template(VectInt) std::vector; 07/22/2005: efuzzyone [CLISP] The clisp module for SWIG: - It can only handle C, clisp currently does not supports ffi bindings to C++. - It has two options, (a) -extern-all this will generate wrappers for all functions and variablestions, (b) -generate-typedef this will generate wrappers "def-c-type" wrappers for typedefs - Can handle pointers to functions, complex types such as n-dimensional arrays of pointers of depth d - Generates wrappers for constants as well as variables - Correctly distinguishes between the declaration of variables in structures and functions - Creates a defpackage "declaration" with the module name as the package name, the created package exports both functions and variables - tries to guess when should a pointer variable be declared as c-ptr or c-pointer 07/22/2005: wsfulton [C#] Changes to support C# structs returned by value. The changes required are: - Using an optional 'null' attribute in the out typemap. If this attribute is specified, then it is used for the $null special variable substitution. - The ctype used in the C/C++ wrappers is no longer initialised to 0 on declaration. Both of these changes fix the situations where an attempt was made to assign 0 to the returned struct. Marshalling structs as value types still requires user defined typemaps. See documentation for an example. 07/22/2005: wsfulton [C#, Java] Fix SWIG_exception usage to work with compilers that don't support empty macro arguments. Unfortunately this fix will stop usage of SWIG_exception being used within typemaps that use "" or %{ %} delimiters, but continues to work with typemaps using {} delimiters. Please use the SWIG_CSharpSetPendingExceptionArgument or SWIG_JavaThrowException methods instead as SWIG_exception is really intended as a platform independent macro for the SWIG library writers. 07/16/2005: mkoeppe [Allegro CL] Use specific foreign types rather than (* :void). Use *swig-identifier-converter*. 06/27/2005: wsfulton Functions declared as 'extern' no longer have an additional function declaration added to the wrapper files. There are some cases where SWIG does not get this right, eg bug #1205859 (extern functions with default arguments declared in a namespace). Also SWIG cannot get non-standard calling conventions correct, eg Windows calling conventions are usually handled like this: %{ #define DLLIMPORT __declspec(dllimport) #define STDCALL __stdcall %} #define DLLIMPORT #define STDCALL %inline %{ DLLIMPORT extern STDCALL void function(int); %} SWIG incorrectly generates: extern void function(int); To which there is no solution as SWIG doesn't handle non-standard calling conventions. The extra 'extern' function that SWIG generates is superfluous unless a user has forgotten to add the function declaration into the wrappers. The -noextern commandline argument is now redundant and a new commandline argument -addextern can be used to obtain the original behaviour. This shouldn't be necessary unless the header file containing the function declaration was inadvertently not added to the wrappers. To fix this add the function declaration into your wrappers, For example, replace: extern void foo(int); with: %inline %{ extern void foo(int); %} *** POTENTIAL INCOMPATIBILITY *** 06/22/2005: wsfulton [C#, Java, Modula3, Ocaml] The intermediary function names have been changed when wrapping variables to match the other language modules so that %extend for a member variable works uniformly across all language modules, eg: %extend ExtendMe { Var; }; %{ void ExtendMe_Var_set(ExtendMe *, double) {...} double ExtendMe_Var_get(ExtendMe *) {...} %} The methods implementing the get/set used to be: %{ void set_ExtendMe_Var(ExtendMe *, double) {...} double get_ExtendMe_Var(ExtendMe *) {...} %} This also changes the name of variable wrapper functions when using -noproxy. The original names can be generated with the -oldvarnames commandline option. *** POTENTIAL INCOMPATIBILITY *** Version 1.3.25 (June 11, 2005) ============================== 06/11/2006: mkoeppe [Guile] Fix handling of anonymous-enum variables. 06/10/2005: mkoeppe [Guile] Fix for function arguments that are passed by copy-of-value. Fix for global "const char *" variables. Fix testcases arrays_dimensionless, arrays_global. 06/08/2005: wsfulton Fix for when a base class defines a symbol as a member variable and a derived class defines the same symbol as a member method. 06/08/2005: wsfulton [C#] More fixes for virtual/new/override modifiers - when a method has protected access in base and public access in derived class. 06/02/2005: wsfulton Fix #1066363 - Follow convention of release tarball name matching directory name. 06/02/2005: wsfulton [C#, Java] Fix #1211353 - typesafe enums (and Java proper enums) wrappers when enum value is negative. 05/27/2005: wsfulton Modernised and tidied up Windows macros --> SWIGEXPORT, SWIGSTDCALL. They can be overridden by users via -D compiler directives if need be. 05/26/2005: wsfulton %csmethodmodifiers can be applied to variables as well as methods now. In addition to the default 'public' modifier that SWIG generates, %csmethodmodifiers will also replace the virtual/new/override modifiers that SWIG thinks is appropriate. This feature is useful for some obscure cases where SWIG might get the modifiers incorrect, for example with multiple inheritance and overriding a method in the base class. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 05/25/2005: wsfulton Added missing constructors to std::pair wrappers (std_pair.i) for all languages. 05/25/2005: wsfulton [C#] Added std::pair wrappers in std_pair.i 05/25/2005: wsfulton [C#] The C# 'new' and 'override' modifiers will be generated when a C++ class inherits methods via a C++ 'using' declaration. 05/25/2005: wsfulton Fix for exception specifications previously being ignored in classes that inherited methods from 'using' declarations, eg calls to Derived::bar below will convert C++ exceptions into a target language exception/error, like it always has done for Base::Bar. class Base { virtual bar() throw (std::string); }; class Derived : public Base { using Base::bar; }; 05/23/2005: wsfulton Fixes for detecting virtual methods in %extend for the -fvirtual option and C# override and new method modifiers. 05/23/2005: wsfulton [C#] The 'new' modifier is now generated on the proxy method when a method in a derived class is not polymorphic and the same method exists in the derived class (ie it hides the base class' non-virtual method). 05/23/2005: wsfulton [Java, C#] Fixes to detection of covariant return types - when the class hierarchy is more than 2 classes deep. 05/21/2005: wsfulton [Java] std::wstring typemaps moved from std_string.i to std_wstring.i 05/21/2005: wsfulton Fix for crash in DohStrstr, bug #1190921 05/21/2005: wsfulton [TCL] Fix for methods with similar names when showing list of names on error - bug #1191828. Patch from Jeroen Dobbelaere. 05/21/2005: wsfulton [TCL] long long overloading fix - bug #1191835, patch from Jeroen Dobbelaere. 05/21/2005: wsfulton Fix bug #1196755 to remove debug from swigtcl8.swg. 05/19/2005: wsfulton [C# and -fvirtual option] Fix for the override key not being generated in the derived class when a virtual method's return type was a typedef in either the base or derived class. Also ensures the method is eliminated when using the -fvirtual option. For example, Derived.method now has the C# override keyword generated: typedef int* IntegerPtr; struct Base { virtual IntegerPtr method(); }; struct Derived : Base { int * method() const; }; [C#] Fix for the override key being incorrectly generated for virtual methods when a base class is ignored with %ignore. 05/13/2005: wsfulton [Java] Fixes to remove "dereferencing type-punned pointer will break strict-aliasing rules" warnings in C wrappers when compiling C code with 'gcc -Wall -fstrict-aliasing'. Patch from Michael Cahill. This modifies many of the casts slightly, for example arg1 = *(DB_ENV **)&jarg1; to arg1 = *(DB_ENV **)(void *)&jarg1; 05/12/2005: wsfulton [C#] Support for C# attributes. C# attributes can be generated: 1) On a C/C++ type basis by specifying an inattributes and/or outattributes typemap attribute in the imtype or cstype typemaps (for C# return type or C# parameter type attributes). 2) On a wrapped method or variable by specifying a csattributes feature (%feature). 3) On a wrapped proxy class or enum by specifying a csattributes typemap. Examples are in the C# documentation (CSharp.html). 04/29/2005: wsfulton New configure option to turn off the default maximum compiler warning as they couldn't be removed even when overriding CFLAGS and CXXFLAGS with configure (./configure CFLAGS= CXXFLAGS=). To turn the maximum warnings off, run: ./configure --without-maximum-compile-warnings 04/28/2005: wsfulton Patch from Scott Michel which reworks the Java constructor and finalize/destructor typemaps, for directors to reduce the number of overall Java typemaps. Added the director_take and director_release typemaps to emulate other modules' __disown__ functionality. *** POTENTIAL INCOMPATIBILITY FOR JAVA DIRECTORS *** 04/28/2005: wsfulton [C#] Fixed problems due to the over eager garbage collector. Occasionally the garbage collector would collect a C# proxy class instance while it was being used in unmanaged code if the object was passed as a parameter to a wrapped function. Needless to say this caused havoc as the C# proxy class calls the C++ destructor when it is collected. Proxy classes and type wrapper classes now use a HandleRef, which holds an IntPtr, instead of a plain IntPtr to marshal the C++ pointer to unmanaged code. There doesn't appear to be any performance degradation as a result of this modification. The changes are in the proxy and type wrapper classes. The swigCPtr is now of type HandleRef instead of IntPtr and consequently the getCPtr method return type has also changed. The net effect is that any custom written typemaps might have to be modified to suite. Affected users should note that the implementation uses the new 'out' attribute in the imtype typemap as the input type is now a HandleRef and the output type is still an IntPtr. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 04/28/2005: wsfulton [C#] Support for asymmetric type marshalling added. Sometimes the output type needs to be different to the input type. Support for this comes in the form of a new optional 'out' attribute for the ctype, imtype and cstype typemaps. If this typemap attribute is not specified, then the type used for both input and output is the type specified in the typemap, as has always previously been the case. If this typemap attribute is specified, then the type specified in the attribute is used for output types and the type specified in the typemap itself is used for the input type. An output type is a return value from a wrapped method or wrapped constant and an input type is a parameter in a wrapped method. An example shows that char * could be marshalled in different ways, %typemap(imtype, out="IntPtr") char * "string" char * function(char *); The output type is thus IntPtr and the input type is string. The resulting intermediary C# code is: public static extern IntPtr function(string jarg1); 04/22/2005: mkoeppe (Matthias Koeppe) [Guile] Fix generation of "define-method" for methods of classes with a constructor. Reported by Luigi Ballabio. 04/15/2005: wuzzeb (John Lenz) [Chicken] For wrapped functions that return multiple values (using argout), SWIG CHICKEN now returns them as multiple values instead of as a list. They can then be accessed using (call-with-values). 04/14/2005: wuzzeb (John Lenz) [Chicken] + Added a whole bunch of new _runme scripts into the chicken test suite. Also fix some bugs these new scripts turned up. + Added optimization when returning a wrapped proxy class. Before, a minor garbage collection was invoked every time a function returned. + All the chicken Examples should now run correctly 04/14/2005: wsfulton [C#] More fixes for typemap matching when wrapping variables, in particular std::string, so that std::string variables can be easily marshalled with a C# string property using: %include "std_string.i" %apply const std::string & { std::string *variable_name }; std::string variable_name; (Recall that all class variables are wrapped using pointers) 04/05/2005: wuzzeb (John Lenz) [Chicken] + Added Examples/chicken/egg, an example on how to build a chicken extension library in the form of an egg. Also updated the documentation on the different linking options. + chicken test-suite now has support to check SWIG with the -proxy argument if there exists a _proxy_runme.ss file. + More fixes for overloaded functions and -proxy 03/31/2005: wsfulton Turned on extra template features for all languages which were previously only available to Python. This enables typemaps defined within a templated class to be used as expected. Requires %template on the templated class, %template() will also pick up the typemaps. Example: template struct Foo { ... %typemap(in) Foo "in typemap for Foo " or %typemap(in) Foo "in typemap for Foo " }; %template(Foo_i) Foo; %template() Foo; will generate the proper 'in' typemaps wherever Foo and Foo are used. 03/30/2005: mkoeppe (Matthias Koeppe) [MzScheme] Patch from Hans Oesterholt for supporting MzScheme 30x. 03/29/2005: wuzzeb (John Lenz) [Chicken] + Reallow older versions of chicken (1.40 to 1.89) by passing -nocollection argument to SWIG + %import now works correctly with tinyclos. (declare (uses ...)) will be exported correctly. + TinyCLOS proxy classes now work correctly with overloaded functions and constructors. 03/29/2005: wsfulton [Java] Patch from Scott Michel for directorout typemaps. Java directors require the directorout typemaps like the other languages now. The new typemaps provide fixes for methods where the return type is returned by reference (this cannot automatically be made thread safe though). 03/22/2005: wsfulton Enum casting fixes. Visual C++ didn't like the C type casting SWIG produced when wrapping C++ enum references, as reported by Admire Kandawasvika. 03/21/2005: wsfulton [Perl] SF #1124490. Fix Perl macro clashes when using Visual Studio's STL string, so now projects can #include . 03/21/2005: wsfulton Fixed %varargs which got broken with the recent default argument changes. Also works for Java and C# for the first time now. 03/17/2005: wuzzeb (John Lenz) [Chicken] + Fix a whole bunch of bugs in the chicken module. The entire test suite now compiles, with the exception of the tests that require std_vector.i, std_deque.i, and so on, which chicken does not have yet. + Add support for %exception and %typemap(exceptions). Exceptions are thrown with a call to (abort) and can be handled by (handle-exceptions) 03/15/2005: wsfulton [Java] Patch from Scott Michel for directors. Modifications to the typemaps giving users fine control over memory ownership and lifetime of director classes. Director classes no longer live forever by default as they are now collectable by the GC. 03/15/2005: wuzzeb (John Lenz) [Chicken] Add support for adding finalizers garbage collected objects. Functions that return new objects should be marked with %newobject and input arguments which consume (or take ownership) of a pointer should be marked with the DISOWN typemap. Also add support for correctly checking the number of arguments passed to a function, and raising an error if the wrong number are passed. 03/14/2005: wuzzeb (John Lenz) Add --without-alllang option to configure.in, which is the same as passing all the --without-python --without-perl5 etc... that Matthias added. 03/09/2005: wsfulton [Php] Memory leak fix for functions returning classes/structs by value. 03/08/2005: wsfulton [Perl] Fix for Perl incorrectly taking memory ownership for return types that are typedefs to a struct/class pointer. Reported by Josh Cherry. 03/07/2005: wsfulton [C#] Various exception changes for the std::vector wrappers. These now more accurately mirror the same exceptions that System.Collections.ArrayList throw. 03/07/2005: wsfulton [C#] Fix undefined behaviour after any of the std::vector methods throw an exception. 03/07/2005: wsfulton [C#] When null is passed for a C++ reference or value parameter, the exception thrown has been corrected to an ArgumentNullException instead of NullReferenceException as recommended in the .NET Framework documentation. The default throws typemaps turn a C++ exception into an ApplicationException, not a SystemException now. 03/07/2005: wsfulton [C#] Numerous changes in C# exception handling have been made over the past few weeks. A summary follows: The way in which C++ exceptions are mapped to C# exceptions is quite different. The change is to fix C# exceptions so that the C++ exception stack is correctly unwound as previously C++ exceptions were being thrown across the C PInvoke layer into the managed world. New typemap attributes (canthrow and excode) have been introduced to control the mapping of C++ to C# exceptions. Essentially a callback into the unmanaged world is made to set a pending exception. The exception to throw is stored in thread local storage (so the approach is thread-safe). The typemaps are expected to return from unmanaged code as soon as the pending exception is set. Any pending exceptions are checked for and thrown once managed code starts executing. There should be minimal impact on execution speed during normal behaviour. Full details will be documented in CSharp.html. The SWIG_CSharpThrowException() function has been removed and replaced with the SWIG_CSharpSetPendingExceptionArgument() and SWIG_CSharpSetPendingException() functions. The original name has been deliberately changed to break old code as the old approach was somewhat flawed. Any user defined exceptions that follow the same pattern as the old approach should also be fixed. Numerous new .NET framework exceptions are now available for easy throwing from unmanaged code. The complete list is: ApplicationException, ArithmeticException, DivideByZeroException, IndexOutOfRangeException, InvalidOperationException, IOException, NullReferenceException, OutOfMemoryException, OverflowException, SystemException, ArgumentException, ArgumentNullException and ArgumentOutOfRangeException. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 05/05/2005: mmatus Fix several memory leaks around. Even when we survive knowning swig is a memory leak factory, it was a little out of control. To run std_containers.i in the python test-suite, swig was using ~260MB, now it uses 'only' ~40MB, which is the same ammount that g++ uses, so, is not that bad. In the process, I found a couple of extra Deletes, which in some cases could trigger seg. faults and/or DOH/asserts. [python] Better support for directors + exception. More verbose errors and added an unexpected exception handler. [python] Fix memory leak for the std::vector > case,reported by Bo Peng. [python] Fix SwigPyObject compare problem reporte by Cameron Patrick. [python] Fix several warnings in the generated code for gnu-gcc, Intel and VC7.1 compilers. 02/25/2005: wuzzeb (John Lenz) Update documentation to use CSS and
instead of
I used a script to convert the docs, and it set all the box classes to be "code". There are actually 4 different classes, "shell", "code", "targetlang", and "diagram". We need to go through and convert the divs depending on what they contain. 02/23/2005: mmatus [Python] Added option -nortti to disable the use of native C++ RTTI with directors (dynamic_cast<> is not used). Add more code for directors to detect and report errors in the python side. Extend the use of SWIGINTERN whenever is possible. Remove template warnings reported by VC7.1. Remove warnings reported by gcc/g++. Finally you can compile using g++ -W -Wall -c mymodule_wrap.cxx and no spurious errors will be generated in the wrapper code. 02/23/2005: wuzzeb (John Lenz) Added -external-runtime argument. This argument is used to dump out all the code needed for external access to the runtime system, and it replaces including the files directly. This change adds two new virtual functions to the Language class, which are used to find the language specific runtime code. I also updated all languages that use the runtime to implement these two functions. 02/22/2005: mmatus Fix %template + private error SF#1099976. 02/21/2005: mmatus Fix swigrun.swg warnings reported when using "gcc -W -Wall" (static/inline not used in front of a function declaration), and add SWIGUNUSED attribute to avoid unused warnings elsewhere. Fix unused variable warnings. [Python] Use new SWIGUNUSED attribute to avoid warnings in SWIGINTERN methods. [Python] Fix PyOS_snprintf for python versions < 2.2 (SF #1104919). [Python] Fix map/multimap to allow empty maps (reported by Philippe Hetroy). [Docs] Add some documentation to Python.html and SWIGPlus.html, including for example the fact that 'friends' are now supported. 02/21/2005: wsfulton [PHP] Patch from Olly Betts, so that wrappers compile with Zend thread safety enabled. 02/17/2005: wsfulton Memory leak fix in some of the scripting language modules when using default arguments in constructors. The scripting language was not taking ownership of the C++ object memory when any of the constructors that use default arguments was called. 02/16/2005: wsfulton SF #1115055: Failed make install. Patch from Rob Stone. 02/16/2005: wsfulton [Java] SF #1123416 from Paul Moore. Correct memory allocation for STRINGARRAY typemaps in various.i. 02/15/2005: wsfulton Disabled typemap search changes for now (see entry 19/12/2004). It breaks old typemaps, lengthens the execution time by about 25% and introduces inconsistencies. 02/15/2005: wsfulton swig -help follows other software by printing to stdout instead of stderr now. swig -version also displays to stdout instead of stderr now. Behaviour reported by Torsten Landschoff. 02/15/2005: wsfulton [Ruby] Fix for the less commonly used ordering of %include and #include, so that the generated code compiles. Bug reported by reported by Max Bowsher. %include foo.h %{ #include foo.h %} 02/15/2005: wsfulton [C#, Java] SWIG_exception macro will now return from unmanaged code / native code as soon as it is called. Fixes possible JVM crashes and other code unexpectedly being executed. Note SWIG_exception is only occasionally used by SWIG library writers, and is best avoided by SWIG users. 02/15/2005: wsfulton [C#, Java] Typemaps can now be targeted at global variable names and static member variable names. Previously the typemaps for the setters were ignored, for example: %typemap(in) int globalint "..." int globalint; 02/13/2005: mkoeppe (Matthias Koeppe) [Guile] Add %typecheck for SWIGTYPE, add %typecheck for ptrdiff_t, fix typemaps for size_t. [Pike] Merge patch from Torsten Landschoff for improved Pike configuration. 02/12/2005: mkoeppe (Matthias Koeppe) New configure switches --without-tcl, --without-python etc. allow to disable the search for installed languages. 01/31/2005: wuzzeb (John Lenz) - Add DohSortList to DOH - Improve the runtime type system: + Speed. Type loading is now O(n log n) instead of O(N^2), which for large modules is a huge improvement. + A whole bunch of functions in swigrun.swg no longer need the swig_type_list_handle passed to them. The only one left is TypeQuery. This also makes runtime.swg a lot smaller. + Split up swig_type_info structure into two structures (swig_type_info and swig_cast_info) + Store a pointer to a swig_type_info rather than just the type name string in the linked list of casts. First off, this makes the guile module a little faster, and second, the SWIG_TypeClientData() function is faster too. + Add the idea of a module into the type system. Before, all the types were stored in one huge linked list. Now, another level is added, and the type system stores a linked list of modules, each of which stores an array of types associated with it. + For more information of how the runtime type system now works, please see Doc/Manual/typemaps.html and Doc/Devel/runtime.txt - Update all language modules to use the new type system. The changes to each language module are minor. All languages are now able to use runtime.swg for external access to the type system. Before only python and perl did. - [guile, mzscheme, ocaml, and php4] These languages opened up the init function inside the .cxx code, and any code in the .swg files in the init section was inside this function. This was a problem for swiginit.swg, which needs to be inserted before the SWIG_init function is opened. Thus I changed these languages to be like python or perl, where the init function is declared in the .swg file. - [Ruby] Instead of moving the init function to the .swg file, I added a new section initbeforefunc, and then added %insert(initbeforefunc) "swiginit.swg" - [MzScheme] Fix enums and fix Examples/Makefile.in so that if multiple -I arguments are specified in the INCLUDES variable, each gets a ++ccf. - [Guile GH] Update Guile GH to use the new type system. See Doc/Manual/Guile.html for how smobs are now used. 01/11/2005: wsfulton [C#] New typemap called 'csconstruct'. The code in this typemaps was previously hard coded and could not be customised by a user. This typemap contains the code that is generated into a proxy class's constructor. [Java] New typemap called 'javaconstruct'. The code in this typemaps was previously hard coded and could not be customised by a user. This typemap contains the code that is generated into a proxy class's constructor. Another typemap named 'javaconstruct_director' is used instead when the proxy class is a director class. [C#, Java] If a C++ class did not have a default constructor, a protected default constructor was automatically generated by SWIG. This seems is unnecessary and has been removed and thereby giving the user almost complete control over the generated code along with the new typemaps above. 19/12/2004: mmatus [Disabled, see entry 02/15/2004] - Fix typemap search, now the "out" typemap search is done as follows int *Foo::foo(int bar) -> int *Foo::foo(int bar) -> int *Foo::foo -> int *foo(int bar) -> int *foo -> int * then, now you can be more specific, and define /* apply only for 'Foo::foo' method */ %typemap(out) int * Foo::foo(int *bar) ...; /* apply for all 'foo' functions/methods */ %typemap(out) int * foo(int *bar) ...; %inline { struct Foo { int *foo(int *bar); }; } 15/12/2004: mmatus - More fixes for templates and template default args. See template_default.i for scary cases that now are supported, besides the already ugly STL/std cases. - Cosmetics and more use of 'const' where it was implicit. - Other fixes for OSS, which is now working again with 1.3.25. Version 1.3.24 (December 14, 2004) ================================== 12/12/2004: wuzzeb (John Lenz) [Chicken] Fix a bunch of bugs relating to -proxy support + non-class variables now export properly using -proxy + static member functions now export properly using -proxy + member class variables now export properly using -proxy + added a -nounit argument, which does not export the (declare (unit ...)) + correctly install swigclosprefix.scm + constants (enums, defines) now correcly export when using -proxy 12/11/2004: wsfulton configure fix for when more than one version of jni_md.h is found in the Java include directory (was generating lots of sed error messages). 12/08/2004: wsfulton [Java] Fixes to arrays_java.i so that one can apply the array typemaps to functions taking pointers as input, eg %include "arrays_java.i" %apply int[] {int*}; void foo(int *a); 12/05/2004: wsfulton [Java] Director mods contributed by Scott Michel. New typemaps directordisconnect and directordisconnect_derived for the swigDirectorDisconnect() method. Also fix to get the javapackage typemap working again. 12/05/2004: mmatus - Finishing the fixes for templates + default template args + specializations. - [Python] Now we use the new templates + default template args in the std/STL library. That means the internal swig files are getting uglier since we now support the original declarations: template > class vector { .... }; template, class _Alloc = std::allocator > > class map { .... }; and the user can use the %template directive as %template() std::vector; %template() std::vector >; %template() std::vector >; Now we are closer to the cleaning/rewriting of the python std/STL support, such that we recover support for MSVC++ 6.0, and we can add support for other languages too. 12/02/2004: wsfulton [Java] Fix for directors when wrapping methods using a member enum and typesafe/proper enums enabled. 12/01/2004: mmatus - Fix typemaps to work with templates and default template args, ie template struct Foo { }; %typemap(in) Foo *{...} %typemap(out) Foo *{...} Foo * foo( Foo *f1, Foo *f2); now 'f1', 'f2' and the return value resolve the provided typemaps properly. This is highly needed for proper STL support, see new std_basic_string.i, std_sstream.i, etc. - Added std_sstream.i, and fix std_basic_string.i to use the new typemaps + template def. arg mechanism. Also, added the needed std_alloc.i. Now, all the containers can be modified to support std::allocator, like in: template > class vector { public: .... }; This change is only completed by now for basic_string. - Fix for smart pointers + members + extensions: %extend Foo { int extension(int i, int j) { return i; } int extension() { return 1; } } %inline %{ class Foo { public: int y; static const int z; }; class Bar { Foo *f; public: Bar(Foo *f) : f(f) { } Foo *operator->() { return f; } }; now you can f = Foo() f.y = 3 a = f.z f->extension() b = Bar(f) b.y = 3 a = b.z b->extension() - Other small errors fixes, mostly python. 11/25/2004: wsfulton [Java] Numerous director bug fixes so that the correct java types and canonicalized types in the JNI code are emitted. Use of the $javaclassname special variables in the director typemaps now consistent with the non-director typemaps. The types used for typemap lookups are also corrected in a few places. If you previously had your own director typemaps, ensure they are using the correct C++ type. *** POTENTIAL INCOMPATIBILITY FOR JAVA DIRECTORS *** 11/25/2004: wsfulton const enum SWIGTYPE & typemaps added. These wrap const enum references as if they were passed by value. Const enum references thus work the same as const reference primitive types such as const double &, const int & etc. Typemaps added for Java, C#, Ruby, Tcl, Perl and Pike. 11/25/2004: wsfulton [Java, C#] New special variable: $*javaclassname, similar to $javaclassname and $&javaclassname. The new one removes a pointer from the C type before obtaining the Java class name. One or more of $javaclassname, $&javaclassname or $*javaclassname may now appear in a typemap. Likewise for C# using csclassname instead of javaclassname. 11/25/2004: wsfulton The last vestiges of enums being handled as integers removed from the internals. The wrapper methods use the enum type rather than an int now. The net result is added type safety for enums when handled as pointers, references etc. Previously in situations such as a method taking a pointer to an enum, a pointer to an int or a pointer to an enum of some other type could inadvertantly be passed to the method. This is now fixed as the descriptor for an enum is no longer based on an int, but the enum type instead. Anonymous enums are still handled as integers. The consequence for scripting language users in correct usage of enums should not be noticeable. There is no change for any of the languages where enums are passed by value - most of the scripting languages will still accept an integer for an enum value and the strongly typed languages still use either typesafe enums, integers or proper enums depending on what the user configures. For Java and C# users a change in the typewrapper class name has occurred (for enum pointers, references etc). For example: enum Numbers { one=1, two }; enum Numbers* number(); In Java and C# this must now be coded as SWIGTYPE_p_Numbers n = modulename.number(); rather than SWIGTYPE_p_int n = modulename.number(); *** POTENTIAL INCOMPATIBILITY *** 11/21/2004: wsfulton/mmatus Added missing deprecated warning for %name and remove remaining %name usage in the SWIG libraries. 11/21/04: mmatus - [Python] Adding the PySwigObject to be used for carrying the instance C/C++ pointers. This is used instead of string and PyCObjects. The new PySwigObject is even safer than PyCObject, and more friendly than plain strings: now you can do print a.this print str(a.this) _00691608_p_A print long(a.this) 135686400 print "%s 0x%x" % (a.this, a.this) _00691608_p_A 0x8166900 the last one is very useful when debugging the C/C++ side, since is the pointer value you will usually get from the debugger. Also, if you have some old code that uses the string representation "_00691608_p_A", you can use it now again using 'str(ptr)', or by calling 'str = PyObject_Str(obj)' in the C/C++ side. This change is mainly for nostalgic swig users that miss the string representation, but also allows to say again if a.this == b.this: return "a is b" and well, since the change were really simple, maybe in the future we will be able to do next = a.this + 1 or add native python iteration over native C/C++ arrays, ie, no need to create/copy new tuples when returning and array or vector. Also, a PySwigPacked object was adding to carry a member method pointer, but this is probably a temporal solution until a more general object for methods is added. Be aware that to simplify maintaining and compatibility with other tools, the old string and PyCObjects representation could disappear very soon, and the SWIG_COBJECTS_TYPES or SWIG_NO_OBJECT_TYPES macros will have no effect at compilation time. Still, the three mechanisms are present in the code just for testing, debugging and comparison purposes. 11/21/04: mmatus - [Python] Adding back support for using the swig runtime code inside the user code. We just allow the user to include the minimal code needed to implement the runtime mechanism statically, just as in done in the swig modules. To use the swig runtime code, for example with python, the user needs include the following: #include // or using your favorite language #include #include // or using your favorite language #include the files swigrun.swg, pyrun.swg and runtime.swg can be checked out by using swig -co, or they can simply be found by adding the swig lib directory to the compiler include directory list, for example SWIGLIB=`swig -swiglib` c++ -I${SWIGLIB} .. of better, using the CPPFLAGS, but that depends on your environment. This change can be ported to the other languages too, you just need to isolate the needed runtime code in a single file like 'pyrun.swg', and provide the SWIG_Runtime_GetTypeList() method. Look at the Lib/python/pyrun.swg file and the Examples/python/swigrun example. 11/15/04: mmatus - Fix mixed_types.i + gcc-3.4, ie, arrays + references + typedefs - Fix multidim arrays + typedefs,ie typedef char character[1]; typedef character word[64]; - Process protected/private bases in the same way before we process protected/private members, ie, we check for constructors, operator new, virtual members, etc. - Fix Ruby/Java to work (or ignore) multi-inheritance + directors. Allow other languages to define if it is supported or not. - Now you can run SWIG_FEATURES="-directors -dirprot" make check-ruby-test-suite make check-python-test-suite make check-java-test-suite make check-ocaml-test-suite and you will get only 'real' errors. ruby and python compile with no errors, java shows some problems. Version 1.3.23 (November 11, 2004) ================================== 11/05/2004: wsfulton Patch #982753 from Fabrice Salvaire: Adds dependencies generation for constructing makefiles. New command line options -MF -MD -MMD to work with the current options -M and -MM. These options are named the same and work the same as in gcc. 11/05/2004: wsfulton %ignore/%rename changes for methods with default arguments to mirror %feature behaviour. See previous entry. *** POTENTIAL INCOMPATIBILITY *** 11/04/2004: wsfulton %feature improvements for fine tuning when wrapping methods with default arguments. Any %feature targeting a method with default arguments will apply to all the extra overloaded methods that SWIG generates if the default arguments are specified in the feature. If the default arguments are not specified in the feature, then the feature will match that exact wrapper method only and not the extra overloaded methods that SWIG generates. For example: %feature("except") hello(int i=0, double d=0.0); void hello(int i=0, double d=0.0); will apply the feature to all three wrapper methods, that is: void hello(int i, double d); void hello(int i); void hello(); If the default arguments are not specified in the feature: %feature("except") hello(int i, double d); void hello(int i=0, double d=0.0); then the feature will only apply to this wrapper method: void hello(int i, double d); and not these wrapper methods: void hello(int i); void hello(); This has been introduced to make %feature more powerful to ease the migration to new default arguments wrapping approach. *** POTENTIAL INCOMPATIBILITY *** If you previously had a %feature and didn't specify the default arguments, you will have to add them in now or you can obtain the original behaviour by using %feature("compactdefaultargs"). 11/04/2004: wsfulton [C#] Typemaps for std::vector added into std_vector.i. The proxy classes generated are modelled on the .NET ArrayList class. This isn't quite ready for general consumption yet, but will work with vectors of primitive types and some classes. 10/3/2004: wuzzeb (John Lenz) [GUILE] The -scm interface is now the default. The old GH interface can still be enabled by passing -gh to SWIG. 10/2/2004: mmatus - More fixes for namespace + class declarations. As an extra bonus, we get %template support for static/members class methods, ie, now you can say: namespace space { struct A { template static void fooT(Y y) { } }; } struct B { template void barT(Y y) {} }; %template(foo) space::A::fooT; %template(foo) space::A::fooT; %template(foo) space::A::fooT; %template(bar) B::barT; %template(bar) B::barT; %template(bar) B::barT; and call A.foo(1) b = B() b.bar(1) note the methods are emitted inside the classes, and hence, the %template name refers to the 'member' method name, not a global namespace name. 10/31/2004: mmatus - Solve namespace + class declarations, as in namespace foo { struct Bar; struct Foo { }; } struct foo::Bar : Foo { }; see namespace_class.i for more examples. - Fix %template directive to properly use namespaces, including the case: namespace one { template struct Ptr {}; } namespace one { struct Obj1 {}; typedef Ptr Obj1_ptr; %template(Obj1_ptr) Ptr; } namespace two { struct Obj2 {}; typedef one::Ptr Obj2_ptr; %template(Obj2_ptr) one::Ptr; } this is done by using the namespace name 'one' to create a namespace node to emit the template instantiation, just as before, but the template parameters are resolved and qualified in the current namespace ('one' or 'two'). This is same way that typedef works. This resolve the smart_pointer_namespace2.i case, and at the same time, several other ones where before swig was generating the "Can't instantiate template 'xx' inside namespace 'yy'" error message. In fact, that error doesn't exist anymore. You can only get an error if you use a bad namespace name or so. 10/30/2004: mmatus - [ruby] Directors fixes: - enums and std::strings are working now (several reports in bug track system) - added patch 1025861 for director + exceptions *** Attention ***: ruby with directors + protected members work with version 1.7+. Older versions seems to have a broken signature for'rb_protect'. If you need to use an old version, look at http://excruby.sourceforge.net/docs/html/ruby__hacks_8hpp-source.html for workarounds. - [ruby] Fix memory allocation problem in typemap (bug 1037259) - [tcl] Fix (enums|constants) + namespace option (reported by jason.m.surprise@intel.com). - [perl] Add patch 962168 for multiple inheretance - Fix 'defined' as variable name. 10/29/2004: wsfulton Seg fault fix for global scope operator used for friend methods: class B { friend void ::globalscope(); ... }; 10/28/2004:mmatus - Added module and swig option "templatereduce" to force swig to reduce any type needed with templates, ie, in these cases %module("templatereduce") test template struct A { }; typedef int Int; %template(A_Int) A ==> %template(A_Int) A typedef B* Bp; %template(A_Bp) A ==> %template(A_Bp) A swig reduces the types Int and Bp to their primitives int and B*. This is closer to the usual compiler resolution mechanism, and it is really needed sometimes when you mix templates + typedefs + specializations. Don't use it if you don't have any problem already, since the type reduction can interfere with some user typemaps, specially if you defined something like typedef int Int; %typemap(in) Int ...; in this case, when you use the "templatereduce" option, swig will ignore the user typemap, since the "typedef int Int" will take precedence, and the usual "int" typemap will be applied. Note that the previous case is not common, and should be avoided, ie, is not recommended to use a typedef and a typemap at the same time, specially if you are going to use templates + specializations. - Directors: virtual destructor is always emitted now, this doesn't cause any harm, and could solve some nasty and mysterious errors, like the one mentioned by Scott. also the destructor is not in-lined, so, that can solve some other mysterious errors when mixing directors + imports + embedded applications + some specific compilers. 10/27/2004: wsfulton [C#] typemaps.i library file with INPUT, OUTPUT and INOUT typemaps added. 10/27/2004: wsfulton [Java] std::wstring typemap fixes in std_string.i from Russell Keith-Magee. 10/25/2004: mmatus - Using + namespace is working now (using_namespace.i). - Derived + nested classes is working now (deriver_nested.i), but of course, we are still waiting for the nested class support. - Directors: - unnamed parameters support, - protected constructor support (automatic and with dirprot mode), - detection of really needed protected declarations (members and constructors) now is done automatically. Even if you don't use the 'dirprot' mode, swig will wrap what is minimally needed (and protected) for the code to compile. what is public, as usual, is always wrapped, and if you use the 'dirport' - Final fixes for the OSS to compile with SWIG 1.3.23 (my very very ugly C++ + templates + everything mounters wrap). 10/25/2004: wsfulton [C#] New commandline option -dllimport. This enables one to specify the name of the DLL for the DllImport attribute. Normally this name comes from the module name, so now it is possible to override this: swig -csharp -dllimport xyz example.i will generate for all the wrapped PInvoke methods: [DllImport("xyz", EntryPoint="...")] public static extern ... The wrappers from many different SWIG invocations can thus be compiled into one DLL. A new special variable $dllimport can also be used in typemaps, pragmas, features etc. This will get translated into the value specified by -dllimport if specified, otherwise the module name. 10/22/2004: wsfulton [Java] Patch #1049496 from Scott Michel fixes directors methods with enums when wrapped with typesafe or proper Java enums. 10/21/2004: wsfulton Fixes for default arguments in director constructors (Python, Ruby, Ocaml). 10/21/2004: mmatus - [Python] Add the '-cpluscast' option to enable the 'new' C++ casting operators, such as 'static_cast', inside the typemaps. By default swig use the old C cast style, even when parsing C++. - [Python] Add the '-new_vwm' option to enable the new SwigValueWrapper mode. Now this is mainly for testing that the typemaps are really safe for any future solution, but you can use it if you have a very strange error with default cosntructors missing + %apply + %typemap, and if everything else fails (see valuwrapper_opaque.i for alternative and current solutions). If you are a user that don't know what is SwigValueWrapper, don't even try it. - [Python] Add the '-noh' option to be used with directors and when you prefer to disable the generation of the director header file. If not used, swig will work as usual generating both the wrap.cxx and wrap.h files. If you use it, swig will only generate wrap.cxx. 10/21/2004: wuzzeb (John Lenz) - If you define SWIG_TYPE_TABLE when compiling a wrapper file, the runtime types will be stored in the given type table name. Using this, you can seperate different modules to share their own type systems. -DSWIG_TYPE_TABLE=Mytable - [Python] If you define SWIG_STATIC_RUNTIME then the type information will be static to this wrapper. Nothing will be shared with any other modules - [Python] If you define SWIG_LINK_RUNTIME, then instead of using the new way of sharing type information, the wrapper will expect to be linked against the Lib/linkruntime.c file. Any modules compiled with SWIG_LINK_RUNTIME and linked against linkruntime.c will all share type information. 10/20/2004: mmatus - [Python] Initial fix for python/import example. Please update the Makefile (autoconf, configure, etc, expert), since now probably is only working with g++, icc and a few other compilers that have the -shared option. We need to create additional shared libraries for the virtual destructors. Old and usually forgotten C++ requirement. Same fix need to be used in perl, I think. - [Python] Fix generation of header file for directors, now directors.swg is also included, so, it can be really used from C++, and it solves some problem with compiler that require that, even with the simple swig inclusion. - [Python] Reordering the methods and moving some bodies outside the class declaration. This is needed due to some gcc-2.96 internal compiler errors. It seems the PYTHON class is getting too large to been declared and defined at the same time. - Add the -oh option to change the output header file name if needed: swig -c++ -python test.i -o test.CC -oh test.HH this is mainly needed when using directors, and if the current default header file name is not good for you, which is generated as follow: swig -c++ -python test.i => test_wrap.h swig -c++ -python test.i -o test.CC => test.h 10/20/2004: wsfulton 1) Compact default arguments feature added. This feature allows one to use the default argument code generation that was used in SWIG-1.3.22 and earlier versions. It produces more compact wrappers as only one wrapper method is generated for any method with default arguments. So the advantage is it generates less code but has the original limitations, like it it does not work with all default arguments and default arguments cannot be taken advantage of in the strongly typed languages (C# and Java). It is implemented via the usual %feature mechanism: %feature("compactdefaultargs"); 2) Keyword arguments (kwargs) are working again for default arguments in the languages that support it, ie, Python and Ruby. The new default argument wrapping approach using overloaded methods cannot support kwargs so the compact default argument feature is automatically turned on when kwargs are specified, by %feature("kwargs"). 3) Compact default arguments are also automatically turned on when wrapping C (not C++) code. This is to support the bizarre notion of default arguments for C code. 10/20/2004: wsfulton Overloaded templated functions in namespaces also working now. Templated functions with default arguments in namespaces too. 10/19/2004: mmatus - Allow to disable the new SwigValueWrapper mechanism, if you add the following line in your language main. /* Turn on safe value wrapper use mode */ Swig_value_wrapper_mode(1); Now is only active in python. All the other languages are using the old resolution, but they can also use the "valuewrapper"/"novaluewrapper" features to fix some of the old broken cases. Note, however, that not all the broken cases can be solved in that way. The new mechanism seems to be working fine in perl, ruby and tcl, but failing in some typemaps in java. Hence, is upto the language maintainer to test it, and decide to enable it or not. Look at the valuewrapper_opaque.i for examples. - Fix more SwigValueWrapper cases when the new mechanism is active. Now it also check for local typemap variables, see valuewrapper_opaque.i for an example when this is needed. But again, this extra checking will only be activated when using the new value wrapper mode. - [Python] Fix variable wrapping of classes with private assign operators. It should be easy to fix in all the other modules, instead of checking if (!Getattr(n,"immutable")) ... you need to verify if (is_assignable(n)) ... Look at the private_assign.i for an example. 10/18/2004: mmatus - %features "director"/"nodirector" now work as expected. - General fixes in %feature to resolve function decl properly, %feature("hello") foo(); char foo() -> f() // was working char *foo() -> f().p // it wasn't - Template + specialization + default template args now is working, (don't confuse with template + default arg values, that was solved before), now this ugly case is working: template > struct Vector { Vector(T a){} }; template <> struct Vector { Vector(){} int foo() { return 0; } }; %template(V_c) Vector >; %template(V_i) Vector; // picks Vector > %template(V_d) Vector; // picks the specialization this is needed for automatic STL support (later will be). - Fix the template + typedef errors in test-suite, which probably will fix another group of strange template + namespaces + typedefs errors. - %warnfilter is working better now, parser.y tries to use them when needed. - **** New default type resolution method (stype.c) ***** It preserves the original mixed types, then it goes 'backward' first deleting the qualifier, then the inner types, for example: typedef A *Aptr; const Aptr&; r.q(const).Aptr -> r.q(const).p.SWIGTYPE r.q(const).p.SWIGTYPE -> r.p.SWIGTYPE r.p.SWIGTYPE -> r.SWIGTYPE r.SWIGTYPE -> SWIGTYPE enum Hello {}; const Hello& hi; r.q(const).Hello -> r.q(const).enum SWIGTYPE r.q(const).enum SWIGTYPE -> r.enum SWIGTYPE r.enum SWIGTYPE -> r.SWIGTYPE r.SWIGTYPE -> SWIGTYPE int a[2][4]; a(2).a(4).int -> a(ANY).a(ANY).SWIGTYPE a(ANY).a(ANY).SWIGTYPE -> a(ANY).a().SWIGTYPE a(ANY).a().SWIGTYPE -> a(ANY).p.SWIGTYPE a(ANY).p.SWIGTYPE -> a(ANY).SWIGTYPE a(ANY).SWIGTYPE -> a().SWIGTYPE a().SWIGTYPE -> p.SWIGTYPE p.SWIGTYPE -> SWIGTYPE before it always stops after finding ref/pointer/enum/array/etc. Now, then, you can define (use and apply) 'higher' typemaps such as: %typemap(in) SWIGTYPE* const& %typemap(out) char FIXSIZE[ANY] %typemap(in) SWIGTYPE* const& %typemap(in) const enum SWIGTYPE& %typemap(in) SWIGTYPE[ANY][ANY] %typemap(in) const char (&)[ANY] It is possible with this change that previous typemaps that were defined (but ignored), now will start to work. Also, it is necessary check for the '%typemap(varin) SWIGTYPE[]', before it was usually not defined (but char[] was), and that can produce some inconsistencies. *** POTENTIAL INCOMPATIBILITY *** This change was needed for STL, since std::vector std::vector, etc, will always generate methods that mix const references with the vector type. Now that is working, all the std::container specialization will not be needed anymore, well, in theory. In the practice, everythin is working as before until the proper mixed types are defined and the libraries simplified to use them. - Change the behavior of extern "java"/"fortran"/"etc", now swig produces a warning, and use extern "C" instead. The warning can also be disable with the "-w 313" flag. (WARN_PARSE_UNDEFINED_EXTERN). - SwigValueWrapper is now more selective (lang.cxx). [Perl/Tcl] - Fix some typemaps (perl/tcl) to work properly with SwigValueWrapper. This was not a problem with SwigValueWrapper, but with the typemaps that now are safe to use with %apply. [Python] - Fix %callback/%pythoncallback work now as before after the def args changes. Also, %callback now is an alias for %pythoncallback, so, they do the same. [Python/Ruby] - %callback is more usable and uniform: %callback("%s_cb") foo(); // for both, python/ruby %callback("%s_cb"); // for both, python/ruby %callback(1) foo(); // only in python. 10/17/2004: arty [OCAML] - Tweak to enum typing for soundness in the presence of multiple modules. - global functions are now unambiguous in multiple loaded modules. - Fixed test case code to build multimodule test cases correctly. - There is no way to share overload resolution across modules because of soundness issues. If the user wants to call some function foo from an arbitrary module bar, they will have to use Bar._foo to call it correctly. Later I will fix the camlp4 module to do something clever in this case. - Promided performance overhaul of class mechanism. - Removed symbol hack for ocaml-3.07 and below which is not needed for ocaml-3.08 and above. 10/16/2004: wuzzeb (John Lenz) [CHICKEN] - Completly change how chicken.cxx handles CLOS and generic code. chicken no longer exports -clos.scm and -generic.scm. The clos code is exported directly into the module.scm file if -proxy is passed. - The code now always exports a unit. Running the test-suite is now majorly broken, and needs to be fixed. - CLOS now generates virtual slots for member variables similar to how GOOPS support works in the guile module. - chicken no longer prefixes symbols by the module name, and no longer forces all names to lower case. It now has -useclassprefix and -closprefix similar to how guile handles GOOPS names. 10/16/2004: wsfulton Templated functions with default arguments working with new default argument wrapping approach. The new approach no longer fails with the following default argument pattern (previously failed with some primitive types, like unsigned primitive types): template int foo(const T& u = T()); %template(foo) foo; This relies on the templated function overloading support just added, so all the combinations of overloading by template parameters and normal parameters as well as overloading with default parameters works. 10/16/2004: wsfulton Added support for the large range of templated function overloading that C++ supports. - Overloaded templated functions, eg template int overload(T t); template int overload(T t, const T &r); - Fixes where the templated type is not used in the parameter list, eg template void xyz(); template<> void xyz(); - Fixes for overloading of plain functions by a templated function: void abc(double d); template void abc(T t); - Overloading by templated parameters fixed: template void foo(T t) {} template void foo(T t, U u) {} %template(foo) foo; - All combinations of the above also working including specializations, eg: void abc(double d); template void abc(T t); template<> void abc(double t); template<> void abc(int t); 10/16/2004: wuzzeb (John Lenz) - Remove the ability to share type information by using c linking. All type sharing happens through a global variable in the target language. + Remove SWIG_NOIMPORT, SWIG_RUNTIME, and related defines. + Deprecate -runtime, -noruntime command line options + Update test-suite common.mk to correctly build multicpptest + Remove reference to precommon.swg + Update the guile_gh interface to share data by a global var instead of c linkage. - Remove Advanced.html, since everything in it is now obsolete 10/09/2004: mmatus - Split the python std/STL C++ library files, now all the language independent definitions are under the directory Lib/std and hence, can be used from other languages. - Add more documentation to the Python STL, and clean unnecessary code. - Add initial C99 complex support, and some fixes for long double. 10/08/2004: mmatus - Fix the SwigValueWrapper for opaque types, now it is applied for opaque templates and classes, for which we don't know if there is or not a default constructor, ie struct A { A(int); }; Still, if you know that you class has a default constructor, and for some very very particular reason you want to avoid the SwigValueWrapper, and you don't want or can't expose the class to swig, now you can say %feature("novaluewrapper") A; class A; or the other way around, if the class has a default constructor, but you want to use the value wrapper, you can say %feature("valuewrapper") A; struct A { A(); .... }; - Fix for char > 128, ie const char tilde_a = '\341'; - Add patch 1041858 for $lextype, which carries the literal type of a symbol. See lextype.i in the test-suite for more details. 10/07/2004: wsfulton {Ruby, Java] Fix director + 'empty' throws struct A { A() throw(); virtual ~A() throw(); int foo() throw(); }; 10/06/2004: wuzzeb (John Lenz) [TCL] - Fix bug reported by William A. Hoffman propagating clientdata between modules. Added clientdata_prop.multicpptest to check for this bug. The fix involved the following changes: + SwigType_clientdata_collect does not need to check types in r_resolved because we only want to propagate clientdata to typedefed classes, and r_mangled already takes care of typedefs. + SWIG_TypeRegister now copies the clientdata field correctly + Move SWIG_Guile_PropagateClientData function from guile module into common.swg, because we need to call it from both guile and tcl. + Add base_names to swig_class to delay the lookup of bases. SWIG now exports the base names and only when the base swig_class is needed is SWIG_TypeQuery(name)->clientdata looked up. - conversion_ns_template testsuite test was failing because the name of the wrapped constructor function was not calculated correctly for structs. Fixed. 10/06/2004: wsfulton Fixes for default arguments used in directors - in virtual methods and director constructors. 10/06/2004: mmatus Fix the __cplusplus macro, and bug 1041170. Now it is working as supposed, ie, you can safely use #ifdef __cplusplus ... all over swig, including inside %defines and %{ %} bodies. *** POTENTIAL INCOMPATIBILITY *** The old trick of using #if __cplusplus doesn't work any more. So, if you have your own typemaps using that syntax, you will need to migrate them to use "#ifdef __cplusplus". 10/05/2004: wuzzeb (John Lenz) - Reorganize how runtime type information is stored and shared between modules. For chicken and mzscheme, I removed the ability to use runtime libraries, while perl, tcl, python, and ruby default to using the new method but can go back to the old method by declaring SWIG_ALLOW_RUNTIME. - line 582 in mzscheme.cxx was generating a segfault on imports.multicpptest, so I fixed it. 10/05/2004: wsfulton Fixes for %extend and overloaded static methods with default arguments. 10/05/2004: mmatus - [python] Fix director + method with 'empty' throw, ie struct A { virtual int foo() throw(); }; other languages should also easy to fix, look for Getattr(n,"throw") in python.cxx. - Fix director + destructor with 'empty' throw struct A { virtual ~A() throw(); }; - Now SWIG_FEATURES parse all and the same options you can pass to swig in the command line. - New command line flag: -features , as in swig -features autodoc=3,director ie, any global feature can be initialized from the command line. This is mainly for testing, but users can also take advantage of it. 10/04/2004: mmatus - Properly qualify type in syntax as 'long(2)' or 'Foo()', this solve old problem with default args, and probably other problems around. However, the default arg problem was also already solved by William (see bellow). - Fix feature_set and feature_get methods. Before they look from particular to general and keep the first feature found. This didn't work well with templates. Now the methods look from general to particular, and override any found feature. - Previously a feature could not be applied to constructors or destructors that weren't explicitly declared in the class. This is now fixed, for example: %feature("featurename") Foo() "..." %feature("featurename") ~Foo() "..." class Foo { // implicit Foo() and ~Foo() }; - Fix missing features for default const/dest, by really 'creating' the methods and applying the features. - Fix return_const_value.i case by adding SwigValueWrapper specialization. - Fix %extend + overload, including overloading actual class methods. - Adding more cases in related files in the test-suite. 10/04/2004: wsfulton Changes to the way default arguments are wrapped. Previously a single method was generated for each method that had default arguments. If a method had 5 arguments, say, of which 1 had a default argument then the call to the wrapped method would pass 5 arguments. The default value was copied into the wrapper method and used if the scripting language passed just 4 arguments. However, this was flawed as the default argument sometimes does not have global access, for example SWIG would generate code that couldn't compile when wrapping: class Tricky { public: void foo(int val = privatevalue); void bar(int val = Tricky::getDefault()); private: static int getDefault(); enum { privatevalue = 200 }; }; Also bugs in resolving symbols generated code that wouldn't compile, for example (probably fixable though): namespace Space { class Klass { }; Klass constructorcall(const Klass& k = Klass()); } The approach also does not work for statically typed languages (C# and Java) as these languages do not allow methods to have variable number of arguments. Although C# has a mechanism to pass a variable number of arguments they must be of the same type and are more like varargs. The new approach solves the above problems and wraps methods with default arguments as if the method was overloaded. So SWIG will now treat void foo(int val=0); as if it had parsed: void foo(int); void foo(); The code generated is then exactly the same as if SWIG had parsed the two overloaded methods. The scripting languages count the arguments passed and call the appropriate method, just like overloaded methods. C# and Java are now able to properly wrap methods with default arguments by generating extra methods, again as if the method was overloaded, so for: void bar(string s="hello", double d=10.0, int i=0); the following proxy methods are generated: void bar(string s, double d, int i); void bar(string s, double d); void bar(string s); void bar(); The new approach comes with a couple of minor knock on effects. 1) SWIG support for default arguments for C (not C++) code no longer works. Previously you could have this interface: %{ void foo(int val); %} void foo(int val=0); and call the wrapped method from a scripting language and pass no arguments whereupon the default of 0 was used. You can get the same behaviour for C code by using the "default" typemap: %typemap(default) int val "$1 = 0;"; %{ void foo(int val); %} void foo(int val); or you could of course compile your code as C++ if you want C++ features :) : %{ void foo(int val=0); %} void foo(int val=0); A couple of SWIG's libraries used this C extension and these have been modified to use the "default" typemap. The "default" typemap is thus unchanged (and still is not and is not fully supported by C# and Java, and is likely to remain so). 2) All features (%feature, %rename, %ignore etc) no longer work as if the method with default arguments is just one method. For example, previously %ignore foo(int); would have ignored the method completely. Now it will only ignore foo(int) but not the extra foo() method. Instead use: %ignore foo; to ignore them all. or %ignore foo(int); %ignore foo(); This of course allows one to fine tune the wrapping, for example one could use: %rename(fooint) foo(int); %rename(foodefaults) foo(); void foo(int val=0); and call them from any language like so: fooint(200) foodefaults() or for example ignore the extra overloaded method, so the defaults cannot be used: %ignore foo(); void foo(int val=0); *** POTENTIAL INCOMPATIBILITY *** 10/2/2004: mmatus [Python] - More cleaning up and uniformation on the Python Lib - Added Robin's docstring patch, plus some fixes, plus some extensions, see autodoc.i example in the test-suite, and try using %feature("autodoc","extended"). This patch is not a complete solution for the documentation problem, just enough to inform python about the parameter list. The expected swig documentation support is far far away yet. 10/1/2004: mmatus - Fix the %callback feature (only used in ruby and python examples, by now, but it should be generic), now member callbacks are working again - Fix wrapping of functions pointers like std::ostream& std::endl(std::ostream&); ie, the ones that return references or enums. [Python] Add the %pythoncallback directive, which is an improved version of %callback, ie, %pythoncallback(1) foo; %pythoncallback(1) A::bar; %pythoncallback(1) A::barm; int foo(int a) { return a; } struct A { static int bar(int a); int barm(int a); }; int foobar(int a, int (*pf)(int a)); in python you can use foo(2) foobar(2,foo) A.bar(2) foobar(2,A.bar) ie, no additional pointer elements are created, and the original 'foo' and 'A.bar' can be used as parameters. In the case of member fucntion however, still you need to use the special variable Class::_cb_ptr, ie: foobarm(3, a, A.barm_cb_ptr) we will try to fix this situation also, but later. [Python] Add more elements from the STL library, now you can use import std std.cout << "hello " << 123 << std.endl [Python] Fix in/out return mechanism, now swig will behave as 1.3.21 but using a python list when needed. The problem is that the types std::pair,std::vector,etc, use tuples, and they interfer with the previous inout tuple type. By using lists we solve the conflicts, swig acts as before, but returns a list when more than one parameter are using the OUT typemap. See the new inout.i example in the test-suite. *** POTENTIAL INCOMPATIBILITY FOR PYTHON MODULE *** [Python] Much better error messages for bad arguments, now you always get the argument number where the error occurred. 09/27/2004: wsfulton Patch from Bill Clarke - 1) Warning emitted when -importall and -includeall is used together, with -includeall taking precedence. 2) Ensure SWIGIMPORTED is always defined when a file is being imported with %import. Note that this is not the same as SWIGIMPORT, which gets defined in all generated wrapper files. 09/26/2004: mmatus - add %feature("exceptionclass") to identify a class used as exception. Before swig identified and marked a class using the "cplus:exceptionclass" attribute. However, the class needed to appear on an throw() statement. Now swig keeps trying to identify the exception classes, as before, but it also allows the user to mark a class by using the %feature explicitly. (mostly relevant for python and chicken) [Python] - fix -modern option + exceptions, which mix old class style with the new one. So, we always need to emit the "nonmodern" python code. - add the "python:nondynamic" feature and its handler now if you have %pythonnondynamic A; struct A { int a; int b; }; then, in the python side aa = A() aa.a = 1 # ok aa.b = 2 # ok aa.c = 3 # error, the class can not be extended dynamically. Since this is a feature, you can use %pythonnondynamic; or %pythondynamic; [ Note: %pythondynamic since deprecated ] to force all the wrapped classes to be "nondynamic" ones. The default, as in regular python, is that all the wrapped classes are dynamics. So, careful with your spelling. 09/14/2004: mmatus - Support the -I- option. - Differentiate between %include and %include "file". This fix several corner cases. [Python] Several patches: - Normalize the Lib file names: *.swg internal files, *.i user files. - Fix Char[ANY] typemaps, so they also delete any extra '\0' chars, now they behave as before (1.3.21). Still, you can use the SWIG_PRESERVE_CARRAY_SIZE macro if you need to preserve the original size (see pystrbase.swg). - Add the Char FIXSIZE[ANY] typemaps, to preserve the original C array sizes (see above). Though, you can't use them yet since %apply and arrays are not working together. - Add pyfragments.swg, now the user can add fragments to override the default ones. 09/10/2004: wsfulton Patch from Bill Clarke which fixes spurious preprocessor bug which shows on Solaris and gcc, eg: Warning(202): Could not evaluate '!defined(SWIGJAVA) && !(defined(SWIGCSHARP)' Also fixes a bug where '#if "a" == "b" == 1' wouldn't have worked 09/10/2004: wsfulton Restored multiple build directories for the test-suite. Patch from Bill Clarke. 09/06/2004: wsfulton Added the missing runtime.dsp Visual Studio project files for the import examples to work. Version 1.3.22 (September 4, 2004) ================================== 09/03/2004: wsfulton The swig.m4 macro for use with the Autoconf/Automake/Libtool has been removed and is no longer installed. Please use the new and better maintained version derived from swig.m4 in the Autoconf macro archive. See http://www.gnu.org/software/ac-archive/htmldoc/ac_pkg_swig.html and http://www.gnu.org/software/ac-archive/htmldoc/ac_python_devel.html. 09/01/2004: wsfulton [Perl] Applied patch #1019669 from Christoph Flamm. Adds support for %feature("shadow") in the same way as it works in Python. This enables one to override the generated shadow/proxy methods, including constructors and destructors. For example: /* Let's make the constructor of the class Square more verbose */ %feature("shadow") Square(double w) %{ sub new { my $pkg = shift; my $self = examplec::new_Square(@_); print STDERR "Constructed an @{[ref($self)]}\n"; bless $self, $pkg if defined($self); } %} class Square { public: Square(double w); ... }; 08/31/2004: mmatus [Python] Incompatibility reported by Bill Clarke (llib@computer.org): If you are using Sun Studio 8 (and possibly earlier versions) to compile the output produced by swig 1.3.22rc1, and you are using C++ and STL templates then you need to use either "-runtime" or "-noruntime". If you use neither of these options then you will probably get compiler errors when trying to compile the wrapper file; the error message will be like this: The name SWIG_Python_ConvertPtr[...] is unusable in static swigpy::traits_asptr[...] If you get this error message, you need to regenerate your wrapper file using 'swig -runtime' or 'swig -noruntime'. You shouldn't get this problem with Sun Studio 9. *** POTENTIAL INCOMPATIBILITY FOR PYTHON MODULE *** 08/26/2004: wsfulton [Perl] Applied #932333 from Ikegami Tsutomu. Fixes long long *OUTPUT and unsigned long long *OUTPUT typemaps in typemaps.i. 08/26/2004: wsfulton Applied patch #857344 from Art Yerkes. Workaround for autoconf bug when running 'make install'. 08/26/2004: wsfulton [Perl] Part of patch #982753 applied. This implements a %perlcode directive. It allows one to add Perl code to the generated .pm file. Works the same as %pythoncode. 08/26/2004: wsfulton [Java] Fix for directors when wrapping virtual methods with exception specifications that were not simple types. Previously code was generated that didn't compile, for example when the exception specification was a pointer. 08/25/2004: wsfulton [C#] Typemap fix for methods that return char *. The CLR would incorrectly delete the memory pointed to by char *. Also applied the same correction to the char array typemaps. 08/24/2004: wsfulton Fixes for -fmicrosoft error/warning message display: - End of file (EOF) warning messages not displaying in correct format - Some messages containing a file path were displaying a double backslash instead of a single backslash 08/23/2004: wsfulton Applied patch #1011604 submitted by Charles Schwieters. Fix for 64 bit tcl interpreters. 08/23/2004: wsfulton Fix for bug #875583 - enum forward declarations previously gave a syntax error. 08/23/2004: mkoeppe [Allegro CL] Use typemaps "ffitype" and "lisptype" to determine the FFI type specifiers from the C type. This makes it possible, for instance, to control whether a C "char" argument takes a Lisp character or a Lisp integer value. The default (taking Lisp characters) is done by these built-in typemaps: %typemap(ffitype) char ":char"; %typemap(lisptype) char "character"; If char means an integer instead, use these typemaps: %typemap(ffitype) char ":char"; %typemap(lisptype) char "integer"; 08/22/2004: wsfulton As discussed in bug #772453, the SWIG library directory is now installed into a different default directory. The library used to be installed to /usr/local/lib/swig1.3. It is now in the more usual architecture independent directory and I have additionally used a version specific subdirectory as the library will rarely work with older versions of SWIG. This release will thus use /usr/local/share/swig/1.3.22 by default, which can be tailored as before using './configure --swiglibdir'. 08/17/2004: mkoeppe [MzScheme] Add support to create native MzScheme structures from C structures. To convert a C structure to an MzScheme structure, use the new runtime macro SWIG_NewStructFromPtr in a typemap. Patch from Dmitriy Zavin. 08/12/2004: wsfulton Patch #837715 from Ben Reser to correctly detect Python lib directory on 64 bit systems. 08/12/2004: wsfulton [C# and Java] Prevent memory leaks in the case of early return from wrapper methods using const std::string & parameters. Modified Mark Traudt patch #951565. 08/12/2004: wsfulton Bug #943783 with patch fixes php char * out typemap NULL values. 08/03/2004: Ahmon Dancy [allegrocl] Additional case mode fixes. Also, make sure foreign types are exported. 07/24/2004: mkoeppe [Guile] In -scm mode, SWIG modules now exchange their pointer type information via the Guile interpreter. It is no longer necessary to build a runtime library or to use -noruntime and -runtime etc. The module (Swig swigrun) which was introduced in the change of 05/17/2004 is no longer automatically built. If you need it, run SWIG on the interface file swigrun.i. 07/23/2004: wsfulton [C#] Bug #917601 Mapping C++ bool fix from Mark Traudt 07/23/2004: wsfulton RPM fixes for latest CVS version including removal of runtime library. 07/23/2004: wsfulton Patch #908955 from Robert H De Vries. RPM file generation fix for Fedore Core 1 and Redhat AS2.1. 07/12/2004: wsfulton Patch #864689 from Robin Dunn: This patch corrects two problems in the XML output of SWIG: 1. There were often extra '/>\n' in the output. 2. value attributes were output with '\n' in them but since that is not technically legal most (all?) XML parsers will strip them out. Replacing the '\n' with the ' ' entity reference solves this as that is legal and XML parsers will convert it to a '\n' when reading the values back in. This patch also adds a new global command line option that will allow the parse tree to be written out in XML *after* some other language module has been run, in order to be able to get extra info that the language module puts in the tree. In this way the XML is a post-processed version of the tree rather than a pre-processed version. Command line option is -dump_xml or -xmlout 07/12/2004: wsfulton [Java] Patch from Scott Michel to fix typesafe enums and proper enums with directors. 07/12/2004: wsfulton HTML documentation (makechap.py) file generator missing end of line patch #908951 from Robert de Vries. 07/08/2004: wsfulton The deprecated runtime library build has been removed. This also removes the dependency on Libtool. Libtool is no longer required to build SWIG. The associated -ldflags SWIG commandline option has also been removed. The examples and test-suite testcases that used the runtime library have been updated to use the replacement approach to using SWIG across multiple modules, that is they use the -noruntime and -runtime commandline options, see Modules.html. Effectively they build their own runtime libraries using -runtime. The examples are import and import_template. The test cases are in the imports and template_typedef_import directories. Anyone who wants the original runtime libraries can either run the test-suite or build the examples and use the appropriate shared object/DLL that is generated with the -runtime commandline option. For example libimports_runtime.so (Python calls it lib_imports_runtime.so) is generated after running the 'make imports.multicpptest' testcase in the Examples/test-suite/ directory. Or use libruntime.so / runtime.dll after building the import examples in Examples//import. 07/07/2004: mkoeppe [Allegro CL] Convert character and string literals in constants to CL syntax. Fix FF:DEF-FOREIGN-CALL for mixed-case C functions. 06/27/2004: wsfulton [Java] New feature for Java exceptions with format %javaexception(exceptionclasses). This feature is a slight enhancement to %exception and the only difference is the addition of the exception classes which are generated into a throws clause. The 'exceptionclasses' is a comma separated list of classes which will be added to the associated proxy method's throws clause. The 'exceptionclasses' are specified like the exception classes in the 'throws' attribute in the typemaps. This feature should be used for correctly handling checked exceptions thrown from JNI code. For example: %javaexception("java.lang.Exception") throwException %{ ... convert a std::logic_error into a java.lang.Exception using JNI code ... %} #include void throwException() { throw std::logic_error("Logic error!"); } will generate a method with a throws clause in the module class: public static void throwException() throws java.lang.Exception { ... } 06/27/2004: wsfulton [C#] New %csconstvalue(value) feature directive for use with constants and enums. This works the same way as %javaconstvalue. For C#, this directive is the only way that one can fix wrapping of C/C++ enums with proper C# enums if the enum item's initialiser cannot compile as C# code. This is because Java enums can use a call into C code to initialise the enum item, whereas in C#, the enum value must be a compile time constant. That is, using %csconst(0) cannot be used in C# to initialise the C# enum item via a PINVOKE call. 06/27/2004: wsfulton [Java] New %javaconstvalue(value) feature directive for use with constants and enums. Sometimes the use of %javaconst(1) will produce code that won't compile under Java. If a compile time constant is required, %javaconst(0) is not an option. The %javaconstvalue directive achieves this goal and the value specified is generated as Java code to initialise the constant. For example: %javaconst(1); %javaconstvalue(1000) BIG; %javaconstvalue("new java.math.BigInteger(\"2000\")") LARGE; %javaconstvalue(10) bar; %{ const int bar = 10; %} %inline %{ #define BIG 1000LL #define LARGE 2000ULL enum Foo { BAR = ::bar }; %} Generates: public interface exampleConstants { public final static long BIG = 1000; public final static java.math.BigInteger LARGE = new java.math.BigInteger("2000"); } public final class Foo { public final static Foo BAR = new Foo("BAR", 10); ... } Previously, none of BIG, LARGE or BAR would have produced compilable code when using %javaconst(1). 06/27/2004: wsfulton %feature enhancements. Features can now take an unlimited number of attributes in addition to the feature name and feature value. The attributes are optional and are much the same as the typemap attributes. For example, the following specifies two optional attributes, attrib1 and attrib2: %feature(featurename, attrib1="attribval1", attrib2="attribval2") name "val"; %feature(featurename, val, attrib1="attribval1", attrib2="attribval2") name; 06/27/2004: wsfulton %feature improvements for the syntax that takes the feature value within the %feature() brackets. The value specified is no longer restricted to being just a string. It can be a string or a number. For example, this is now acceptable syntax: %feature("featurename",20.0); whereas previously it would have to have been: %feature("featurename","20.0"); Useful for features that are implemented as a macro, for example: #define %somefeature(value) %feature("somefeature",value) These will now work accepting either a string or a number: %somefeature("Fred"); %somefeature(4); 06/06/2004: wuzzeb (John Lenz) [Chicken, Guile] - Created the Examples/test-suite/schemerunme directory, which holds all the runme scripts for guile and chicken (and possibly mzscheme...). The guile and chicken _runme files then (load "../schemerunme/foo.scm"). - In chicken module, fix a few bugs invlolving dynamic casts. 06/03/2004: wsfulton Patch to fix wrapping of templated methods. ISO compliant compilers, like Comeau and GCC-3.4.0, don't like the template specifier that SWIG was generating when calling the method. This fix may break some non standard compliant compilers, for example, Sun workshop compilers prior to version 6.2.p2. Patch submitted by Bill Clarke. 06/03/2004: wsfulton [Java, C#] Undocumented special variable $imclassname removed. New special variable $module is replaced by the module name, as specified by %module or -module commandline option. $imclassname can be created from $module. 06/03/2004: wsfulton [C#] Same as for Java below. The new typemaps are named differently, namely, csbody and csbody_derived. The deprecated typemaps are csgetcptr and csptrconstructormodifiers. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 06/03/2004: wsfulton [Java] Typemap changes for the Java proxy / typewrapper and enum classes. A new typemap called javabody contains the essential support code for generation into the body of these classes. There is also a new javabody_derived typemap which is used instead for wrapped classes that have a wrapped base class. The code is basically, the getCPtr() method and swigCPtr and swigCMemOwn member variables. These used to be hard coded with no way to modify the code. The introduction of this typemap makes it possible for the user to tailor nearly every aspect of the code generation. The exception now is the code for director classes. The javagetcptr and javaptrconstructormodifiers typemaps are deprecated and are no longer used as the code that these generated can be put in the more flexible javabody and javabody_derived typemaps. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** The following macros contributed by Scott Michel may help you upgrade if you have used the javagetcptr typemap: /* Utility macro for manipulating the Java body code method attributes */ %define SWIGJAVA_ATTRIBS(TYPENAME, CTOR_ATTRIB, GETCPTR_ATTRIB) %typemap(javabody) TYPENAME %{ private long swigCPtr; protected boolean swigCMemOwn; CTOR_ATTRIB $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } GETCPTR_ATTRIB static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %typemap(javabody_derived) TYPENAME %{ private long swigCPtr; CTOR_ATTRIB $javaclassname(long cPtr, boolean cMemoryOwn) { super($moduleJNI.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } GETCPTR_ATTRIB static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %enddef /* The default is protected getCPtr, protected constructor */ SWIGJAVA_ATTRIBS(SWIGTYPE, protected, protected) /* Public getCPtr method, protected constructor */ %define PUBLIC_GETCPTR(TYPENAME) SWIGJAVA_ATTRIBS(TYPENAME, protected, public) %enddef /* Public getCPtr method, public constructor */ %define PUBLIC_BODYMETHODS(TYPENAME) SWIGJAVA_ATTRIBS(TYPENAME, public, public) %enddef 06/03/2004: wsfulton [Java, C#] The contents of the class modifier typemaps and pragmas have changed. They must now include the class type. Previously 'class' was hard coded. This change enables flexibility into what type of class is generated, for example the proxy class could be an interface instead of a class. For Java this affects the javaclassmodifiers typemap and the jniclassclassmodifiers and moduleclassmodifiers pragmas. For C# this affects the csclassmodifiers typemap and the imclassclassmodifiers and moduleclassmodifiers pragmas. Unless you have overridden the default versions of these typemaps or pragmas, you shouldn't be affected. However, if you have, upgrading is easy, for example class Foo {}; %typemap(javaclassmodifiers) Foo "public final" must now be: class Foo {}; %typemap(javaclassmodifiers) Foo "public final class" *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 05/31/2004: wsfulton Fix for C++ exception specifications that are references. Problem reported by Oren Miller. Also improves the generated exception declarations in the catch handler for pointers - a pointer is used instead of a reference to a pointer. Added default throws typemaps for SWIGTYPE &, SWIGTYPE * and SWIGTYPE[ANY] (Java and C#). 05/31/2004: wsfulton [Java, C#] Some minor typesafe enum improvements, including storing the name of the enum item. The toSring() / ToString() methods are overridden to return this name. 05/30/2004: wuzzeb (John Lenz) [Chicken] - Update how examples and the test suite are built. - Symbol names are no longer converted to lower case - Added union_runme.ss, which was copied and modified from the guile module 05/26/2004: lballabio (Luigi Ballabio) Committed on behalf of Marcelo (who still has problems with the SourceForge CVS.) Added Python typemaps for FILE* with (Python-only) test. 5/24/2004: dancy * Allegro CL module: Now using some macros (defined in Lib/allegrocl/allegrocl.swg), swig-defconstant and swig-defun, for defining constants and foreign functions. This makes the generated file a bit neater. Now strips a layer of parenthesis from constants. Uses (* :void) instead of :foreign-address now. 05/20/2004: wsfulton Unnamed enum global variables are now supported in addition to the recently added support for unnamed enum member variables. For example: struct Foo { enum { enum1, enum2 } MemberInstance; }; enum { enum3, enum4 } GlobalInstance; The int typemaps are used for wrapping the get/set accessor methods. If the sizeof an enum is not the same size as an int then setting the variable will silently do nothing as the casts cannot be easily and portably generated. If you need to solve this highly obscure situation, write the assignment using the %exception feature. 05/20/2004: wsfulton [C#] C# enum wrapping mods. Similar to the Java module, enums can be wrapped using one of 3 approaches: 1) Proper C# enums - use %include "enums.swg" 2) Typesafe enums - use %include "enumtypesafe.swg" 3) Simple constant integers (original approach) - use %include "enumsimple.swg" See each of these files for further details. Each of these files use typemaps and a new feature to control the generated code. The feature is: %csenum(wrapapproach); where wrapapproach should be one of: "proper", "typesafe", "typeunsafe" or "simple". [No implementation deemed necessary for type unsafe enums]. The default approach is proper C# enums. Anonymous enums are always wrapped by constant integers. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 05/20/2004: wsfulton [Java] Java enum support added. There are now 4 ways in which enums can be wrapped: 1) Proper Java enums - use %include "enums.swg" 2) Typesafe enums - use %include "enumtypesafe.swg" 3) Type unsafe enums (constant integers) - use %include "enumtypeunsafe.swg" 4) Simple constant integers (original approach) - use %include "enumsimple.swg" See each of these files for further details. Each of these files use typemaps and a new feature to control the generated code. The feature is: %javaenum(wrapapproach); where wrapapproach should be one of: "proper", "typesafe", "typeunsafe" or "simple". The default typemaps will handle enums that may or may not have specified initial values, for example ten is specified: enum Numbers { zero, ten(10) }; However, the amount of generated Java code can be cut down, by modifying these typemaps if none of the enums have initial values (proper Java enums and typesafe enums approach). The default approach is typesafe enums. Anonymous enums are always wrapped by constant integers. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 05/11/2004: wsfulton [Java, C#] Fix bug using %rename on enum items and when using %javaconst(1) / %csconst(1) For example, the following used to generate code that wouldn't compile: %rename(Obj) Object; enum Grammar { Subject, Object }; 04/28/2004: wsfulton [Java, C#] Minor fixes when using combinations of the javainterfaces, javabase, csinterfaces and csbase typemaps. 05/18/2004: wsfulton [Java] JVM link failure on some systems fixed when using std_vector.i. Also adds default vector constructor for use from Java. 05/17/2004: mkoeppe (Matthias Koeppe) [Guile] New runtime functions SWIG_PointerAddress, SWIG_PointerType, SWIG_IsPointerOfType, SWIG_IsPointer. [Guile] In -scm mode, wrap several SWIG runtime functions and export them into the module (Swig swigrun). The runtime module is now built with "module" linkage. [Guile] GOOPS proxy objects now also print the pointer address of the C object. 05/14/2004: lyle Added Kou's patch for the Ruby %import directive so that modules with "nested" names are handled properly. Consider an interface file foo.i that has this %module declaration at its top: %module "misc::text::foo" Now consider another interface file spam.i that imports foo.i: %import foo.i Before this patch, this would result in the following code being generated for spam_wrap.c: rb_require("misc::text::foo"); With this patch, however, you'll get the correct path name for the call to rb_require(), e.g. rb_require("misc/text/foo"); See SourceForge Bug #928299. 05/12/2004: wsfulton Patch for emitting directors when %feature("director") specified for a class with no virtual methods, but does have a virtual destructor. Submitted by Kevin Smith. 05/06/2004: mkoeppe (Matthias Koeppe) New SWIG runtime function SWIG_TypePrettyName, which returns an unmangled type name for a swig_type_info object. [Guile]: Use it for printing pointer objects. 05/03/2004: dancy (Ahmon Dancy) * Lib/allegrocl/allegrocl.swg: Updated comments about identifer conversion. * Sources/Modules/allegrocl.cxx: Register /dev/null for "header" target. Also, disregard "const" qualifiers during type conversion. 05/02/2004: wuzzeb (John Lenz) [Chicken] Fix bug 782468. To fix this bug, the runtime code has been rewritten, and pointers are now represented as a C_SWIG_POINTER_TYPE. Chicken version > 1.40 is now required! * Typemap incompatibility: typemaps no longer use chicken_words. If a typemap needs some space, it should just call C_alloc * argout typemaps no longer use the /* if ONE */ construct to build an output list. A SWIG_APPEND_VALUE macro, exactly like guile and mzscheme is now used. 04/25/2004: mkoeppe (Matthias Koeppe) [Guile] In the generated GOOPS code, don't create methods that would not specialize any arguments; simply re-export the primitive functions. (This is a performance optimization which reduces load time and execution time.) [Guile] In -gh mode, fix the "too many initializers" error which was caused by an incompatible swig_type_info layout. [Guile] The typemap for FILE * in ports.i now also accepts a regular FILE * pointer object. Also a bug with Scheme file ports that are open for input and output has been fixed. 04/25/2004: wsfulton Change entry 03/21/2004 revoked. The change introduced another inconsistency (reference typemaps beings used instead of pointer typemaps for member variables as well as static member variables and global variables for some languages, but only for C++ and not C). This would break user's current typemaps and introduce further inconsistencies. Alternative solution required and being discussed. 04/10/2004: mmatus (Marcelo Matus) Added the -directors flag. This enables the director mode for the interface and all the classes that don't set the "feature:nodirector" explicitly. You can use this in your module if you want to use the director feature in all your classes, but it is most intended for testing purposes, like: make check-python-test-suite SWIG="../../../swig -directors" make check-ruby-test-suite SWIG="../../../swig -directors" make check-java-test-suite SWIG="../../../../swig -directors" These commands will run the entire test-suite using directors, and not only the specific 'directors_*' cases. This should be done from time to time. 04/10/2004: mmatus (Marcelo Matus) [python] Added support for std::wstring and wchar_t, for compiler and python versions that support them. When needed, use %inlcude std_string.i // 'char' strings %inlcude std_wstring.i // 'wchar_t' strings 04/10/2004: mmatus (Marcelo Matus) [python] Fix the default behaviour (seg. fault) when an inplace operator (+=,-=,...) was wrapped, as reported by Lucriz (lucriz@sitilandia.it), when the most common form was used: A& A::operator+=(int i) { ...; return *this; } ^^^^ ^^^^^^ ie, an object is returned and its contains the same 'this' value than the input object, which is deleted after the operation "a += b", leaving the result with no real object, but a seg. fault. To fix it, we needed to introduce a new feature and use an old one: %feature("self:disown") A::operator+=; %feature("new") A::operator+=; here, "self:disown" disable the ownership of the 'self' or input object, and the "new" feature transfers the ownership to the result object. The feature/solution could also be used in other languages that use gc and implement the inplace operators, or other operators, in a similar way. *** POTENTIAL INCOMPATIBILITY FOR Python MODULE *** If you already are using the inplace operators in python, and you implemented some kind of workaround to the problem fixed here, it is possible you could end with 'free' objects that never get deleted. If that is the case, and you want to disable the current fix, use: %feature("self:disown","") A::operator+=; %feature("new","") A::operator+=; 04/07/2004: cheetah (William Fulton) [C#] C++ enums are no longer wrapped by integers, they are now wrapped by C# enums. For Example, given C++: enum AnEnum { foo, bar }; typedef AnEnum AnEnumeration; void something(AnEnum e, AnEnumeration f); The following is generated: public enum AnEnum { foo, bar } public static void something(AnEnum e, AnEnum f) {...} Note that a global enum like AnEnum above is generated into its own file called AnEnum.cs. Enums defined within a C++ class are defined within the C# proxy class. Some of the typemaps for modifying C# proxy classes also work for enums. For example global enums can use %typemap(csimports) to add in extra using statements. Global enums and class enums can use %typemap(csclassmodifiers) to make the enum private, public etc. %typemap(csbase) to change the underlying enum type (enum base) If we add this for the above example: %typemap(csclassmodifiers) AnEnum "protected" %typemap(csbase) AnEnum "long" the following is generated: protected enum AnEnum : long { foo, bar } *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 04/07/2004: cheetah (William Fulton) Seg fault fix for empty enums, like enum Foo {}; 03/21/2004: mmatus [Note: this change revoked on 04/25/2004] [Python] Makes the following 'var' cases more uniform: std::string ga; struct A { static std::string sa; std::string ma; }; now the three variables (ga, sa, ma) can be assigned as: cvar.ga = "hello"; A.sa = "hello"; a.ma = "hello"; ie, now 'ma' will also use a std::string typemap 'in' if defined, before it was only accepting a 'p_std_string' pointer. Note, however, that 'ma' will not use the 'varin/varout' typemaps (that probably could be more natural), but it will pick up the 'in' typemap for const std::string& (which is easier). The changes in cwrap.c and lang.cxx will probably fix the behaviour in other languages that do not overload the membervarHandler method "too much". 03/21/2004: mmatus [Python] Disabling the default instantiations like: %template() std::pair; for all the primitive types and STL containers/classes. They are expensive, specially for pair and map, and the previous behaviour also requires the user to perform manual instantiations. Still, if the speed difference is not important, it can be re-enabled by defining the macro SWIG_STD_DEFAULT_INSTANTIATION (see std_common.i). Also, normalizing the INPUT/OUTPUT/INOUT typemaps. Now they use the same conversors than the rest of the typemaps, and you can use them for std::pair, std::string and all the other STL types, like in: void p_inoutd(std::pair *INOUT); Added the attribute.i and implicit.i files with macros to transform functions pairs like 'set_x'/'get_x' (or 'T& x()'/'const T& x() const') into an attribute, and allowing the use of implicit constructors in typemaps (see the files for more details). 03/21/2004: mkoeppe [Guile] Fix the documentation strings of functions with anonymous arguments. 03/18/2004: mmatus [Python] More general std_string.i interface. Now you can wrap it using %template(string) std::basic_string; and use the std::string as a base class: struct A : std::string { }; But more important, swig will recognize both std::basic_string and std::string as the same type. 03/16/2004: mmatus Previously added, but not mentioned before: - friend declaration support, swig now emits a global function in the same class scope. - ref/unref features: to mix ref counting C++ classes and native script ref counting mechanisms (like in python). Use it like: %feature("ref") RCObj "$this->ref();" %feature("unref") RCObj "$this->unref();" And the class RCObj, and all the derived ones, will perform the right ref/unref calls when a new pointer is returned to the target language, or when the target language attempts to delete the object. See the refcount.i file in the test-suite for more details. 03/16/2004: mmatus [Python] Using the new %fragment support, major rewrote of the python swig library, including: - Almost automatic template/typemap instantiation for the STL components. For example, now you can write: %template(vector_i) std::vector; and a specialized vector_i class is emitted with all the needed typemaps. No need to use the old 'specialize_vector' macros. Note you can also define %template(matrix_i) std::vector >; %template(vector_pii) std::vector >; - The empty template instantiation %template() std::vector; defines the vector typemaps, but no proxy class. For all the fundamental types, the empty template instantiation are defined, so, you can say %include std_vector int func(const std::vector& a); where the proper typemap is applied to 'a', but no std::vector proxy is generated. - All the STL containers present a more uniform behavior and more complete interface declaration. The following are now supported: std::vector std::list std::deque std::set std::multiset std::map std::multimap not a container, but also supported: std::pair also, more typemaps are defined for all of them, including varin, varout, typecheck, etc. - Initial attempt to implement the STL containers considering allocators, ie: std::vector it is partially working, but it is just a workaround while swig improves its template type support. Please test with your particular setup. It seems to be working with g++ 3.2.2, g++ 2.96, Intel icc and SGI CC compilers, plus python 1.5.2, 2.0 and 2.3, but since we are using templates, there is a chance you can find some problems when using with an old C++ compiler. 03/16/2004: mmatus - Allowing the empty %template directive, such as %template() std::vector; to process the class "typedef"s and "typemap"s. Before only the internal "typedef"s were processed. This makes possible to emit the default in/out typemaps without the need of wrapping an specialized vector instance. - Adding the preprocessor extension #@ which mangles the following macro argument, like in: #define macro(X) #@X macro(int) -> int macro(std::string) -> std_s_s_string - Fragments can now be "type specialized", as the typemaps. The syntax is as follows %fragment("name","header") { /* a type independent fragment (old syntax) */ } %fragment("name" {Type}, "header") { /* the fragment is type dependent */} Now fragments can also be used inside templates: template struct A { %fragment("incode"{A},"header") { /* 'incode' specialized fragment */ } %typemap(in,fragment="incode"{A}) { /* here we use the 'type specialized' fragment "incode"{A} */ } }; 03/11/2004: cheetah (William Fulton) [Java] Director bug which meant that some virtual functions overridden in Java were not being called on some operating systems. Bug reported and fixed by Robert de Vries and Scott Michel. 03/02/2004: mkoeppe (Matthias Koeppe) [Guile] In -scm mode, don't forget to check the type of string arguments. 02/24/2004: cheetah (William Fulton) [C#] New commandline option -namespace . This allows one to specify a C# namespace into which all C# classes are generated. 02/23/2004: mkoeppe (Matthias Koeppe) [MzScheme] Use FUNC_NAME rather than a bogus typemap variable for signalling errors. Call scheme_wrong_type with a zero-based argument number. Reported by Ondrej Pacovsky, SF #902621. [Guile] Define FUNC_NAME also in the dispatch wrapper for overloaded functions. Patch by John Lenz, SF #896255. 02/22/2004: mkoeppe (Matthias Koeppe) [Guile] In -scm mode, don't try to invoke a null destructor function. 02/20/2004: cheetah (William Fulton) Fixes so that the SWIG source will compile using the Digital Mars Compiler (formerly Symantic compiler) on Windows. Submitted by Scott Michel. 02/13/2004: mkoeppe (Matthias Koeppe) [MzScheme] New command-line argument -noinit. Use it for building the runtime library, where we don't want to define the functions scheme_initialize etc. Reported by Tim Brown, SF #891754. [MzScheme] Don't produce invalid C code when invoked with the -declaremodule option. Reported by Tim Brown, SF #891108. [Guile] Build the runtime library with passive linkage, to rename the SWIG_init function uniquely. 02/12/2004: cheetah (William Fulton) [Java, C#] Patch submitted by Bill Hoffman which prevents SWIG from crashing when a file for the typewrapper class cannot be opened. 02/11/2004: cheetah (William Fulton) [Java, C#] Overloading changes: - Methods which are overloaded in const only no longer generate Java code that won't compile - the first method parsed is used and a warning is displayed. Note that this behaviour is slightly different to the scripting languages which always uses the non-const method. - Warning messages 509 and 512 replaced by new warning number 516, which is more relevant to these statically typed languages as the overloaded methods aren't 'shadowed', they are ignored. 01/23/2004: mkoeppe (Matthias Koeppe) [Guile] Replace the "known_classes" hash table by a node attribute. Methods of classes in C++ namespaces now get the proper specializer in the GOOPS declaration. Reported by rm@mh-freiburg.de. 01/23/2004: mkoeppe (Matthias Koeppe) [Guile] Uniquify the argument names in GOOPS shadow method declarations. Reported by rm@mh-freiburg.de. 01/21/2004: sunshine (Eric Sunshine) Revived the NextStep port of SWIG. Fixed fatal problem in DohStrstr() caused by difference in strstr() implementation which made %apply become entirely dysfunctional. On NextStep, strstr("foo","") evaluates to NULL; whereas, on modern platforms, it evaluates to "foo". %apply relies extensively upon strstr("foo","") evaluating to non-NULL, therefore it failed catastrophically when faced with NextStep's strstr(). Added `bool' check to configure.in since NextStep's C++ compiler does not supply this type. swig.h now fakes up `bool' if needed. Worked around NextStep C++ compiler bug in which C++ code is disallowed inside extern "C" functions. This problem affected all language modules, since they publish hook functions of the form: extern "C" Language *swig_foo(void) { return new FOO(); } Fixed by creating a C++ wrapper: static Language *new_swig_foo() { return new FOO(); } extern "C" Language *swig_foo(void) { return new_swig_foo(); } Ensured that Swig_copy_string() is used in place of strdup() since NextStep does not supply strdup(). Fixed detection of Ruby library name and location in configure.in. Problem 1: Assumed that library always resided in Ruby's "archdir", which was correct for Ruby 1.6.x, but which is incorrect for Ruby 1.8.x, in which case the library normally resides in Ruby's "libdir". Problem 2: Assumed that the library could always be linked via "-l"+RUBY_INSTALL_NAME (where RUBY_INSTALL_NAME typically is "ruby"), however this failed for platforms, such as NextStep, which do not support shared libraries. In this case, the static library name in 1.8.x is libruby-static.a, thus -lruby-static is required. The new logic works correctly for static and shared libraries for 1.6.x and 1.8.x. Fixed detection of Perl CFLAGS in configure.in for NextStep. Detection code extracted CFLAGS from Perl's %Config hash but neglected to add a newline to the value before passing it through `sed'. NextStep's ancient `sed' discards input which is not terminated with a newline, thus Perl CFLAGS always evaluated to the empty string. 01/16/2004: cheetah (William Fulton) Tidy up in the exception handling code that is generated when C++ exception specifications are wrapped with the throws typemap. This redundant code is no longer generated: catch(...) { throw; } 01/12/2004: wsfulton on behalf of mmatus (marcelo matus) if a method uses %exception and the method requires the use of the throws typemap, the code in a throws typemap will be generated inside the try body. For example: %exception method { try { // method action $action } catch (int i) { // method int catch handler } catch (...) { // method generic catch handler } } %typemap(throws) Except %{ // throws typemap Except catch handler %} %inline %{ class Except {}; void method(int i) throw (Except); Will generate: { try { // method action try { method(arg1); } catch(Except &_e) { // throws typemap Except catch handler } } catch (int i) { // method int catch handler } catch (...) { // method generic catch handler } } As can be seen, the inner try catch block is for the throws typemaps. Previously, this was reversed so that the inner try catch block was the %exception code. In the example above, it would have been impossible to catch Except as the catch all (...) would catch the exception instead. Version 1.3.21 (January 11, 2004) ================================= 01/10/2004: cheetah (William Fulton) The output format for both warnings and errors can be selected for integration with your favourite IDE/editor. Editors and IDEs can usually parse error messages and if in the appropriate format will easily take you directly to the source of the error. The standard format is used by default except on Windows where the Microsoft format is used by default. These can be overridden using command line options, for example: $ swig -python -Fstandard example.i example.i:4: Syntax error in input. $ swig -python -Fmicrosoft example.i example.i(4): Syntax error in input. 01/09/2004: beazley Fixed [ 871909 ] simple namespace problem. This was a problem using anonymous structures in a namespace. For example: namespace ns { typedef struct { int n; } S; }; Reported by Josh Cherry. 01/09/2004: beazley Fixed some broken Perl examples. 12/28/2003: cheetah (William Fulton) [Java and C#] Fixes for wrapping covariant (polymorphic) return types. For example: struct Base { virtual ~Base(); virtual Base* copy() const = 0; }; struct Derived : Base { virtual Derived* copy() const; }; The Derived::copy proxy method returns Base not Derived. A warning is issued about this. Previously the pointer used by the proxy class was incorrectly treated as a Base* instead of a Derived*. 12/18/2003: cheetah (William Fulton) Fix so that Windows paths are displayed correctly when reporting errors. An error previously would have been shown something like: .?xample.i:14: Syntax error in input. instead of: .\example.i:14: Syntax error in input. Version 1.3.20 (December 17, 2003) ================================== 12/17/2003: beazley Last minute modifications. Perl5 module now generates shadow classes by default like all of the other modules. PHP4 wrappers no longer include "config.h". 12/14/2003: beazley Weakened warning message related to constructor names so that an unusual nested-class wrapping technique would work again (apparently it worked in some older SWIG releases). For example: class Scope { class ClassA; class ClassB; }; class Scope::ClassA { ... }; class Scope::ClassB { ... } Note: There is still some odd interaction with the SWIG symbol table/type system that will need to be looked at in a future release. Reported by Gustavo Niemeyer. 12/11/2003: cheetah (William Fulton) [Java] Protected class methods are wrapped as protected Java methods when using the dirprot director feature. This can be changed using %javamethodmodifiers to something else should the need arise, for example, private or package access. 12/11/2003: cheetah (William Fulton) [Java, C#] %javamethodmodifiers (Java) and %csmethodmodifiers (C#) operate slightly differently. Previously this feature had to be present to set the method modifiers. Now it is only used if it exists for the method being wrapped. The default is "public" as previous however, when wrapping protected director methods it is "protected". This change will not affect existing use of the %javamethodmodifiers or %csmethodmodifiers. 12/11/2003: mmatus (Marcelo Matus) This fix some recurring reports about keywords not been properly identified and warned, and it solves the problem of how to add a test file to the test-suite such that it doesn't use any keyword of all the supported languages (and doing it without compiling the test for all the supported languages, thing that is not always possible, and without requiring you to know all the supported language keywords, thing that is always impossible). So these are the changes globally speaking: - Uniform the definition of the keyword warnings through the supported languages: all the languages has now a separate file that defines the keywords or bad names: python/pythonkw.swg chicken/chickenkw.swg .... - Added keyword list for most of the languages that didn't have one (using the new separated file). - Added the "All keywords" warning support: -Wallkw option. This option allows you to include all the known keywords for all the supported languages, and can be used as: swig -Wallkw .... This will help to the process of adding a test-suite file that can be compiled in all the swig supported languages, and it will be also helpful for users who want to create multi-language libraries. And these are the detailed changes (mostly file addition): - For the languages that already have some sort of keyword warning list, move it to an external languagekw.swg file, ie: move keywords from python.swg -> pythonkw.swg move keywords from chicken.swg -> chickenkw.swg move keywords from tcl8.swg -> tclkw.swg and re-include languagekw.swg from language.swg. - For the language that didn't have a keyword list, and for the ones that I could find a list, add the languagekw.swg file, ie: csharp/csharpkw.swg java/javakw.swg php4/phpkw.swg pike/pikekw.swg ruby/rubykw.swg also add a line in language.swg to include languagekw.swg, but now it is commented!!!, like in java.swg: /* java keywords */ /* please test and activate */ //%include "javakw.swg" ie, there will be no change in how swig runs normally until the language maintainer test and uncomment that line. So, please check each languagekw.swg file (I left the link to the keyword list source for checking), and after testing, uncomment the %include line. - Added the file allkw.swg, which includes all the languagekw.swg files. For the languages that has no languagekw.swg file right now, and if they need one, add the file into the language directory, and add the corresponding include line into the allkw.swg file. - Added the -Wallkw that includes the allkw.swg file. Note that the old -lallkw.swg option couldn't be used since it include the file after it would be needed. Hopefully, the -Wallkw option will be added to the default rules in the related test-suite Makefiles, so, when creating a new test, or adding a new swig library file (like _std_deque.i), swig will warn you if you are using a bad name, considering all the language where it needs to run. Right now you can test it by using: make check-python-test-suite SWIG="swig -Wallkw" or using your favorite target language, it doesn't matter. And yes, there are several examples that are using reserved keywords, specially from csharp. *** Remember ****: the new keyword warning lists are not included by default in any of language that before didn't have one. To enable the keyword warnings as the default behavior, the inclusion of the languagekw.swg file has to be uncommented at each language.swg file. So, all the language maintainers, please check the keywords list. Also, you can add buit-in names, and not only keywords, like 'True/False' in python. Remember that you can be more specific and refer only to member names, like *::configure or *::cget (see an example in the tcl8/tcl8kw.swg file), or only global names, like ::range (see an example in the python/pythonkw.swg file. Just to be consistent, use the following codes: - Use code 314 for keyword and/or fatal bad names. - Use code 321 for buit-in and/or not fatal bad names. so, they can't be disabled/enabled independently (see python/pyhtonkw.swg for examples). **** And don't add any new test file without checking it with the -Wallkw option!! (that includes me) *****. 12/11/2003: cheetah (William Fulton) SF bug #854634 Added support for accepting the Unix directory separator '/' on Windows and the Mac in addition to the native one ( '\' on Windows). This can be used in %import, %include and commandline options taking a path, for example -I. On Cygwin, both the Windows and Unix directory separator can now be used (was '/' only). 12/10/2003: mmatus (Marcelo Matus) [python] Implementing the runtime "reprotected" director members, if you have: %feature("director") B; class Bar { public: virtual ~Bar(); virtual int hello() { return do_hello();) protected: virtual int do_hi() {return 0;} virtual int do_hello() {return 0;} }; then, at the python side import my_module class Foo(my_module.Bar): def do_hello(self): return 1 pass b = Bar() # Pure C++ Director class f = Foo() # C++ Director + python methods b.hello() # Ok, and it calls C++ Bar::do_hello() f.hello() # Ok, and it calls Python Foo::do_hello() b.do_hi() # RuntimeError, do_hi() is protected!! f.do_hi() # RuntimeError, do_hi() is protected!! b.do_hello() # RuntimeError, do_hello() is protected!! f.do_hello() # Ok, since it its redefined in python. Here Bar.do_hello is always protected, but Foo.do_hello is "public", because it is redefined in python. Before, all the 'do_hello' methods were public. This seems to be a good compromise between C++ and python philosophies, ie, all the director protected methods keep protected at the user side (C++ way) until they are redefined (python way, were all defined methods are always public). And this is not only a good compromise, it also seems to be the only way to do it :). Now ruby has native director protected members, and python pure runtime support. I guess these are the two possible extreme cases. And hopefully, they could be used as templates to modify the other languages that support directors, so they can "reprotect" the protected director members at the target language side. This finished the director protected support for the python language. Ocalm will need to add the "reprotection" later. 12/10/2003: mmatus (Marcelo Matus) The following case (reported by Lyle Johnson) was fixed: %rename(x) Foo::y(); class Foo { public: void y(); protected: int x; }; swig warned that the symbol 'x' was already defined, and the renaming fails. 'x' was not emitted, since it is protected, but it was kept in the symbol table with too much information. Now swig works for all the cases (plain, director and dirprot) again. This was fixed by allowing the parser.y to decide much closer what to do with 'x'. Before all the discarding or generation was resolved at the lang.cxx stage. Also the changes in parser.y to implement the director protected mode are now much more encapsulated, and they get disabled if the mode is not enabled. Before the deactivation was done at the generation stage (lang.cxx). By the other hand, if the director mode is enabled, and %rename is done, reusing a protected member name, there is a pathological case: %rename(x) Foo::y(); class Foo : public A { public: void y(); protected: int x; /* works */ static int x; /* works */ static void x(); /* works */ typedef void x(); /* works */ virtual void x(); /* always fails, as it should, since Foo::x() will be emitted in the director */ void x(); /* always fails, but sometimes it shouldn't, since the Foo::x() will not be emitted if it is not virtual */ }; The last case is not always right because at the parser.py stage it is not possible to decide if the protected member Foo::x() could or not conflict with the renamed Foo::y(), since Foo::x() could be virtual by inheritance. I guess this just an intrinsic limitation, and no much can be done about it without resorting into larger changes to postpone, under certain conditions, the multiply symbol detection (lang.cxx stage). So, by now, it is just considered a well known "feature" in the director protected mode. The good news is that it seems to be a rare case, and it can be avoided by the user by hiding 'x' before renaming 'y': %rename(_x) Foo::x(); %rename(x) Foo::y(); 12/08/2003: mmatus (Marcelo Matus) The virtual method detections now properly treats the following cases: namespace foo { typedef int Int; } struct A {}; typedef A B; struct Foo { virtual ~Foo() {} virtual Foo* cloner() = 0; virtual int get_value() = 0; virtual A* get_class() = 0; virtual void just_do_it() = 0; }; struct Bar : Foo { Bar* cloner(); foo::Int get_value(); B* get_class(); void just_do_it(); }; All the Foo and Bar methods are virtual. A new attribute "virtual:type" record the base polymorphic type. In the previous cases we have: type : Bar virtual:type : Foo type : foo::Int virtual:type : int type : B virtual:type : A type : void virtual:type : void This attribute is useful in languages (java+directors) that could have problems redefining Bar* Bar::cloner(). If you never had code like the above, you will see no effects. But if you have some code like that, you will see some effects since some methods that before were not properly treated as virtual, will start to act like that. This could enlarge your director classes. 12/08/2003: mmatus (Marcelo Matus) The director protected member support (dirprot) is disabled by default. It can be enable by using '-dirprot' or by adding the option to the module declaration, like: %module(directors="1",dirprot="1") my_module This module option was added to properly compile the director_protected.i and director_nested.i examples. The feature has been tested with python[2.2,2.3] and ruby[1.6.7], both at compilation and runtime, and java[j2sdk1.4.1_01], but only at compilation (my java installation doesn't run any of the director examples, olds nor news). Please test for ocaml and java. The errors reported by William and Scott were fixed, except for a warning about SWIG_JavaThrowExecption() multiply defined. I can't reproduce this error with my examples. We will wait for Scott to send us a minimal case. 12/07/2003: mmatus (Marcelo Matus) The director protected member support has been completly moved out from python.cxx, and now resides in the common lang.cxx, emit.cxx and allocate.cxx files. This means it should work for all the other languages that currently support directors, ie, python, java, ocalm and ruby. The change has been tested with python (compilation+runtime) and java (just compilation). Please add runtime tests for the missing languages and test it. The '-nodirprot' option was moved to the principal main, and can be used from all the languages. 12/07/2003: cheetah (William Fulton) [Java] Fixed and improved error checking of STRING_OUT typemaps in various.i. 12/04/2003: mmatus (Marcelo Matus) - Now the virtual members with no explicit declarator are properly identified: struct A { virtual int f() = 0; }; struct B : A { int f(); }; Here, B::f() is virtual, and the director and the virtual elimination mechanism now recognize that. - [C#] This fix also fixes the problem where 'override' was not being used on any overridden virtual method, so for struct B above, this C# code is generated: public class B : A { ... public override int f() { ... } ... } - Initial support for protected virtual methods. They are now properly emitted when using with director (python only by now). %feature("director") A; struct A { protected: virtual int f1() = 0; }; %feature("director") B; struct B : A{ protected: int f1(); virtual f2(); }; This can be dissabled by using the '-nodirprot' option. - The feature 'nodirector' is working now at the top level, so, it must work for all the languages: %feature("director") A; %feature("nodirector") A::f2; struct A { virtual int f1(); virtual int f2(); }; in this case, only 'f1' is exported to the director class. - Added director support for const TYPE& arguments (python). 12/02/2003: cheetah (William Fulton) [Java] Fix for INOUT and OUTPUT typemaps in typemaps.i for when the JNI type is bigger than the C type. For example, unsigned long (32bits on most systems) is mapped to jlong (64bits). Returned value was incorrect. Bug reported by Brian Hawley. 12/02/2003: cheetah (William Fulton) [C# and Java] Better fix for entry dated 05/11/2003. Fixes the following typemaps: Java: javabase, javainterfaces, javaimports, javaclassmodifiers, javaptrconstructormodifiers, javafinalize, javagetcptr & javacode. C#: csbase, csinterfaces, csimports, csclassmodifiers, csptrconstructormodifiers, csfinalize, csgetcptr & cscode. It also fixes bug in using arrays of C structs with arrays_java.i as reported Scott Michel. 12/02/2003: beazley [Perl] Fixed [ 852119 ] recursive inheritance in output .pm, perl5. Reported by William Dowling. 12/02/2003: beazley [Tcl] Fixed [ 755382 ] calling func(const vector& p) evaluates p[0] in interp. The Tcl type checker was improperly handling the interpreter result when type violations were supposed to be ignored. Reported by Flaviu Popp-Nowak. 11/30/2003: cheetah (William Fulton) Fixed [ 545058 ] configure's --with-tclincl has no effect 11/30/2003: cheetah (William Fulton) [Java] Fixed [ 766409 ] missing symbol SWIG_JavaThrowException during module load SWIG's internal functions are all static as there is no need for different SWIG generated modules to share any code at runtime. 11/30/2003: beazley [Tcl] Added support for C++ pointers to members. 11/28/2003: cheetah (William Fulton) Fixed [ 848335 ] Directors: #include wrapper .h file - was incorrectly adding a directory to the generated #include "foo_wrap.h" statement in some situations. 11/28/2003: cheetah (William Fulton) [Java] Fixed [ 849064 ] JAVA : Access modifier for derived class wrong. The delete() method is always public now. It used to be protected whenever a destructor was non public. An UnsupportedOperationException runtime exception is thrown instead of making delete() protected now. 11/28/2003: beazley [Perl5] Added support for C++ pointers to members. 11/28/2003: beazley Fixed [ 850151 ] PYVERSION with python2.3 in configure of SWIG 1.3.19 (Maybe). 11/28/2003: beazley Fixed [ 850666 ] #include extra line added. This should fix some problems with getting correct line numbers on error messages. 11/26/2003: beazley Fixed another one of Marcelo's evil template bugs (infinite recursion). [ 849504 ] template and typedef -> inf. recursion. 11/26/2003: beazley Fixed parsing problem with declarations like this: int *x = &somearray[0]; 11/25/2003: beazley Fixed [ 756552 ] missing default argument class scope with "|". This is really only a band-aid fix for use of class-enums in expressions. For example: class A { public: enum Flag { flag1 = 0x1, flag2 = 0x2 }; void foo(int x = flag1 | flag2); }; Note: there are still some (more subtle) cases that are broken, but hard to fix due to an issue with template expansion. Will address later. Reported by Dmitry Mironov. 11/25/2003: beazley Incorporated [ 840878 ] support for %inline { ... } (PATCH). This adds support for the following: %inline { ... some code ... } The difference between this and %inline %{ ... %} is that the enclosed text is processed by the SWIG preprocessor. This allows special macros and other processing to be used in conjunction with %inline. Contributed by Salvador Fandino Garcia. 11/25/2003: beazley Fixed [ 836903 ] C++ inconsistency (with void arguments). SWIG was having difficulty with f() vs f(void) in C++ programs. For instance: class A { public: virtual void f(void) = 0; }; class B { public: virtual void f(); // Not matched to f(void) correctly }; The parser now normalizes all declarations of the form f(void) in C++ classes to f(). This should fix a variety of subtle problems with inheritance, optimizations, overloading, etc. Problem reported by Partho Bhowmick. 11/25/2003: beazley [Perl5] Incorporated [ 841074 ] better croaking (PATCH). This fixes some problems with strings and provides some new error functions. Contributed by Salvador Fandino Garcia. 11/25/2003: beazley Fixed [ 791835 ] Default argument with cast: txt = (char *)"txt" syntax Error. The parser should now accept things like this: void foo(char *s = (char *) "Hello"); Problem reported by Claudius Schnorr. 11/24/2003: beazley [Tcl] Fixed problem with cross module linking. Previously modules referred to base classes through a global variable. Now, the module looks up base classes through the type system itself---avoiding the need to link to a global like before. Caveat: modules with base classes must be loaded before modules with derived classes. 11/24/2003: mkoeppe (Matthias Koeppe) [Guile] In -scm mode, use () to represent null pointers, as it is done in -gh mode. 11/23/2003: mkoeppe (Matthias Koeppe) Add a generated script "preinst-swig", which can be used to invoke SWIG before it has been installed. It arranges that the runtime libraries from the source directory are used. 11/23/2003: mkoeppe (Matthias Koeppe) [Guile] In -gh mode, don't forget to call SWIG_Guile_Init. Add a SWIG_contract_assert macro. 11/23/2003: mkoeppe (Matthias Koeppe) [MzScheme] Update the configure check for the dynext object to work with MzScheme 205. 11/20/2003: mmatus Fixed the include/import error reported by Kerim Borchaev, where two files with names like 'dir1/hello.i' 'dir2/hello.i' can not be include at the same time. Swig was including just the first one, assuming the second one was not a different one, since it was checking/keeping just the basename 'hello.i'. 11/19/2003: beazley Changes to the SWIG runtime library support. - The -c command line option has been renamed to -noruntime - New command line option: -runtime. When supplied, this inserts the symbol SWIG_GLOBAL into the wrapper code. This, in turn, makes all of the runtime support functions globally visible. - New library file: swigrun.i. Used to create modules for runtime library (if needed). 11/18/2003: cheetah (William Fulton) 'make srcrpm' rpmbuild fix - patch from Joe Cooper 11/18/2003: mkoeppe (Matthias Koeppe) [Guile] Change meaning of configure option --with-guile to the name of the Guile executable. The new option --with-guile-prefix can be used to specify the tree where Guile is installed. (However, usually it suffices to use the single option --with-guile-config.) When running the run tests test-suite, make sure to use the version of Guile that SWIG was configured for. 11/17/2003: mkoeppe (Matthias Koeppe) [Guile] Improvements to object-ownership management in "-scm" mode. (They do not apply to the default "-gh" mode.) * Renamed the smob type that indicates that the object can be garbage collected from "collected swig" to "collectable swig", which is more precise. * Export the destructor functions again. It is now allowed to explicitly call destructors, even for garbage-collected pointer objects. A pointer object that has been passed to a destructor is marked in a special way using a new smob type, "destroyed swig". (This helps avoid nasty memory bugs, where references to dead C objects are still held in Scheme. Moreover, the garbage collector will not try to free a destroyed object once more.) * Destructor-like functions can also mark their arguments as destroyed by applying the typemap SWIGTYPE *DESTROYED. (It calls the function SWIG_Guile_MarkPointerDestroyed.) * Functions that "consume" their objects (or that "own" them after the call) can mark their arguments as not garbage collectable. This can be done by applying the typemap SWIGTYPE *CONSUMED. (It calls the function SWIG_Guile_MarkPointerNoncollectable.) * The macro TYPEMAP_POINTER_INPUT_OUTPUT from library pointer-in-out.i creates additional typemaps PTRTYPE *INPUT_CONSUMED, PTRTYPE *INPUT_DESTROYED. They mark the passed pointer object likewise. The typemap PTRTYPE *OUTPUT creates a garbage-collectable pointer object, like %newobject does for a returned pointer. Use the new typemap PTRTYPE *OUTPUT_NONCOLLECTABLE to create a pointer object that will not be garbage collected. 11/17/2003: mkoeppe (Matthias Koeppe) [Guile] Handle $input in "freearg" typemaps. Never qualify GOOPS slot names with the class name. Handle optional arguments properly in the GOOPS methods. 11/16/2003: cheetah (William Fulton) Fixes for installation to work with the upcoming Automake-1.8. mkinstalldirs was being used by a non-Automake makefile. mkinstalldirs is being phased out and so was not being created by Automake. install-sh used instead. 11/16/2003: cheetah (William Fulton) [Java] Numerous director improvements, tweaks and bug fixes since the initial implementation have been contributed by Scott Michel. 11/12/2003: beazley [Python] When %feature("shadow") is used to add code to shadow classes, the special variable $action expands to the name of the underlying wrapper function that would have been called normally. 11/12/2003: beazley [Python] When generating proxy class code, SWIG emits a few default methods for __repr__() and other Python special methods. Some of these methods are emitted after all of the contents of a class. However, this makes it hard to override the methods using %pythoncode and some other directives that allow code to be inserted into a class. These special methods are now emitted into the code *before* all of the other methods. Suggested by Eric Jones. 11/11/2003: beazley Preprocessor enhancement. For include statements like this: %include "foo/bar.i" the directory "foo" is now added to the search path while processing the contents of bar.i. Thus, if bar.i includes other files in the same directory, they will be found. Previously, you would have to add additional directories using -I to make this work correctly. Note: the C preprocessor seems to behave in an identical manner on many (most? all?) systems. Suggested by Kerim Borchaev. 11/11/2003: beazley Configuration changes to make SWIG work on Mac OS X 10.3.x (Panther). Tested with Python, Tcl, Perl, and Ruby---all of which seem to work. 11/08/2003: cheetah (William Fulton) [Java] Fixed the typemaps in various.i which were mostly broken. char **STRING_IN and char **STRING_RET typemaps replaced with STRING_ARRAY. float *FLOAT_ARRAY_RETURN typemap removed. 11/08/2003: beazley [Tcl] Tcl module now emits a safe module initialization function by default. It can be removed by running 'swig -nosafe'. 11/04/2003: mkoeppe (Matthias Koeppe) [Guile] Only use the SCM_ API when the function `scm_slot_exists_p' exists (needed for GOOPS support). This function was renamed during the Guile 1.5 series from `scm_slots_exists_p'. Report the right runtime library when invoked with -scm -ldflags. 11/03/2003: mkoeppe (Matthias Koeppe) [Chicken] Fix #782052. The --with-chickencfg configure option (and others) were not accepted. 11/02/2003: mkoeppe (Matthias Koeppe) [Guile] Merge new set of GOOPS changes by John Lenz. GOOPS objects are now manipulated directly by the C code. Some fixes to typemap-GOOPS interaction. 11/02/2003: mkoeppe (Matthias Koeppe) [Guile] Remove the file argument to -scmstub and -goops. The Scheme files are now always called MODULE.scm or MODULE-primitive.scm, where MODULE is the module name and "primitive" can be changed by the -primsuffix option. The Scheme files are now placed in the directory given by the -outdir option, or the current directory. (Patch by John Lenz, slightly modified.) *** INCOMPATIBILITY [Guile] *** 11/02/2003: mkoeppe (Matthias Koeppe) Unify the pointer-conversion runtime API. The standard functions are: * SWIG_NewPointerObj (POINTER, TYPE, FLAGS) -- Create an scripting object that represents a typed pointer. FLAGS are language specific. * SWIG_ConvertPtr (INPUT, RESULT, TYPE, FLAGS) -- Get a pointer from the scripting object INPUT and store it in the place RESULT. When a type mismatch occurs, return nonzero. * SWIG_MustGetPtr (INPUT, TYPE, ARGNUM, FLAGS) -- Get a pointer from the scripting object INPUT and return it. When a type mismatch occurs, throw an exception. If ARGNUM > 0, report it as the argument number that has the type mismatch. [Guile]: No changes. [MzScheme]: No changes. [Perl]: Add the function SWIG_NewPointerObj. The function SWIG_MakePtr is kept. The function SWIG_MustGetPtr is currently not supported. [Python]: Add the function SWIG_MustGetPtr. [Ruby]: Add the function SWIG_MustGetPtr. [Tcl]: Remove the "interp" argument of SWIG_NewInstanceObj, SWIG_ConvertPtr, SWIG_ConvertPacked, and SWIG_ConvertPtrFromString. The function SWIG_MustGetPtr is currently not supported. No changes to Pike because its pointer conversion code did not look complete. No changes to PHP4, because I did not understand its runtime code. No changes to Chicken because major changes are expected soon anyway. No changes to Java, OCaml, C# because they do not seem to have a pointer-conversion runtime API. *** INCOMPATIBILITY [Tcl] *** 11/02/2003: mkoeppe (Matthias Koeppe) [Perl5, PHP4, Pike, Python, Ruby, Tcl]: Use the preprocessor to rename external functions of the SWIG runtime API to follow the naming convention SWIG__. This should allow linking more than one interpreter into a program. 10/31/2003: cheetah (William Fulton) [C#] Fix since introducing the exception and std::string delegates. The fix overcomes linker errors when using more than one SWIG module. Problem reported by Andreas Schörk. 10/31/2003: beazley Incorporated patch: [ 823302 ] Incr Tcl support. Contributed by Alexey Dyachenko. Note: needs documentation. 10/31/2003: beazley Incorporated patch: [ 829325 ] new Python Module options and features. Robin Dunn writes: This patch makes a number of changes to the SWIG python module. 1. Add -apply option, and change the default code output to use the foo(*args, **kw) calling syntax instead of using apply(). If the -apply option is given then code is generated as before. This is very similar to Patch #737281 but the new -modern option makes the second half of that patch unnecessary so it is not included here. 2. Add -new_repr option. This is the same as my Patch #797002 which I will mark as closed since it is no longer needed. When this new option is used then the __repr__ methods that are generated for proxy classes will be more informative and give details about the python class and the C++ class. 3. Add %feature("addtofunc"). It allows you to insert one or more lines of code inside the shadow method or function that is already generated, instead of replacing the whole thing like %feature("shadow") does. For __init__ it goes at the end, for __del__ it goes at the begining and for all others the code generated is expanded out to be like def Bar(*args, **kwargs): val = _module.Foo_Bar(*args, **kwargs) return val and the "addtofunc" code is inserted just before the return statement. If the feature is not used for a particular method or function then the shorter code is generated just like before. 4. A little bit of refactoring to make implementing addtofunc a little easier. 5. Added a -modern command-line flag that will cause SWIG to omit the cruft in the proxy modules that allows it to work with versions of Python prior to 2.2. The result is a simpler, cleaner and faster python proxy module, but one that requires Python 2.2 or greater. 10/31/2003: beazley Incorporated patch: [ 829319 ] XML module tweaks. This adds a new command line option -xmllite that greatly reduces the amount of emitted XML code by eliminating some fields mostly used in SWIG's internal processing. Contributed by Robin Dunn. 10/31/2003: beazley Incorporated patch: [ 829317 ] Adds DohSplitLines function. Contributed by Robin Dunn. 10/29/2003: beazley Fixed [ 827907 ] argout objects not being wrapped properly (PATH). Patch contributed by Salvador Fandiño García. 10/29/2003: beazley Fixed [ 826996 ] perl type checking ignores perl subclasses. This enhancement makes it so wrapped classes and structs can be subclassed in Perl and used normally. Patch contributed by Salvador Fandiño García. 10/16/2003: cheetah (William Fulton) [C#] IntPtr marshalled with a void* instead of int in C function declarations. The casts thus look more conventional, for example: // old DllExport double SWIGSTDCALL CSharp_get_Shape_x(int jarg1) { ... Shape *arg1 = (Shape *) 0 ; arg1 = *(Shape **)&jarg1; ... } // new DllExport double SWIGSTDCALL CSharp_get_Shape_x(void * jarg1) { ... Shape *arg1 = (Shape *) 0 ; arg1 = (Shape *)jarg1; ... } 10/14/2003: beazley Fixed a subtle problem with overloaded methods and smart pointers. If a class has overloaded methods like this: class Foo { public: int bar(int x); static int bar(int x, int y); }; and the class is used as a smart pointer: class FooPtr { public: Foo *operator->(); }; The SWIG would try to expose the static member Foo::bar through FooPtr---resulting bogus wrapper code and a compiler error. Due to the way in which overloading is handled, it is extremely difficult to eliminate the static method in this case. Therefore, it is still exposed. However, the generated code now compiles and works. 10/05/2003: mkoeppe (Matthias Koeppe) [Guile, MzScheme, Chicken]: Remove symbol clashes between the runtime libraries by renaming all extern common.swg functions with the preprocessor. 10/05/2003: mkoeppe (Matthias Koeppe) [Guile] Added basic GOOPS support, contributed by John Lenz. See the documentation for details. *** NEW FEATURE *** 10/04/2003: mkoeppe (Matthias Koeppe) [Guile] New option, -only-setters, which disables traditional getter and setter procedures for structure slots. 10/03/2003: mkoeppe (Matthias Koeppe) [Guile] Added run test for reference_global_vars by John Lenz. 09/30/2003: beazley Partial solution to [ 792180 ] C++ smart-pointer/namespace mixup revisited. The problem is not easy to fix (at least it doesn't seem so), but is related to the instantiation of qualified templates inside of other namespaces. SWIG now generates an error message in this case rather than generating broken wrappers. 09/30/2003: beazley Fixed [ 800012 ] ENTER macro from CORE/scope.h clashes with libc search.h. Reported by Britton Leo Kerin. 09/30/2003: beazley Fixed [ 811518 ] Casting ints to doubles (w/ solution?) Addresses a problem with overloading in the Perl module. Reported by Gerald Dalley. 09/28/2003: mkoeppe [Guile with -scm option] Fix typo in generated code for procedures-with-setters. Reported by John Lenz. 09/26/2003: beazley Fixed [ 812528 ] externs not correct when throw is in signature. Reported by Joseph Winston. 09/23/2003: cheetah (William Fulton) SWIG was generating a number of symbols that didn't comply with the ISO C/C++ standard, in particular ISO/IEC 14882:1998(E) 17.4.3.1.2 where double underscores are forbidden as well as symbols starting with an underscore followed by an upper case letter. Most of these have been rooted out. See new section added to internals.html development manual 'Symbol Naming Guidelines for Generated C/C++ Code'. 09/23/2003: cheetah (William Fulton) Director typemap name changes: inv => directorin outv => directorout argoutv => directorargout *** POTENTIAL INCOMPATIBILITY *** 09/19/2003: mrose (Mark Rose) [Python] Director constructors now default to __disown = 0, which is the intended behavior and fixes the director_finalizer test case under python. 09/12/2003: cheetah (William Fulton) [C#] - Typemaps added for std::string and const std::string &. - New delegate for creating a C# string given a char *. It can be used by calling SWIG_csharp_string_callback as shown in the std::string 'out' typemap. Useful if the return type is mapped to a C# string and the calling function is responsible for cleaning up memory as the C# garbage collector doesn't free the memory created in C/C++ and then returned as a C# string. - The exception delegates have moved into an inner class in the intermediate class, thereby freeing up the static constructor. 09/11/2003: beazley (Internals) Major refactoring of iteration over lists and hashes. The DOH library now uses iterators. They work like this: List *l = (some list); Iterator i; for (i = First(l); i.item; i = Next(i)) { // i.item contains the actual list item. // i.item is NULL at end of list ... } Hash *h = (some hash); Iterator j; for (j = First(h); j.item; j = Next(j)) { // j.item contains hash table item // j.key contains hash table key // Both j.item and j.key are NULL at end ... } The old iteration functions Firstitem(), Nextitem(), Firstkey(), and Nextkey() are gone. The new iterators are simpler, result in better memory use, and may be faster. Also, there are no longer any problems iterating over the same list/hash in multiple places at the same time. For example, this is fine: Iterator i,j; for (i = First(l); i.item; i = Next(i)) { for (j = First(l); j.item; j = Next(j)) { ... } } (This never worked in previous versions). *** POTENTIAL INCOMPATIBILITY ***. This will probably break third party extensions to SWIG (or give them further encouragement to join the SWIG CVS-tree :-). 09/10/2003: mkoeppe (Matthias Koeppe) [Guile] Fix memory leaks in the "list-vector.i" typemaps. 09/09/2003: mkoeppe (Matthias Koeppe) [Chicken] Use C_mk_bool rather than C_mkbool. This fixes the wrapping of boolean values for Chicken 1.10 and newer. Reported by Dave / Felix Winkelmann . 09/05/2003: cheetah (William Fulton) [Java] Directors implemented for Java. In summary this is a big new feature which supports upcalls from C++ to Java. Code is generated to support C++ callbacks to call into Java and true polymorphic behaviour for Java classes derived from C++ classes. See java.html for details. Contributed by Scott Michel. 09/05/2003: Tiger Created contract example directory at /SWIG/Examples/contract Added simple contract examples (simple_c & simple_cxx) Modified contract module's output format *** NEW FEATURE *** 09/01/2003: cheetah (William Fulton) Test-suite build improvements: - Multiple build directories working for the test suite, so it is now possible to run configure in multiple subdirectories and run the test suite in each of these sub directories. - 'make distclean' fixed so it doesn't bomb out on the Examples directory when using multiple subdiretory builds. Required the following directories to be moved: Examples/GIFPlot/Perl -> Examples/GIFPlot/Perl5 Examples/GIFPlot/Php -> Examples/GIFPlot/Php4 These new directories used to be symbolic links to the old directory. Also the Examples/test-suite/Perl symbolic link has been removed. - Running the test-suite, other than from the root directory, say in Examples/test-suite/python will now display all the code being executed. - The following 3 C# compilers are detected during configure and work with the test-suite: Mono, Portable.NET and Microsoft. 09/01/2003: Tiger Added inheritance support for design by contract feature. 09/01/2003: beazley Fixed [ 794914 ] Wrong types in template specialization. SWIG was not handling arguments correctly in template partial specialization. For example, template class Foo { public: T *blah(); }; %template(FooInt) Foo; in this class, the return type of blah was set to 'int **', but it should really be 'int *'. This has been fixed, but it will affect all prior uses of partial specialization. 09/01/2003: beazley Fixed [ 786394 ] Patch for generated perl code does not compile under RedHat9. Reported by Scott Finneran. 09/01/2003: beazley Fixed [ 791579 ] (unsigned) long long handled incorrectly (Tcl). This was an error in the Tcl typemaps.i file. Reported by Kjell Wooding. 09/01/2003: beazley Fixed [ 797573 ] no way to rename classes coming from C structures. This problem relates to renaming of anonymous structures with a typedef. For example: %rename(Bar) Foo; typedef struct { ... } Foo; Reported by Britton Leo Kerin. 09/01/2003: beazley Fixed [ 797576 ] -help seems to imply that only tcl-specific options exist. Added a comment to alert user to other options. Reported by Britton Leo Kerin. 09/01/2003: beazley Fixed [ 798205 ] Segfault in SWIG_ConvertPtr. Reported by Prabhu Ramachandran. 08/30/2003: mrose (Mark Rose) Modified the director typemaps in python/std_complex.i to use the new-style macro and conversion functions, which eliminated some redundant code. Fixed a few bugs in these typemaps as well, although more testing is needed. 08/29/2003: mrose (Mark Rose) Completed initial support for wrapping abstract classes with directors. Constructor wrappers will be generated for abstract classes that have directors, and instances of the director classes will be created regardless of whether the proxy class has been subclassed in the target language. No checks are made during construction to ensure that all pure virtual methods are implemented in the target language. Instead, calls to unimplemented methods will throw SWIG_DIRECTOR_PURE_VIRTUAL_EXCEPTION exceptions in C++. Integrated Prabhu Ramachandran's typemap patches, which provide director typemap support for enums and std::size_t, and fix a couple bugs in the director std::vector<> typemaps. 08/29/2003: cheetah (William Fulton) [C#] Implemented exception handling for throwing C# exceptions from C/C++ code. A few delegate functions are available for calling which then throw the C# exception. Use the SWIG_CSharpThrowException function from C/C++ typemaps. See the generated wrapper code or csharphead.swg for all available exceptions. Example: SWIG_CSharpThrowException(SWIG_CSharpException, "exception description"); The 'throws' typemaps are also now implemented, so code is automatically generated to convert any C++ exception into a C# System.Exception when the C++ method declares an exception specification such as: int foo() throw(Bar); Also any parameters that are references to a C++ class or a class passed by value and are passed as a C# null will now throw a C# NullReferenceException. 08/29/2003: cheetah (William Fulton) [C#] Fix to match the calling convention of all pinvoke methods so that they match the calling convention used by default in the C# 'static extern' declarations (__stdcall is used on Windows). 08/19/2003: cheetah (William Fulton) [Java] Reworked std::string typemaps. Fixes a number of string in std namespace problems. For example %template vector. The templated class' get method wasn't returning a Java String, but a SWIGTYPE_p_string. Reported by Zach Baum. 08/15/2003: beazley Fixed [ 763522 ] 1.3.19 segfault in SwigType_add_pointer/DohInsertitem. Related to problem with unnamed class handling in Perl module. 08/15/2003: beazley Fixed [ 763563 ] Missing indication of optional arguments. Tcl module. Reported by Krzysztof Kozminski. 08/15/2003: beazley Fixed [ 787432 ] long param handled as int. Tcl module now uses Tcl_GetLongFromObj to convert integer values. 08/11/2003: beazley Fixed [ 775989 ] numeric template parameters. There were some errors in template expansion related to the use of arrays where the array dimension was a template parameter. It should work now. Reported by Bryan Green. 08/10/2003: mrose (Mark Rose) Added a director typemap (outv) for return by value and cleaned up up a few of the commented director typemaps. 08/10/2003: mrose (Mark Rose) Fixed constructor generation for director classes to ignore private constructors. Protected constructors are also ignored for now, pending a solution to the problem of wrapping classes that only define protected constructors. 08/07/2003: cheetah (William Fulton) New commandline option -outdir to specify where the language specific files are to be generated. This is useful for target languages like Python, Java etc which generate proxy files in the appropriate language. This option does not apply to the C/C++ wrapper file. 08/07/2003: cheetah (William Fulton) On Windows the generated files (other than the _wrap.c or _wrap.cxx files) were sometimes incorrectly being generated into the current directory unless the input file used the Unix path separator. The Windows path separator should now be used. Bug reported by Robert Davies. 08/07/2003: beazley Added array variable set typemap to Perl module. 08/07/2003: beazley Fixed [ 775677 ] Array init causes codegen bug.. 08/07/2003: beazley Fixed [ 779062 ] Class"\n"::foo not supported. SWIG should now correctly handle whitespace in between namespace qualifiers. For example "A :: Foo :: Bar". 07/31/2003: cheetah (William Fulton) Fixes for parameters which are classes that are passed by value and have a default value. A copy constructor for SwigValueWrapper is required (SF #780056). Also fixed memory leak in these circumstances. These mods also fix SF #780054. 07/28/2003: beazley Improved run-time error message for pointers in Python module. Contributed by Zooko. 07/10/2003: ballabio (Luigi Ballabio) [Almost all languages] Wrappers for std::pair added. Typemaps for Python, Ruby, Guile and MzScheme. 07/01/2003: mkoeppe (Matthias Koeppe) [Chicken] Handle the case of more than one argout typemap per function. 06/29/2003: cheetah (William Fulton) [Java, C#] SF #670949 request. The destructor wrapper function name is now configurable. A new attribute called methodname in the javadestruct/javadestruct_derived (Java) or csdestruct/csdestruct_derived (C#) typemaps specifies the method name. For example in Java the destructor is wrapped by default with the delete method: %typemap(javadestruct, methodname="delete") SWIGTYPE {...} 06/27/2003: cheetah (William Fulton) [Java, C#] The throws attribute for adding exception classes to the throws clause also now works with the following typemaps: newfree javain, javaout (Java) csin, csout (C#) For example, the 'AnException' will be added to the throws clause in the proxy function: %typemap(javaout, throws="AnException") int { int returnValue=$jnicall; if (returnValue==0) throw new AnException("Value must not be zero"); return returnValue; } 06/25/2003: mrose (Mark Rose) [Python] Director typemap marshalling checks for null pointers when walking the parameter list instead of relying soley on the parameter count. Cures a segfault that occurred for multiple argument inv typemaps. Someone with more Swig experience should probably review this code. 06/24/2003: mkoeppe (Matthias Koeppe) [Chicken] Don't emit calls to "C_check_for_interrupt", which may result in an endless loop. Patch by felix@proxima-mt.de. 06/20/2003: cheetah (William Fulton) [C#] Finalizers now use destructor syntax as the override which was used in the Finalize method is not in the ECMA standards, spotted by the MS compiler. 06/10/2003: cheetah (William Fulton) [C#] A number of changes have been made to remove the Java naming that was used in the C# module. Typemap name changes: jni -> ctype jtype -> imtype jstype -> cstype javain -> csin javaout -> csout javainterfaces -> csinterfaces javabase -> csbase javaclassmodifiers -> csclassmodifiers javacode -> cscode javaimports -> csimports javaptrconstructormodifiers -> csptrconstructormodifiers javagetcptr -> csgetcptr javafinalize -> csfinalize Feature name changes: javaconst -> csconst javamethodmodifiers -> csmethodmodifiers Pragma changes: pragma(java) -> pragma(csharp) jniclassbase -> imclassbase jniclassclassmodifiers -> imclassclassmodifiers jniclasscode -> imclasscode jniclassimports -> imclassimports jniclassinterfaces -> imclassinterfaces Special variable name changes: $javaclassname -> $csclassname $javainput -> $csinput $jnicall -> $imcall This will break SWIG interface files that use these typemaps, features and pragmas. Please update your code or use macros for backwards compatibility. *** POTENTIAL INCOMPATIBILITY FOR C# MODULE *** 06/10/2003: mkoeppe (Matthias Koeppe) [MzScheme] Applied MzScheme module updates contributed by John Lenz . - Updated mzscheme to use SWIG's common runtime type system from common.swg. - The Lib/mzscheme directory has been reorganized to standardize names across the language modules: mzscheme.i was moved to mzscheme.swg, mzscheme.swg and mzschemedec.swg have been removed, mzrun.swg (which contains the runtime code) has been added. - The swig_proxy structure was renamed to swig_mz_proxy. swig_mz_proxy now contains a pointer to a swig_type_info structure. - Added varin and varout typemaps for SWIGTYPE [] and SWIGTYPE &. - Garbage collection by calling scheme_add_finalizer() has been added. *** NEW FEATURE [MzScheme] *** 06/10/2003: cheetah (William Fulton) [Java] New typemaps: javadestruct and javadestruct_derived for the C++ destructor wrapper. The javadestruct version gets used by classes at the top of an inheritance chain and the javadestruct_derived version gets used by other classes. [C#] cildispose and cildisposeoverride typemaps replaced by csdestruct and csdestruct_derived typemaps. The delete() method has been removed and its functionality put into these typemaps designed for the Dispose() method. - New typemaps csinterfaces and csinterfaces_derived replace the javainterfaces typemap. Also fixes the peculiarity of all classes in an inheritance chain individually deriving from the IDisposable interface. - New typemap csfinalize for finalizers. C++ destructors are now called by garbage collector during finalization. Problem reported by Andreas Schörk. 06/10/2003: Tiger Modified contract code for error message output. Contract code can now print out simple error message. Modified contract code to prepare for inheritance 06/03/2003: mkoeppe [Guile] Applied Guile module updates contributed by John Lenz . - SWIG currently uses Guile's gh_ API, which is marked as deprecated in Guile 1.6 and will be removed in Guile 1.9. This change introduces a command-line flag "-scm" which causes SWIG to generate wrappers that use Guile's SCM API instead; this requires Guile >= 1.6. - The Lib/guile directory has been reorganized to standardize names across language modules: guiledec.swg and guile.swg have been moved into guile_gh_run.swg, guile.i has been moved to guile_gh.swg, guile_scm.swg and guile_scm_run.swg which contain the SCM API stuff have been added - ghinterface.i, which contains the defines from the gh_ functions to the scm_functions has been added - The API for dealing with pointer objects is now SWIG_ConvertPtr, SWIG_MustGetPtr, SWIG_NewPointerObj. - Added varin and varout typemaps for SWIGTYPE [] and SWIGTYPE & - Garbage collection has been added. *** NEW FEATURE [Guile] *** 06/01/2003: cheetah (William Fulton) Dimensionless arrays such as int foo[] = {1, 2}; extern int bar[]; produce a warning that the variable is read-only. Depending on the target language, this used to cause compile errors or generate a setter that generated a runtime error. A setter cannot be automatically generated because the array size cannot be determined by SWIG. A varin, globalin or memberin typemap (depending on the target language) must be written by the user. 05/29/2003: beazley Refinement to default typemap matching and arrays. When an array is declared like this: int foo[4]; The default typemap now resolves to SWIGTYPE [ANY] If no match is found for that, it then resolves to SWIGTYPE [] If no array dimension is specified in the original declaration, the SWIGTYPE [] is used right away. Note: This change has been made to resolve problems related to arrays with and without dimensions. For example, sometimes SWIG was generating setter functions for array variables with no dimensions (an error). Likewise, SWIG sometimes made arrays with dimensions read-only (also an error). This fixes the arrays_global test problem. 05/28/2003: beazley Fixed subtle type handling bug with references and pointers. If you had functions like this: typedef Foo Bar; Foo *func1(); void func2(Bar &x); Then func2() wouldn't accept objects returned by func1() because of a type error. It should work now. Reported by Brian Yang. 05/21/2003: cheetah (William Fulton) Fixes to some of the Visual C++ example project files which would not work with spaces in the paths held in the environment variables used to point to the target language's library / include directory. SF bug #740769 05/21/2003: songyanf (Tiger) Added -contracts option. First try of the idea of "Wrap by Contract": build up realiable cross-language module by wrapping with SWIG. Implemented basic assertion (preassertion & postassertion & invariant) for simple C/C++ functions. Current format of contracts are: %contract class_name :: func_name (paras...) { require: boolean exprs; exprs; ensure: boolean expr; exprs; invariant: boolean expr; exprs; } *** NEW FEATURE *** 05/19/2003: cheetah (William Fulton) Build tweaks. There were a few preprocessor definitions which were specified in the Makefile for passing on the commandline when compiling. These are now all defined in swigconfig.h. Autoconf doesn't normally allow installation directories to be defined in this config header file, but an autoconf archive macro enables this. This macro along with future autoconf macros are going to be put in the Tools/config directory. 'swig -version' now reports the target build platform. 05/11/2003: cheetah (William Fulton) [C# and Java] Fix to the following typemaps: javabase, javainterfaces, javaimports, javaclassmodifiers, javaptrconstructormodifiers, javafinalize, javagetcptr & javacode. These are the typemaps for modifying/generating proxy classes. Previously the typemaps would use the proxy class name and not the C++ type, which was inconsistent with all other typemaps. In most circumstances the proxy class name and the C++ class name/type is the same except for classes in namespace, templated classes etc. so this shouldn't affect most cases. *** POTENTIAL INCOMPATIBILITY FOR JAVA and C# MODULES *** 05/09/2003: cheetah (William Fulton) Visual C++ Project files have been added so that the runtime libraries can be built on Windows (for Tcl, Perl, Python and Ruby). 05/01/2003: beazley Fixed problem with return by value, const, and private constructors. For example: class B { private: B(); public: B(const B&); }; class A { ... const B returnB() const; ... }; Problem and patch suggestion reported by Bill Hoffman. 04/29/2003: cheetah (William Fulton) Build changes: - Single autoconf invocation - autoconf in the Tools directory has gone. - Libtool bootstrapped when running autogen.sh. This requires anyone using the cvs version of SWIG to have libtool installed on their machine. Suggest version 1.4.2 or higher, preferably the latest - 1.5. - Automake is now used to build the runtime libraries in conjunction with libtool. - Runtime libraries are now successfully built as DLLs on Cygwin. - Skipping languages is no longer just determined in the top level makefile but in configure.in. This info is used for building the runtime libraries and for running the examples and test-suite. - These changes have fixed multiple build directory builds, that is building from directories other than the top level directory. Installation from multiple build directories also working. An initial configure in the top level directory is no longer needed as described in 04/02/2003 entry. A 'make distclean' will be needed before building in a directory other than the top level directory if the autotools have been run from this top level directory at some point, but autoconf will tell you this. Note that 'make check' only works from the top level directory at the moment. 04/28/2003: beazley Fixed [ 723471 ] Wrapper_print() fails with preprocessor directives. 04/28/2003: beazley Minor refinement of const static member variable handling described in CHANGES 08/11/2002. Previously, SWIG merely checked to see if there was an initializer in the declaration. Now, SWIG additionally checks to make sure the static member is const. 04/25/2003: ljohnson (Lyle Johnson) [Ruby] Added a kind of limited support for multiple inheritance, activated using the -minherit command-line option. I've also updated the "C++ Inheritance" section of the Ruby documentation to discuss how this works, and its limitations. Also also modified the minherit.i test case to run against this. 04/25/2003: ljohnson (Lyle Johnson) [Ruby] Added the -globalmodule command-line option for the Ruby module, for wrapping stuff into the global module (Kernel) instead of a nested module. Updated documentation accordingly. 04/23/2003: mrose (Mark Rose) Fixed symname error in director calls to Python methods that extend C++ operators. Stopped director destructor wrappers from calling __set_up, which was leaving the director flag in an inconsistent state. 04/23/2003: beazley Fixed problem with namespace resolution and nested namespaces. Reported by Alfred Lorber (and Marcelo Matus). 04/16/2003: cheetah (William Fulton) Patch for Java examples and test-suite to run on Mac OS X. 04/15/2003: ljohnson (Lyle Johnson) [Ruby] Incorporated Nobu Nakada's patches for supporting the Ruby 1.8 allocation framework. 04/15/2003: ljohnson (Lyle Johnson) [Ruby] Replaced all uses of the deprecated STR2CSTR() macro with the safer StringValuePtr() macro. For more information, see ruby-talk:67059 and follow-ups to that post. 04/11/2003: beazley Fixed problem with preprocessor macro expansion. For example: #define min(x,y) ((x) < (y)) ? (x) : (y) int f(int min); Reported by Sebastien Recio. 04/10/2003: cheetah (William Fulton) [Java] Added a runtime check to typemaps in arrays_java.i library to check that the Java array passed in is the same size as the C array and throw an exception if not. Also fix to use delete instead of free for arrays created using new. 04/07/2003: cheetah (William Fulton) Remove GCC3 warning when compiling the examples and test-suite: cc1plus: warning: changing search order for system directory "/usr/include" cc1plus: warning: as it has already been specified as a non-system directory See SF patch #715531 submitted by Gerald Williams 04/03/2003: cheetah (William Fulton) [C#] Improved wrapping of enums and constants. These were previously wrapped as C# variables rather than constants. Either these are wrapped as readonly (runtime) constants or compile time constants, depending on the %javaconst directive (The directive is likely to change name soon). For example wrapping: %javaconst(0); #define ABC 22 %javaconst(1) XYZ; #define XYZ 33 is now: public static readonly int ABC = examplePINVOKE.get_ABC(); public const int XYZ = 33; 04/03/2003: cheetah (William Fulton) [Java] Global constants and enums are put in their own interface called xxxConstants, where xxx is the module name. This is an improvement as it is possible to derive (implement) a Java class from the xxxConstants interface to improve the syntax; namely when wrapping: enum {ONE=1, TWO, THREE}; accessing these from a Java class implementing xxxConstants is neater: int number = ONE; than the previous: int number = xxx.ONE; Patch submitted by Dave Dribin. 04/02/2003: cheetah (William Fulton) Build improvements for multiple builds. This allows one to build the SWIG executable and runtime libraries for different platforms/compilers etc by running configure in different directories. This isn't 100% just yet and won't be until libtool is better configured... a 'configure' and 'make distclean' needs to be run in the root directory before it all works. For example: $ ./configure $ make distclean $ mkdir config1; cd config1; ../configure CC=gcc CXX=g++; make; cd .. $ mkdir config2; cd config2; ../configure CC=cc CXX=c++; make; cd .. To be improved. A 'make check' does not work yet either. 04/01/2003: beazley Fixed template partial specialization argument expansion bug. This showed up when trying to use std_vector.i with vectors of pointers. 03/31/2003: cheetah (William Fulton) Fix for parallel make builds of SWIG, for example make -j 4 Build failure reported by Bill Clarke. 03/28/2003: beazley Released 1.3.19. Version 1.3.19 (March 28, 2003) =============================== 03/28/2003: beazley Variety of minor bug fixes to the 1.3.18 release including: - Segmentation fault with %extend directive. - Typemap variable substitution bug. - Expression evaluation bug. - Large memory leak with template expansion. Version 1.3.18 (March 23, 2003) =============================== 03/21/2003: beazley Fixed two problems with the %extend directive, overloading, and template expansion. See the 'template_extend_overload' and 'template_extend_overload_2' tests in Examples/test-suite for details. 03/20/2003: cheetah (William Fulton) [C#] Added some typemaps as suggested by Andreas Schoerk for handling parameters that are passed as pointers or by reference. These have been put in typemaps.i. 03/20/2003: beazley Fixed a C++ scoping bug related to code like this: class Foo { public: int Foo::bar(); }; Previously, SWIG just tossed out the Foo::bar() declaration. Now, the declaration is wrapped provided that the prefix is exactly the same as the current scope (including any enclosing namespaces). Reported by Bruce Lowery. 03/20/2003: beazley Incorporated [ 696516 ] Enabling exception processing for data member access. In some compilers, attribute access can generate exceptions. However, SWIG ordinarily assumes that no exceptions will be raised. To disable this, use the %feature("allowexcept"). For example: %feature("allowexcept") Foo::x; ... class Foo { public: int x; /* Exception handling enabled */ ... }; Patch contributed by Yakov Markovitch. 03/20/2003: beazley Incorporated Patch. [ 701860 ] Improve Performance (python proxies). Gives a performance boost to proxy class code and the management of the .this and .thisown attributes. Contributed by Mike Romberg. 03/19/2003: cheetah (William Fulton) [C# and Java] Added missing vararg support. 03/18/2003: mrose (Mark Rose) Removed code related to tagging individual methods for directors. The concept of having directors for some but not all virtual methods of a class is deeply flawed. The %feature("nodirector") tag is also gone. Directors are off by default. To enable them for a class, issue %feature("director") classname; which will create director methods for every virtual method in the hierarchy of the class. 03/17/2003: beazley Fixed a subtle problem with passing arguments of type function. For example: int foo(int x(int, int)); or typedef int binop_t(int, int); int foo(binop_t x); In old versions, this would produce code that wouldn't compile. Now, SWIG merely adds an extra pointer, making these declarations the same as: int foo(int (*x)(int, int)); typedef int binop_t(int, int); int foo(binop_t *x); Reported by Garth Bushell. 03/17/2003: mrose (Mark Rose) Fixed the return statement for director base class calls that have no return value. 03/15/2003: beazley Fixed a problem with const smart-pointer wrapping. For example: class Foo { public: int x; void bar() const; void spam(); }; class Blah { ... const Foo *operator->(); ... }; In this case, only "x" and "bar" are visible from Blah (since application of spam violates constness). Moreover, access to "x" is read-only. 03/15/2003: mrose (Mark Rose) Cleaned up two signed versus unsigned comparisons in python/std_vector.i. 03/15/2003: cheetah (William Fulton) [C#] Global variables are wrapped using properties instead of get and set methods. Member variable wrapping bug fixes, for example wrapping pointers work now. Typemaps are used for all variable wrapping to generate the property code. 03/13/2003: mrose (Mark Rose) Fixed a bug in the virtual method unrolling for directors. The order of unrolling is now from base to derived, to ensure that the most derived implementation of a director method is found. Director methods for pure virtual methods now throw DIRECTOR_PURE_VIRTUAL_EXCEPTION if _up is set. 03/12/2003: cheetah (William Fulton) [C#] Polymorphism fix: virtual functions now use the appropriate keyword in the C# proxy class, virtual or override. Some 'using System;' statement fixes needed by the Mono compiler. 03/11/2003: beazley Fixed subtle bug in the application of SwigValueWrapper<> to template classes with default constructors. Reported by Bruce Lowery. 03/11/2003: beazley The $descriptor(type) variable is now expanded in code supplied to %extend. This is useful for certain kinds of advanced wrapping (especially container classes). 03/11/2003: luigi Support for std::map. (a) Integration with scripting language (a la std::vector) for Python, Ruby, MzScheme, and Guile; (b) Simple wrapper for other languages 03/10/2003: beazley Fixed problem with escape sequences in string and character constants. SWIG wasn't parsing certain octal codes correctly. 03/07/2003: beazley Fixed a variety of subtle preprocessor problems reported by Sebastien Recio. (a) Empty preprocessor values no longer generate "bad constant value" errors. For example: #define FOO #define FOO BAR (b) Macro names can now span multiple lines (technically valid, although questionable practice). For example: #define A_LONG_MACRO_\ NAME 42 (c) Whitespace is no longer required before certain macro values. For example: #define FOO"Hello" #define BAR\ "Hello" 03/07/2003: ljohnson (Lyle Johnson) [Ruby] Added missing long long and unsigned long long typemaps in the Lib/ruby/typemaps.i library file. 03/07/2003: mrose (Mark Rose) Added Examples/python/callback to demostrate how directors can be used to implement callbacks in Python Added Examples/python/extend to demonstrate virtual method calls from C++ to Python (really the same as the callback example, just a different context). Added four tests for very basic director functionality. These have runtime tests under python. The Python module now emits #define SWIG_DIRECTORS near the top of the output file if directors are enabled. This is useful for disabling parts of tests in target languages that don't support directors. 03/06/2003: mrose (Mark Rose) Added a section to Doc/Manual/Python.html on cross language polymorphism (directors). 03/06/2003: mrose (Mark Rose) The short-lived "-fdirectors" command line option has been removed. To enable directors, instead use the extended %module directive as follows: %module(directors="1") modulename 03/06/2003: cheetah (William Fulton) The long long typemaps have been rewritten so that they can be more easily used with non ISO compilers, like Visual C++. For example if you are wrapping the Windows 64 bit type __int64 the long long typemaps can be used with %apply: %apply long long { __int64 }; __int64 value1(__int64 x); __int64 will now appear in the generated code instead of long long. 03/06/2003: beazley *** DEVELOPER CHANGE *** Swig module mutation has been changed slightly. When a language class method wants to save node attributes, it now uses one of the following functions: Swig_require() Swig_save() The first argument to these functions is a namespace in which saved attributes are placed. For example,this code Node *n; Swig_save("cDeclaration",n,"type","parms","name",NIL); saves the attributes as "cDeclaration:type", "cDeclaration:parms", and so forth. If necessary, a language module can refer to old values by using this special namespace qualifier. In addition to this, a special attribute "view" contains the name of the last namespace used to save attributes. In the above example, "view" would have the value "cDeclaration". The value of "cDeclaration:view" would have the previous view and so forth. Swig_restore(n) restores a node to the state before the last Swig_require() or Swig_save() call. Note: This change makes it easier for language modules to refer to old values of attributes. 03/06/2003: mrose (Mark Rose) Merged the cross-language polymorphism patch. When enabled, C++ "proxy" classes (called directors) are generated for each specified C++ class. Directors pass method calls from C++ to Python, similar to the way the usual proxy (shadow) classes pass method calls from Python to C++. Together, these two types of proxies allow C++ classes that are extended in Python to behave just like ordinary C++ classes and be used in C++ like native objects. This feature is still very experimental and is disabled by default. To enable director support, specify '-fdirectors' on the SWIG command line or in the SWIG_FEATURES environment variable. In the interface file, add %feature("director") to generate directors for all classes that have virtual methods. See http://stm.lbl.gov/~tm2/swig/ProxyDoc.html for more details. 03/03/2003: beazley Fixed a small glitch in typemap local variable replacement. If you had a typemap like this: %typemap(in) type ($1_type temp) { ... temp = ...; ... } and no occurrence of "$1_type" appeared in the body, then the local variable type wouldn't be substituted. 03/03/2003: cheetah (William Fulton) [C#] New version of the CSharp module which is typemap based. It also uses ECMA C# and no longer uses Microsoft Visual C++.NET glue. This means that it will work on non-Windows platforms. Contributed by Neil Cawse. 02/27/2003: beazley Fixed [ 653548 ] error parsing casting operator definition. SWIG now ignores casting operators declared outside of a class. For example: inline A::operator char *() { ... } Bug reported by Martin Casado. 02/27/2003: beazley Added support for anonymous bit-fields. For example: struct Foo { int x : 4; int : 4; int y : 8; }; Anonymous bit-fields are ignored by SWIG. Problem reported by Franz Höpfinger. 02/26/2003: cheetah (William Fulton) [Java] Better typemaps in the Examples/java/typemap example and also fixes subtle bug when using the StringBuffer typemaps more than once. 02/26/2003: beazley Fixed [ 642112 ] Constants char bug. 02/26/2003: beazley Fixed [ 675337 ] Partial template specialization not entirely working. There was a subtle problem related to the naming and ordering of template partial specialization arguments. Matching worked okay, the resulting templates weren't expanded correctly. 02/25/2003: beazley Fixed problem with parsing (and generating code) for references to arrays. For example: int foo(int (&x)[10]); 02/25/2003: beazley Fixed [ 635347 ] Compilation warning from libpy.c. Reported by Daniel L. Rall. 02/25/2003: beazley Fixed a subtle problem with virtual method implementation checking and typedef. typedef int *intptr; struct A { virtual int *foo() = 0; }; struct B : public A { virtual intptr foo() { }; }; SWIG was treating these declarations as different even though they are the same (via typedef). 02/25/2003: ljohnson (Lyle Johnson) [Ruby] Added range checking for the NUM2USHRT macro, per [ 675353 ]. 02/24/2003: beazley Fixed a subtle problem with the code that determined if a class is abstract and can be instantiated. If you had classes like this: struct A { virtual int foo(int) = 0; }; struct B : virtual A { virtual int foo(int); }; struct C : virtual A { }; /* Note order of base classes */ struct D : B, C { }; /* Ok */ struct E : C, B { }; /* Broken */ then SWIG determined that it could instantiate D(), but not E(). This inconsistency arose from the depth-first search of the inheritance hierarchy to locate the implementations of virtual methods. This problem should now be fixed---SWIG will attempt to locate any valid implementation of a virtual method by traversing over the entire hierarchy. 02/22/2003: cheetah (William Fulton) [Java] Fix for using enum typemaps. The Java final static variable type can be set using the jstype typemap, enabling enums to be mapped to something other than int. Bug reported by Heiner Petith. 02/21/2003: songyanf (Tiger) Added CSharp (C#) module prototype i.e. csharp.cxx & csharp.h at Source/Modules/. They are for test usage only now and need improvement. The interface also need to be modified. *** NEW FEATURE *** 02/20/2003: songyanf (Tiger) Fixed problem with typedef with -fvirtual. Similar as beazley's modification today. 02/20/2003: beazley Added support for gcc-style variadic preprocessor macros. Patch [ 623258 ] GCC-style vararg macro support. Contributed by Joe Mason. 02/20/2003: beazley Fixed [ 605162 ] Typemap local variables. Reported by Lyle Johnson. 02/20/2003: beazley Fixed problem with abstract classes and typedef. For example: class Foo { public: virtual void foo(int x) = 0; }; typedef int Integer; class Bar : public Foo { public: virtual void foo(Integer x); }; SWIG was getting confused about the latter method---making Bar abstract. Reported by Marcelo Matus. 02/19/2003: cheetah (William Fulton) [Java] %javaconst(flag) can also be used on enums as well as constants. This feature enables true Java compiler constants so that they can be used in Java switch statements. Thanks to Heiner Petith for patches. 02/19/2003: songyanf (Tiger) Modified -fcompact feature to deal with PP lines 02/18/2003: beazley Fixed [ 689040 ] Missing return value in std_vector.i. Reported by Robert H. de Vries. 02/18/2003: beazley Fixed a few evil scoping problems with templates, namespaces, and the %extend directive. Problem reported by Luigi Ballabio. 02/18/2003: cheetah (William Fulton) [Ruby] Improved support for Visual C++ and other native Windows compilers. It is no longer necessary to specify "/EXPORT:Init_", where is the swig module name when linking using these native Windows compilers. 02/15/2003: songyanf (Tiger) Added -fvirtual option. Reduce the lines and size of the wrapper file by omitting redifined virtual function in children classes. Modified -compact option to -fcompact option Added -small option. -small = -fvirtual -fcompact And it can be extended by future feature options, which are used to reduce wrapper file szie. Added SWIG_FEATURES environment variable check. To dynamically set the feature options such as -fcompact & -fvirtual *** NEW FEATURE *** 02/13/2003: lenz Updated Doc/Manual/Perl5.html to talk about C++ compile problems configure.in now checks for PERL5_CCFLAGS Runtime/Makefile.in and Example/Makefile.in now use PERL5_CCFLAGS Added Lib/perl5/noembed.h which contains all the known macro conflicts 02/12/2003: beazley Fixed [ 685410 ] C++ Explicit template instantiation causes SWIG to exit. Fixes a syntax error with declarations similar to this: template class std::vector; SWIG now ignores the instantiation and generates a warning message. We might do more later. Reported by Thomas Williamson. 02/11/2003: cheetah (William Fulton) Rewrote bool typemaps to remove performance warning for compiling generated code under Visual C++. 02/11/2003: cheetah (William Fulton) Fix for wrapping reference variables (const non-primitive and all non-const types) for example: int& i; Class& c; const Class& c; 02/11/2003: beazley Fixed more very subtle preprocessor corner cases related to recursive macro expansion. For example: #define cat(x,y) x ## y cat(cat(1,2),3) // Produces: cat(1,2)3 #define xcat(x,y) cat(x,y) xcat(xcat(1,2),3) // Produces 123 See K&R, 2nd Ed. p. 231. 02/10/2003: cheetah (William Fulton) Fixed [ 683882 ] - patch submitted by F. Postma for SWIG to compile on HP-UX. 02/10/2003: beazley Fixed subtle preprocessor argument expansion bug. Reported by Marcelo Matus. 02/10/2003: songyanf Added -compact option. Reduce the lines and size of the wrapper file by omitting comments and combining short lines. *** NEW FEATURE *** 02/07/2003: beazley Fixed [ 651355 ] Syntax error with cstring.i Reported by Omri Barel. 02/07/2003: beazley Fixed [ 663632 ] incompatibility with standard cpp. This is a refinement that fixes this problem: // Some macro with an argument #define FOO(x) x int FOO; /* Not a macro---no arguments */ 02/05/2003: beazley Fixed [ 675491 ] parse error with global namespace qualification. Submitted by Jeremy Yallop. 02/04/2003: beazley Fixed bug in varargs processing introduced by the numinputs typemap parameter. 01/08/2003: ttn [xml] Fix string-replacement ordering buglet. Thanks to Gary Herron. 12/23/2002: cheetah (William Fulton) Further build changes: - The SWIG executable is now built using a single Makefile. - This makefile is generated by Automake (Source/Makefile.am). - Dependency tracking and tags support are in this makefile. - Automake 1.7.2 and Autoconf 2.54 minimum versions are needed to build SWIG from CVS. - Running ./autogen.sh now installs Autoconf/Automake support files into Tools/config and these files are no longer stored in CVS. - Bug fixes in 'make install' for systems using .exe executable extension and ./configure --with-release-suffix=whatever 12/16/2002: cheetah (William Fulton) More build changes: - Autoconf's AC_CANONICAL_HOST replaces proprietary approach for detecting build host. - Autoconf support files moved to Tools/config. 12/16/2002: cheetah (William Fulton) Modifications to run on MacOS, submitted by Bernard Desgraupes. Mainly ensuring generated files are output in the appropriate directory for some modules. 12/11/2002: cheetah (William Fulton) Various build modifications and bug fixes: - Simplification of version string. Use autoconf's PACKAGE_VERSION instead. - Build time removed from SWIG version. - Using standard autoconf config header generation. - Updated old autoconf macros as reported by autoupdate. - Removed $prefix in autoconf from search paths as autoconf won't expand them. - Subtle bug fix where 'make prefix=/somewhere; make clean; make prefix=/somwhere/else' produced an executable using the incorrect library directories. - Added -ldflags commandline option for MzScheme, Ocaml, Pike and PHP. - Fixed reporting of compiler used when using -version commandline option. - SWIG web address added to -version commandline option. 12/11/2002: beazley Minor fix to Tcl dynamic cast typemaps. Reported by Kristopher Blom. 12/10/2002: beazley Fixed subtle template argument replace bug. Reported by Chris Flatley. 12/10/2002: beazley Reverted CHANGES 09/03/2002, preprocessor argument evaluation. Arguments are not evaluated during collection, K&R, p. 230. 12/06/2002: beazley Fixed [ 649022 ] Compilation problems with KAI/KCC 12/02/2002: beazley SWIG 'rel-1-3' CVS branch merged back into the main branch. Version 1.3.17 (November 22, 2002) ================================== 11/19/2002: beazley Fixed [ 613922 ] preprocessor errors with HAVE_LONG_LONG. 11/19/2002: beazley Fixed [ 615480 ] mzscheme SWIG_MustGetPtr_. 11/19/2002: beazley Fixed [ 635119 ] SWIG_croak causes compiler warning. 11/16/2002: cheetah (William Fulton) [Java] Added typemaps for pointers to class members. 11/15/2002: cheetah (William Fulton) [Java] Bug fix: Overloaded C++ functions which cannot be overloaded in Java once again issue a warning. 11/14/2002: cheetah (William Fulton) [Java] Handling of NULL pointers is improved. A java null object will now be translated to and from a NULL C/C++ pointer by default. Previously when wrapping: class SomeClass {...}; void foo(SomeClass *s); and it was called from Java with null: modulename.foo(null) a Java NullPointerException was thrown. Extra typemaps had to be written in order to obtain a NULL pointer to pass to functions like this one. Now the default wrapping will detect 'null' and translate it into a NULL pointer. Also if a function returns a NULL pointer, eg: SomeClass *bar() { return NULL; } Then this used to be wrapped with a SomeClass proxy class holding a NULL pointer. Now null is returned instead. These changes are subtle but useful. The original behaviour can be obtained by using the original typemaps: %typemap(javaout) SWIGTYPE { return new $&javaclassname($jnicall, true); } %typemap(javaout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { return new $javaclassname($jnicall, $owner); } %typemap(javagetcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ protected static long getCPtr($javaclassname obj) { return obj.swigCPtr; } %} *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 11/12/2002: beazley Fixed problem with abstract methods and signatures. For example: class abstract_foo { public: virtual int meth(int meth_param) = 0; }; class abstract_bar : public abstract_foo { public: int meth(int meth_param_1, int meth_param_2) { return 0; } }; In this case, abstract_bar is still abstract. Fixes [ 628438 ] Derived abstract class not abstract. Reported and patched by Scott Michel. 11/11/2002: beazley Fixed a matching problem with typemaps and array dimensions. For example, if you had this: typedef char blah[20]; and a typemap: %typemap() char [ANY] { ... $1_dim0 ... } then $1_dim* variables weren't be expanded properly. It should work now. Problem reported by Pankaj Kumar Goel. 11/07/2002: mkoeppe Added an experimental new module that dumps SWIG's parse tree as (Common) Lisp s-expressions. The module is invoked with SWIG's -sexp command-line switch. The output can be read into Common Lisp. There is (prototype) example Lisp code that generates Foreign Function Interface definitions for use with Kevin Rosenberg's UFFI. *** EXPERIMENTAL NEW FEATURE *** 11/07/2002: mkoeppe Removed duplicate declaration of "cpp_template_decl" in parser.y; bison 1.75 complained. 11/06/2002: cheetah (William Fulton) [Java] Default primitive array handling has changed like arrays of classes. C primitive arrays are no longer wrapped by a Java array but with a pointer (type wrapper class). Again the changes have been made for efficiency reasons. The original typemaps have been moved into arrays_java.i, so the original behaviour can be obtained merely including this file: %include "arrays_java.i" The array support functions are no longer generated by default. They are only generated when including this file, thus this often unused code is only generated when specifically requiring this type of array support. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 11/05/2002: ljohnson (Lyle Johnson) [Ruby] Added support for nested module declarations (as was previously added for the Perl module). So a %module directive of the form: %module "Outer::Inner::Foo" will nest everything as (in Ruby code): module Outer module Inner module Foo # stuff goes here end end end 11/05/2002: mkoeppe [MzScheme] Add an argument (-declaremodule) that generates code to correctly declare a primitive module extension. Patch submitted by Bruce Butterfield. 11/02/2002: cheetah (William Fulton) [Java] Added patch submitted by Michael Cahill to remove unused parameter warnings for the jenv and cls parameters. This patch also also allows one to use "void" in the jni typemap for any type without code being generated attempting to return a value. 10/29/2002: cheetah (William Fulton) [Java] Array handling is different. Arrays of classes are no longer wrapped with proxy arrays, eg wrapping class X {...}; X foo[10]; used to be wrapped with these Java getters and setters: public static void setFoo(X[] value) {...} public static X[] getFoo() {...} This approach is very inefficient as the entire array is copied numerous times on each invocation of the getter or setter. These arrays are now wrapped with a pointer so it is only possible to access the first array element using a proxy class: public static void setFoo(X value) {...} public static X getFoo() {...} Arrays of enums have also been similarly changed. This behaviour is now like the other SWIG language's implementation and the array library should be used to access the other elements. The original behaviour can be achieved using the macros and typemaps in arrays_java.i, for example: %include "arrays_java.i" JAVA_ARRAYSOFCLASSES(X) class X {...}; X foo[10]; *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 10/29/2002: cheetah (William Fulton) [Java] Two new typemaps javain and javaout for generating the proxy class and type wrapper class method calls to the JNI class. The new typemaps are really used for transforming the jstype (used in proxy class and type wrapper classes) to the jtype (used in the JNI class) and visa versa. A javain typemap is required whenever an in typemap is written and similarly javaout for an out typemap. An example is probably best to show them working: %typemap(javain) Class "Class.getCPtr($javainput)" %typemap(javain) unsigned short "$javainput" %typemap(javaout) Class * { return new Class($jnicall, $owner); } %inline %{ class Class {}; Class * bar(Class cls, unsigned short ush) { return new Class(); }; %} The generated proxy code is then: public static Class bar(Class cls, int ush) { return new Class(exampleJNI.bar(Class.getCPtr(cls), ush), false); } Some new special variables have been introduced in order to use these typemaps. Here $javainput has been replaced by 'cls' and 'ush'. $jnicall has been replaced by the native method call, 'exampleJNI.bar(...)' and $owner has been replaced by 'false'. $javainput is analogous to the $input special variable. It is replaced by the parameter name. $jnicall is analogous to $action in %exception. It is replaced by the call to the native method in the JNI class. $owner is replaced by either true if %newobject has been used otherwise false. The java.swg file contains default javain and javout typemaps which will produce the same code as previously. This change is only of concern to those who have written their own typemaps as you will then most likely have to write your own javain and javaout typemaps. The javaout typemap also makes it possible to use a Java downcast to be used on abstract proxy base classes. See the Java documentation on dynamic_cast. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 10/24/2002: ttn [Methodology] Upgaded to libtool 1.4.3, presumably w/ better support for newish platforms (like MacOS X). 10/21/2002: ttn Fixed Runtime/Makefile.in bug -- thanks to Richard Calmbach. 10/18/2002: ttn Fixed typo in doh.h -- thanks to Max Horn. Version 1.3.16 (October 14, 2002) ================================= 10/13/2002: beazley Fixed bug with %extend directive and %feature reported by William Fulton. 10/13/2002: beazley Added OpenVMS build directory (vms). Contributed by Jean-François Pieronne. 10/09/2002: cheetah (William Fulton) [Java] Added throws clause to the native functions in the JNI class. The throws clause is the same as the one generated for proxy functions and module class functions. 09/27/2002: beazley Fixed some problems with the %import directive and classes that were defined but not wrapped. Problem reported by Leslie Brooks, Gerry Woods, and others. 09/23/2002: cheetah (William Fulton) [Java] Some error checking added: 1) OutOfMemoryException check in the char * typemaps. 2) As SWIG treats pointers, references and passing by value all the same, it is possible to pass a NULL pointer to a function that expects an object passed by value or by reference. A NullPointerException is now thrown under this scenario. 09/20/2002: ttn [Methodology] Reworked "make clean" and "make install" to be more table driven. [Docs] Explain how to extend "make install" w/ extra-install.list. 09/15/2002: beazley Deprecation of the "ignore" typemap. The "ignore" typemap has been deprecated in favor of a generalization of the "in" typemap. To ignore an argument, use something like this instead: %typemap(in,numinputs=0) int *output (int temp) { $1 = &temp; } This change fixes a number of subtle bugs related to the interaction of the "in" and "ignore" typemaps (which were supposed to be mutually exclusive). The use of the numinputs argument is reserved for future expansion. Currently, values >1 will generate an error. However, future releases of SWIG may utilize that to support multi-input typemaps. %typemap(ignore) still works, but generates a warning message and is translated to %typemap(in,numinputs=0). *** POTENTIAL INCOMPATIBILITY *** *** NEW FEATURE *** 09/15/2002: beazley Fixed segmentation fault for unnamed structures. For example: typedef struct { } *blah; Reported by Roger Gibson. Note: we might be able to generate wrappers in special cases. 09/13/2002: beazley Minor modification to generated wrapper functions. Pointer arguments are now always set to an initial value of 0. Simplifies typemap writing and cleanup code (since you can rely on zero-value initialization). This also greatly reduces the need to ever write an "arginit" typemap. 09/12/2002: beazley Minor enhancement to smart-pointer support. If operator->() is part of an ignored base class like this, %ignore Bar; class Foo { public: int blah(); }; class Bar { /* Ignored */ public: ... Foo *operator->(); ... }; class Spam : public Bar { }; then methods from Foo are still available. For example, >>> s = Spam() >>> s.blah() 0 >>> The only catch is that the operator->() itself is not available (since it wasn't wrapped). Therefore, there won't be any __deref__() operation unless it is explicitly added to Spam (either using %extend or just placing operator->() in the definition of Spam). 09/11/2002: ttn [Methodology] Reworked "make check" to be more table driven. [Docs] Docuemented methodology in Manual/Extending.html. 09/11/2002: ttn [Docs] Prefixed Manual/*.html with "" to pander dotingly to (over-)sensitive editors. 09/10/2002: ttn [Guile] Converted Examples/guile/simple "make check" behavior to actually check execution results. Reduced iteration counts so that the test doesn't take too long. 09/10/2002: beazley SWIG-1.3.15 released. Version 1.3.15 (September 9, 2002) ================================== 09/09/2002: beazley Fixed nasty runtime type checking bug with subtypes and inheritance and templates. 09/09/2002: cheetah (William Fulton) [Java] Java exception classes for a method's throws clause can be generated by specifying them in a comma separated list in the throws attribute in any one of the following typemaps: in, out, check, freearg, argout and throws. A classic example would be to convert C++ exceptions into a standard Java exception: %typemap(throws, throws="java.io.IOException") file_exception { jclass excep = jenv->FindClass("java/io/IOException"); if (excep) jenv->ThrowNew(excep, $1.what()); return $null; // or use SWIG_fail } class file_exception {...}; void open(const char *filename) throw(file_exception); The Java method will then be declared with a throws clause: public static void open(String filename) throws java.io.IOException {...} 09/08/2002: mkoeppe * [Guile] Improved the documentation system. The arglist no longer gets cluttered with type specification, making it more readable. (Also the ILISP function C-u M-x `arglist-lisp' RET works better this way.) The types of arguments are explained in an extra sentence after the arglist. There are now two documentation-related typemap arguments: %typemap(in, doc="$NAME is a vector of integers", arglist="$name") int *VECTOR { ... } The "arglist" texts of all arguments of a function make up its arglist in the documentation. The "doc" texts of all arguments are collected to make a sentence that describes the types of the arguments. Reasonable defaults are provided. As usual, $name is substituted by the name of the argument. The new typemap variable $NAME is like $name, but marked-up as a variable. This means that it is upper-cased; in TeXinfo mode ("-procdocformat texinfo") it comes out as @var{name}. The directives %values_as_list, %values_as_vector, %multiple_values now also have an effect on the documentation. (This is achieved via the new pragmas return_nothing_doc, return_one_doc, return_multi_doc.) Documentation has also improved for variables that are wrapped as procedures-with-setters (command-line switch "-emit-setters"). * [Guile] Emit constants as _immutable_ variables. (This was broken recently.) 09/07/2002: mkoeppe [Guile] Updated the typemaps in list-vector.i. 09/07/2002: mkoeppe Short-circuit the typechecks for overloaded functions. (The changes in code generation are visible in the new testcase "overload_complicated".) 09/06/2002: cheetah (William Fulton) [Java] Solution for [ 596413 ] New typemap so that the Java proxy classes and type wrapper classes wrapper constructor modifier can be tailored by users. The default value is protected. Normally SWIG generates a constructor like this which can only be accessed within one package: protected Bar(long cPtr, boolean cMemoryOwn) { ... } If you are using SWIG across multiple packages or want to use this constructor anyway, it can now be accessed outside the package. To modify use for example: %typemap(javaptrconstructormodifiers) SWIGTYPE "public" to change to public for all proxy classes and similarly for all type wrapper classes: %typemap(javaptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "public" 09/06/2002: cheetah (William Fulton) [Java] Added throws typemaps for the Java module. C++ exceptions get converted into java.lang.RuntimeException Java exceptions. Warning: This may change from java.lang.Runtime exception in the future. 09/05/2002: cheetah (William Fulton) [Java] Fix for variables declared as references. 09/05/2002: beazley Fixed [ 605162 ] Typemap local variables. Reported by Lyle Johnson. 09/05/2002: ljohnson (Lyle Johnson) [Ruby] More updates to the Ruby module documentation, including a new typemap example that demonstrates how to collect key-value pairs from an argument list into a Hash. 09/05/2002: beazley Fixed bug with template expansion and constructors. template class Foo { public: Foo() { } }; The extra in the constructor was carried through in the name--causing runtime problems in generated modules. Reported by Jordi Arnabat Benedicto. 09/05/2002: mkoeppe [Guile] Support overloading. 09/04/2002: ljohnson (Lyle Johnson) [Ruby] Updated typemaps for long long and unsigned long long types to use Ruby 1.7 support for these types when available. 09/04/2002: ljohnson (Lyle Johnson) [Ruby] Added output typemaps for const reference to primitive types. 09/04/2002: mkoeppe [Guile] Fix pass-by-value typemaps. Reported by Arno Peters via Debian bugtracking (#156902), patch by Torsten Landschoff . 09/03/2002: samjam (Sam Liddicott) Better reference support. Functions that want a void** can take a NULL by reference and the void* will be made for you and then passed-by-reference Also all integer-class native types can be passed by reference where an int* or int& etc is needed 09/03/2002: beazley Changed the evaluation order of preprocessor macro arguments. Arguments are now expanded by the preprocessor *before* they are passed to macro expansion. This fixes a subtle expansion bug reported by Anthony Heading. 09/03/2002: beazley Fixed the file include order (again, apparently). See 2/27/99. 09/02/2002: beazley [Perl] Better exception handling support. Since Perl error handling relies on setjmp/longjmp, wrapper functions have been modified slightly to provide an extra block scope: XS(foo) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; { /* Normal wrapper function here */ ... SWIG_croak("An error occurred\n"); ... XSRETURN(argvi); /* Successful return */ fail: /* cleanup code */ } croak(_swig_err); } The macro SWIG_croak(x) sets the value of _swigerr to x and executes a "goto fail". The whole wrapper function is enclosed block scope to provide proper cleanup of C++ objects. Since croak executes a longjmp(), there is no way to properly reclaim resources if this executes in the same scope as the wrapper function. The _swigmsg[] variable is normally unused, but can be used to store small error messages using sprintf or snprintf. It has a capacity of at least 256 bytes (SWIG_MAX_ERRMSG). 09/02/2002: beazley [Tcl] Added better support for exceptions. Instead of returning TCL_ERROR, use the macro SWIG_fail to return with an error. This ensures that arguments are properly cleaned up. Exception specifiers are now handled by default. 09/02/2002: ljohnson (Lyle Johnson) [Ruby] The type-checking system for the Ruby module has had a flaw in that some types which should be considered equivalent weren't. This bug was best demonstrated by the inherit_missing.i test suite case, which defines a base class "Foo" that is subclassed by "Bar". The "Foo" class isn't actually wrapped (i.e. it's not directly accessible from Ruby) but we'd still like to be able to pass "Bar" instances to functions expecting Foos and have that work; it wasn't. The revised implementation (similar to that used for some other language modules) adds a new instance variable (__swigtype__) to each object that indicates its SWIG type; that is, each "Bar" instance will now have a string instance variable called "__swigtype__" whose value is "_p_Bar". Unless developers were taking advantage of this low-level implementation detail, they shouldn't notice any compatibility problems; nevertheless, I'm marking it as a "potential incompatibility". *** POTENTIAL INCOMPATIBILITY *** 09/01/2002: ljohnson (Lyle Johnson) [Ruby] Fixed SF Bug #603199. 08/08/2002: cheetah (William Fulton) [Java] Added OUTPUT, INPUT and INOUT typemaps in typemaps.i for C++ references. 08/27/2002: mkoeppe [Guile] Fixed error in "lib_std_vector" testcase and compiler warning in "lib_cdata" testcase. 08/27/2002: ljohnson (Lyle Johnson) [Ruby] Added the "%mixin" directive, which allows the user to specify a comma-separated list of module names to mix-in to a class. So, for example, if you'd like to specify that Ruby's Enumerable module should be mixed-in to your class Foo, you'd write: %mixin Foo "Enumerable"; or to specify that the modules Fee, Fie and Fo should be mixed in to Foo: %mixin Foo "Fee,Fie,Fo"; *** NEW FEATURE *** 08/27/2002: ljohnson (Lyle Johnson) [Ruby] Modified the %alias directive so that multiple aliases can be specified for an instance method by using a comma-separated list of aliases. 08/27/2002: ljohnson (Lyle Johnson) [Ruby] Added "throw" typemaps for the Ruby module. 08/26/2002: beazley Two new command line options for printing dependencies. 'swig -M' lists all file dependencies. 'swig -MM' lists dependencies, but excludes files in the SWIG library. Example: % swig -M -python example.i example_wrap.cxx: \ /u0/beazley/Projects/lib/swig1.3/swig.swg \ /u0/beazley/Projects/lib/swig1.3/python/python.swg \ example.i \ example.h % swig -MM -python example.i example_wrap.cxx: \ example.i \ example.h *** NEW FEATURE *** 08/26/2002: beazley Fixed [ 597599 ] union in class: incorrect scope. Reported by Art Yerkes. 08/26/2002: beazley Fixed [ 600132 ] Default argument with namespace. Reported by Shibukawa Yoshiki. 08/24/2002: beazley Automatic C++ exception handling enabled for all language modules. This is pretty simple. If you have a class like this: class Foo { }; class Bar { public: void blah() throw(Foo); } then the generated wrapper code looks like this: wrap_Bar_blah() { ... try { arg1->blah(); } catch (Foo &_e) { /* "throw" typemap code inserted. $1 = _e */ } catch (...) { throw; } } The "throw" typemap can be used to raise an error in the target language. It can do anything. Here is a very simple example: %typemap("throw") Foo { PyErr_SetString(PyExc_RuntimeError, "Foo exception"); return NULL; } To make this work in each language module, simply define a few default "throw" typemaps for SWIGTYPE, SWIGTYPE *, int, const char *, and a few common exception types. That's all there is to it. Automatic exception handling can be disabled using -noexcept or setting the NoExcept global variable to 1. *** NEW FEATURE *** 08/23/2002: beazley [ Python ] Automatic translation of C++ exception specifications into error handling code. For example: class Foo { }; class Bar { public: void blah() throw(Foo); } In this case, Foo is wrapped as a classic-style class (compatible with exception handling). Furthermore, you can write Python code like this: b = Bar() try: b.blah(); except Foo,e: # Note use of exception class here! # Handle Foo error ... The object "e" in the exception handler is just a wrapped Foo object. Access it like a normal object. If an exception is not wrapped as a class, a RuntimeError exception is raised. The argument to this exception is the exception object. For example: class Bar { public: void blah() throw(int); } b = Bar() try: b.blah(); except RuntimeError,e: print e.args[0] # Integer exception value Comments: - If a class is used as an exception, it *must* be wrapped as a Python classic-style class (new classes don't work). - Automatic exception handling is compatible with %exception. - Use -noexcept to turn off this feature. - The newly introduced "throw" typemap is used to raise Python errors (naturally). *** EXPERIMENTAL NEW FEATURE *** 08/23/2002: beazley Information from throw() specifiers is now stored in the parse tree. For example: class Foo { public: int blah() throw(spam,bar); } The stored information is fully corrected for namespaces and works with templates. Uses will follow. 08/22/2002: beazley Exception handling code is no longer applied to member access function. For example, in this code %exception { try { $action } catch(whatever) { ... } } class Foo { public: int x; ... } The exception handling code is not applied to accessor functions for Foo::x. This should reduce the amount of extra code generated. Caveat: Exception handling code *is* used when attributes are accessed through a smart-pointer or a synthesized attributed added with %extend is used. 08/22/2002: beazley Made more patches to hopefully eliminate problems when compiling SWIG as a 64-bit executable. 08/22/2002: beazley Fixed a bug with const reference members, variables, and static members. For example: class Foo { public: static const int &ref; }; SWIG was trying to generate "set" functions which wouldn't compile. 08/21/2002: beazley Made the warning message for "Class X might abstract" off by default. Enable with -Wall. 08/21/2002: beazley Refined handling of const and non-const overloaded methods. If a class defines a method like this: class Foo { public: int bar(int); int bar(int) const; } Then the non-const method is *always* selected in overloading and the const method silently discarded. If running with -Wall, a warning message will be generated. 08/19/2002: beazley Better support for using declarations and inheritance. Consider this: class Foo { public: int blah(int x); }; class Bar { public: double blah(double x); }; class FooBar : public Foo, public Bar { public: char *blah(char *x); using Foo::blah; using Bar::blah; }; Now SWIG wraps FooBar::blah as an overloaded method that uses all accessible versions of blah(). See section 15.2.2 in Stroustrup, 3rd Ed. SWIG also supports access change through using declarations. For example: class Foo { protected: int x; int blah(int x); }; class Bar : public Foo { public: using Foo::x; using Foo::blah; }; Caveat: SWIG does not actually check to see if declarations imported via 'using' are in the inheritance hierarchy. If this occurs, the wrapper code won't compile anyways---not sure it's worth worrying about. 08/18/2002: beazley Modified overloading dispatch to not include nodes with an "error" attribute. A language module can set this if a node couldn't be wrapped and you don't want it included in the dispatch function. 08/18/2002: beazley Enhancement to overloaded function dispatch. The dispatcher is now aware of inheritance relationships. For example: class Foo { }; class Bar : public Foo { }; void spam(Foo *f); void spam(Bar *b); In this case, the dispatcher re-orders the functions so that spam(Bar *b) is checked first---it is more specific than spam(Foo *f). 08/17/2002: beazley Added -Werror command line option. If supplied, warning messages are treated as errors and SWIG will return a non-zero exit code. 08/17/2002: beazley Fixed [ 596135 ] Typedef of reference can't compile. For example: typedef int &IntRef; void foo(IntRef i); SWIG-1.3.14 generated code that wouldn't compile. Version 1.3.14 (August 12, 2002) ================================ 08/11/2002: mmatus Static const members initialized during declaration, and only them, ie: struct A { static const int a = 1 ; // this one static const int b; // not this one }; are emitted like constants (equivalent to enums or explicit %constant). This is because they cannot be added directly to 'cvar' since they lack the needed reference (well, you can force them to have a real reference, but in an ugly way which goes completely again the original purpose of initialize them during declaration, you also have to deal with extra linking matters, and it take a while to figure out what is the problem and how to solve it). Please test it with your preferred target language, and not only the code generation, but really run the example in the test-suite (static-const-member-2.i) because the problem and the solution cannot be "fully" appreciated until you try to load the module and run it. In some target languages (python specially), this can produces a difference in the way that the static constant members 'a' and 'b' are internally wrapped. Hopefully, they still can be accessed in the same way. 08/11/2002: mmatus [python] Now static const members can be accessed in a more natural way, ie, if you have struct A { typedef unsigned int viewflags; static const viewflags forward_field = 0; static const viewflags backward_field; }; now you can do: print A.backward_field and also a = A() print a.forward_field Note that if the static const members don't have an initializer (like backward_field), still you can access them in the same way in the python side, but the implementation is a quite different: backward_field will still appear in the cvar entity, and also, you are responsible to initialize it in some code unit, and link it properly. forward_field, by the other hand, will not appear in the cvar entity but only as a A member, similar to what happen with enum or %constant members. 08/11/2002: mmatus [python] Common code in the __setattr__/__getattr__ now goes to two "free" methods at the beginning of the proxy file, from where each class use it. This change reduces the size of the proxy file, specially if you wrap a lot of small classes in one module (up to 33% in some cases), making it faster to load too. 08/09/2002: beazley [Perl5] If a function that returns char * returns NULL, undef is returned to the Perl interpreter. 08/09/2002: beazley Fix to conversion operators and namespaces. For example: namespace ns { struct Foo { }; struct Bar { operator Foo*(); }; } In the wrapper code, SWIG was using ->operator Foo*() when it should have been using ->operator ns::Foo*(). Note: if using %rename with a conversion operator, you might have to do this: %rename(toFooPtr) ns::operator ns::Foo*(); // ^^^^ note extra qualifier namespace ns { ... 08/09/2002: beazley [Python] Minor enhancement to 'const' variable declarations. Normally const declarations are wrapped as read-only variables accessible only through the cvar attribute (see SWIG.html for a discussion of why). However, in many programs, "const" declarations may just be constants---making the cvar. access awkward. To fix this, "const" declarations are now available both through cvar. and as a simple name. For example: const int FOO = 42; In Python: >>> print example.cvar.FOO 42 >>> print example.FOO 42 Note: There are cases where the value of a "const" variable might change. For example: char *const BAR = "Hello World"; In this case, the pointer itself can not change, but the data being pointed to could be modified. In these situations, cvar.BAR should be accessed to obtained the current value. 08/08/2002: beazley [Python] Fixed generation of the proxy code (.py files) to more closely follow the order of declarations as they appear in the .i file. In the past, all of the class wrappers appeared first, followed by function stubs, inserted Python code, and other details. 08/08/2002: cheetah (William Fulton) [Java] Proxy method _delete() changed to delete(). There shouldn't ever be a wrapped function called delete() as it is a C++ keyword and there is no such thing as a member function in C. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** Backwards compatibility can be achieved by adding the function back in for all proxy classes: %typemap(javacode) SWIGTYPE %{ public void _delete() { delete(); } %} Java backwards compatibility summary ------------------------------------ There are a number of changes that have been made in improving the Java module for ver 1.3.14. If at all possible change your code to take advantages of the improvements. If you were using proxy classes you may not notice any backwards compatibility issues. Here is an example which will help with most backwards compatibility problems where it is not possible to modify the code that uses the generated output: Replace: %module modulename With: %module (jniclassname="modulename") modulename; %typemap(javacode) SWIGTYPE %{ public long getCPtr$javaclassname() { return swigCPtr; } public void _delete() { delete(); } %} %pragma(java) jniclassclassmodifiers="public"; The proxy constructors that took parameters (long cPtr, boolean cMemoryOwn) were public and are now protected. If you were making use of these then you'll have to modify your code and the best solution would be to use the new type wrapper classes. The other main areas are the pragmas and global variable wrapping. Replace the pragmas with one of the new directives or typemaps mentioned below and use %rename on the variables. If you were not using proxy classes, you will have to define a jstype typemap as well as a jtype typemap. 08/08/2002: cheetah (William Fulton) [Java] Fix for wrapping two dimension array variables. 08/07/2002: beazley [Python,Tcl] Object management now has a much better sense of ownership. Ownership bits is changed whenever an object is stored in a global variable or structure member. For example: struct Foo { int val; Foo *next; }; Now in Python >>> f = Foo() >>> f.thisown 1 >>> g = Foo() >>> g.next = f # Assign a pointer >>> f.thisown # Notice ownership change 0 >>> This scheme is mostly a conservative heuristic designed to provide segmentation faults. It could cause a memory leak if ownership is changed unnecessarily. In this case, you can either write a typemap (that doesn't change ownership), or manually set the thisown attribute back to 1. 08/07/2002: beazley [Tcl] Major usability improvements to the object interface. Suppose you had code like this: struct Foo { int x; int spam(); }; void blah(Foo *f); In past versions of SWIG, you could create objects and use them like this: % Foo f % f configure -x 3 % f spam 37 The only problem is that if you tried to call blah(), it didn't work: % blah f Type Error. Expected _p_Foo % Instead, you had to do this: % blah [f cget -this] SWIG now automatically extracts the -this pointer, avoiding this problem. This means that saying "blah f" is perfectly legal and everything will still work normally. Caveat: Since pointer strings start with a leading underscore (_), don't use this in object names. For example: % Foo _f % blah _f # Potential crash Objects now have a -thisown attribute that shows the ownership. This builds upon the CHANGES 11/24/2001 entry. 08/07/2002: samjam, Sam Liddicott Properly implemented pointer system using php resources. Still need to work out whether or not to let script-users call destructors directly 08/06/2002: beazley Upgraded mzscheme module to support version 201 and added overloading support. 08/05/2002: beazley Added parsing support for extra grouping (in very limited cases). For example: typedef int (FuncPtr)(int, double); *** EXPERIMENTAL *** 08/03/2002: ljohnson (Lyle Johnson) [Ruby] Updates to typemaps.i as those done previously for Perl, Python and Tcl modules. Now supports reference types with INPUT, OUTPUT and INOUT typemaps. 08/02/2002: beazley New library file cstring.i added. Provides macros for manipulating char * data. 08/02/2002: beazley Deprecated the %new directive. Use %newobject instead. For example: %newobject foo; ... char *foo(); %newobject follows the same rules as %rename, %ignore, %feature, etc. *** POTENTIAL INCOMPATIBILITY *** 08/01/2002: cheetah (William Fulton) [Java] New attribute 'jniclassname' for the module directive allows a way of changing the JNI class name from the default which uses the modulename with JNI appended after it. %module (jniclassname="name") modulename If 'name' is the same as 'modulename' then the module class name gets changed from 'modulename' to modulenameModule. 08/01/2002: beazley Fixed problem with file include order. Language specific directories should take precedence over generic directories. For example: "swig_lib/python/foo.i" should be loaded before "swig_lib/foo.i". I thought this was the case already, but apparently it has been broken for quite some time. 08/01/2002: beazley Added std_deque.i library file. Work in progress. 08/01/2002: beazley [Python,Tcl,Perl] Improvements to typemaps.i. INPUT/INOUT typemaps perform better error checking. Typemaps are now supplied for references like int &OUTPUT, double &INOUT, etc. 08/01/2002: beazley [Python] Deprecated the T_* and L_* typemaps in typemaps.i. Multiple return values are always placed in a tuple. Deprecated the BOTH typemaps. This is now INOUT (e.g., int *INOUT). *** POTENTIAL INCOMPATIBILITY FOR PYTHON MODULE *** 08/01/2002: beazley Deprecated the array.i, carray.i, and timer.i library files. 08/01/2002: beazley Deprecated the pointer.i library file. Use cpointer.i instead. *** POTENTIAL INCOMPATIBILITY *** 08/01/2002: cheetah (William Fulton) [Java] For consistency the global variable getters and setters use the JavaBean property design pattern like member variables always have. This means if you are wrapping a variable called foo, the getter is called getFoo() and the setter is called setFoo(). Before the recent changes to the Java module the getters and setters were called get_foo() and set_foo(). If you really want the original function names use the %rename directive like this: %rename(_foo) Foo; 07/31/2002: beazley Fixed casting problem with multiple inheritance. If you had this, class foo {}; class bar : public foo {}; class baz : public foo {}; class spam : public bar, public baz {}; then the wrappers wouldn't compile due to an ambiguous cast. Reported by Art Yerkes. 07/30/2002: cheetah (William Fulton) [Java] Due to new static typechecking all pointers held in a Java long are part of the internal workings and this pointer value in the Java long has become abstracted data. The type wrapper constructor and getCPtr() methods are as such protected. If you need to mess around with pointers from Java or for example create a proxy class or type wrapper class around a null pointer, add a function/constructor to do so with the %javacode typemap. You can also make getCPtr() public again with the %javagetcptr typemap. 07/30/2002: cheetah (William Fulton) [Java] Fixes for %typemap(ignore). In particular when ignoring the last parameter in a function. Also for all parameters in constructors. These mods have also fixed multi-argument typemaps for proxy classes - SF 581791. 07/30/2002: cheetah (William Fulton) [Java] %newobject (replacement for %new) now implemented for Java. 07/29/2002: beazley Fixed problem with typemap copies, %apply, and %clear inside C++ namespaces. 07/28/2002: cheetah (William Fulton) [Java] The JNI class now has package access as the class modifier has been changed from "public" to nothing. This has been done as this class is now more for the internal workings of SWIG since the module class has static type checking for all types. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** Backwards compatibility can be achieved by using the %jniclassclassmodifier pragma to change it back to "public". 07/28/2002: cheetah (William Fulton) [Java] Proxy/Shadow classes are generated by default. The -proxy and -shadow command line options are deprecated. If you want to use the low-level functional interface then use the new -noproxy commandline option. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 07/28/2002: cheetah (William Fulton) [Java] Remaining pragmas shakeup. These were the remaining pragmas and their new names where changed: modulebase modulecode moduleclassmodifiers moduleimport => moduleimports moduleinterface => moduleinterfaces The moduleimports works slightly differently to how the moduleimport pragma worked. Now it actually takes code which gets placed before the class definition so the whole import statement has to be given, for example: %pragma(java) moduleimports=%{ import java.io.*; import java.math.*; %} The moduleinterfaces is slightly different to the old moduleinterface in that if more than one interface is required they must be comma separated in one use of the pragma, for example: %pragma(java) moduleinterfaces="Serializable, MyInterface" These last two pragmas are consistent with the javainterfaces and javaimports typemap. A similar set of pragmas has been introduced, namely: jniclassbase jniclasscode jniclassclassmodifiers jniclassimport jniclassinterface These work in the same way as their module counterparts. Note that previously the moduleXXX pragmas worked on the old module class which is now called the JNI class (the class with the native functions). The jniclassXXX pragmas now work on the new module class (the class that has all the global functions and global variable getters and setters when using proxy classes, plus all other remaining functions when using the low-level procedural interface). In summary the contents of the pragmas make up a class like this: class modulename extends implements { ... SWIG generated functions ... } } *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 07/28/2002: cheetah (William Fulton) [Java] Deprecated modulemethodmodifiers pragma and replaced with a better %feature based directive called %javamethodmodifiers. A useful example would be for synchronisation in multi-threaded apps: %javamethodmodifiers foo(int a) "public synchronized"; Changes this function from the default ("public") to "public synchronized". *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 07/26/2002: beazley Several directives now allow optional configuration parameters. These include: %module(name="value", name="value", ...) modulename %import(name="value", ...) "filename.i" %extend(name="value", ...) classname { ... } These currently have no effect and are reserved for future expansion. 07/26/2002: beazley Enhancements to smart-pointer handling. SWIG only provides extra support for a smart-pointer if operator->() returns a proper pointer. For example: Foo *operator->(); If operator->() returns an object by value or reference, then SWIG examines the returned object to see if it also implements operator->(). If so, SWIG chases operator->() until it can find one that returns a pointer. This allows cases like this to work: class Foo { public: void blah(); }; class Bar { ... Foo *operator->(); ... }; class Spam { ... Bar operator->(); ... }; For example: >>> s = Spam() >>> s.blah() # Invokes Foo::blah() The s.blah() call actually invokes: ((s.operator->()).operator->())->blah(); 07/26/2002: beazley Fixed a bug with typedef and references. For example: typedef Foo & FooRef; FooRef blah(); Previous versions of SWIG generated code that wouldn't compile. 07/25/2002: beazley Wrapping of static methods has been improved in proxy classes. In older versions of SWIG, if you had this: class Foo { public: static void bar(); }; The static method was only available as a function Foo_bar(). For example: >>> Foo_bar() Now, the static method can also be invoked through an instance like this: >>> f = Foo() >>> f.bar() # Invokes static method This works with all versions of Python. Additionally, for Python-2.2, the static method can be invoked as: >>> Foo.bar() The old-style function is still support for backwards compatibility. If you care about making your code across different versions of Python, either use Foo_bar() or access the method through an instance. 07/25/2002: beazley Changes to the Python module. Proxy classes now utilize new Python-2.2 features including properties and static methods. However, these features are supported in a way that provides backwards compatibility with older Python versions. In other words, proxy classes work with all versions of Python and only use new features when running on Python-2.2. 07/25/2002: beazley Modified %extend so that overloaded methods can be added. For example: %extend Foo { void bar(int x) { }; void bar(char *s) { }; ... } This works with both C++ *and* C. 07/24/2002: cheetah (William Fulton) [Java] More new typemaps so that the Java proxy classes and type wrapper classes can be further tailored by users. These are the default code for generating the finalize() methods (proxy classes only) and the getCPtr() methods for proxy classes and type wrapper classes: %typemap(javafinalize) SWIGTYPE %{ protected void finalize() { _delete(); } %} %typemap(javagetcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ public static long getCPtr($javaclassname obj) { return obj.swigCPtr; } %} The javagetcptr typemap will enable users to handle Java null by overriding this typemap - a requested feature. The -nofinalize commandline option has been deprecated. The javafinalize typemap is more powerful as it will allow the removal of the finalize methods for all or any one or more particular proxy class. 07/23/2002: cheetah (William Fulton) [Java] The getCPtrXXX() function has been changed to a static function and is now of the form: protected static long getCPtr(XXX obj) {...} This is a requested change which will allow Java null pointers to be used as null can be passed in for obj. However, to achieve this the appropriate code must be written using the new javagetcptr typemap directive. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** Backwards compatibility can be achieved by adding this function back in using the new javacode typemap: %typemap(javacode) SWIGTYPE %{ // SWIG-1.3.12 and SWIG-1.3.13 public long getCPtr$javaclassname() { return swigCPtr; } // SWIG-1.3.11 and earlier public long getCPtr() { return swigCPtr; } %} 07/23/2002: cheetah (William Fulton) [Java] New directive to control constant code generation - %javaconst. The default handling for handling constants is to get the value through a JNI call, eg #define YELLOW 5 #define BIG 1234LL results in: public final static int YELLOW = modulename.get_YELLOW(); public final static long BIG = modulename.get_BIG(); Earlier versions of the Java module initialised the value using the C value: public final static int YELLOW = 5; public final static long BIG = 1234LL; This works in most cases, but the value for BIG won't compile as 1234LL is not valid Java code and this is one of the reasons why the default is now to get the values through a JNI call. The side effect is that these 'constants' cannot be used in switch statements. The %javaconst directive allows one to specify the way the constant value is initialised and works like other %feature directives, eg %javaconst(0); // all constants from this point on are initialised using the C value %javaconst(1) BIG; // just BIG initialised using JNI call (must be parsed before BIG is defined) 07/23/2002: beazley *** IMPORTANT CHANGES TO THE PYTHON MODULE *** (1) The Python module now enables shadow/proxy classes by default. This means that two files are always created by SWIG. For instance, if you have this: // file: foo.i %module foo ... Then swig generates two files "foo_wrap.c" and "foo.py". (2) The name of the low-level C extension module has been changed to start with a leading underscore. This means that you have to compile the module as follows: $ cc -c -I/usr/local/include/python2.2 foo_wrap.c $ cc -shared foo_wrap.o $(OBJS) -o _foo.so ^^^^ note extra underscore This naming scheme is consistent with other Python modules that utilize extension code. For instance, the socket module consists of "_socket.so" and "socket.py". In previous versions of SWIG, the shared object file was named "foocmodule.so". (3) A new directive can be used to insert Python code into the corresponding .py file. For example: %pythoncode %{ def foo(): print "Hello World" %} This directive allows you to create modules as a mix of C and Python. Python code is seamlessly added to the module. (4) The -shadow command line option is deprecated. This is turned on by default. (5) To disable the generation of the extra python file, use the "-noproxy" command line option. *** POTENTIAL INCOMPATIBILITY *** This change will likely break the build environment of projects that utilize shadow classes. To fix this, you probably only need to change the name of the target .so file. For example, if you have Makefile information like this: TARGET = examplecmodule.so Just change it to: TARGET = _example.so *** DOCUMENTATION UPDATE *** The file Doc/Manual/Python.html has been updated to describe these changes. 07/23/2002: beazley Added -noextern option. If supplied, SWIG will not generate extra extern declarations. This is sometimes an issue on non-unix platforms. 07/23/2002: beazley Added a warning for ignored friend functions. 07/23/2002: beazley Fixed [ 574498 ] -proxy and %include "pointer.i" clash. Reported by David Creasy. 07/23/2002: beazley Fixed [ 576103 ] global destruction warning with shadow. Perl extensions should no longer report the warning "Use of uninitialized value during global destruction." when running with "perl -w". Reported by Brett Williams. 07/23/2002: beazley In C++ mode, SWIG now always defines namespace std. By default, it's empty. However, this will silence errors from programs that include statements such as "using namespace std;". This fixes Bug [ 584017 ] using namespace std generates error. Reported by Joseph Winston. 07/22/2002: beazley Added a new warning message for %apply. If you use %apply but no typemaps are defined, you will get a warning message. This should help with problems like this: %apply char *OUTPUT { ... }; In old versions of SWIG, this silently did nothing. Now you get an error like this: file:line. Warning. Can't apply (char *OUTPUT). No typemaps are defined. 07/22/2002: cheetah (William Fulton) [Java] Started Java pragma deprecation. Replacements use %typemap based directives and enable proxy classes and the new type wrapper classes to be tailored in various ways. These are the new typemaps: %typemap(javabase) - base (extends) for Java class %typemap(javaclassmodifiers) - class modifiers for the Java class: default is "public" %typemap(javacode) - java code is copied verbatim to the Java class %typemap(javaimports) - import statements for Java class %typemap(javainterfaces) - interfaces (extends) for Java class And these are the %pragma directives being deprecated: allshadowbase allshadowclassmodifiers allshadowcode allshadowimport allshadowinterface shadowbase shadowclassmodifiers shadowcode shadowimport shadowinterface Note that it is possible to target a particular proxy class: %typemap(javaimports) Foo "import java.util.*"; or a particular type wrapper class: %typemap(javaimports) double* "import java.math.*"; Note that $javaclassname in these typemaps are substituted with either the proxy classname when using proxy classes or the SWIGTYPE class name. 07/18/2002: cheetah (William Fulton) [Java] Java module overhaul to implement static type checking of all types. 1) Changes when using Java Proxy classes ---------------------------------------- Previously when wrapping global functions: class SomeClass{}; void foo(SomeClass* s); SomeClass* bar(); The native method prototypes used a long for pointers and looked like this: public class modulename { ... public final static native void foo(long jarg1); public final static native long bar(); } and unlike member functions of a C++ class there was no wrapper around the native calls to make the use of them more user friendly. They would be used from Java like this: SomeClass s = new SomeClass(modulename.bar(), false); modulename.foo(s.getCPtrSomeClass()); Note that the following will have the same effect, but then it would not have been possible to call any proxy member functions in SomeClass: long s = modulename.bar(); modulename.foo(s); Now wrapper functions are generated: public class modulename { public static void foo(SomeClass s) { // calls the native function } public static SomeClass bar() { // calls the native function } } Which means these functions can now be used more naturally with proxy classes: SomeClass s = modulename.bar(); modulename.foo(s); 2) Changes when not using Java Proxy classes -------------------------------------------- The so called low-level interface was rather low-level indeed. The new static type checking implementation makes it less so but it remains a functional interface to the C/C++ world. Proxy classes are the obvious way to use SWIG generated code, but for those who want a functional interface all non-primitive types now have a simple Java class wrapper around the C/C++ type. Pointers and references to primitive types are also wrapped by type wrapper classes. The type wrapper classnames are based on the SWIG descriptors used by the other language modules. For example: C/C++ type Java type wrapper class name ---------- ---------------------------- int* SWIGTYPE_p_int double** SWIGTYPE_p_p_double SomeClass* SWIGTYPE_p_SomeClass SomeClass& SWIGTYPE_p_SomeClass SomeClass SWIGTYPE_p_SomeClass Note that everything wrapped by SWIG is accessed via a pointer even when wrapping functions that pass by value or reference. So the previous example would now be used like this: SWIGTYPE_p_SomeClass s = example.bar(); example.foo(s); Note that typedefs that SWIG knows about are resolved, so that if one has class Foo{}; typedef Foo Bar; then any use of Bar will require one to use SWIGTYPE_p_Foo; Some considerations: Make sure you make a firm decision to use either proxy classes or the functional interface early on as the classnames are different. 3) Pointers and non-parsed types -------------------------------- Sometimes SWIG cannot generate a proxy class. This occurs when the definition of a type is not parsed by SWIG, but is then used as a variable or a parameter. For example, void foo(Snazzy sds); If SWIG has not parsed Snazzy it handles it simply as a pointer to a Snazzy. The Java module gives it a type wrapper class around the pointer and calls it SWIGTYPE_p_Snazzy. In other words it handles it in the same manner as types are handled in the low-level functional interface. This approach is used for all non-proxy classes, eg all pointer to pointers and pointers to primitive types. 4) Backwards compatibility ----------------------- Backwards compatibility is not an issue if you have been using proxy classes and no global variables/functions. Otherwise some changes will have to be made. The native methods still exist but they are now in a JNI class, which is called modulenameJNI. As this class is really part of the internal workings, it should not be required so the class has become protected. Some pragmas/directives will hopefully be added to help with backwards compatibility. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 07/18/2002: beazley Modified wrapping of uninstantiated templates returned by value. Just to be safe, they are now wrapped by SwigValueWrapper<> just in case they don't define a default constructor. This would be used if you had code like this Foo blah(); void moreblah(Foo x); but you didn't instantiate Foo using %template. We should probably add a warning for this. 07/17/2002: beazley Added an error check to detect shadowed template paramaters. For example: template class Foo { public: int T; }; This results in an error, not a warning. This warning is also needed to fix some rather insidious problems like this: struct T { int blah; }; template class Foo { public: typedef T Traits; // Which T is this???? }; In this case, the template parameter T shadows the outer structure (which is what you want). 07/16/2002: beazley Improved support for templates with integer arguments. SWIG is much more aware of situations such as this: const int Size = 100; %template(Foo100) Foo<100>; void bar(Foo *x); // Knows that Foo is the same as Foo<100>; 07/15/2002: beazley Fixed bug with %feature/%ignore/%rename and namespaces. For example: %ignore Foo::Bar namespace Foo { class Bar { ... }; } Reported by Marcelo Matus. 07/09/2002: beazley Added parsing support for constructors that try to catch exceptions in initializers. For example: class Foo { Bar b; public: Foo(int x) try : b(x) { ... } catch(int) { ... } } This has no effect on the generated wrappers. However, the try and catch parts of the declaration are ignored. See Stroustrup, 3rd Ed, section 14.4.6.1 for details. 07/06/2002: beazley Fixed bug in template symbol table management. This fixes two bugs. First, mixing abstract methods, templates, and inheritance no longer generates a failed assertion. template class A { public: virtual void foo() = 0; }; template class B : public A { }; %template(A_int) A; %template(B_int) B; This fix also fixes a subtle problem with default values and templates. For example: template struct B { typedef unsigned int size_type; static const size_type nindex = static_cast(-1); void foo(size_type index = nindex); }; Bugs reported by Marcelo Matus. 07/05/2002: ljohnson (Lyle Johnson) [Ruby] Changed the definition of the SWIG_ConvertPtr() function for the SWIG/Ruby runtime support so that it looks like the Python version. If the last argument (flags) is non-zero, SWIG_ConvertPtr() will raise an exception for type mismatches as before. If flags is zero, this function will return -1 for type mismatches without raising an exception. *** POTENTIAL INCOMPATIBILITY FOR RUBY MODULE *** 07/04/2002: beazley Overloaded functions/methods/constructors now work in many language modules. The support is completely transparent--just call the function normally and SWIG will dispatch to the correct implementation. There are a variety of issues associated with this. Please refer to the overloading section of Doc/Manual/SWIGPlus.html for details. *** NEW FEATURE *** 07/04/2002: beazley Fixed a bug with namespaces, enums, and templates. For example: namespace hello { enum Hello { Hi, Hola }; template struct traits { typedef double value_type; }; traits::value_type say_hi() { return traits::value_type(1); } } SWIG wasn't generating wrappers that properly qualified traits. Reported by Marcelo Matus. 06/30/2002: beazley Supplied array variable typemaps for Tcl module. If you have a variable like this: int foo[10]; then a set function like this is generated: void foo_set(int *x) { memmove(foo,x,10*sizeof(int)); } 06/30/2002: beazley New %fragment directive. When writing typemaps, it can be easy to get carried away and write a lot of code. However, doing so causes tremendous code bloat. A common way to solve this is to write helper functions. For example: %{ void some_helper_function() { ... } %} %typemap(in) type { some_helper_function(...); } The only problem with this is that the wrapper file gets polluted with helper functions even if they aren't used. To fix this, a new fragment directive is available. For example: (corrected typo in line below - 06/26/2008) %fragment("type_header","header") %{ void some_helper_function() { ... } %} %typemap(in, fragment="type_header") type { some_helper_function(...); } In this case, the code fragment is only emitted if the typemap is actually used. A similar capability is provided for declaration annotation and the %feature directive. For example: %feature("fragment","type_header") SomeDeclaration; The first argument to %fragment is the fragment name. The second argument is the file section where the fragment should be emitted. The primary use of this directive is for writers of language modules and advanced users wanting to streamline typemap code. *** EXPERIMENTAL NEW FEATURE *** 06/30/2002: beazley Supplied memberin typemaps for all arrays in an attempt to eliminate confusion about their use. 06/29/2002: beazley Experimental support for smart-pointers. When a class defines operator->() like this class Foo { ... Bar *operator->(); ... }; SWIG locates class Bar and tries to wrap its member variables and methods as part of Foo. For example, if Bar was defined like this: class Bar { public: int x; int spam(); }; You could do this (in the target language): f = Foo() f.x = 4 # Accesses Bar::x f.spam() # Accesses Bar::spam The primary use of this feature is to emulate the behavior of C++ smart-pointers---which allow attributes to accessed transparently through operator->. This feature is supported automatically in SWIG---no special directives are needed. To disable this behavior. Use %ignore to ignore operator->. *** NEW FEATURE *** 06/26/2002: beazley Deprecated the %except directive. %exception should be used instead. 06/25/2002: beazley Major cleanup of the modules directory. Eliminated most header files, consolidated module code into single files. 06/24/2002: beazley Reworked the instantiation of language modules. All language modules must now define a factory function similar to this: extern "C" Language * swig_python(void) { return new PYTHON(); } This function is then placed in a table and associated with a command line option in swigmain.cxx. This approach has a number of benefits. It decouples the SWIG main program from having to know about the class definitions for each module. Also, by using a factory function, it will be easier to implement dynamic loading of modules (simply load the file and invoke the factory function). 06/24/2002: beazley Fixed syntax error for reference conversions. For example: operator Foo &(); 06/24/2002: beazley Fixed syntax error for operator new[] and operator delete[]. 06/24/2002: beazley Fixed code generation problem for constants and default arguments involving templates. 06/19/2002: ljohnson (Lyle Johnson) [Ruby] Fixed a bug for the '-feature' command line argument; that setting was effectively being ignored and so the feature name was always set equal to the module name. 06/17/2002: beazley Fixed problems with static members and enums in templates. Version 1.3.13 (June 17, 2002) ============================== 06/16/2002: beazley Fixed a bug with __FILE__ expansion in the preprocessor. On Windows, the backslash (\) is now converted to (\\) in the string literal used for __FILE__. Reported by Steve Glaser. 06/14/2002: beazley Fixed warning message about 'name private in this context'. The warning is only generated for public methods. Reported by Scott Michel. 06/14/2002: beazley Fixed some problems related to template instantiation and namespaces. When SWIG expands a template, it does so with fully resolved types. For example, if you have this: template class foo { }; typedef double Double; %template(foo_d) foo; then, it is handled as foo in the typesystem. This fixes a number of subtle problems with inheritance and templates. 06/14/2002: ljohnson (Lyle Johnson) [Ruby] Added missing bool typemaps for INPUT, OUTPUT and INOUT in Lib/ruby/typemaps.i. 05/29/2002: cheetah (William Fulton) [Java] Fix for a couple of broken pragmas. 05/29/2002: cheetah (William Fulton) Fix for unnecessary cast when wrapping global variable where the type is not parsed by SWIG - Java variables example failure as reported by Larry Virden. 06/10/2002: beazley Modified %template to allow for empty instantiations. %template() foo; This registers foo with the type system, but doesn't wrap it (same as %ignore). This may only be a temporary measure. SWIG might be able to automatically instantiate templates in certain cases. 06/10/2002: beazley Fixed function prototype problems with Tcl 8.4 06/09/2002: beazley Fixed problem with templates and location of base classes. This one is a little mind-bending, but here is an example that illustrates: template struct traits { typedef ArgType arg_type; typedef ResType res_type; }; template struct Function { }; template struct Class : Function::arg_type, typename traits::res_type> { }; %template(traits_dd) traits ; %template(Function_dd) Function ; %template(Class_dd) Class ; In this example, the base class of 'Class' is determined from the Function template, but the types are obtained through typedefs. Because of this, SWIG could not locate the wrapped base class (Function). Should be fixed in 1.3.13 even though I can think of a million other things that might also be broken. 06/07/2002: beazley Fixed a problem with conversion operators. If you had an operator like this, operator double() const; SWIG was ommitting the "const" qualifier. This affected %rename and other directives. Reported by Zhong Ren. 06/07/2002: beazley Lessened the strictness of abstract class checking. If you have code like this: class Foo { public: virtual int method() = 0; }; class Bar : public Foo { public: Bar(); ~Bar(); }; SWIG will go ahead and generate constructor/destructors for Bar. However, it will also generate a warning message that "Bar" might be abstract (since method() isn't defined). In SWIG-1.3.12, SWIG refused to generate a constructor at all. 06/07/2002: beazley Change to %template directive. If you specify something like this: %template(vi) std::vector; It is *exactly* the same as this: namespace std { %template(vi) vector; } SWIG-1.3.12 tried to instantiate the template outside of the namespace using some trick. However, this was extremely problematic and full holes. This version is safer. 06/07/2002: beazley Fixed bug with scope qualification and templates. For example: A::DD Before, this was separated as scopes A, and DD. Fixed now. 06/06/2002: beazley Allow the following syntax: class A { }; struct B : A { ... }; A base class without a specifier is assumed to be public for a struct. 06/06/2002: beazley Fixed syntax error with template constructor initializers. Reported by Marcelo Matus. 06/06/2002: beazley Fixed bug with default template arguments. Reported by Marcelo Matus. 06/05/2002: beazley Fixed subtle problems with %rename directive and template expansion. Code like this should now work: %rename(blah) foo::method; ... template class foo { public: void method(); }; %template(whatever) foo; 06/05/2002: beazley Resolved some tricky issues of multi-pass compilation and and inheritance. The following situation now generates an error: class Foo : public Bar { ... }; class Bar { ... }; The following code generates a warning about incomplete classes. class Bar; class Foo : public Bar { }; The following code generates a warning about an undefined class. class Foo : public Bar { }; // Bar undefined This fixes a failed assertion bug reported by Jason Stewart. 06/05/2002: ljohnson [Ruby] Added a warning message for the Ruby module about the lack of support for multiple inheritance. Only the first base class listed is used and the others are ignored. (Reported by Craig Files). 06/03/2002: beazley Fixed a bug with struct declarations and typedef. For example: typedef struct Foo Foo; struct Foo { ... }; A few other subtle struct related typing problems were also resolved. Version 1.3.12 (June 2, 2002) ============================= 05/30/2002: beazley Fixed problem related to forward template class declarations and namespaces. Bug reported by Marcelo Matus. 05/30/2002: beazley Added 'make uninstall' target. Contributed by Joel Reed. 05/29/2002: beazley Fixed rather insidious bug with %rename, %feature and template specialization. For example: %exception vector::__getitem__ { ... some exception ... } template class vector { ... T __getitem__(int index); // Fine ... }; template<> class vector { ... T __getitem__(int index); // Oops. ... }; Now, the %exception directive (and other features) should correctly apply to both vector and specializations. 05/29/2002: beazley Subtle changes to %template() directive. Template arguments are now reduced to primitive types in template matching. For example: template class vector { ... partial specialization ... } typedef int *IntPtr; // Gross typedef // Gets the above partial specialization %template(vectorIntPtr) vector; This change is extremely subtle, but it fixes a number of potential holes in Luigi's STL library modules. For example: typedef int Integer; %template(vectori) vector; 05/29/2002: beazley Fixed rather insidious typemap bug related to const. const was being discarded through typedefs. 05/29/2002: ljohnson (Lyle Johnson) [Ruby] Added input typemaps for const references to primitive types (in Lib/ruby/ruby.swg). 05/29/2002: cheetah (William Fulton) [Java] The java arrray support functions are enclosed by a SWIG_NOARRAYS #define. Useful if not using arrays and it is desirable to minimise the amount of compiled code. 05/29/2002: cheetah (William Fulton) [Java] Enums were not renamed when using %name or %rename fix. 05/28/2002: ljohnson [Ruby] Modified the name of the wrapper functions for the "new" singleton method and "initialize" instance method for consistency with the other language modules. The wrapper name for the function that implements "new" is alloc_classname and the wrapper name for the function that implements "initialize" is new_classname. 05/27/2002: beazley Changes to runtime. Pointer conversion/creation functions now almost always have an extra "flags" argument. For example: SWIG_ConvertPtr(obj, void **, swig_type_info *ty, int flags); ^^^^^^^^^^ This extra parameter is reserved for future expansion and will be used for more control over pointers in future versions. 05/27/2002: beazley Fix for C++ classes with private assignment operators. It is now possible to safely return objects like this by value. Caveat: the class must provide a copy constructor. 05/26/2002: beazley -proxy option added to many language modules. This is the same as -shadow. We are merely changing terminology. 05/26/2002: beazley [perl] Fixed some inconsistencies in the -package option. -package merely sets the package name to be used on the wrappers. It does not change the name of the shared library file or the name of the generated .pm file. This was broken at some point, but works again now. 05/25/2002: beazley [perl] Fixed [ 475452 ] memory leak in return-by-value. Problem related to static member variables returning newly allocated objects. Reported by Roy Lecates. 05/25/2002: beazley [perl] Fixed [ 513134 ] %BLESSEDMEMBERS isn't always right. Reported by Fleur Diana Dragan. 05/25/2002: beazley Fixed [ 540735 ] -importall and the -I option. 05/25/2002: beazley [guile] Fixed [ 532723 ] Default arg for char* can SegV. Error in guile module. Reported by Brett Williams. 05/25/2002: beazley Subtle change to typemap application code. The "freearg" typemap must exactly match up with the "in" or "ignore" typemap. For example: %typemap(in) (char *data, int len) { ... }; %typemap(freearg) char *data { ... }; void foo(char *data, int len); In this case, the "in" typemap is applied, but the freearg typemap is not. This is because the freearg typemap doesn't match up with the input argument sequence. 05/25/2002: beazley Fixed [ 548272 ] Default argument code missing braces. Reported by Brett Williams. 05/25/2002: beazley Fixed [ 547730 ] SwigValueWrapper needed for constructors. Reported by William Fulton. 05/25/2002: beazley Undefined identifiers now evaluate to 0 when evaluating preprocessor expressions. For example: #if !FOO ... #endif where FOO is undefined or set to some non-numeric value. Fixes [ 540868 ] #if defined whatever - not parsed. Reported by Adam Hupp. 05/24/2002: beazley SWIG now ignores the C++ 'export' keyword. 05/23/2002: beazley Some refinement of type-name mangling to account for pointers, arrays, references, and other embedded type constructs. 05/23/2002: beazley Initial attempt at supporting template partial specialization. At the very least, it is parsed and the classes are stored. Matching of instantiations to specialized version is more limited and based on the SWIG default typemap rules: SWIGTYPE * SWIGTYPE [] SWIGTYPE & Now, why in the world would you want to use this feature? Other than allowing for slightly modified class APIs, this capability is primarily used to provide advanced wrapping support for STL-like objects. It can also be mixed with typemaps. Here is an example: /* Generic version */ template class vector { %typemap(in) vector * { // A container of objects } }; /* Partial specialization (pointers) */ template class vector { %typemap(in) vector * { // A container of pointers to objects. } }; /* Specialization (integers). */ template<> class vector { %typemap(in) vector * { // A container of integers. } }; *** EXPERIMENTAL FEATURE *** 05/23/2002: beazley Enhancement to typemaps. Normally, typemap variables are renamed to avoid conflicts. For example: %typemap(in) int * (int temp) { $1 = &temp; } This results in code that creates and uses variables "temp1","temp2", "temp3" and so forth depending on how many times the typemap is used. Sometimes you want a single variable instead. To do that, using the following naming scheme: %typemap(in) int *(int _global_temp) { } Is this case, a single variable _global_temp is emitted in the wrapper functions. It is shared across all typemaps. Repeated typemaps do not replicate the variable---they use the first one emitted. *** NEW FEATURE *** 05/23/2002: beazley Minor enhancement to typemaps. If you have this code, %typemap(in) Foo (int somevar = 3) { ... } the default value for somevar is now emitted into the wrapper code. 05/22/2002: beazley Fixed %extend to be better behaved in namespaces. If you have code like this: namespace foo { struct bar { %extend { void blah(); }; }; } SWIG matches the blah() method to a C function named void foo_bar_blah(foo::bar *self). This is consistent with the non-namespace version. Bug reported by Marcelo Matus. 05/22/2002: beazley New library files: cpointer.i, carrays.i, cmalloc.i. These provide access to C pointers and memory allocation functions. See Doc/Manual/Library.html for details. 05/22/2002: cheetah (William Fulton) [Java] C type char no longer maps to Java type byte, but to Java type char. It is now treated as a character rather than a signed number. This fits in with the other language modules and is a more natural mapping as char* is mapped as a string of characters. Note that the C signed char type is still mapped to a Java byte. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 05/22/2002: cheetah (William Fulton) [Java] Improved constants wrapping. Constants (#define and %constant) values are now obtained through a JNI call. Previously the value was compiled as Java code, but this didn't work for all cases, eg #define 123ULL. 05/22/2002: beazley Fixed bogus error message with %extend directive and C++ access specifiers. Reported by Marcelo Matus. 05/22/2002: beazley Namespaces and enums now work correctly. For example: namespace Foo { enum Bar { A, B }; } Bug reported by Marcelo Matus. 05/21/2002: beazley The %types directive can now be used to specify inheritance relationships in the runtime type system. For example, %types(Foo = Bar); specifies that Foo isa Bar. Using this is potentially quite dangerous. However, this is useful in certain cases (and in the SWIG library). 05/20/2002: beazley %nodefault and %makedefault directives now require a trailing semicolon. For example: %nodefault; ... %makedefault; In addition both directives can take a class name. For example: %nodefault Foo; class Foo { /* No default constructor/destructor */ }; class Bar { /* Default constructor/destructor generated */ }; *** POTENTIAL INCOMPATIBILITY *** If you don't use the trailing semicolon, things will mysteriously break. 05/20/2002: beazley More improvements to type system handling. SWIG now correctly handles template names and parameters in a namespace. For example: namespace foo { template class bar { }; typedef int Integer; void blah(bar *x); }; In the generated code, all of the typenames are properly qualified. 05/17/2002: cheetah (William Fulton) [Java] deprecated broken -jnic and -jnicpp commandline options. The C or C++ JNI calling convention is now determined from the -c++ commandline option. 05/16/2002: cheetah (William Fulton) [Java] The JCALL macros which exist so that the same typemaps can be used for generating both the C and C++ JNI calling conventions no longer appear in the generated code. This is because the output is now passed through the SWIG preprocessor which does the macro expansion for either C or C++ (depending on whether -c++ is passed on the SWIG commandline). The generation of the functions used in the array typemaps have been adjusted to take account of this. The side effect is that any typemaps which contained JCALL macros within %{ %} brackets will have to be moved within {} brackets so that the SWIG preprocessor can expand the macros. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 05/13/2002: beazley Class templates may now be used as template parameters. For example: template class C> class Foo { ... }; template class Bar { ... }; %template(Fooi) Foo; SWIG doesn't really do anything special with this---it's just another way of specifying a template parameter. 05/13/2002: beazley Minor refinement of template support. Template parameter names are no longer required for types. For example: template class Foo { }; Obviously, names are required for template; 05/12/2002: beazley New macro expansion in typemaps. The sequence: $descriptor(type) Will expand into the SWIG type descriptor structor for the given type. Type may be any abstract datatype. For example: $descriptor(int *) $descriptor(int (*)(int,double)) $descriptor(vector *) Caveat: It is *NOT* currently legal to use other typemap substitution variables in the macro. For example $descriptor($1_type). The primary purpose of this modification is to better support typemaps for container objects or to allow typemaps that might be performing type conversions. *** NEW FEATURE *** 05/11/2002: beazley The wrapping of references to primitive types has been changed as follows: Arguments of type 'const primitive &' are now passed by value as opposed to pointers. Return values of type 'const primitive &' are returned as values instead of pointers. 'primitive' is any one of int, short, long, long long, char, float, double, bool (as well as unsigned variants). This change is being made to better support C++ wrapping--especially code that makes use of templates and the STL. 05/11/2002: beazley The %template directive can now be used to access templates in a namespace. For example: namespace std { template class complex { T re, im; public: complex(T _r = T(), T _i = T()) : re(_r), im(_i) { } T real() { return re; } T imag() { return im; } }; } %template(complex) std::complex; Note: There are some very subtle namespace/symbol table management issues involved in the implementation of this. It may not work in certain cases. 05/10/2002: beazley Member template constructor support added. For example: template struct pair { _T1 first; _T2 second; pair() : first(_T1()), second(_T2()) { } template pair(const pair<_U1,_U2> &x); }; To instantiate the template, use %template and %extend. For example, this expands the constructor into a default copy constructor: %extend pair { %template(pair) pair<_T1,_T2>; } Highly experimental. Other uses may be broken. 05/10/2002: beazley The %extend (%addmethods) directive no longer works unless it appears in the public section of a class. An error message is now generated (as opposed to a segmentation fault). 05/09/2002: beazley New %warnfilter() directive. This directive attaches a warning filter to specific declarations and has the same semantics as %rename, %ignore, %feature, and so forth. For example: %warnfilter(501) foo; // Suppress overloaded warning int foo(int); int foo(double); or %warnfilter(501) Object::foo(double); class Object { public: int foo(int); int foo(double); }; This feature only suppresses warnings in later stages of code generation. It does not suppress warnings related to preprocessing or parsing. *** NEW FEATURE *** 05/09/2002: beazley SWIG now supports C99 variadic preprocessor macros. For example: #define debugf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__) The argument "..." is used to indicate variable arguments which are all placed into the special argument name __VA_ARGS__ in the macro expansion. SWIG also implements the GNU (##) extension for swallowing the preceding comma when __VA_ARGS__ is empty. For example: #define debugf(fmt,...) fprintf(stderr,fmt, ##__VA_ARGS__) Here is how this is expanded: debugf("%d", 3) --> fprintf(stderr,"%d",3) debugf("Hello") --> fprintf(stderr,"Hello" ) (notice the deleted comma). *** NEW FEATURE *** 05/08/2002: samjam (Sam Liddicott) Many changes to php module. Shadow classes are now implemented entirely in native C and no need for php-code shadow wrappers Populated template config.m4 and Makefile.in as needed by phpize are generated. 05/08/2002: ljohnson (Lyle Johnson) [Ruby] A copy constructor is now turned into a "clone" instance method (see Dave's change for copy constructors dated 4/7/2002). This seems like the appropriate thing to do for Ruby code. 05/08/2002: ljohnson (Lyle Johnson) [Ruby] Fixed [ 553864 ] Inline destructor code not written. 05/08/2002: beazley %ignore behaves better with constructors, destructors, and the type system in general. For constructors and destructors, %ignore now suppresses the creation of a default constructor or destructor. For example: %ignore ~Foo; class Foo { public: Foo(); ~Foo(); ... }; In SWIG-1.3.11, ~Foo() simply "disappeared" and the code generator created a wrapper for a default destructor (as if it was never declared in the interface). In SWIG-1.3.12, %ignore suppresses the creation of a destructor if one is actually defined. Similarly, even though a declaration is ignored, information may still be needed to properly handle types. For example, here is a very subtle error that is fixed by this change: %ignore std::string; // Prevent class wrapping namespace std { class string { ... }; %typemap(in) string * { ... } } void foo(std::string *s); // Broken. Before this fix, %ignore would cause the class definition to disappear. This, in turn, would cause the typemap to be misapplied. 05/08/2002: beazley Minor changes to %rename, %ignore, %feature, and related directives for better support of destructors. Destructors can now be precisely tagged. For example: %ignore Foo::~Foo; %feature("action") ~Bar { ... } *Developer warning* Operations such as renaming and feature attachment for classes used to be applied to destructors as well. For instance, if you did this: %rename(Bar) Foo; The operation applied to the class itself, the constructor, and the destructor. This is no longer the case. Now such operations will only apply to the class and the constructor. Note: if you were relying on this for class renaming, be aware that renamed classes should really only be handled at the level of the class itself and not the level of individual declarations in the class (although they can be renamed individually if needed). As far as I know, the Language class is already taking care of this case correctly. 05/07/2002: beazley New set of tests. The Examples/test-suite/errors directory contains tests that try to exercise all of SWIG's error and warning messages. 05/07/2002: beazley Start of a warning framework. Warning messages are now assigned numeric values that are shown in warning messages. These can be suppressed using the -w option. For example: swig -w302 example.i swig -w302,305 example.i Alternatively, the #pragma preprocessor directive can be used to disable this: #pragma SWIG nowarn=302 #pragma SWIG nowarn=302,305 Note: Since SWIG is a multi-pass compiler, this pragma should only be used to change global settings of the warning filter. It should not be used to selectively enable/disable warnings in an interface file. The handling of #pragma occurs in the C++ preprocoessor and affects all subsequent stages of compilation. The -Wall option turns on all warnings and overrides any filters that might have been set. Warnings can be issued from an interface using %warn. For example: %warn "110:%section is deprecated" The first part of a warning message is an optional warning number. A complete set of warning numbers is found in Source/Include/swigwarn.h. *** NEW FEATURE *** 05/07/2002: beazley Internal parsing change. Directives to include files now use brackets [ ... ] instead of { ... }. %includefile "foo.i" [ ... ] The use of { ... } was a bad choice because they were included implicitly by the preprocessor and made it impossible to properly detect legitimate missing '}' errors. 04/16/2002- 05/02/2002: beazley SWIG European Tour: Paris-Amsterdam-Bath. 04/23/2002: beazley The %addmethods directive has been renamed to %extend. For example: class Foo { ... }; %extend Foo { int blah() { ... }; int bar() { ... }; ... }; Motivation: the %addmethods directive can be used for many other tasks including adding synthesized attributes, constructors, and typemaps. Because of this, "addmethods" is somewhat misleading. %extend more precisely describes this operation---extension of a class or structure. *** POTENTIAL INCOMPATIBILITY *** %addmethods still works via a macro definition. However, a warning message may be generated. Errors involving %addmethods will actually refer to the %extend directive. 04/23/2002: beazley Further refinement of the type system. Typedef now propagates through functions, pointers to functions, and pointers to member functions. For example: typedef int Integer; void foo(int (*x)(int), Integer (*y)(Integer)); In this case, arguments 'x' and 'y' have exactly the same type (and would obviously accept objects of either type). Similarly, consider this: class Foo { }; typedef Foo Bar; void bar(int (Foo::*x)(int), int (Bar::*y)(int)); In this case, arguments x and y are the same type (via typedef). 04/22/2002: beazley SWIG now generates a warning message if any part of an expression involves values from a private part of a class. For example: class Foo { private: static int X; public: void blah(int a, int b = X); // Warning }; In this case, the default argument is ignored. There are workarounds, but they are rather clumsy. For instance, you might do this: %feature("action") blah(int,int) { if ($nargs == 1) { result = blah(arg1); } else { result = blah(arg1,arg2); } } void blah(int a, int b = 0); 04/21/2002: beazley Use of the %inline directive inside a namespace is forbidden and now generates an error message. This is not allowed since the inlined code that is emitted is not placed inside a namespace. This confuses other stages of parsing. 04/21/2002: beazley Some bug fixes to casting operations and expression parsing. Due to some parsing issues, it is not currently possible to use casts for all possible datatypes. However, the common cases work. 04/20/2002: beazley (Amsterdam) Member templates now work. Simply use the %template directive inside a class or %addmethods to create instantiations (see Doc/Manual/SWIGPlus.html). Supporting this was easy---earlier changes to templates made it possible using only a two-line modification to the parser and a few minor modifications elsewhere. Hmmm, come to think of it, the smoke was rather thick in that Internet "cafe". *** NEW FEATURE *** 04/19/2002: beazley (TGV) Improved handling of non-type template parameters. For example: vector; Simple numbers and strings can be used with the %template directive as well. For example: %template(vecint100) vector; Note: Arithmetic expressions are not currently allowed. Default template arguments now work and do not have to be given to %template. 04/18/2002: beazley (Paris) Change in internal template handling. Template parameters are now fully integrated into the type system and are aware of typedefs, etc. This builds upon the change below. *** DEVELOPER WARNING *** Word of caution to language module writers. The "name" parameter of certain parse tree nodes (classes, functions, etc.) may be parameterized with types. This parameterization is done using SWIG type-strings and not the underlying C version. For example, int max(int *,int *) has a name of "max<(p.int)>". If you use the name directly, you may get syntax errors in the generated code. To fix this, use SwigType_namestr(name) to convert a parameterized name to a C name with valid syntax. The internal version is used to reduce template types to a common representation and to handle issues of typedef. 04/16/2002: beazley (somewhere over the Atlantic) Enhancement of typedef resolution. The type system is now aware of template arguments and typedef. For example: typedef int Integer; foo(vector *x, vector *y); In this case, vector and vector are the same type. There is some interaction between this mechanism and the implementation of typemaps. For example, a typemap defined for vector * would apply to either type. However, a typemap for vector * would only apply to that type. Typedefs and typemaps and matched by left-most expansion. For example: vector --> vector --> vector 04/24/2002: cheetah (William Fulton) [Java] Changes to Java shadow classes. Overcomes a bug where the module assumed that a pointer to a derived class could be used in place of a pointer to a base class. Thanks to Stephen McCaul for analysing the bug and submitting patches. A consequence is that the getCPtr() method in each shadow class has disappeared and has been replaced with a getCPtrXXX(), where XXX is the shadow class name. If you have code that previously used getCPtr(), and the associated class is wrapping a C struct or a C++ class that is not involved in an inheritance chain, just use the new method. If however, the class is involved in an inheritance chain, you'll have to choose which pointer you really want. Backwards compatibility has been broken as not using the correct pointer can lead to weird bugs through ill-defined behaviour. If you are sure you want the old methods, you could add them back into all shadow classes by adding this at the beginning of your interface file: %pragma(java) allshadowcode=%{ public long getCPtr(){ return swigCPtr; } %} Please see entry dated 07/23/2002 to see how to do this after the deprecation of the allshadowcode pragma. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 04/13/2002: beazley Fixed problem with default arguments and references. Declarations such as this should now work: void foo(const string &x = "Hello"); 04/12/2002: beazley Added typemap $* substitutions for typemaps involving arrays. Requested by William Fulton. 04/11/2002: beazley Template specialization is now supported. For example: template<> class vector { ... }; When the %template directive is used, it will use a specialization if one is defined. There are still some limitations. Partial specialization is not supported. A template of type does not match all pointers. *** NEW FEATURE *** 04/11/2002: beazley Major change to template wrapping internals. Template declarations are no longer processed as macros but now result in real parse-tree nodes. The %template directive expands these nodes into a specific instantiation. This change enables a number of new and interesting capabilities: Directives such as %rename, %feature, and %addmethods can now be applied to uninstantiated templates. For example: %rename(barsize) vector::bar(char *buf, int len); ... template class vector { public: ... void bar(char *buf); void bar(char *buf, int len); // Renamed ... }; %template(intvector) vector; // Renaming carries through By parsing templates into an internal data structure, it will be possible to support specialization (and maybe partial specialization). This is highly experimental and a work in progress. *** POTENTIAL INCOMPATIBILITY *** In SWIG-1.3.11, template declarations were simply processed as weird macros. No other information was retained. This made it impossible to support more advanced features and complicated many other parts of the implementation. 04/09/2002: beazley Change to template class wrapping. There were a variety of "issues" with the old approach related to parsing, the type system, and namespaces. These changes are meant to rectify some of these problems: A specific instantiation of a template can now be specified by including the class inline like this: class vector { public: vector(); ~vector(); ... whatever ... }; This is template specialization, but partial specialization is not yet implemented. The %template directive has been modified to expand roughly as follows: %template(vecint) vector; becomes %rename(vecint> vector; class vector { public: vector(); ... }; Note that this simply builds upon the code above (templates included inline). This modified approach to wrapping fixes some subtle type issues. For instance, you can now define typemaps and typedefs like this: %typemap(in) vector * { ... } typedef vector intvector; ... void blah(intvector *v); // Gets the above typemap This did not work in SWIG-1.3.11 due to a peculiarity of the template implementation. %template(name) no longer installs the template as a class with name "name". This might break %addmethods as described in the manual. For example: %template(vecint) vector; %addmethods vecint { // Fails. vecint not a class ... }; To fix this, just use the template name instead: %addmethods vector { ... } Note: This technique might be a way to implement some bizarre template specialization techniques. For example: %addmethods vector { // Only applied if vector instantiated later %typemap(in) vector * { ... } ... }; *** POTENTIAL INCOMPATIBILITY *** 04/08/2002: beazley Fixed [ 540868 ] #if defined whatever - not parsed. SWIG should now correctly handle preprocessor directives like this: #if defined __cplusplus ... #endif Note: was implemented previously, but there was a minor bug. Reported by Adam Hupp. 04/07/2002: beazley %readonly and %readwrite are deprecated due to a change in the implementation. Instead of being pragmas, mutability is now controlled as a "feature" using the following two directives: %immutable; int x; // read-only variable int y; // read-only variable %mutable; int z; // Modifiable %immutable and %mutable are much more powerful than their older counterparts. They can now pinpoint a specific declaration like this: %immutable x; /* Any x */ %immutable Foo::x; /* x in class Foo */ In fact, the matching algorithm is the same as for %rename, %ignore, and other directives. This means that the declaration %immutable Foo::x; would not only apply to class Foo but to all derived classes as well. *** POTENTIAL INCOMPATIBILITY *** %immutable and %mutable must be terminated by a semi-colon. This differs slightly from the older %readonly and %readwrite directives. Since %immutable and %mutable can be applied to declarations the semicolon is needed to distinguish between a global feature and one targeted to a single declaration. Note: this incompatibility is the primary reason for changing the name of the directive. 04/07/2002: beazley New handling of copy constructors. If a class defines constructors like this: class Foo { public: Foo(); Foo(const Foo &); // Copy constructor ... }; SWIG now generates a function copy_Foo() for the copy constructor. In previous verions, this generated a name-clash and an error message. To preserve backwards compatibility, SWIG does not change the behavior if %rename is used to resolve the name conflict. However, if no name resolution is made, this new approach is used. Copy constructors may be handled as a special case in the target language. However, this is up to the language module itself. 04/07/2002: beazley The %template directive is now namespace aware. This allows code like this: namespace foo { template max(T a, T b) { return a > b ? a : b; } } using namespace foo; %template(maxint) max; // Ok namespace bar { using foo::max; %template(maxdouble) max; // Ok } Caveat: the template name supplied to %template must be defined in the same scope in which the %template directive appears. This code is illegal: %template(maxint) foo::max; 04/07/2002: beazley Minor enhancement to preprocessor. The preprocessor can now perform string comparison. For example: #define A "hello" ... #if A == "hello" ... #endif The primary use of this is in SWIG macros. For example: %define FOO(x) #if #x == "int" /* Special handling for int */ ... #endif %enddef Normal users can probably safely ignore this feature. However, it may be used in parts of the SWIG library. 04/07/2002: beazley Further refinement of default constructor/destructor wrapper generation. SWIG is now much more aware of pure virtual methods. For instance: class A { /* Abstract */ public: virtual void method1() = 0; virtual void method2() = 0; }; class B : public A { /* Abstract */ public: virtual void method1() { }; }; class C : public B { /* Ok */ public: virtual void method2() { }; }; In this case, SWIG will only generate default constructors for C. Even though B looks fine, it's missing a required method and is abstract. 04/04/2002: beazley Subtle change to structure data member access. If you have a structure like this: struct Foo { Bar b; }; The accessor functions for b are generated as follows: (1) If b is *not* defined as a structure or class: Bar Foo_b_get(Foo *self) { return self->b; } void Foo_b_set(Foo *self, Bar value) { self->b = value; } (2) If b *is* defined as a structure or class: Bar *Foo_b_get(Foo *self) { return &self->b; } void Foo_b_set(Foo *self, Bar *value) { self->b = *value; } See the "Structure data members" section of Doc/Manual/SWIG.html for further details. *** POTENTIAL INCOMPATIBILITY *** This may break interfaces that relied on a lot of a undeclared structure and class names. To get the old behavior, simply use a forward declaration such as "struct Bar;" 04/04/2002: beazley C++ namespace support added. SWIG supports all aspects of namespaces including namespace, using, and namespace alias declarations. The default behavior of SWIG is to flatten namespaces in the target language. However, namespaces are fully supported at the C++ level and in the type system. See Doc/Manual/SWIGPlus.html for details on the implementation. 04/02/2002: cheetah (William Fulton) [Java] Sun has modified javac in jdk1.4 to no longer compile an import of an unnamed namespace. To fix this SWIG no longer generates the import for packageless classes. http://developer.java.sun.com/developer/bugParade/bugs/4361575.html As reported SF #538415. 03/27/2002: ljohnson (Lyle Johnson) [Ruby] Added support for pointer-to-member, similar to that for the Python module. Remarkably similar. Also added a new example for this (Examples/ruby/mpointer), which is remarkably similar to the Python example of the same name. 03/26/2002: ljohnson (Lyle Johnson) [Ruby] Made a few minor edits to the "Advanced Topics" chapter of the SWIG manual and added a new major section about how to create multi-module Ruby packages with SWIG. 03/26/2002: ljohnson (Lyle Johnson) [Ruby] Removed all of the old Ruby pragmas. If any of this functionality is truly missed we can resurrect it, preferably with some kind of feature-based directive. 03/25/2002: ljohnson (Lyle Johnson) [Ruby] Fixed SWIG exception library support for Ruby, which has apparently been broken for some time. Luckily, no one seems to have noticed. 03/23/2002: beazley C++-namespace support in SWIG directives. %addmethods: The %addmethods directive now accepts a fully qualified classname and can be used inside C++ namespace declarations. For example: // Attaches to the class Foo::Bar below %addmethods Foo::Bar { int somemethod() { ... } }; namespace Foo { class Bar { public: ... }; // Attaches to the class Bar above %addmethods Bar { int othermethod() { ... }; } } %feature, %rename, %ignore, %exception, and related directives: Namespaces are fully integrated into the renaming and declaration matcher. For example: %rename(display) Foo::print; // Rename in namespace Foo %ignore Foo::Bar::blah; // Ignore a declaration %rename directives can be placed inside namespace blocks as well. For example: namespace Foo { %rename(display) print; // Applies to print below void print(); }; Most other SWIG directives should work properly inside namespaces. No other changes are needed. 03/22/2002: beazley Some changes to internal symbol table handling. SWIG no longer manages structures and unions in a separate namespace than normal declarations like ANSI C. This means you can't have a structure with the same name as a function. For example: struct Foo { ... } int Foo() { ... } This approach is more like C++. It's not clear that SWIG ever really supported the ANSI C anyways---using the same name would almost certainly generate a name-clash in the target language. 03/22/2002: ljohnson (Lyle Johnson) [Ruby] Fixed [ 517302 ] for handling of renamed overloaded constructors. Now, renamed overloaded constructors are converted into class singleton methods (basically acting as "factory" methods). 03/21/2002: beazley Fixed [ 532957 ] %ignore parse error and casting operator. Reported by William Fulton. 03/18/2002: beazley (** ADVANCED USERS ONLY **) Added support for dynamic casting in return values. A somewhat common problem in certain C++ programs is functions that hide the identity of underlying objects when they are returned from methods and functions. For example, a program might include some generic method like this: Node *getNode(); However, Node * may just be base class to a whole hierarchy of different objects. Instead of returning this generic Node *, it might be nice to automatically downcast the object into the appropriate type using some kind dynamic cast. Assuming you understand the peril involved, a downcast can now be performed using the following function in the run-time type checker: swig_type_info *SWIG_TypeDynamicCast(swig_type_info *, void **ptr); This function checks to see if the type can be converted to another type. If so, a different type descriptor (for the converted type) is returned. This type descriptor would then be used to create a pointer in the target language. To use this, you would write a typemap similar to this: %typemap(out) Node * { swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); $result = SWIG_NewPointerObj($1, ty); } Alternatively, %typemap(out) Node * = SWIGTYPE *DYNAMIC; To make the typemap have any effect, you have to write a supporting function that knows how to perform downcasting. For example: %{ static swig_type_info * Node_dynamic_cast(void **ptr) { Node **nptr = (Node **) ptr; Element *e = dynamic_cast(*nptr); if (e) { *ptr = (void *) e; return SWIGTYPE_p_Element; } Data *d = dynamic_cast(*nptr); if (d) { *ptr = (void *) d; return SWIGTYPE_p_Data; } return 0; } %} There is no restriction on how types are determined. dynamic_cast<> uses C++ RTTI. However, if you had some other mechanism for determining the type, you could use that here. Note: it is important to save the new pointer value back into the argument as shown. When downcasting, the value of the pointer could change. Finally, to make the casting function available, you have to register it with the run-time type checker. Put this macro in your interface file. DYNAMIC_CAST(SWIGTYPE_p_Node, Node_dynamic_cast); Note: this feature does not introduce a performance penalty on normal SWIG operation. The feature is only enabled by writing a new typemap that explicitly calls SWIG_TypeDynamicCast() to make a conversion. Examples/test-suite/dynamic_cast.i contains a simple example. This feature is not supported in the Java module due to differences in the type-checking implementation. *** EXPERIMENTAL FEATURE *** 03/17/2002: beazley Small change to type-name handling of unnamed structures and typedef. If a structure of this form appears: typedef struct { ... } Foo; Then 'Foo' is used as the proper typename for the structure. Furthermore, Foo can now be used as a name in C++ inheritance. SWIG was already kind of doing this, but this modification refines the implementation to more closely follow the C++ ARM, section 7.1.3, p. 106. This fixes a couple of obscure corner cases. 03/16/2002: beazley Modified C++ inheritance with a few enhancements. First, type information needed for casting and type-equivalence is generated even when base-classes aren't defined in the interface. For example: class Foo : public Bar { /* Bar unspecified */ public: ... }; void blah(Bar *b); In this case, the blah() function still accepts Foo * even though nothing is really known about Bar. Previous SWIG versions would just generate a type error. Inheritance has also been modified to work through typedef. For example: class Bar { }; typedef Bar OtherBar; class Foo: public OtherBar { } In this case, the base class of OtherBar is correctly resolved back to Bar. The use of the name OtherBar is lost in this resolution (the wrappers will simply use Bar instead of the typedef name OtherBar). 03/13/2002: beazley %typemap, %apply, and related directives can now appear inside class definitions. 03/13/2002: beazley Fixed a variety of problems related to compiling SWIG on 64-bit platforms. 03/12/2002: beazley Fixed problem with "ignore" and "in" typemaps. Local variables associated with "in" were being added to the wrapper function even though they were never used. Mostly harmless, but it would lead to a variety of compilation warnings. 03/12/2002: beazley Some changes to the internal type system and handling of nested C++ types. In previous versions of SWIG, if you had the following: class Foo { public: typedef int Blah; }; class Bar : public Foo { public: void somemethod(Blah x); }; The argument type in somemethod() would implicitly be set to Bar::Blah. Although this is technically allowed, it breaks typemaps. For example: %typemap(in) Foo::Blah { ... } doesn't match like you expect. This has been changed in SWIG-1.3.12. Now, types are expanded using the class in which they were defined. So, the argument type in somemethod() will be Foo::Blah---since the type Blah was defined in Foo. 03/10/2002: beazley Fixed some subtle type scoping problems with typedef and C++ classes. For example: typedef int Blah; class Bar { public: typedef double Blah; void foo(Blah x, ::Blah y); ... } 03/10/2002: beazley Highly experimental change to handle variable length arguments. First, there is no portable or reliable way to wrap a varargs function in full generality. However, you *can* change the function signature using %varargs. %varargs(char *) fprintf; ... void fprintf(FILE *f, char *fmt, ...); In this case, the variable length parameter "..." is simply replaced by the parameters given in %varargs. This results in a function like this: void fprintf(FILE *f, char *fmt, char *s); More than one argument can be used and default values can be defined. For example, this code specifies a maximum of four arguments. %varargs(char *x1 = 0, char *x2 = 0, char *x3 = 0, char *x4 = 0) fprintf; *** EXPERIMENTAL NEW FEATURE *** 03/10/2002: beazley Change to handling of variable length arguments. varargs is now handled as a proper parameter and is passed to the code generator. However, it still can't be handled correctly (and will generate a typemap warning). This change has been made to better incorporate variable length arguments with other directives such as %ignore, %rename, %feature, and so forth. 03/10/2002: beazley Fixed [ 522555 ] Syntax error parsing "define" construct. SWIG is a little more restrictive in determining #define statements that will be wrapped as constants. Also added a better parser error rule for handling bad constants. 03/08/2002: cheetah (William Fulton) [Java] Bug fix: Classes renamed with %rename that are derived from another class generate more appropriate shadow class code. 03/08/2002: cheetah (William Fulton) [Java] Fixed SF [ #523632 ] and [ #513335 ] both reported by Israel Tanner. Support for types that are used which are in a typedef. The appropriate shadow class name is generated. Also generated correct shadow classname when a templated class is used within another templated class. See the cpp_typedef.i testcase. 03/08/2002: cheetah (William Fulton) [Java] Bug fix: No type was generated in shadow classes for types that weren't wrapped by SWIG. The type is treated as a raw pointer, ie no shadow class. 02/22/2002: beazley Refined the matching algorithm used by %rename, %ignore, and %feature. If a type signature is supplied, it must exactly match that used in the declaration---including any use of const. For example: %rename(foo1) foo(int); %rename(bar1) bar(int) const; class Blah { public: void foo(int); // Matched --> foo1 void foo(int) const; // Not matched void bar(int); // Not matched void bar(int) const; // Matched --> bar1 } In previous versions, a non-const specification would match both the non-const and const declarations. However, the whole point of %rename and related directives is that they be able to precisely pinpoint exact declarations in an interface. This fixes the problem. 02/21/2002: beazley Reworked the handling of default constructor and destructors. SWIG now makes a preliminary pass over the parse tree to discover which classes support default allocation. This fixes a number of very subtle issues in code generation and call/return by value. 02/18/2002: cheetah (William Fulton) Improved support on Cygwin: Perl, Python, Tcl, Ruby and Java should work out of the box, barring the runtime library. Removed dllwrap and replaced with newly working gcc -shared instead for Cygwin. All this will require the new improved binutils 20010802 and later, but the latest Cygwin is usually the best recommendation. 02/15/2002: beazley Fixed some problems related to wrapping of global variables and Perl shadow classes. Reported by Chia-liang Kao. 02/15/2002: ljohnson (Lyle Johnson) [Ruby] Made a fix to the code generation for C++ class constructors so that we get both a "new" singleton method and an "initialize" instance method for each class. This change enables developers to derive new Ruby classes from SWIG-wrapped C++ classes and then override their initialize methods to provide subclass-specific instance initialization. 02/15/2002: ljohnson (Lyle Johnson) [Ruby] Massive documentation update for the Ruby module, contributed by Craig Files. 02/14/2002: ljohnson (Lyle Johnson) [Ruby] Bug fix: An error in the SWIG runtime support for Ruby was causing several of the examples to fail. Reported by William Fulton. 02/14/2002: ljohnson (Lyle Johnson) [Ruby] Bug fix: Enumerations defined within a class (such as those seen in the Examples/ruby/enum example) were not being exported with the correct names. Reported by William Fulton. 02/13/2002: ljohnson (Lyle Johnson) [Ruby] Added a warning message when we run across overloaded class constructors for C++ code, that this is currently not supported (even if the overloads have been %renamed). For an example of where this doesn't work, see Examples/ruby/operator. 02/13/2002: ljohnson (Lyle Johnson) [Ruby] Added an "ignored" warning message when the parser runs across an operator!=() declaration for C++ code. 02/11/2002: ljohnson (Lyle Johnson) [Ruby] Added the "import", "import_template", "operator" and "template" examples. 02/11/2002: ljohnson (Lyle Johnson) [Ruby] Added multi-module support. 02/09/2002: ljohnson (Lyle Johnson) [Ruby] Added the missing "#define SWIG_NOINCLUDE" at the top of the wrapper code when the '-c' option is used. 02/09/2002: ljohnson (Lyle Johnson) Corrected a minor off-by-one error for the size of the swig_types[] array that's generated in the wrapper code. 02/08/2002: beazley Fixed SF [ #515058 ] Wrong code for C++ templates. Reported by Israel Taller. Version 1.3.11 (January 31, 2002) ================================= 01/30/2002: beazley Fix to pass/return by value for C++ objects that define no default constructor. Changes to the typemap system made it impossible to wrap C++ objects with no default constructor. This has been fixed, but the solution involves some clever template magic contributed by William Fulton. Please see the comments in the file Lib/swig.swg for further details. This solution is experimental and may be refined in a future release. 01/30/2002: beazley Global variables and member data of type "const char *" can be set, but the old value is silently discarded without any garbage collection. This may generate a memory leak. This change is needed to more safely handle variables like this: const char *foo = "Hello World\n"; In this case, it's not safe to free the old value. However, SWIG can dynamically allocate a new value and make foo point to it. To fix this memory leak, you can probably do this: %clear const char *foo; %apply char * {const char *foo}; *** POTENTIAL INCOMPATIBILITY *** 01/30/2002: beazley Two minor typemap enhancements have been added. First, typemaps can issue a warning message by including a special warning attribute. For example: %typemap(in,warning="I'm going to do something dangerous") ... The warning message will show up whenever the typemap is applied. Second, a typemap can force a no-match by defining %typemap(in) sometype "pass"; If this is used, the typemap system will *not* record a typemap match for "sometype". This can be used to block selected typemaps. For example, if you wanted to disable a typemap feature for some type, you could do this. // Do not allow global variables of type 'const char *' to be set. %typemap(varin) const char * "pass"; It might also be possible to use this to do subtle and strange things with typemaps. For example, if you wanted to make 'blah *' an output value and 'const blah *' an input parameter, you might do this: %typemap(ignore) blah *(blah temp) { $1 = &temp; } %typemap(argout) blah * { ... return a value ... } /* Block unqualified typemaps defined above */ %typemap(ignore) const blah * "pass"; %typemap(argout) const blah * "pass"; %typemap(in) const blah * { ... get input value ... } (This potential applications of typemaps suggested by Greg Stein). *** NEW FEATURE *** 01/29/2002: cheetah (william fulton) [Java] Bug fix: No enumerations were wrapped when the -shadow commandline option was not specified. Reported by Israel Taller. 01/28/2002: cheetah (william fulton) [Java] Global arrays are successfully wrapped. In fact they started mostly working in SWIG-1.3.10. 01/28/2002:richardp Added first attempt at C++ and -shadow support for PHP4 module, please test and mail me if any problems/ideas on improving it. There is a known problem with uninitialized member variables, please see Examples/php4/sync/README for details. Also more PHP documentation added to Doc/Manual/Php.html 01/27/2002:beazley The ANSI C size_t type is now recognized as an integer by default. 01/26/2002:beazley long long and unsigned long long support added to many language modules. This is not a portable feature and will require compiler support for the long long type. In target languages that do not support long long (e.g., Tcl and Perl), numbers are converted to a string of digits. This prevents their use in arithmetic calculations, but still allows values to be set from a string. long long support requires the use of the strtoll() and strtoull() functions as well as the 'lld' and 'llu' format specifiers of sprintf(). 01/26/2002:beazley Fixed [ #501827 ] Delete method is not called. The Tcl module wasn't correctly calling destructors when they were defined using %addmethods. This has been fixed. Reported by Reinhard Fobbe. 01/26/2002: beazley Better support for long long and unsigned long long. Typemaps have been included in a number of modules for handling these types. In addition, the parser has been modified to accept long long literals such as 1234LL and 1234ULL. 01/27/2002: cheetah (william fulton) [Java] A C char[] is mapped to a Java String which is the default SWIG handling of char[] and char*. It used to be mapped to byte[]. Note that a C signed char[] array is mapped to byte[]. *** POTENTIAL INCOMPATIBILITY *** 01/25/2002: beazley Fixed a problem with return-by-value, C++, and objects that define no default constructor. Reported by Joel Reed. 01/25/2002: cheetah (william fulton) [Java] Overhaul of the Java module. The C code generation is now done from typemaps. 01/24/2002: cheetah (william fulton) [Java] Support for arrays of enum pointers 01/20/2002: cheetah (william fulton) [Java] Error checking for null Java objects being passed to native functions. Exception thrown now whereas before the JVM crashed. 01/18/2002: cheetah (william fulton) [Java] Corrected behaviour for functions that take arrays. For example, when this c function: void arrayfn(int array[]); is wrapped the corresponding native function public final static native void arrayfn(int[] array); is produced. Previously if the C function made any changes to the array elements, these were not reflected back into the Java array. This has now been corrected so that the changes are propogated back to Java and the calling function will see these changes. This is how pure Java functions work, ie arrays are passed by reference. 01/15/2002:mkoeppe [Guile] New file cplusplus.i with C++ typemaps contributed by Marcio Luis Teixeira . 01/11/2002: cheetah (william fulton) [Java] Changed mapping of C long to Java type. Was mapped to Java long, now mapped to Java int. If you want the previous mapping to Java long use this approach in your interface file: %clear long; %typemap(jni) long "jlong" %typemap(jtype) long "long" %typemap(jstype) long "long" %clear long[ANY]; %typemap(jni) long[ANY] "jlongArray" %typemap(jtype) long[ANY] "long[]" %typemap(jstype) long[ANY] "long[]" %typemap(in) long[ANY] {write me for array support} %typemap(out) long[ANY] {write me for array support} %typemap(argout) long[ANY] {write me for array support} %typemap(freearg) long[ANY] {write me for array support} *** POTENTIAL INCOMPATIBILITY *** This new mapping is more appropriate when interfacing to 32 bit applications which are used in the current 32-bit JVMs. For future 64-bit JVMs you may have to change these mappings - eg on Unix LP64 systems, but not on Microsoft 64bit Windows which will be using a P64 IL32 model. This may be automated in a future version of SWIG. 01/10/2002:beazley Fixed [ 501677 ] %init block in wrong place. Reported by Luigi Ballabio. 01/09/2002: cheetah (william fulton) [Java] Default support for the long long type. signed long long is mapped to a Java long. unsigned long long is mapped to BigInteger. 01/09/2002:beazley Experimental change to parser to better support mixing of int, long, short, unsigned, float, and double. The parser should now support types like this: short unsigned int int unsigned short unsigned short int unsigned int short This change also enables a type of 'long double' (previously unsupported) to be used. *** NEW FEATURE *** 01/05/2002: cheetah (william fulton) [Java] Casting fix for when function return type is a pointer as reported by Gary Pennington 2002-01-05. The upper 32bits of the 64 bit jlong will have contained junk for 32bit pointers. 01/05/2002: cheetah (william fulton) [Java] Better pointer handling in Java is possible as the INPUT, OUTPUT and INOUT typemaps have been added into typemaps.i. 01/05/2002: cheetah (william fulton) [Java] $null can be used in input typemaps to return early from JNI functions that have either void or a non-void return type. Example: %typemap(check) int * %{ if (error) { SWIG_exception(SWIG_IndexError, "Array element error"); return $null; } %} If the typemap gets put into a function with void as return, $null will expand to nothing: void jni_fn(...) { if (error) { SWIG_exception(SWIG_IndexError, "Array element error"); return ; } ... } otherwise $null expands to zero, where javareturntype is either a pointer or a primitive type: javareturntype jni_fn(...) { if (error) { SWIG_exception(SWIG_IndexError, "Array element error"); return 0; } ... } 01/02/2002: cheetah (william fulton) [Java] The Java module incorrectly used argout typemaps for strings. This is now corrected and the code now resides in the freearg typemap. The argout array typemaps have been split into argout and freearg typemaps. This correction may require some user written typemaps to be modified. *** POTENTIAL INCOMPATIBILITY *** 12/28/2001: cheetah (william fulton) [Java] Multi typemaps now working for Java see multimap example. [Java] Fix for recently introduced bug - freearg typemap code was appearing before the function call. 12/28/2001: cheetah (william fulton) [Java] JCALL macro for JNI calls that work in both C and C++ typemaps have been replaced with JCALL0, JCALL1, JCALL2, JCALL3 and JCALL4 macros. *** POTENTIAL INCOMPATIBILITY *** 12/22/2001:beazley Resolved some inconsistent behavior with %rename and class renaming. If you specify the following: %rename(Foo) Bar; class Bar { public: Bar(); ~Bar(); } Then the %rename directive applies to the class itself, the constructor, and the destructor (all will be renamed to Foo). If a class defines more than one constructor, the overloaded variants can still be renamed by specifying parameters to %rename. For example: %rename(Bar_copy) Bar(Bar &); class Bar { public: Bar(); Bar(Bar &); ~Bar(); }; There are still some odd corner cases. If you specify %rename(Foo) ::Bar; then only the name of the class is changed and the constructor/destructor names are left unmodified. If you specify %rename(Foo) *::Bar; then the names of the constructor/destructor functions are modified but the name of the class is not. 12/21/2001: cheetah (william fulton) [Java] jni, jtype and jstype typemaps no longer hardcoded but real typemaps. New variable substitution, $javaclassname, can be used in the jstype typemaps. It is replaced with the Java shadow class name where applicable. [Java] Fix for recently introduced bug to do with inheritance when using %import. [Java] A few more bug fixes, todo with %rename and using the kind with the type, eg void fn(union uni myuni, struct str mystr, class cl mycl); 12/20/2001:beazley Fixed [ #494524 ] Preprocessor bug - apostrophe and #subst. 12/20/2001:beazley Added SWIG_VERSION preprocessor symbol. This is a hexadecimal integer such as 0x010311 (corresponding to SWIG-1.3.11). This can be used in the interface as follows: #if SWIG_VERSION >= 0x010311 /* Use some fancy new feature */ #endif Note: The version symbol is not defined in the generated SWIG wrapper file. *** NEW FEATURE *** 12/20/2001:mkoeppe [MzScheme]: Renamed mzswig_make_boolean to swig_make_boolean, as the latter is used in the typemaps. Reported by Luigi Ballabio. 12/17/2001:mkoeppe [Guile]: Rewrote list-vector.i using multi-dispatch typemaps. Updated pointer-in-out.i. Make the deprecated typemap-substitution of "$source" in "argout" work as before. 12/16/2001:mkoeppe [Guile]: Fixed macros %values_as_list, %values_as_vector, %multiple_values to use the proper %pragma syntax. New Guile example/test "multivalue"; new Guile run-test for test-suite item "list-vector" (currently broken). 12/14/2001:mkoeppe [Guile]: Fixed typemap-substition bug for "varin". Relaxed valid-identifier check to allow all R5RS identifiers. Version 1.3.10 (December 10, 2001) ================================== 12/08/2001:beazley Modified %typemap so that %{ ... %} can also be used as a code block (mostly for completeness). For example: %typemap(in) blah %{ ... %} This form does not introduce a new block scope. Also, the code enclosed in %{ ... %} is not processed by the preprocessor. 12/08/2001:beazley Fixed [ #459614 ] SWIG with multiple TCL interpreters. 12/08/2001:beazley Fixed [ #417141 ] rubydec.swg is wrong Reported by Paul Brannan. 12/08/2001:beazley Fixed [ #410557 ] Problem with %addmethods on NT. Reported by Magnus Ljung. 12/08/2001:beazley Fixed [ #445233 ] Enhancement: handle access change. SWIG now parses (but ignores) C++ access changes for the the following: class A { protected: void something() { } public: A() {} }; class B : private A { public: B() : A() { } protected: A::something; <---- Parsed, but ignored }; Suggested by Krzysztof Kozminski. 12/08/2001: cheetah (william fulton) Fix for Ruby to work using Visual C++. 12/06/2001:beazley Fixed [ #465687 ] unsigned short parameters fail. Reported by Gerald Williams. 12/06/2001:beazley Fixed SF [ #489594 ] PyString_FromString can't take NULL arg. Reported by John Merritt. SWIG now converts string values to Python using code like this: resultobj = result ? PyString_FromString(result) : Py_BuildValue(""); 12/06/2001:beazley Fixed SF [ #463561 ] Type conversions not generated. Reported by Gerald Williams. 12/04/2001:beazley Fixed SF [ #470217 ] Tcl default argument handling. Reported by Shaun Lowry. 12/04/2001:beazley Fixed SF [ #472088 ] defined(MACRO) expanded everywhere. Embedded preprocessor directives such as %#if defined(FOO) are not expanded by the SWIG preprocessor. Reported by Gerald Williams. 12/04/2001:beazley Fixed SF [ #476467 ] Problems with #define & commas. 12/04/2001:beazley Fixed SF [ #477547 ] wrong declaration of pointer functions. Bad prototypes in Lib/tcl/ptrlang.i. 12/04/2001:beazley Fixed SF [ #483182 ] Constants can take args by mistake. When swig -perl5 -const is used, constants are declared with a void prototype. For example: sub ICONST () { $examplec::ICONST } Patch submitted by Rich Wales. 12/03/2001:beazley New %exception directive. This is intended to replace %except. It works in exactly the same manner except it does not accept a language specifier. For example: %exception { try { $action } catch(SomeError) { error } } %exception is also name aware---allowing it to be applied to specific declarations in an interface. For example: %exception foo { ... exception for any function/method foo ... } %exception Foo::bar { ... exception for method bar in class Foo ... } %exception Foo::bar(double) { ... exception for method bar(double) in class Foo ... } The semantics of this name matching is exactly the same as for %rename. *** NEW FEATURE *** 12/03/2001:beazley Substantial cleanup of the Python shadow class code. Shadow classes used to be created in this rather complicated manner involving about a half-dozen strings created in bits and pieces. Shadow classes are now generated in a more straightforward manner--in the same order that appears in the interface file. *** POTENTIAL INCOMPATIBILITY *** The order in which declarations appear in the shadow file may differ. 12/03/2001:beazley The %insert directive (%{ ... %}, %runtime, %header, %wrapper, etc.) can now be used inside of a class definition. This has potential uses when generating shadow class code. For example: class Foo { ... %insert("shadow") %{ # Some python code def blah(self): print "I'm blah!" %} ... }; The support for class code insertion depends on the language module. However, the intent of this feature is to simplify the task of extending shadow class code. In the Python module, this inserts code with the proper level of indendation (regardless of what was used in the SWIG interface). *** NEW FEATURE *** 11/29/2001: cheetah (william fulton) Modifications for Java and Python modules to work on cygwin. Unfortunately a lot of the python module has started to produces code which cannot be auto-imported using cygwin libtools so most of it is still broken. 11/28/2001:beazley The %rename and %feature directive can now be used inside of a class definition. For example: class Foo { %rename(foo_i) foo(int); %rename(foo_d) foo(double); public: ... void foo(int); void foo(double); ... }; When used in this manner, the %rename directive only applies to members of the class in which it appears as well as all derived classes. In fact, this is really just the same as saying: %rename(foo_i) Foo::foo(int); %rename(foo_d) Foo::foo(double); class Foo { ... }; *** NEW FEATURE *** 11/26/2001:beazley Added the experimental %feature directive. %feature can be used to attach arbitrary string attributes to parse tree nodes. For example: %feature("except") blah { try { $function } catch (Error) { whatever; } } or %feature("set") *::x_set "x"; or %feature("blah") Foo::bar(int,double) const "spam"; The syntax is borrowed from the %rename directive. In fact, the exact same semantics apply (inheritance, matching, etc.). %feature is a very powerful low-level primitive that can be used to customize individual language modules and to provide hints to any stage of code generation. Features are attached to parse tree nodes as attributes with names like "feature:*" where * is replaced by the feature name (e.g., "feature:except", "feature:set", etc.). Language modules can then look for the features using a simple attribute lookup. %feature is intended to be a replacement for a number of older SWIG directives including %except and specialized pragmas. It is more powerful (due to its parameterized name matching) and it provides very precise control over how customization features are attached to individual declarations. There are future expansion plans that will build upon this capability as well. It's not certain that %feature will ever be used directly by SWIG users. Instead, it may be a low-level primitive that is used in high-level macro definitions. For instance, to support properties, you might define a macro like this: %define %property(name, setf, getf) %feature("set") setf #name; %feature("get") getf #name; %enddef Which allows a user to specify things like this: %property(p, get_p, set_p); class Blah { public: int get_p(); void set_p(int); }; *** EXPERIMENTAL NEW FEATURE *** 11/24/2001:beazley The Tcl module has been expanded with some new features for managing object ownership. For example: set c [Circle -args 20] $c area # Invoke a method $c -disown # Releases ownership of the object $c -acquire # Acquires ownership of the object If Tcl owns the object, its destructor is invoked when the corresponding object command is deleted in Tcl. To simplify the destruction of objects, the following syntax can be used: $c -delete # Delete an object This is an alternative for the more obscure variant of rename $c {} These features also add functionality at the C API level. The following functions manage ownership from C and can be used in typemaps. SWIG_Acquire(void *ptr); SWIG_Disown(void *ptr); A new function for constructing instances is also available: Tcl_Obj * SWIG_NewInstanceObj(Tcl_Interp *interp, void *ptr, swig_type_info *type, int own); When used in a typemap, this creates a pointer object and an interpreter command that can be used to issue methods and access attributes as shown above. *** NEW FEATURE *** 11/23/2001:beazley All Python-related %pragma operations have been eliminated. Most of these were written for older SWIG versions in order to compensate for limitations in earlier releases. In an effort to reduce the amount of code-clutter and potential for errors, it is easier to simply eliminate the pragmas and to start over (if needed). To be honest, I'm not even sure the pragmas worked in 1.3.9 and recent releases. Note: If you need to insert code into the shadow class file created by SWIG, simply use the %shadow directive like this: %shadow %{ def some_python_code(): print "blah!" %} *** POTENTIAL INCOMPATIBILITY *** 11/22/2001:beazley Sweeping changes to the way in which the Python module handles shadow classes. In early implementations, shadow classes were merely Python wrappers around typed pointer objects. However, some users actually wanted to receive the shadow class object in C. To accommodate this, the dereferencing of the "this" pointer in a shadow class was moved to C as described in CHANGES [8/8/99]. However, the process of returning pointers to Python was still somewhat problematic. Specifically, shadow classes never worked in situations such as these: - Use of any kind of output typemap ('out' or 'argout') - Global variables (broken as far as I can tell). In the past, some users have dealt with this by manually trying to create shadow class objects themselves from C/C++. However, this was difficult because the C wrappers don't really know how to get access to the corresponding Python class. The Python module has now been modified to automatically attach shadow class objects to pointers when they are returned to Python. This process occurs in the function SWIG_NewPointerObj() so the process is completely transparent to users. As a result, shadow classes are now more seamlessly integrated with typemaps and other features of SWIG. This change may introduce a number of incompatibilities. The SWIG_NewPointerObj() now takes an extra parameter "own" to indicate object ownership. This can be used to return a pointer to Python that Python should destroy. In addition, older code that tries to manually construct shadow class objects or which expects bare pointers may break---such pointers may already be encapsulated by a shadow class. *** POTENTIAL INCOMPATIBILITY *** 11/20/2001:beazley Modified the %insert directive to accept single braces { ... }. For example: %insert("header") { ... some code ... } This works exactly like %{ ... %} except that the code in the braces is processed using the preprocessor. This can be useful in certain contexts such as low-level code generation in language modules. *** NEW FEATURE *** 11/20/2001:beazley Command line options are now translated into preprocessor symbols. For example: ./swig -python -shadow -module blah interface.i Creates the symbols: SWIGOPT_PYTHON 1 SWIGOPT_SHADOW 1 SWIGOPT_MODULE blah Modules can look for these symbols to alter their code generation if needed. *** NEW FEATURE *** 11/20/2001:beazley Massive overhaul of the Perl5 module. A lot of code generation is now driven by tables and typemaps. The generated wrapper code also makes use of tables to install constants, variables, and functions instead of inlining a bunch of procedure calls. The separate variable initialization function is gone. Most code generation is controlled via the perl5.swg file in the library. *** POTENTIAL INCOMPATIBILITY *** 11/13/2001:beazley Added parsing support for the C++ typename keyword. Primarily this is added to better support templates. For example: template void blah(C& v) { typename C::iterator i = v.begin(); } Note: typename is supported in the parser in the same way as 'struct' or 'class'. You probably shouldn't use it anywhere except in templates. *** NEW FEATURE *** 11/11/2001:beazley Massive overhaul of the language module API. Most functions now use a common, very simple, API. There are also a number of interesting semantic side-effects of how code is actually generated. Details will be forthcoming in Doc/Manual/Extending.html. *** POTENTIAL INCOMPATIBILITY *** Language modules written for previous versions of SWIG will no longer work, 11/10/2001:beazley Fixed a very subtle bug due to unnamed class wrapping. For example, if you did this typedef struct { int x,y; } gdPoint, *gdPointPtr; void foo(gdPointPtr x); Then the foo function would get a type-error. The problem has to do with internal typedef handling and the fact that the typedef declarations after the struct appear later in the parse tree. It should work now. Problem reported by Vin Jovanovic. 11/09/2001:beazley Subtle change to "out" typemaps (and related variations). The name that is attached to the typemap is now the raw C identifier that appears on a declaration. This changes the behavior of member functions. For example: %typemap(out) int foo { ... } class Blah { public: int foo(); // typemap gets applied } Previous versions never really specified how this was supposed to work. In SWIG1.1, you could probably write a typemap for the wrapper name like this: %typemap(out) int Blah_foo { ... } However, this old behavior is now withdrawn and not supported. Just use the member name without any sort of special prefix. *** POTENTIAL INCOMPATIBILITY *** 11/06/2001:beazley Changes to Tcl module initialization: (1) SWIG now automatically includes the code needed to work with Tcl stubs. Simply compile with -DUSE_TCL_STUBS. (2) SWIG now automatically calls Tcl_PkgProvide to register a package name. The package name is the same as the name specified with the %module directive. The version number is set to "0.0" by default. To change the version number, use swig -pkgversion 1.2 interface.i. *** POTENTIAL INCOMPATIBILITY *** Modules that provided stubs and Tcl_PkgProvide on their own might break. Simply remove that code. 11/05/2001:beazley Changed code generation of constants in the Tcl module. Constants are now stored in a large table that get installed at module startup. There are also no longer any static variables so it should generate somewhat less code. 11/04/2001:beazley The "const" typemap has been renamed to "constant" in many language modules. "const" is a C keyword which made the handling of the typemap directive somewhat awkward in the parser. *** POTENTIAL INCOMPATIBILITY *** 11/04/2001:beazley %typemap directive can now accept nearly arbitrary keyword parameters. For example: %typemap(in,parse="i",doc="integer") int "..."; The purpose of the keyword parameters is to supply code generation hints to the target language module. The intepretation of the parameters is language specific. *** NEW FEATURE *** 11/04/2001:beazley Slight semantic change to internal call/return by value handling. In previous versions of SWIG, call-by-value was translated into pointers. For example: double dot_product(Vector a, Vector b); turned into this: double wrap_dot_product(Vector *a, Vector *b) { return dot_product(*a,*b); } This translation was normally performed by the SWIG core, outside of the control of language modules. However, a side effect of this was a lot of bizarre typemap behavior. For example, if you did something like this: %typemap(in) int32 { ... } You would find that int32 was transformed into a pointer everywhere! (needless to say, such behavior is unexpected and quite awkward to deal with). To make matters worse, if a typedef was also used, the pointer behavior suddenly disappeared. To fix this, the pointer transformation is now pushed to the language modules. This produces wrappers that look roughly like this: double wrap_dot_product(Vector *a, Vector *b) { Vector arg1 = *a; Vector arg2 = *b; return dot_product(arg1,arg2); } This change also makes it easy to define typemaps for arbitrary undefined types. For example, you can do this (and it will work regardless what int32 is): %typemap(in) int32 { $1 = (int32) PyInt_AsLong($input); } *** POTENTIAL IMCOMPATIBILITY *** This change may break call/return by value code generation in some language modules. 11/03/2001:beazley Changed the name of the default typemaps to the following: %typemap() SWIGTYPE { ... an object ... } %typemap() SWIGTYPE * { ... a pointer ... } %typemap() SWIGTYPE & { ... a reference ... } %typemap() SWIGTYPE [] { ... an array ... } %typemap() enum SWIGTYPE { ... an enum value ... } %typemap() SWIGTYPE (CLASS::*) { ... pointer to member ... } These types are used as the default for all types that don't match anything else. See CHANGES log entry for 8/27/2000 for the old behavior. The role of these types is also described in Doc/Manual/Typemaps.html *** POTENTIAL INCOMPATIBILITY *** 10/25/2001:beazley Modified Guile and Mzscheme modules to support multi-argument typemaps. 10/25/2001: cheetah (william fulton) [Java] Fix to handle pointers to arrays. 10/24/2001:beazley Defining a typemap rule for enum SWIGENUM can now be used to define default behavior for enum variables. 10/22/2001:beazley Ruby module modified to support multi-argument typemaps. 10/22/2001:beazley The Ruby module can now handle functions with an arbitrary number of arguments. Previous versions were limited to to functions with only 9 or 16 arguments depending on the use of default arguments. Note: from some inspection of the Ruby interpreter source, the new approach might be a little faster as well. 10/18/2001:beazley Fixed a bug with forward class declarations and templates. class Foo ; Bug reported by Irina Kotlova. 10/16/2001:beazley Support for multivalued typemaps added. The typemaps are specified using the syntax below. Within each typemap, variable substitution is handled as follows: %typemap(in) (int argc, char *argv[]) { $arg; // The input object in the target language $1; // C local variable for first argument $2; // C local variable for second argument // These variables refer to either argument $1_type, $1_ltype, $1_basetype, etc... (argc) $2_type, $2_ltype, $2_basetype, etc... (argv[]) // Array dimension of argv $2_dim0 } Basically any variable that was available in normal typemaps is available for either argument by prefacing the variable name by '$n_' where n is the argument position. Notes: (1) Multi-valued typemaps can only be applied to a single object in the target scripting language. For example, you can split a string into a (char *, int) pair or split a list into a (int, char []) pair. It is not possible to map multiple objects to multiple arguments. (2) To maintain compatibility with older SWIG versions, the variables such as $target and $type are preserved and are mapped onto the first argument only. (3) This should not affect compatibility with older code. Multi-valued typemaps are an extension to typemap handling. Single valued typemaps can be specified in the usual way. The old $source and $target variables are officially deprecated. Input variables are referenced through $arg$ and output values are reference through $result$. *** NEW FEATURE *** 10/16/2001:beazley Added parsing support for multivalued typemaps. The syntax is a little funky, but here goes: // Define a multivalued typemap %typemap(in) (int argc, char *argv[]) { ... typemap code ... } // Multivalued typemap with locals %typemap(in) (int argc, char *argv[])(int temp) { ... typemap code ... } // Copy a multivalued typemap %typemap(in) (int argcount, char **argv) = (int argc, char *argv[]); // Apply a multivalued typemap %apply (int argc, char *argv[]) { (int argcount, char **argv) }; Note: this extra parsing support is added for future extension. No language modules currently support multi-valued typemaps. 10/11/2001:beazley Modified the typemap matching code to discard qualifiers when checking for a match. For example, if you have a declaration like this: void blah(const char *x); The typemap checker checks for a match in the following order: const char *x const char * char *x char * If typedef's are involved, qualifier stripping occurs before typedef resolution. So if you had this, typedef char *string; void blah(const string x); typemap checking would be as follows: const string x const string string x string const char *x const char * char *x char * The primary reason for this change is to simplify the implementation of language modules. Without qualifier stripping, one has to write seperate typemaps for all variations of const and volatile (which is a pain). *** POTENTIAL INCOMPATIBILITY *** Typemaps might be applied in places where they weren't before. 10/9/2001: beazley SWIG now generates wrappers that properly disambiguate overloaded methods that only vary in constness. For example: class Foo { ... void blah(); void blah() const; ... }; To handle this, the %rename directive can be used normally. %rename(blah_const) blah() const; In the resulting wrapper code, method calls like this are now generated: (obj)->blah() // Non-const version ((Foo const *)obj)->blah() // const version This should force the right method to be invoked. Admittedly, this is probably obscure, but we might as well get it right. 10/8/2001: beazley The preprocessor now ignores '\r' in the input. This should fix the following bug: [ #468416 ] SWIG thinks macro defs are declarations? 10/8/2001: beazley Added support for ||, &&, and ! in constants. This fixes SF [ #468988 ] Logical ops break preprocessor. However, at this time, constants using these operators are not supported (the parser will issue a warning). 10/4/2001: beazley Added -show_templates command line option. This makes SWIG display the code it actually parses to generate template wrappers. Mostly useful for debugging. *** NEW FEATURE *** 10/4/2001: beazley Change to semantics of %template directive. When using %template, the template arguments are handled as types by default. For example: %template(vecint) vector; %template(vecdouble) vector; To specify a template argument that is *not* a type, you need to use default-value syntax. For example: %template(vecint) vector; %template(vecdouble) vector; In this case, the type name doesn't really matter--only the default value (e.g., 50, 100) is used during expansion. This differs from normal C++, but I couldn't figure out a better way to do it in the parser. Might implement an alternative later. *** POTENTIAL INCOMPATIBILITY *** 10/4/2001: beazley Major changes to template handling in order to provide better integration with the C++ type-system. The main problem is as follows: Suppose you have a template like this: template void blah(const T x) { stuff }; Now suppose, that you instantiate the template on a type like this in SWIG: %template(blahint) blah; In C++, this is *supposed* to generate code like this: void blah(int *const x) { stuff }; However, in SWIG-1.3.9, the template substitution gets it wrong and produces void blah(const int *x) { stuff }; (notice the bad placement of the 'const' qualifier). To fix this, the SWIG parser now generates implicit typedefs for template type arguments that produces code roughly equivalent to doing this: typedef int *__swigtmpl1; %template(blahint) blah<__swigtmpl1>; which generates code like this: void blah(const __swigtmpl1 x) { stuff }; Since this is correct in both C++ and SWIG, it provides the right semantics and allows everything to compile properly. However, to clean up the generated code a little bit, the parser keeps track of the template types and performs back-substitution to the original type when building the parse tree. Thus, even though the implicit typedef is used in the input and may appear in the generated wrapper file (for proper compilation), the parse tree will hide a lot of these details. For example: void blah(const __swigtmpl1 x) { stuff }; will look like it was declared as follows (which is what you want): void blah(int *const x) { stuff } The only place you are likely to notice the typedef hack is in bodies of template functions. For example, if you did this, template class blah { ... %addmethods { void spam() { T tempvalue; ... } } } you will find that 'T tempvalue' got expanded into some strange typedef type. This *still* compiles correctly so it's not a big deal (other than looking kind of ugly in the wrapper file). 10/4/2001: beazley Fixed some inheritance problems in Tcl Object interface. 10/1/2001: beazley Tcl module has changed to use byte-backed pointer strings. This implementation should be safe on 64-bit platforms. However, the order in which digits appear in pointer values no longer directly corresponds to the actual numerical value of a pointer (on little-endian machines, pairs of digits appear in reverse order). 10/1/2001: beazley Perl5 module is now driven by a configuration file 'perl5.swg' in the SWIG library. 10/1/2001: beazley The perl5 module no longer tries to apply the "out" typemap in code generated for magic variables. I'm surprised that this ever worked at all (since all of the code that was there was wrong anyways). Use the "varout" typemap to handle global variables. 10/1/2001: beazley Fixed a bug related to character array members of structures. For example: struct Foo { char name[32]; }; SWIG is normally supposed to return a string, but this was broken in 1.3.9. The reason it was broken was actually due to a subtle new feature of typemaps. When a data member is set to an array like this, the return type of the related accessor function is actually set to an array. This means that you can now write typemaps like this: %typemap(python,out) char [ANY] { $target = PyString_FromStringAndSize($source,$dim0); } This functionality can be used to replace the defunct memberout typemap in a more elegant manner. 9/29/2001: beazley Some further refinement of qualified C++ member functions. For example: class Foo { ... void foo() const; ... }; (i) The SWIG parser was extended slightly to allow 'volatile' and combinations of 'const' and 'volatile' to be used. This is probably rare, but technically legal. Only added for completeness. (ii) For the purposes of overloading, qualified and non-qualified functions are different. Thus, when a class has methods like this: void foo(); void foo() const; Two distinct methods are declared. To deal with this, %rename and similar directives have been extended to recognize const. Thus, one can disambiguate the two functions like this: %rename(fooconst) Foo::foo() const; or simply ignore the const variant like this: %ignore Foo::foo() const; Note: SWIG currently has no way to actually invoke the const member since the 'const' is discarded when generating wrappers for objects. 9/27/2001: beazley New directive. %namewarn can be used to issue warning messages for certain declaration names. The name matching is the same as for the %rename directive. The intent of this directive is to issue warnings for possible namespace conflicts. For example: %namewarn("print is a python keyword") print; The name matching algorithm is performed after a name has been resolved using %rename. Therefore, a declaration like this will not generate a warning: %rename("Print") print; ... void print(); /* No warning generated */ Since the warning mechanism follows %rename semantics, it is also to issue warnings for specific classes or just for certain member function names. (Dave - I've been thinking about adding something like this for quite some time. Just never got around to it) *** NEW FEATURE *** 9/27/2001: beazley Enhanced the %ignore directive so that warning messages can be issued to users. This is done using %ignorewarn like this: %ignorewarn("operator new ignored") operator new; The names and semantics of %ignorewarn is exactly the same as %ignore. The primary purpose of this directive is for module writers who want to ignore certain types of declarations, but who also want to alert users about it. A user might also use this for debugging (since messages will appear whenever an ignored declaration appears). *** NEW FEATURE *** 9/26/2001: beazley Super-experimental support for overloaded operators. This implementation consists of a few different parts. (i) Operator names such as 'operator+' are now allowed as valid declarator names. Thus the 'operator' syntax can appear *anyplace* a normal declarator name was used before. On the surface, this means that operators can be parsed just like normal functions and methods. However, it also means that operator names can be used in many other SWIG directives like %rename. For example: %rename(__add__) Complex::operator+(const Complex &); (ii) Operators are wrapped *exactly* like normal functions and methods. Internally, the operator name is used directly meaning that the wrapper code might contain statements like this: arg0->operator*((Complex const &)*arg1); This all seems to parse and compile correctly (at least on my machine). (iii) SWIG will no longer wrap a declaration if its symbol table name contains illegal identifier characters. If illegal characters are detected, you will see an error like this: Warning. Can't wrap operator* unless renamed to a valid identifier. The only way to fix this is to use %rename or %name to bind the operator to a nice name like "add" or something. Note: the legal identifier characters are determined by the target language. There are certain issues with friend functions and operators. Sometimes, friends are used to define mixed operators such as adding a Complex and a double together. Currently, SWIG ignores all friend declarations in a class. A global operator declaration can probably be made to work, but you'll have to rename it and it probably won't work very cleanly in the target language since it's not a class member. SWIG doesn't know how to handle operator specifications sometimes used for automatic type conversion. For example: class String { ... operator const char*(); ... }; (this doesn't parse correctly and generates a syntax error). Also: operators no longer show up as separate parse-tree nodes (instead they are normal 'cdecl' nodes). I may separate them as a special case later. See Examples/python/operator for an example. *** SUPER-EXPERIMENTAL NEW FEATURE *** Version 1.3.9 (September 25, 2001) ================================== 9/25/2001: beazley Fixed parsing problem with type declarations like 'char ** const'. SWIG parsed this correctly, but the internal type was represented incorrectly (the pointers and qualifiers were in the wrong order). 9/25/2001: beazley Withdrew experimental feature (noted below) that was causing serious parsing problems. Version 1.3.8 (September 23, 2001) ================================== 9/23/2001: beazley Included improved distutils setup.py file in the Tools directory (look for the setup.py.tmpl file). Contributed by Tony Seward. 9/23/2001: beazley Included two new RPM spec files in the Tools directory. Contributed by Tony Seward and Uwe Steinmann. 9/21/2001: beazley Fixed SF Bug [ #463635 ] Perl5.swg does not compile in Visual C++ 9/21/2001: beazley Two new directives control the creation of default constructors and destructors: %nodefault %makedefault These replace %pragma nodefault and %pragma makedefault. (old code will still work, but documentation will only describe the new directives). 9/21/2001: beazley Fixed SF Bug [ #462354 ] %import broken in 1.3.7. 9/20/2001: beazley Parser modified to ignore out-of-class constructor and destructor declarations. For example: inline Foo::Foo() : Bar("foo") { } inline Foo::~Foo() { } Suggested by Jason Stewart. *** EXPERIMENTAL FEATURE *** 9/20/2001: beazley Modified the parser to ignore forward template class declarations. For example: template class MapIter; Suggested by an email example from Irina Kotlova. 9/20/2001: beazley Fixed problem with undeclared tcl_result variable in the "out" typemap for Tcl. Reported by Shaun Lowry. 9/20/2001: beazley Incorporated changes to make SWIG work with ActivePerl. Contributed by Joel Reed. 9/20/2001: beazley Slight change to the parsing of C++ constructor initializers. For example: class Foo : public Bar { public: Foo() : Bar(...) {...} }; SWIG now discards the contents of the (...) regardless of what might enclosed (even if syntactically wrong). SWIG doesn't need this information and there is no reason to needless add syntax rules to handle all of the possibilities here. 9/20/2001: beazley Change to typemaps for structure members. If you have a structure like this: struct Vector { int *bar; }; The member name 'bar' is now used in any accessor functions. This allows the "in" typemap to be used when setting the value. For example, this typemap %typemap(python,in) int *bar { ... } now matches Vector::bar. It should be noted that this will also match any function with an argument of "int *bar" (so you should be careful). *** NEW FEATURE. POTENTIAL INCOMPATIBILITY *** 9/20/2001: beazley Fixed SF bug #462642 setting string values in structures 9/20/2001: beazley Fixed SF bug #462398 problem with nested templates. 9/20/2001: beazley Fixed SF bug #461626 problem with formatting and C++ comments. 9/20/2001: beazley Fixed SF bug #462845 Wrong ownership of returned objects. 9/19/2001: beazley Fixed SF bug #459367. Default constructors for classes with pure virtual methods. 9/19/2001: beazley Fixed problem with default arguments and class scope. For example: class Foo { public: enum bar { FOO, BAR }; void blah(bar b = FOO); ... } SWIG now correctly generates a default value of "Foo::FOO" for the blah() method above. This used to work in 1.1, but was broken in 1.3.7. Bug reported by Mike Romberg. Version 1.3.7 (September 3, 2001) ================================== 9/02/2001: beazley Added special %ignore directive to ignore declarations. This feature works exactly like %rename. For example: %ignore foo; // Ignore all declarations foo %ignore ::foo; // Only ignore foo in global scope %ignore Spam::foo; // Only ignore in class Spam %ignore *::foo; // Ignore in all classes %ignore can also be parameterized. For example: %ignore foo(int); %ignore ::foo(int); %ignore Spam::foo(int); %ignore *::foo(int); *** NEW FEATURE *** 9/02/2001: cheetah (william fulton) [Java] shadowcode pragma modified so that the code that is output in the shadow file is placed relative to where it is placed in the c/c++ code. This allows support for JavaDoc function comments. 9/01/2001: beazley Fixed SF Patch [ #447791 ] Fix for python -interface option. Submitted by Tarn Weisner Burton. 9/01/2001: beazley SWIG no longer generates default constructors/destructors for a class if it only defines a private/protected constructor or destructor or if any one of its base classes only has private constructors/destructors. This was reported in SF Patch [ #444281 ] nonpublic/default/inhereted ctor/dtor by Marcelo Matus. 9/01/2001: beazley Added patch to Perl5 module that allows constants to be wrapped as constants that don't require the leading $. This feature is enabled using the -const option. Patch contributed by Rich Wales. *** NEW FEATURE *** 8/31/2001: beazley Added parsing support for the 'volatile' type qualifier. volatile doesn't mean anything to SWIG, but it is needed to properly generate prototypes for declarations that use it. It's also been added to make the SWIG type system more complete. *** NEW FEATURE *** 8/30/2001: beazley Added support for parameterized %rename directive. *** This new feature can be used to greatly simplify the task of resolving overloaded methods and functions. *** In prior versions of SWIG, the %rename directive was used to consistently apply an identifier renaming. For example, if you said this: %rename foo bar; Every occurrence of 'foo' would be renamed to 'bar'. Although this works fine for resolving a conflict with a target language reserved word, it is useless for for dealing with overloaded methods. This is because all methods are simply renamed to the same thing (generating the same conflict as before). Therefore, the only way to deal with overloaded methods was to go through and individually rename them all using %name. For example: class Foo { public: virtual void bar(void); %name(bar_i) virtual void bar(int); ... }; To make matters worse, you had to do this for all derived classes too. class Spam : public Foo { public: virtual void bar(void); %name(bar_i) virtual void bar(int); ... }; Needless to say, this makes it extremely hard to resolve overloading without a lot of work and makes it almost impossible to use SWIG on raw C++ .h files. To fix this, %rename now accepts parameter declarators. The syntax has also been changed slightly. For example, the following declaration renames all occurrences of 'bar(int)' to 'bar_i', leaving any other occurrence of 'bar' alone. %rename(bar_i) bar(int); Using this feature, you can now selectively rename certain declarations in advance. For example: %rename(bar_i) bar(int); %rename(bar_d) bar(double); // Include raw C++ header %include "header.h" When %rename is used in this manner, all occurrence of bar(int) are renamed wherever they might occur. More control is obtained through explicit qualification. For example, %rename(bar_i) ::bar(int); only applies the renaming if bar(int) is defined in the global scope. The declaration, %rename(bar_i) Foo::bar(int); applies the renaming if bar(int) is defined in a class Foo. This latter form also supports inheritance. Therefore, if you had a class like this: class Spam : public Foo { public: void bar(int); } The Spam::bar(int) method would also be renamed (since Spam is a subclass of Foo). This latter feature makes it easy for SWIG to apply a consistent renaming across an entire class hierarchy simply by specifying renaming rules for the base class. A class wildcard of * can be used if you want to renaming all matching members of all classes. For example: %rename(bar_i) *::bar(int); will rename all members bar(int) that are defined in classes. It will not renamed definitions of bar(int) in the global scope. The old use of %rename is still supported, but is somewhat enhanced. %rename(foo) bar; // Renames all occurrences of 'bar'. %rename(foo) ::bar; // Rename all 'bar' in global scope only. %rename(foo) *::bar; // Rename all 'bar' in classes only. %rename(foo) Foo::bar; // Rename all 'bar' defined in class Foo. *** NEW FEATURE *** 8/30/2001: beazley Added support for data-member to member-function transformation. For example, suppose you had a structure like this: struct Vector { double x,y; }; Now suppose that you wanted to access x and y through a member function interface instead of the usual SWIG behavior. For example: f.set_x(3.4) # instead of f.x = 3.4 x = f.get_x() # instead of x = f.x To do this, simply use the new %attributefunc directive. For example: %attributefunc(get_%s,set_%s) struct Vector { double x,y; }; %noattributefunc The arguments to %attributefunc are C-style printf format strings that determine the naming convention to use. %s is replaced with the actual name of the data member. SWIG provides a number of printf extensions that might help. For example, if you wanted to title case all of the attributes, you could do this: %attributefunc(get%(title)s,set%(title)s); This will turn an attribute 'bar' to 'getBar()' and 'setBar()'. (someone requested this long ago, but I finally figured how to implement it in a straightforward manner). *** EXPERIMENTAL NEW FEATURE *** 8/30/2001: beazley SWIG now automatically generates default constructors and destructors if none are defined. This used to be enabled with a command line switch -make_default, but most people want these functions anyways. To turn off this behavior use the -no_default option or include the following pragma in the interface file: %pragma no_default; This may break certain interfaces that defined their own constructors/destructors using the same naming convention as SWIG. If so, you will get duplicate symbols when compiling the SWIG wrapper file. *** POTENTIAL INCOMPATIBILITY *** 8/29/2001: beazley Changes to Perl5 shadow class code generation. Iterators are no longer supported (FIRSTKEY, NEXTKEY). Also, attribute access has been changed to rely on inheritance in order to provide better behavior across modules. 8/28/2001: beazley Various obscure improvements to the type system and classes. Strange declarations like this are now wrapped correctly (i.e., the generated wrapper code doesn't cause the C++ compiler to die with a type error). class Foo { public: typedef double Real; Real foo(Real (*op)(Real,Real), Real x, Real y); }; Inheritance of types is also handled correctly. 8/28/2001: beazley Changes to class wrappers. When SWIG sees two classes like this, class X { public: void foo(); ... } class Y : public X { public: void bar(); ... } it now only generates two wrapper functions: X_foo(X *x) { x->foo(); } Y_bar(Y *y) { y->bar(); } Unlike SWIG1.15, the foo() method does *not* propagate to a wrapper function Y_foo(). Instead, the base class method X_foo() must be used. This change should not affect modules that use shadow classes, but it might break modules that directly use the low-level C wrappers. This change is being made for a number of reasons: - It greatly simplifies the implementation of SWIG--especially with anticipated future changes such as overloaded methods. - It results in substantially less wrapper code--especially for big C++ class hierarchies (inherited declarations are no longer copied into every single derived class). - It allows for better code generation across multiple SWIG generated modules (code isn't replicated in every single module). *** POTENTIAL INCOMPATIBILITY *** 8/22/2001: cheetah (william fulton) Provided some Windows documentation in the Win directory and some Visual C++ project files for running examples on Windows. 8/28/2001: mkoeppe [Guile] Handle renamed overloaded functions properly; thanks to Marc Zonzon for the patch. See the new test case name_cxx. 8/27/2001: mkoeppe [Tcl] Removed lots of warnings issued by the Sun Forte compilers, which were caused by mixing function pointers of different linkages (C++/C). 8/23/2001: mkoeppe Improved the MzScheme module by porting Guile's pointer type checking system and making type dispatch typemap-driven. 8/22/2001: beazley Entirely new symbol table processing. SWIG should be able to report much better error messages for multiple declarations. Also, the new symbol table allows for overloaded functions (although overloading isn't quite supported in the language modules yet). 8/22/2001: cheetah (william fulton) * [Java] %new support added. * [Java] Package JNI name refixed! 8/19/2001: beazley Python module modified to support pointers to C++ members. This is an experimental feature. *** NEW FEATURE *** 8/19/2001: beazley Added limited parsing and full type-system support for pointers to members. None of SWIG's language modules really know how to deal with this so this is really only provided for completeness and future expansion. Note: SWIG does not support pointers to members which are themselves pointers to members, references to pointers to members, or other complicated declarations like this. *** NEW FEATURE *** 8/19/2001: beazley SWIG is much better at parsing certain C++ declarations. Operators and friends generally don't cause anymore syntax errors. However, neither are really supported. 8/18/2001: beazley Added *highly* experimental support for wrapping of C++ template declarations. Since C++ templates are essentially glorified macros and SWIG has a fully operational C preprocessor with macro support, the parser now converts template declarations to macros. For example, a function template like this template T max(T a, T b); is internally converted into a macro like this: %define %_template_max(__name,T) %name(__name) T max(T a, T b); %enddef To instantiate a version of the template, a special %template declaration is used like this: %template(maxint) max; %template(maxdouble) max; The parameter to the %template directive must be proper C identifier that's used to uniquely name the resulting instantiation. When used, the the expanded macro looks like this: %name(maxint) int max(int a, int b); %name(maxdouble) double max(double a, double b); A similar technique is used for template classes. For instance: template class vector { T *data; int sz; public: vector(int nitems); T *get(int n); ... }; Gets converted into a macro like this: %define %_template_vector(__name, T) %{ typedef vector __name; %} class __name { T *data; int sz; public: __name(int nitems); T *get(int n); ... }; typedef __name vector; %enddef An a specific instantiation is created in exactly the same way: %template(intvec) vector; The resulting code parsed by SWIG is then: %{ typedef vector intvec; %} class intvec { int *data; int sz; public: intvec(int nitems); int *get(int n); ... }; typedef intvec vector; Note: the last typedef is non-standard C and is used by SWIG to provide an association between the name "intvec" and the template type "vector". CAUTION: This is an experimental feature and the first time SWIG has supported C++ templates. Error reporting is essential non-existent. It will probably break in certain cases. *** EXPERIMENTAL NEW FEATURE **** 8/15/2001: beazley Change to wrapping of multi-dimensional arrays. Arrays are now properly mapped to a pointer to an array of one less dimension. For example: int [10]; --> int * int [10][20]; --> int (*)[20]; int [10][20][30]; --> int (*)[20][30]; This change may break certain SWIG extensions because older versions simply mapped all arrays into a single pointer such as "int *". Although possibly unusual, the new version is correct in terms of the C type system. *** POTENTIAL INCOMPATIBILITY *** 8/06/2001: cheetah (william fulton) * [Java] Array setters generated for struct/class array members. 8/13/2001: beazley Many improvements to Tcl/Perl/Python modules to better work with multiple interface files and the %import directive. 8/13/2001: beazley Fixed up the behavior of %import in the Python module. SWIG no longer pollutes the module namespace by using 'from module import *' to refer to the other module. Instead, it does a proper 'import module'. Also, SWIG may work a lot better when importing modules that include references to other imported modules. 8/13/2001: mkoeppe Added new typemap substitutions, generalizing those of the Guile-specific 5/27/2001 changes: * $descriptor is the same as SWIGTYPE$mangle, but also ensures that the type descriptor of this name gets defined. * $*type, $*ltype, $*mangle, $*descriptor are the same as the variants without star, but they REMOVE one level of pointers from the type. (This is only valid for pointer types.) * $&type, $<ype, $&mangle, $&descriptor are the same as the variants without ampersand, but they ADD one level of pointers to the type. The Guile-specific substitution $basedescriptor was removed because it was useless. 8/12/2001: beazley The %extern directive is now deprecated and withdrawn. The purpose of this directive was to import selected definitions from other interface files and headers. However, the same functionality is better handled through %import. This leaves SWIG with two file inclusion directives: %include filename - Inserts into current interface %import filename - Import types and classes from another module *** POTENTIAL INCOMPATIBILITY *** 8/09/2001: beazley Added new support for wrapping C/C++ callback functions. A common problem with some C libraries is that many functions take a function pointer as an argument. For example: int do_op(..., int (*op)(int,int), ...); Unfortunately, the only way to call such a function is to pass it a function pointer of some compatible type. In previous versions of SWIG, you had to solve this problem with some really gross hacks. For example, if you wanted to use the following function as a callback, int foo(int, int); you had to install a pointer to it as a constant. For example: %constant int (*FOO)(int,int) = foo; or const int (*FOO)(int,int) = foo; or if you had a really old SWIG version: typedef int (*OP_FUNC)(int,int); int do_op(..., OP_FUNC, ...); const OP_FUNC FOO = foo; Now, you can do one of two things: %constant int foo(int,int); This creates a constant 'foo' of type int (*)(int,int). Alternatively, you can do this: %callback("%s"); int foo(int,int); int bar(int,int); %nocallback; In this case, the functions are installed as constants where the name is defined by the format string given to %callback(). If the names generated by the format string differ from the actual function name, both a function wrapper and a callback constant are created. For example: %callback("%(upper)s"); int foo(int,int); int bar(int,int); %nocallback; Creates two wrapper functions 'foo', 'bar' and additionally creates two callback constants 'FOO', 'BAR'. Note: SWIG still does not provide automatic support for writing callback functions in the target language. *** NEW FEATURE *** 8/06/2001: cheetah (william fulton) * struct nesting fixes as per SF bug #447488. 8/03/2001: beazley The %name directive now applies to constants created with #define and %constant. However, most language modules were never written to support this and will have to be modified to make it work. Tcl, Python, and Perl modules are working now. *** NEW FEATURE *** 8/03/2001: beazley Massive changes and simplification of C declaration parsing. Although SWIG is still not a full C parser, its ability to handle complex datatypes including pointers to functions and pointers to arrays has been vastly improved. 8/03/2001: cheetah (william fulton) * Distribution fixes: autoconf no longer needed to install SWIG. 8/02/2001: beazley Removed two undocumented parsing features. SWIG no longer supports out-of-class static function or variable declarations. For example: static int Foo::bar; This feature may return if there is sufficient demand. However, since SWIG is most often used with header files, it is more likely for these definitions to be included in the class definition. *** POTENTIAL INCOMPATIBILITY *** 8/02/2001: cheetah (william fulton) * Cleanup of the GIFPlot examples. Upgraded Java GIFPlot example. 8/01/2001: cheetah (william fulton) * [Java] Efficiency changes: _cPtr used where possible rather than getCPtr(). Bug fixes for inheritance - derived class sometimes didn't delete the c memory when _delete() was called. * [Java] Abstract c++ classes are wrapped with a java abstract shadow class. Also a pure virtual function is mapped with an abstract method. * The default output file has always been _wrap.c. It is now _wrap.cxx if the -c++ commandline option is passed to swig. This has been done as otherwise c++ code would appear in a c file. *** POTENTIAL INCOMPATIBILITY *** 7/31/2001: beazley Modified the %constant directive to be more C-like in syntax. The syntax is now: %constant NAME = VALUE; %constant TYPE NAME = VALUE; For example: %constant Foo *Bar = &Spam; A more subtle case is as follows: %constant int (*FOO)(int,int) = blah; *** POTENTIAL INCOMPATIBILITY *** Modules that were using the %constant directive directly will need to be modified. 7/30/2001: beazley Removed obscure and undocumented form of the %inline directive: %inline int blah(int a, int b) { ... } *** POTENTIAL INCOMPATIBILITY *** (note: this feature was never documented and is withdrawn) 7/30/2001: beazley Removed support for functions with no explicitly declared return type. For example: foo(int); In C, such functions were implicitly assumed to return an 'int'. In C++, this is illegal. Either way, it's considered bad style. Removing support for this in SWIG will simplify certain issues in parsing. *** POTENTIAL INCOMPATIBILITY *** 7/30/2001: mkoeppe * Partial merge from the CVS trunk. The Source/DOH directory and most of the Source/Swig directory is up-to-date now. * [Guile] %scheme is now a macro for %insert("scheme"). New syntax: %scheme "FILENAME"; New syntax: %scheme %{ SCHEME-CODE %} New macros %multiple_values, %values_as_list, %values_as_vector. 7/29/2001: beazley %readonly and %readwrite have been turned into SWIG pragmas. %pragma(swig) readonly and %pragma(swig) readwrite. Macros are used to provide backwards compatibility. 7/29/2001: beazley Minor changes to %pragma directive. %pragma must always be directed to a specific language. For example: %pragma(swig) make_default; %pragma(perl5) include = "blah.i"; Also extended the pragma directive to allow code blocks %pragma(foo) code = %{ ... some code ... %} *** POTENTIAL INCOMPATIBILITY *** 7/29/2001: beazley Change to the way 'const' variables are wrapped. In previous versions of SWIG, a 'const' variable was wrapped as a constant. Now, 'const' variables are wrapped as read-only variables. There are several reasons for making this change, mostly pertaining to subtle details of how 'const' actually works. This will probably break old interfaces that used 'const' to create constants. As a replacement, consider using this: const int a = 4; ===> %constant int a = 4; *** POTENTIAL INCOMPATIBILITY *** 7/29/2001: beazley Reorganization and simplification of type parsing. Types with 'const' should work correctly now. 7/29/2001: beazley Most swig directives related to the documentation system are now deprecated. 7/29/2001: beazley Removed support for Objective-C in order to simplify parser reconstruction. Will return if there is sufficient demand. *** POTENTIAL INCOMPATIBILITY *** 7/29/2001: beazley Code inclusion has been modified in the parser. A common directive %insert is now used for everything. This inserts a file into the output: %insert(header) "foo.swg" This inserts some inline code into the output %insert(header) %{ ... some code ... %} There are five predefined targets for the insert directive: "header" - Header section of wrapper file "runtime" - Runtime section of wrapper file "wrapper" - Wrapper section "init" - Initialization function "null" - Nothing. Discard. The following directives are still supported, but are now defined in terms of macros: %{ ... %} -> %insert(header) %{ ... %} %init %{ ... %} -> %insert(init) %{ ... %} %wrapper %{ ... %} -> %insert(wrapper) %{ ... %} %runtime %{ ... %} -> %insert(runtime) %{ ... %} Language modules can define new named targets by using the C API function Swig_register_filebyname() (see main.cxx). For example, if you wanted to expose a shadow class file, you could do this: Swig_register_filebyname("shadow", f_shadow); Then in the interface file: %insert(shadow) %{ ... %} Note: this change should not affect any old interfaces, but does open up new possibilities for enhancements. 7/29/2001: beazley SWIG now always includes a standard library file 'swig.swg'. This file defines a large number of macro definitions that define the behavior of various SWIG directives. Previously, all SWIG directives were handled as special cases in the parser. This made the parser a large bloated mess. Now, the parser is stripped down to a few simple directives and macros are used to handle everything else. 7/26/2001: cheetah (william fulton) * Fixes for Sourceforge bug #444748 - new testcase cpp_static: [TCL] Class with just static member variable/function fix [Java] Fixed static variables support [Ruby] Static variables workaround removed 7/27/2001: mkoeppe * stype.c (SwigType_default): Strip qualifiers first. The default type of "int * const" is now "SWIGPOINTER *". * main.cxx: Define "__cplusplus" in SWIG's preprocessor if in C++ mode. * [Guile]: Added some support for arrays and C++ references, fixing the "constant_pointers" test case. * Moved most tests from the old Guile-specific test-suite to the new test-suite. Also moved perl5/pointer-cxx example there. 7/26/2001: cheetah (william fulton) * Test-suite added. * Initial testcases: constant_pointers cpp_enum defines sizeof_pointers unions virtual_destructor * Make clean improvements. 7/24/2001: cheetah (william fulton) * [Java] Underscores in the package name and/or module name no longer give linking problems. 7/17/2001: cheetah (william fulton) * More parser bug fixes for constant pointers 7/19/2001: mkoeppe * [Guile] Aesthetic improvement in variable wrappers. 7/18/2001: beazley * Fixed core-dump problem in pointer library when freeing character arrays. SF Bug [ #415837 ] pointer lib core dump 7/18/2001: beazley * Fixed problem with default destructors and shadow classes. SF bug #221128. 7/18/2001: beazley * To provide better line-number tracking in interfaces with lots of macros, special locator comments are now generated by the SWIG preprocessor. For example: /*@foo.i,42,BLAH@*/expanded macro/*@@*/ The first /*@...@*/ sequence sets the context to point to the macro code. The /*@@*/ comment terminates the context. The SWIG parser should ignore all of the locator comments as should the C compiler (should such comments end up in generated wrapper code). 7/18/2001: mkoeppe * The parser now handles severely constified types in typemaps. This introduced a new shift/reduce conflict, but only with a heuristic function-pointer catch-all rule. * [Guile]: Added typemaps for severely constified types. * Fixed the "template-whitespace" problem by canonicalizing whitespace, especially around angle brackets and commas. 7/17/2001: mkoeppe * [Guile]: A Scheme file is emitted if the -scmstub FILE.SCM command-line option is used. The %scheme directive (implemented as a macro for a pragma) allows to insert arbitrary code here. In "simple" and "passive" linkage, the file gets filled with define-module and export declarations. 7/17/2001: cheetah (william fulton) * Parser bug fix to support constant pointers, eg int* const ptr. Fixed everywhere - variables, parameters, return types etc. Note that when wrapping a constant pointer variable only the getter is generated. 7/17/2001: mkoeppe * Fixed SF bug #441470 (#define X "//" would not be parsed, see test-suite entry "preproc-1"), reported by T. W. Burton . * Changed the type of character constants to "char", rather than "char *". Changed the individual language modules to keep the old behaviour, except for the Guile module, where it is desired to make them Scheme characters. This fixes SF bug #231409, test-suite entry "char-constant". * Applied patch for DOH/Doh/memory.c by Les Schaffer (avoid required side effects in assert). 7/17/2001: cheetah (william fulton) * Bug fix in parser for virtual destructor with void as parameter * Bug fix in parser #defines embedded within classes/structs/unions Consequently %constant can now also be placed within a struct/class/union. * Bug fix in parser to allow sizeof(*I_am_a_pointer) within a #define 7/16/2001: mkoeppe * Added changes for the Macintosh contributed by Luigi Ballabio . * Some "const" fixes in the code. * [Guile]: Made the constant-wrapper functions much shorter. 7/13/2001: mkoeppe * [Guile]: Some "const" fixes for Guile version 1.3.4. * Handle anonymous arguments with default values and static array members of classes. Both bugs reported by Annalisa Terracina ; see the files Examples/guile/test-suite/static-array-member.i and anonymous-arg.i. Version 1.3.6 (July 9, 2001) ============================= 7/09/2001: cheetah (william fulton) * GIFPlot examples: FOREGROUND and BACKGROUND definition missing after TRANSPARENT #define fix in GIFPlot 7/03/2001: beazley Fixed up the version numbers so that the release is known as 1.3.6. All future releases should have a similar version format. 7/02/2001: mkoeppe * [Python]: Prevent the problem of self.thisown not being defined if the C++ class constructor raised an exception. Thanks to Luigi Ballabio . 6/29/2001: mkoeppe * More portability fixes; fixed "gcc -Wall" warnings. 6/29/2001: cheetah (william fulton) * GIFPlot examples: TRANSPARENT #define multiple times on Solaris (clashes with stream.h). * Multiple definition bug fix for shadow classes. The perl and python modules had workarounds which have been replaced with fixes in the core. Many of the Language::cpp_xxxx functions now set a flag which the derived classes can access through is_multiple_definition() to see whether or not code should be generated. The code below would have produced varying degrees of incorrect shadow class code for the various modules: class TestClass { public: TestClass() {} TestClass(int a) {} ~TestClass() {} unsigned long xyz(short k) {} unsigned long xyz(int n) {} static void static_func() {} static void static_func(int a) {} }; void delete_TestClass(int a); 6/27/2001: mkoeppe * [Perl] Another const-related portability fix. 6/26/2001: cheetah (william fulton) * [Java] Added in cpp_pragma() support with a host of new pragmas - see jswig.html. These are designed for better mixing of Java and c++. It enables the user to specify pure Java classes as bases and/or interfaces for the wrapped c/c++. * [Java] Old pragmas renamed. Warning given for the moment if used. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 6/25/2001: mkoeppe * Incorporated more build changes contributed by Wyss Clemens for swig/ruby on cygwin. 6/20/2001: cheetah (william fulton) * Makefile mods so that 'make check' uses the swig options in the makefiles * [Java] Removed Generating wrappers message * [Java] NULL pointer bug fix * [Java] Bug fix for Kaffe JVM 6/20/2001: mkoeppe * SWIG_TypeQuery from common.swg now returns a swig_type_info* rather than a void*. This fixes a problem when using pointer.i and C++, as illustrated by the new test-suite example perl5/pointer-cxx. * Portability fixes (const char *). * Incorporated build changes contributed by Wyss Clemens , which make swig runnable on cygwin. 6/19/2001: cheetah (william fulton) * [Java] Bug fix for SF bug #211144. This fix is a workaround until fixed in the core. 6/19/2001: mkoeppe * [Guile]: Portability fixes for use with the Sun Forte compilers. * [Tcl]: Portability fix (const char *). * [Tcl]: Configure now first tries to find a tclConfig.sh file in order to find the Tcl include directory, library location and library name. * [Python]: Added a few possible library locations. 6/18/2001: mkoeppe * [Guile]: Don't call scm_c_export if nothing is to be exported. Don't warn on %module if module has been set already (this frequently occurs when %import is used). 6/16/2001: mkoeppe * [Guile]: New "passive" linkage, which is appropriate for multi-module extensions without Guile module magic. 6/15/2001: mkoeppe * [Guile]: Fixed printing of smobs (space and angle were missing). * Properly generate type information for base classes imported with the %import directive. Thanks to Marcelo Matus for the report and the patch; this closes SF bug #231619; see also Examples/guile/test-suite/import*. * [Guile]: Fix casting between class and base class; the runtime type system had it the wrong way around; see Examples/guile/test-suite/casts.i * Make typemaps for SWIGPOINTER * with arg name take precedence over those without arg name, to match normal typemap precedence rules. * Fixed the random-line-numbers problem reported as SF bug #217310; thanks to Michael Scharf . * [Guile]: Handle the %name and %rename directives. * New syntax: %name and %rename now optionally take double quotes around the scripting name. This is to allow scripting names that aren't valid C identifiers. 6/14/2001: beazley Made a minor change to the way files are loaded in order to get file/line number reporting correct in the preprocessor. 6/14/2001: mkoeppe * The parser now understands the (non-standard) "long long" types. It is up to the individual language modules to provide typemaps if needed. Reported by Sam Steingold, SF bug #429176. * The parser now understands arguments like "const int * const i". This fixes SF bug #215649. * Fixed the Guile test-suite. 6/13/2001: mkoeppe Partial merge from the CVS trunk at tag "mkoeppe-merge-1". This covers the following changes: | 01/16/01: ttn | Wrote table of contents for Doc/engineering.html. Added section | on CVS tagging conventions. Added copyright to other docs. | 9/25/00 : beazley | Modified the preprocessor so that macro names can start with a '%'. | This may allow new SWIG "directives" to be defined as macros instead | of having to be hard-coded into the parser. | | *** Also a yet-to-be-documented quoting mechanism with backquotes | *** has been implemented? 6/13/2001: mkoeppe * When configure does not find a language, don't use default paths like /usr/local/include; this only causes build problems. * New directory: Examples/Guile/test-suite, where a few bugs in 1.3a5 are demonstrated. * Handle C++ methods that have both a "const" and a "throw" directive (see Examples/Guile/test-suite/cplusplus-throw.i); thanks to Scott B. Drummonds for the report and the fix. * Handle C++ pointer-reference arguments (like "int *& arg") (see Examples/Guile/test-suite/pointer-reference.i, reported as SF bug #432224). * [Ruby] Fixed typo in rubydec.swg; thanks to Lyle Johnson! * Don't stop testing when one test fails. * [Guile, MzScheme] Don't print "Generating wrappers...". 6/12/2001: mkoeppe [Guile] VECTORLENINPUT and LISTLENINPUT now have separate list length variables. TYPEMAP_POINTER_INPUT_OUTPUT attaches argument documentation involving SCM_TYPE to the standard pointer typemaps. INOUT is now an alias for BOTH. 6/12/2001: cheetah (william fulton) Some Java documentation added. [Java] Fixed bugs in import pragma and shadow pragma. 6/12/2001: mkoeppe Fix declarations of SWIG_define_class (Lib/ruby/rubydec.swg) and SWIG_TypeQuery (Lib/common.swg). Thanks to Lyle Johnson for the patches. 6/11/2001: mkoeppe [Guile] Use long instead of scm_bits_t; this makes the generated wrapper code compatible with Guile 1.3.4 again. Thanks to Masaki Fukushima for pointing this out. 6/11/2001: cheetah (william fulton) The generic INSTALL file from autoconf added. Few changes to README file. 6/11/2001: mkoeppe Fixed typo in Makefile.in; thanks to Greg Troxel . 6/08/2001: cheetah (william fulton) make check works again. Examples/GIFPlot configure generated by top level autoconf now. 6/08/2001: mkoeppe Another build change: The new script autogen.sh runs autoconf in the appropriate directories. The top-level configure also configures in Examples/GIFPlot. 6/07/2001: mkoeppe Made the Makefile work with non-GNU make again. 6/07/2001: cheetah (william fulton) [Java] Class/struct members that are arrays of pointers to classes/structs - Shadow class's get/set accessors now use Java classes instead of longs (pointers). [Java] Shadow classes will now clean up memory if function return type is a class/struct. [Java] New example called reference based on the same example from other modules. 6/06/2001: mkoeppe New configure option --with-release-suffix allows for attaching a suffix to the swig binary and the swig runtime libraries. Minor changes to the build system. "swig -swiglib" works again. If invoked with the new option "-ldflags", SWIG prints a line of linker flags needed to link with the runtime library of the selected language module. 6/06/2001: mkoeppe [Guile] gswig_list_p is an int, not a SCM. This typo caused warnings when compiling with a Guile configured with strict C type checking. In INPUT and BOTH typemaps generated by the SIMPLE_MAP macro, use the SCM_TO_C function to convert from Guile to C (rather than C_TO_SCM). Use scm_intprint to print pointers (rather than sprintf). Allow using "-linkage" instead of "-Linkage". 6/05/2001: cheetah (william fulton) [Java] Mods for using inherited c++ classes from Java [Java] New example called class based on the same example from other modules 6/05/2001: cheetah (william fulton) [Java] destructor (_delete()) was not aware of %name renaming [Java] extends baseclass did not know about %name renaming [Java] extends baseclass did extend even when the baseclass was not known to swig [Java] sometimes enum-declarations occurred before the Java class declaration [Java] unrelated enum initialisations no longer appear in Java class [Java] if module ends in '_' correct JNI names are now produced 6/04/2001: cheetah (william fulton) [Java] Shadow class mods - Modified constructor replaces newInstance(). _delete() now thread safe. getCPtr() replaces _self. _selfClass() removed as now redundant. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** [Java] Not all output java files had SWIG banner. New banner. [Java] Shadow class finalizers are output by default: Command line option -finalize deprecated and replaced with -nofinalize. *** POTENTIAL INCOMPATIBILITY FOR JAVA MODULE *** 6/ 1/2001: mkoeppe [Guile] Cast SCM_CAR() to scm_bits_t before shifting it. This is required for compiling with a Guile configured with strict C type checking. 6/ 1/2001: mkoeppe Added configure option "--with-swiglibdir". 5/31/2001: mkoeppe [Guile] Support multiple parallel lists or vectors in the typemaps provided by list-vector.i. New typemaps file, pointer-in-out.i. 5/25/2001: cheetah (william fulton) [Java] HTML update for examples. 5/28/2001: mkoeppe Minor changes to the build system. Added subdirectory for Debian package control files. 5/28/2001: mkoeppe [Guile] Build a runtime library, libswigguile. 5/28/2001: mkoeppe [Guile] New typemap substitution $*descriptor. Use the {} syntax, rather than the "" syntax for the standard typemaps, in order to work around strange macro-expansion behavior of the SWIG preprocessor. This introduces some extra braces. 5/27/2001: mkoeppe [Guile] Handle pointer types with typemaps, rather than hard-coded. New typemap substitutions $descriptor, $basedescriptor; see documentation. Some clean-up in the variable/constants wrapper generator code. New convenience macro SWIG_Guile_MustGetPtr, which allows getting pointers from smobs in a functional style. New typemap file "list-vector.i", providing macros that define typemaps for converting between C arrays and Scheme lists and vectors. 5/25/2001: cheetah (william fulton) [Java] STL string moved into its own typemap as it is c++ code and it break any c code using the typemaps.i file. - Fixes for wrappers around global variables - applies to primitive types and user types (class/struct) and pointers to these. - Structure member variables and class public member variables getters and setters pass a pointer to the member as was in 1.3a3 and 1.1 (1.3a5 was passing by value) - Parameters that were arrays and return types were incorrectly being passed to create_function() as pointers. - Fix for arrays of enums. [Java] Updated java examples and added two more. [Java] Java module updated from SWIG1.3a3 including code cleanup etc. [Java] enum support added. [Java] Array support implemented [Java] Shadow classes improved - Java objects used rather than longs holding the c pointer to the wrapped structure/c++class 5/22/2001: mkoeppe [Guile] Fixed extern "C" declarations in C++ mode. Thanks to Greg Troxel . 5/21/2001: mkoeppe [Guile] New linkage "module" for creating Guile modules for Guile versions >= 1.5.0. 4/18/2001: mkoeppe [MzScheme] Added typemaps for passing through Scheme_Object pointers. 4/9/2001 : mkoeppe [MzScheme] Added typemaps for `bool'. Inclusion of headers and support routines is now data-driven via mzscheme.i. Headers come from the new file mzschemdec.swg. Don't abort immediately when a type-handling error is reported. When searching for typemaps for enums, fall back to using int, like the Guile backend does. Support char constants. Emit correct wrapper code for variables. 3/12/2001: mkoeppe [Guile] Fixed typemaps for char **OUTPUT, char **BOTH. 3/2/2001 : mkoeppe [Guile] Every wrapper function now gets a boolean variable gswig_list_p which indicates whether multiple values are present. The macros GUILE_APPEND_RESULT, GUILE_MAYBE_VALUES and GUILE_MAYBE_VECTOR use this variable, rather than checking whether the current return value is a list. This allows for typemaps returning a list as a single value (a list was erroneously converted into a vector or a multiple-value object in this case). 3/1/2001 : mkoeppe [Guile] Added support for returning multiple values as vectors, or passing them to a muliple-value continuation. By default, multiple values still get returned as a list. 3/1/2001 : mkoeppe [Guile] Added a "beforereturn" pragma. The value of this pragma is inserted just before every return statement. 3/1/2001 : mkoeppe [Guile] Added support for Guile 1.4.1 procedure documentation formats, see internals.html. 2/26/2001: mkoeppe [Guile] Made the wrapper code compile with C++ if the "-c++" command-line switch is given. Thanks to . 2/26/2001: mkoeppe [Guile] Now two type tables, swig_types and swig_types_initial, are used, as all other SWIG language modules do. This removes the need for the tricky construction used before that the broken Redhat 7.0 gcc doesn't parse. Reported by . 2/26/2001: mkoeppe [Guile] Fixed typemaps for char *OUTPUT, char *BOTH; a bad free() would be emitted. Added typemap for SCM. Version 1.3 Alpha 5 =================== 9/19/00 : beazley [Python] Python module generates more efficient code for creating the return value of a wrapper function. Modification suggested by Jon Travis. 9/19/00 : beazley Library files specified with the -l option are now included at the end of the interface file (reverting to the old behavior). 9/19/00 : beazley Fixed some problems with enum handling. enums are now manipulated as 'int', but cast into the enum type when values are passed to the corresponding C function. 9/19/00 : mkoeppe [Guile] Removed "-with-smobs" command-line option, as this is the default now. Added "-emit-setters" command-line option, which turns on generating procedures-with-setters; see internals.html. 9/18/00 : mkoeppe Incorporated patch #101430, fixing bugs in the Guile module: 1. Some arguments were erroneously taken as *optional* arguments when ignored arguments were present. 2. Guile 1.3.4 was not supported since functions introduced in Guile 1.4 were used. 3. Added handling of `const char *'. 9/17/00 : beazley Fixed problem with failed assertion and large files. 9/17/00 : beazley Fixed problem with the '%' character appearing in added methods and function bodies. Preprocessor bug. Version 1.3 Alpha 4 (September 4, 2000) ======================================= 9/3/00 : ttn Added instructions for maintainers in Examples/README on how to make examples also be useful in the testing framework. Also, "make check" now uses ./Lib by via env var `SWIG_LIB'. This is overridable like so: make chk-swiglib=/my/experimental/swig/Lib check 9/3/00 : beazley Added $typemap variable to typemaps. This gets replaced with a string indicating the typemap that is applied. Feature request from rsalz. 9/3/00 : beazley Experimental optimization to code generation for virtual member functions. If you have two classes like this: class A() { virtual void foo(); } class B() : public A { virtual void foo(); } Swig now will generate a single wrapper function for this A_foo(A *a) { a->foo(); } and use it as the implementation of both A_foo() and B_foo(). This optimization only takes place if both methods are declared as virtual and both take identical parameters. *** EXPERIMENTAL FEATURE *** 9/3/00 : beazley Restored the "memberin" typemap for setting structure members. Unlike the old version, the new version is expanded inline in the wrapper function allowing access to scripting language internals (a sometimes requested feature). The "memberout" typemap is gone. Use the "out" typemaps instead. *** POTENTIAL INCOMPATIBILITY *** 9/3/00 : beazley Attribute set methods no longer return the value of a member. For example: struct Foo { int x; ... } now gets set as follows: void Foo_x_set(Foo *f, int x) { f->x = x; } In SWIG1.1 it used to be this: int Foo_x_set(Foo *f, int x) { return (f->x = x); } This has been changed due to the complexity created by trying to do this with more exotic datatypes such as arrays. It also complicates inlining and handling of the "memberin" typemap. *** POTENTIAL INCOMPATIBILITY *** 9/2/00 : beazley Removed the ptrcast() and ptrmap() functions from the pointer.i library file. Old implementation is incompatible with new type system. *** POTENTIAL INCOMPATIBILITY *** 9/2/00 : beazley New runtime function SWIG_TypeQuery(const char *name) added. This function can be used to extract the type info structure that is used for type-checking. It works with either the nice C name or mangled version of a datatype. For example: swig_type_info *ty = Swig_TypeQuery("int *"); swig_type_info *ty = Swig_TypeQuery("_p_int"); This is an advanced feature that has been added to support some exotic extension modules that need to directly manipulate scripting language objects. *** NEW FEATURE *** 9/2/00 : beazley New directive %types() added. This is used to explicitly list datatypes that should be included in the runtime type-checking code. Normally it is never necessary to use this but sometimes advanced extensions (such as the pointer.i library) may need to manually add types to the type-checker. *** NEW FEATURE *** 8/31/00 : beazley Improved handling of string array variables. For example, a global variable of the form "char name[64]" is automatically managed as a 64 character string. Previously this didn't work at all or required the use of a special typemap. *** NEW FEATURE (Tcl, Perl, Python) *** 8/31/00 : ttn Added Makefile target `check-c++-examples', which uses new files under Examples/C++ contributed by Tal Shalif. Now "make check" also does "make check-c++-examples". Also, expanded actions in `check-gifplot-example' and `check-aliveness'. 8/30/00 : mkoeppe Major clean-up in the Guile module. Added typemap-driven documentation system. Changed to handle more than 10 args. Updated and extended examples. *** NEW FEATURE *** 8/29/00 : beazley Added new %insert directive that inserts the contents of a file into a portion of the output wrapper file. This is only intended for use by writers of language modules. Works as follows: %insert(headers) "file.swg"; %insert(runtime) "file.swg"; %insert(wrappers) "file.swg"; %insert(init) "file.swg"; *** NEW FEATURE *** 8/29/00 : beazley Added new %runtime directive which includes code into the runtime portion of the wrapper code. For example: %runtime %{ ... some internal runtime code ... %} There is no practical reason for ordinary users to use this feature (almost everything can be done using %{ ... %} instead). However, writers of language modules may want to use this in language configuration files. *** NEW FEATURE *** 8/28/00 : beazley Typemaps can now be specified using string literals like this: %typemap(in) int "$target = SvIV($source);"; When code is specified like this, it is *NOT* enclosed inside a local scope (as with older typemap declarations). Note: character escape sequences are interpreted in the code string so if you want to include a quote or some other special character, make sure you use a (\). *** NEW FEATURE *** 8/27/00 : beazley Typemaps have been modified to follow typedef declarations. For example, if you have this: typedef int Number; %typemap(in) int { ... get an integer ... } void foo(Number a); The typemap for 'int' will be applied to the argument 'Number a'. Of course, if you specify a typemap for 'Number' it will take precedence (nor will it ever be applied to an 'int'). *** POTENTIAL INCOMPATIBILITY *** 8/27/00 : beazley Default typemap specification has changed. In older versions of swig, you could do this: %typemap(in) int SWIG_DEFAULT_TYPE { ... } To specify the default handling of a datatype. Now that SWIG follows typedef declarations, this is unnecessary. Simply specifying a typemap for 'int' will work for all variations of integers that are typedef'd to 'int'. Caveat, specifying the default behavior for pointers, references, arrays, and user defined types is a little different. This must be done as follows: %typemap() SWIGPOINTER * { ... a pointer ... } %typemap() SWIGREFERENCE & { ... a reference ... } %typemap() SWIGARRAY [] { ... an array ... } %typemap() SWIGTYPE { ... a user-defined type (by value) ... } *** POTENTIAL INCOMPATIBILITY *** 8/15/00 : dustin The file swig-1.3a1-1.spec has been added to the Tools directory. It can be used to build a redhat package for SWIG, although it will need to be updated for the next public release. 8/15/00 : beazley Typemaps have been completely rewritten. Eventually they may be replaced with something better, but for now they stay. However, there are a number of a significant changes that may trip some people up: 1. Typemap scoping is currently broken. Because of this, the following code won't work. %typemap(in) blah * { ... } class Foo { ... int bar(blah *x); } %typemap(in) blah *; /* Clear typemap */ (this breaks because the code for the class Foo is actually generated after the entire interface file has been processed). This is only a temporary bug. 2. In SWIG1.1, the %apply directive worked by performing a very complex type-aliasing procedure. From this point on, %apply is simply a generalized typemap copy operation. For example, %apply double *OUTPUT { double *x, double *y }; Copies *ALL* currently defined typemaps for 'double *OUTPUT' and copies them to 'double *x' and 'double *y'. Most people probably won't even notice this change in %apply. However, where it will break things is in code like this: %apply double *OUTPUT { double *x }; %typemap(in) double *OUTPUT { ... whatever ... } void foo(double *x); In SWIG1.1, you will find that 'foo' uses the 'double *OUTPUT' rule even though it was defined after the %apply directive (this is the weird aliasing scheme at work). In SWIG1.3 and later, the 'double *OUTPUT' rule is ignored because it is defined after the %apply directive. 3. The %clear directive has been modified to erase all currently defined typemaps for a particular type. This differs from SWIG1.1 where %clear only removed rules that were added using the %apply directive. 4. Typemap matching is now performed using *exact* types. This means that things like this %typemap(in) char * { } %typemap(in) const char * { } are different typemaps. A similar rule applies for pointers, arrays, and references. For example: %typemap(in) double * { } used to apply to 'double &', 'double []', Now, it only applies to 'double *'. If you want a 'double &', you'll need to handle that separately. 5. Array matching has been simplfied. In SWIG1.1, array matching was performed by trying various combinations of dimensions. For example, 'double a[10][20]' was matched as follows: double [10][20] double [ANY][20] double [10][ANY] double [ANY][ANY] In SWIG1.3, only the following matches are attempted: double [10][20] double [ANY][ANY] On the positive side, typemap matching is now *significantly* faster than before. *** POTENTIAL INCOMPATIBILITY *** 8/15/00 : beazley Secret developer feature. Since datatypes are now represented as strings internally, you can bypass limitations of the parser and create a wild datatype by simply enclosing the raw string encoding in backticks (``) and sticking it in the interface file anywhere a type is expected. For example, `a(20).a(10).p.f(int,int)`. This feature is only intended for testing (i.e., you want to see what happens to your language module if it gets a reference to a pointer to an array of pointers to functions or something). *** SICK HACK *** 8/14/00 : beazley Completely new type-system added to the implementation. More details later. 8/11/00 : beazley Cleaned up some of the I/O handling. SWIG no longer generates any temporary files such as _wrap.wrap, _wrap.ii, _wrap.init. Instead, these "files" are kept around in memory as strings (although this is transparent to language modules). 8/4/00 : ttn Added Makefile target "check" and variants. This can be used like "make check" or, to explicitly skip a language LANG: "make skip-LANG=true check". LANG is skipped automatically if ./configure determines that LANG support is insufficient. Currently, the check is limited to doing the equivalent of "make all" in some of the Examples directories. This should be expanded both horizontally (different types of tests) and vertically (after "make all" in an Examples subdir succeeds, do some additional tests with the resulting interpreter, etc). 8/4/00 : ttn Added Makefile target "distclean", which deletes all the files ./configure creates, including config.status and friends. 8/3/00 : harcoh java changes??? [todo: document changes] 7/23/00 : beazley Typemaps have been modified to key off of the real datatypes used in the interface file. This means that typemaps for "const char *" and "char *" will be difference as will typemaps for "Vector" and "Vector *." *** POTENTIAL INCOMPATIBILITY *** This is likely to break interfaces that rely on the odd type handling behavior of typemaps in SWIG1.1--especially with respect to interfaces involving pass-by-value. 7/23/00 : beazley New %constant directive. This directive can be used to create true constants in the target scripting language. It's most simple form is something like this: %constant FOO 42; In this case, the type is inferred from the syntax of the value (in reality, all #define macros are translated into directives of this form). An expanded version is as follows: %constant(Foo *) FOO = &FooObj; In this case, an explicit type can be specified. This latter form may be useful for creating constants that used to be specified as const Foo *FOO = &FooObj; (which are now treated as variables). *** EXPERIMENTAL FEATURE *** The syntax may change in the final release. 7/23/00 : beazley Modified the parser so that variable declarations of the form "const type *a" are handled as variables, not constants. Note: SWIG1.1 handled this case erroneously because const char *a is a pointer variable that can be reassigned. *** POTENTIAL INCOMPATIBILITY *** Note: just because this is the "right" way to do things, doesn't mean it's the most appropriate interpretation. I suspect that many C programmers might use 'const char *' with the intent of creating a constant, without realizing that they've created a reassignable global variable. 7/23/00 : beazley The C/C++ wrapping layer has been completely redesigned and reimplemented. This change should iron out a few rough spots with the handling of datatypes. In addition, the wrapper code is somewhat cleaner. *** POTENTIAL INCOMPATIBILITY *** This change may break interfaces that involve subtle corner-cases with typemaps and the %addmethods directive since some of these features had somewhat type handling behavior in SWIG1.1. 7/23/00 : beazley The "memberin" and "memberout" typemaps are gone for the moment, but they might return as soon as I figure out how to integrate them with some of the streamlined C wrapper functions. *** POTENTIAL INCOMPATIBILITY *** 7/22/00 : beazley A variety of old type handling functions such as print_type(), print_full(), print_mangle(), etc... are gone and have been replaced with a smaller set of functions. See the file Doc/internals.html for details. This will break all third party language modules. *** POTENTIAL INCOMPATIBILITY *** 7/20/00 : beazley Deprecated the %val and %out directives. These directives shouldn't really be necessary since typemaps can be used to achieve similar results. This also cleans up the handling of types and parameters quite a bit. *** POTENTIAL INCOMPATIBILITY *** 7/20/00 : ttn Fixed unspecified-module bug in Guile support and removed more non-"with-smobs" functionality using patches submitted by Matthias Koeppe. Re-enable recognition of "-with-smobs" (with no effect since we use smobs by default now) for the time being. After the 1.3a4 release, this option will signal an error. 7/17/00 : ttn Fixed NULL-input bug in parameter list handling. Reported by Matthias Koeppe. 7/12/00 : beazley Fixed memory leak in Python type-checking code. Reported by Keith Davidson. Bug #109379. 7/10/00 : beazley Changed internal data structures related to function parameters. 7/10/00 : beazley Fixed some bugs related to the handling of the %name() directive and classes in the Tcl module. Problem reported by James Bailey. 7/10/00 : beazley Fixed parsing and enum handling problems with character constants. Reported by Greg Kochanski. 7/10/00 : beazley Removed WrapperFunction class from the core and updated the language module. This will break third party modules. *** POTENTIAL INCOMPATIBILITY *** 7/9/00 : beazley Implementation of SWIG no longer makes use of C++ operator overloading. This will almost certainly break *all* third party language modules that are not part of the main SWIG CVS tree. Sorry. *** POTENTIAL INCOMPATIBILITY *** 7/8/00 : beazley Removed the experimental and undocumented "build" typemap that was intended to work with multiple arguments. Simply too weird to keep around. Besides, a better replacement is in the works. 7/6/00 : ttn Removed non-"with-smobs" functionality (Guile support), i.e., "-with-smobs" is now the default and no longer needs to be specified on the command-line. 7/5/00 : ttn Incorporated Ruby support contributed by Masaki Fukushima. 6/28/00 : ttn Applied more-than-10-args bugfix patch contributed by Matthias Koeppe. 6/27/00 : beazley Rewrote some of the string handling and eliminated the C++ implementation (which is now just a wrapper). 6/27/00 : ttn Added Doc/index.html and Doc/internals.html. The target audience for the latter is new SWIG developers. Version 1.3 Alpha 3 (June 18, 2000) =================================== 6/18/00 : beazley Removed the naming.cxx, hash.cxx, and symbol.cxx files from the SWIG1.1 directory. Continued to migrate things away from the C++ base (although there's still a lot of work to do). 6/17/00 : beazley Added a few more examples to the Examples directory. Still need to do a lot of work on this. 6/16/00 : beazley Added -includeall to follow all #include statements in the preprocessor. 6/15/00 : beazley Tried to fix as many C++ warnings as possible when compiling with the Sun Workshop C++ compiler. Unfortunately, this means that there are a lot of statements that contain string literals of the form (char*)"Blah". 6/15/00: beazley A variety of cleanup and performance optimization in the low-level DOH library. This seems to result in a speedup of 50-100% for preprocessing and other related tasks. 5/10/00 : ttn Applied variable-wrapping bugfix patch contributed by Matthias Koeppe. 4/17/00 : ttn Updated MzScheme support contributed by Oleg Tolmatcev. We now use a `Scheme_Type'-based structure to wrap pointers. 4/11/00 : ttn Incorporated further Guile-support patch by Matthias Koeppe. Typemaps previously deleted have been re-added. There is now exception handling (see Doc/engineering.html). `SWIG_init' is now declared extern only for simple linkage. Some bugs were fixed. 4/06/00 : ttn Incorporated MzScheme support contributed by Oleg Tolmatcev. This includes new directories Lib/mzscheme and Examples/mzscheme. 4/03/00 : ttn Added Examples/guile and children. This is an adaptation of the same-named directory from the SWIG-1.1p5 distribution. Added Guile-specific section to Doc/engineering.html. 4/02/00 : ttn Incorporated new guilemain.i by Martin Froehlich. Incorporated Guile-support rewrite patch by Matthias Koeppe. The command line option "-with-smobs" enables implementation of pointer type handling using smobs, the canonical mechanism for defining new types in Guile. Previous implementation (using strings) is at the moment still supported but deprecated. At some point, "-with-smobs" will be the default and no longer required. 3/13/00 : beazley Added purify patches submitted by Ram Bhamidipaty. 3/02/00 : ttn Added support for different Guile "linkage" schemes. Currently, "-Linkage hobbit" works. Version 1.3 Alpha 2 (March 1, 2000) =================================== 2/29/00 : beazley Made SWIG ignore the 'mutable' keyword. 2/29/00 : beazley Incorporated some patches to the Perl5 module related to the -hide option and the destruction of objects. Patch submitted by Karl Forner. 2/27/00 : ttn Incorporated Guile support contributed by Matthias Koeppe. This includes a cpp macro in Lib/guile/guile.swg and the entire file Lib/guile/typemaps.i. 2/25/00 : ttn Modified configure.in and Makefile.in files to support non-local build (useful in multi-arch environments). 2/24/00 : ttn Incorporated Guile support contributed by Clark McGrew. This works with Guile 1.3, but since it depends heavily on the gh_ interface, it should work for all later versions. It has not been tested with versions before 1.3. WARNING: Code is unstable due to experimentation by ttn. 2/16/00 : beazley A variety of performance improvements to the Python shadow class code generation. Many of these result in substantial runtime performance gains. However, these have come at a cost of requiring the use of Python 1.5.2. For older versions, use 'swig -noopt -python' to turn off these optimization features. Version 1.3 Alpha 1 (February 11, 2000) ======================================= 2/11/00 : Added 'void' to prototype of Python module initializer. Reported by Mark Howson (1/20/00). 2/11/00 : beazley Modified the Python shadow class code to discard ownership of an object whenever it is assigned to a member of another object. This problem has been around for awhile, but was most recently reported by Burkhard Kloss (12/30/99). 2/11/00 : beazley Added braces around macros in the exception.i library. Reported by Buck Hodges (12/19/99) 2/11/00 : beazley Fixed bug in the constraints.i library. Reported by Buck Hodges (12/14/99) 2/11/00 : beazley The %native directive now generates Tcl8 object-style command calls. A full solution for Tcl7 and Tcl8 is still needed. Patch suggested by Mike Weiblen (11/29/99) 2/11/00 : beazley Modified the typemap code to include the $ndim variable for arrays. Patch provided by Michel Sanner (11/12/99). 2/11/00 : beazley Modified the Python module to raise a Runtime error if an attempt is made to set a read-only member of a shadow class. Reported by Michel Sanner (11/5/99). 2/10/00 : The documentation system has been removed. However, it is likely to return at some point in the future. 2/1/00 : Added a number of performance enhancements to the Python shadow classing and type-checking code. Contributed by Vadim Chugunov. 1. Remove _kwargs argument from the shadow wrappers when -keyword option is not specified. This saves us a construction of keyword dictionary on each method call. def method1(self, *_args, **_kwargs): val = apply(test2c.PyClass1_method1, (self,) + _args, _kwargs) return val becomes def method1(self, *_args): val = apply(test2c.PyClass1_method1, (self,) + _args) return val 2. Incorporate self into the _args tuple. This saves at least one tuple allocation per method call. def method1(self, *_args): val = apply(test2c.PyClass1_method1, (self,) + _args) return val becomes def method1(*_args): val = apply(test2c.PyClass1_method1, _args) return val 3. Remove *Ptr classes. Assume that we are SWIGging a c++ class CppClass. Currently SWIG will generate both CppClassPtr class that hosts all methods and also CppClass that is derived from the former and contains just the constructor. When CppClass method is called, the interpreter will try to find it in the CppClass's dictionary first, and only then check the base class. CppClassPtr functionality may be emulated with: import new _new_instance = new.instance def CppClassPtr(this): return _new_instance(CppClass, {"this":this,"thisown":0}) This saves us one dictionary lookup per call. The new module was first added in Python-1.5.2 so it won't work with older versions. I've implemented an alternative that achieves the same thing 4. Use CObjects instead of strings for pointers. Dave: This enhancements result in speedups of up to 50% in some of the preliminary tests I ran. 2/1/00 : Upgraded the Python module to use a new type-checking scheme that is more memory efficient, provides better performance, and is less error prone. Unfortunately, it will break all code that depends on the SWIG_GetPtr() function call in typemaps. These functions should be changed as follows: if (SWIG_GetPtr(string,&ptr,"_Foo_p")) { return NULL; } becomes if (SWIG_ConvertPtr(pyobj, &ptr, SWIG_TYPE_Foo_p) == -1) { return NULL; } Note: In the new implementation SWIG_TYPE_Foo_p is no longer a type-signature string, but rather an index into a type encoding table that contains type information. *** POTENTIAL INCOMPATIBILITY *** 1/30/00 : loic Conditionally compile experimental code with --enable-experiment configure flag. Fix .cvsignore to ignore configure & yacc generated files 1/28/00 : loic Apply automake everywhere Keep configure scripts so that people are not *forced* to autoconf Keep sources generated by yacc so that compilation without yacc is possible. Source/LParse/cscanner.c: change lyacc.h into parser.h to please default yacc generation rules. Use AC_CONFIG_SUBDIRS in configure.in instead of hand made script. Update all relevant .cvsignore to include .deps Fixed missing ; line 136 Source/Swig/swig.h 1/13/00 : beazley Fixed a number of minor end-of-file parsing problems in the preprocessor. 1/13/00 : beazley Added -freeze option that forces SWIG to freeze upon exit. This is only used as a debugging tool so that I can more easily examine SWIG's memory footprint. 1/13/00 : beazley Added patch to guile module for supporting optional arguments Patch contributed by Dieter Baron. 1/13/00 : loic Added .cvsignore, Examples/.cvsignore, Source/DOH/Doh/.cvsignore Source/SWIG1.1/main.cxx: Fixed -I handling bug Source/Modules1.1/java.cxx: fixed char* -> const char* warnings that are errors when compiling with gcc-2.95.2 Source/SWIG1.1/main.cxx: cast const char* to char* for String_replace token and rep should really be const. 1/12/00 : beazley Added Harco's Java modules. 1/12/00 : beazley Revoked the %ifdef, %ifndef, %endif, %if, %elif, and %else directives. These are no longer needed as SWIG now has a real preprocessor. *** POTENTIAL INCOMPATIBILITY *** 1/12/00 : beazley Moved the documentation modules from the SWIG directory to the Modules directory (where they really should have been to begin with). 1/12/00 : beazley Removed the -stat option for printing statistics. The statistics reporting was inadequate and mostly broken anyway. *** POTENTIAL INCOMPATIBILITY *** 1/12/00 : beazley Removed the -t option for reading a typemap file. More trouble than it's worth. Just include typemaps at the top of the interface file. *** POTENTIAL INCOMPATIBILITY *** 1/12/00 : beazley Removed the %checkout directive. *** POTENTIAL INCOMPATIBILITY *** 1/12/00 : beazley Removed the -ci option for file checkin. Too problematic to implement. Probably better to just put your SWIG library under CVS instead. *** POTENTIAL INCOMPATIBILITY ***. 1/11/00 : beazley Deleted the LATEX module. Sorry... Didn't know anyone who was using it. Besides, I'm looking to simplify the documentation system. *** POTENTIAL INCOMPATIBILITY *** 1/11/00 : beazley Modified the ASCII documentation module to use a .txt suffix for its output file instead of .doc. 1/11/00 : beazley Added the long-lost SWIG preprocessor back to the system. It should be enabled by default. Raw preprocessed output can be viewed using swig -E file.i. *** NEW FEATURE *** 1/11/00 : beazley and djmitche Completely reorganized the SWIG directory structure. The basic organization is now: Source/ SWIG source code Lib/ SWIG library files (swig_lib) Doc/ Documentation Examples/ Examples More directories will be added as needed. 12/08/99: Loic Dachary (loic@senga.org) Enhanced package handling for perl5 and c++. With new option -hide Foo::Bar, every perl5 object (Frob) is qualified by Foo::Bar::Frob. The package name is solely used to encapsulate C/C++ wrappers output in _wrap.c and the corresponding perl package in .pm. Note that a package name may contain :: (Frob::Nitz) and will be relative to the package name provided by -hide (Foo::Bar::Frob::Nitz). In *_wrap.c, SWIG_init macro is used. Was previously defined but not used and simplifies code. Added typemap(perl5,perl5in) and typemap(perl5,perl5out) that do the equivalent of typemap(perl5,in) and typemap(perl5,out) but contain perl code and applies to wrappers generated by -shadow. Lacking proper regression tests I used Examples/perl5/{c++,constraint,defarg,except, graph/graph[1234],multinherit,nested,shadow,simple,tree, typemaps/{argv,argv2,arraymember,database,file,ignore,integer, output,passref,reference,return}}/. I ran swig with and without the patches, diff the generatedsources, run the .pl files and checked that the results are identical. In all those examples I had no error. 11/21/99: Modified the Tcl module to provide full variable linking capabilities to all datatypes. In previous versions, a pair of accessor functions were created for datatypes incompatible with the Tcl_LinkVar() function. Now, we simply use variable traces to support everything. This may break scripts that rely upon the older behavior. *** POTENTIAL INCOMPATIBILITY *** 11/21/99: Added slight tweak to wrapper generator to collect local variables of similar type. Produces somewhat more compact wrapper code. 11/20/99: Modified the Tcl module to use SWIG_GetArgs() to parse arguments. This is a technique borrowed from Python in which arguments are converted using a format string convention similiar to fprintf(). This results in a *substantial* reduction in the size of the resulting wrapper code with only a modest runtime overhead in going through the extra conversion function. 11/13/99: Completely rewrote the class/structure generation code for the Tcl module. Now, a small set of runtime functions are used to implement the functionality for all classes (instead of a massive amount of runtime code being generated for each class). Class specific information is simply encoded in a series of static tables. This results in a *HUGE* reduction in wrapper code size--especially for C++. 11/13/99: Removed the -tcl (Tcl 7.x) module. Tcl 8.0 is now several years old and the defacto standard--no real reason to keep supporting the old version at this point. 11/13/99: Cleaned up -c option for Python module. The pyexp.swg file is now gone. 11/13/99: Fixed external declarations to work better with static linking on Windows. Static linking should now be possible by defining the -DSTATIC_LINK option on the command line. Patch contributed by Alberto Fonseca. 11/5/99 : Fixed an obscure code generation bug related to the generation of default constructors. Bug reported by Brad Clements. 11/5/99 : Fixed a few memory problems found by purify. 11/5/99 : Officially deprecated the -htcl, -htk, and -plugin options from the Tcl and Tcl8 modules. 10/26/99: Removed unused variable from python/typemaps.i. Patch contributed by Keith Davidson. 8/16/99 : Added _WIN32 symbol to libraries to better support Windows. 8/16/99 : Deprecated the Perl4 module. It is no longer included in the distribution and no longer supported. In the entire 3 years SWIG has been around I never received a single comment about it so I'm assuming no one will miss it... 8/16/99 : Modified the type-checking code to register type mappings using a table instead of repeated calls to SWIG_RegisterMapping(). This reduces the size of the module initialization function somewhat. 8/15/99 : Cleaned up the pointer type-checking code in the Tcl module. 8/15/99 : Many changes to the libraries to support runtime libraries. 8/13/99 : Eliminated C++ compiler warning messages about extern "C" linkage. 8/13/99 : Some cleanup of Python .swg files to better support runtime libraries on Windows. 8/13/99 : Modified the %pragma directive to attach pragmas declared inside a class definition to the class itself. For example: class foo { ... %pragma(python) addtomethod = "insert:print `hello world'" ... } Most people don't need to worry about how this works. For people writing backend modules, class-based pragmas work like this: lang->cpp_open_class() // Open a class lang->cpp_pragma() // Supply pragmas ... // Emit members lang->cpp_close_class() // Close the class All of the pragmas are passed first since they might be used to affect the code generation of other members. Please see the Python module for an example. Patches contributed by Robin Dunn. 8/13/99 : Patch to Python shadow classes to eliminate ignored exception errors in destructors. Patch contributed by Robin Dunn. 8/11/99 : Minor patch to swig_lib/python/swigptr.swg (added SWIGSTATIC declaration). Patch contributed by Lyle Johnson. 8/11/99 : Added FIRSTKEY/NEXTKEY methods to Perl5 shadow classes Patch contributed by Dennis Marsa. 8/11/99 : Modified Python module so that NULL pointers are returned and passed as 'None.' Patch contributed by Tal Shalif. 8/10/99 : Fixed missing 'int' specifiers in various places. 8/10/99 : Added Windows makefile for Runtime libraries. Contributed by Bob Techentin. 8/10/99 : Fixed minor problem in Python runtime makefile introduced by keyword arguments. 8/8/99 : Changed $target of perl5(out) typemap from ST(0) to ST(argvi). Patch contributed by Geoffrey Hort. 8/8/99 : Fixed bug in typemap checking related to the ANY keyword in arrays and ignored arguments. Error reported by Geoffrey Hort. 8/8/99 : %enabledoc and %disabledoc directives can now be used inside class/structure definitions. However, no check is made to see if they are balanced (i.e., a %disabledoc directive inside a class does not have to have a matching %enabledoc in the same class). 8/8/99 : Keyword argument handling is now supported in the Python module. For example: int foo(char *bar, int spam, double x); Can be called from Python as foo(x = 3.4, bar="hello", spam=42) To enable this feature, run SWIG with the '-keyword' command line option. Mixing keyword and default arguments should work as well. Unnamed arguments are assigned names such as "arg1", "arg2", etc... *** POTENTIAL INCOMPATIBILITY *** Functions with duplicate argument names such as bar(int *OUTPUT, int *OUTPUT) will likely cause problematic wrapper code to be generated. To fix this, use different names or use %apply to map typemaps to alternate names. 8/8/99 : Handling of the 'this' pointer has been changed in Python shadow classes. Previously, dereferencing of '.this' occurred in the Python shadow class itself. Now, this step occurs in the C wrappers using the following function: SWIG_GetPtrObj(PyObject *, void **ptr, char *type) This function can accept either a string containing a pointer or a shadow class instance with a '.this' attribute of appropriate type. This change allows the following: 1. The real shadow class instance for an object is passed to the C wrappers where it can be examined/modified by typemaps. 2. Handling of default/keyword arguments is now greatly simplified. 3. The Python wrapper code is much more simple. Plus, it eliminated more than 300 lines of C++ code in the Python module. *** CAVEAT : This requires the abstract object interface. It should work with Python 1.4, but probably nothing older than that. 8/8/99 : Fixed handling of "const" and pointers in classes. In particular, declarations such as class foo { ... const char *msg; const int *iptr; } are handled as assignable variables as opposed to constant values (this is the correct behavior in C/C++). Note: declarations such as "char *const msg" are still unsupported. Constants declared at the global level using const are also broken (because I have a number of interfaces that rely upon this behavior). *** POTENTIAL INCOMPATIBILITY *** This may break interfaces that mistakenly treat 'const char *' types as constant values. 8/8/99 : Modified the parser to support bit-fields. For example: typedef struct { unsigned int is_keyword : 1; unsigned int is_extern : 1; unsigned int is_static : 1; } flags; Bit-fields can only be applied to integer types and their are other restrictions. SWIG performs no such type-checking (although the C compiler will catch problems when it tries to compile the wrapper code). 8/8/99 : Removed trailing space of $basetype substitution in typemaps. This is to allow things like this: %typemap(python, argout) spam** OUTPUT{ ... char* a = "$basetype_p"; ... } (Patch suggested by Nathan Dunfield). 6/22/99 : Made a very slight tweak to the Perl5 shadow class code that allows typemaps to alter the return type of objects (to support polymorphic types). Patch contributed by Drake Diedrich. 4/8/99 : Fixed null pointer handling bug in Perl module. Patch contributed by Junio Hamano. 3/17/99 : Fixed bug in perl5ptr.swg for ActiveState Perl. Patch contributed by Greg Anderson. 2/27/99 : Eliminated segmentation fault when Swig runs on empty files. 2/27/99 : Added patch to Guile module to eliminate unused variables. Contributed by Mike Simons. 2/27/99 : Fixed problem with %addmethods returning references. 2/27/99 : Fixed Runtime/Makefile. Patch contributed by Mike Romberg. 2/27/99 : Incorporated patches to the type-checker. 2/27/99 : Fixed problem with -exportall switch and shadow classes in Perl5 module. Patch contributed by Dennis Marsa. 2/27/99 : Modified Perl5 module to recognize 'undef' as a NULL char *. Patch contributed by Junio Hamano. 2/27/99 : Fixed the Perl5 module to support the newer versions of ActiveState Perl for Win32. 2/27/99 : Fixed the include order of files specified with the -I option. 2/5/98- : Dave finishes his dissertation, goes job hunting, moves to 2/5/99 Chicago and generally thrashes about. Version 1.1 Patch 5 (February 5, 1998) ====================================== 2/4/98 : Fixed a bug in the configure script when different package locations are specified (--with-tclincl, etc...). 2/2/98 : Fixed name-clash bug related to the switch to C macros for accessor functions. The new scheme did not work correctly for objects with members such as 'obj', 'val', etc... Fixed the bug by appending the word 'swig' to macro argument names. Patch contributed by Rudy Albachten. 2/2/98 : Slight fix to the Perl5 module to eliminate warning messages about 'varname used only once : possible typo'. Fix contributed by Rudy Albachten. 1/9/98 : Fixed a bug in the Perl 5 module related to the creation of constants and shadow classes. 1/9/98 : Fixed linking bug with Python 1.5 embed.i library file. Version 1.1 Patch 4 (January 4, 1998) ===================================== 1/4/98 : Changed structured of the Examples directory to be more friendly to Borland C++. 1/4/98 : Added the function Makefile.win.bc for compiling the examples under Borland 5.2. 1/4/98 : Slight change to the perl5 module and C++ compilation. The library is now included before any Perl headers because Perl the extern "C" linkage of math.h screws alot of things up (especially on Windows). 1/2/98 : Change to the Python module that reduces the number of constants created by C++ classes, inheritance, and shadow classes. This modification may introduce a few slight incompatibilities if you attempt to use the non-shadow class interface with shadow classes enabled. Patch contributed by Mike Romberg. 1/2/98 : Support for Tcl 8.0 namespaces has been added. This *replaces* the original SWIG mechanism that assumed [incr Tcl] namespaces. To use namespaces, simply run SWIG with the following options swig -tcl -namespace foo.i This places everything in a namespace that matches the module name swig -tcl -namespace -prefix bar foo.i This places everything in the namespace 'bar' The use of namespaces is new in Tcl 8.0. However, the wrapper code generated by SWIG will still work with all versions of Tcl newer than and including Tcl 7.3/Tk3.6 even if the -namespace option is used. *** POTENTIAL INCOMPATIBILITY *** This change may break existing applications that relied on the -prefix and -namespace options. 1/2/98 : Added the following constants to the Tcl wrapper code SWIG_name - Name of the SWIG module SWIG_prefix - Prefix/namespace appended to command names SWIG_namespace - Name of the namespace SWIG library writers can use these to their advantages. 1/2/98 : Fixed a bug in the Tcl8 module related to the creation of pointer constants (the function SWIG_MakePtr was missing from the wrapper code). 1/2/98 : Added the consthash.i library file to the Tcl and Tcl8 modules. 1/1/98 : Changed and cleaned up the Python typemaps.i file. The following significant changes were made : 1. The OUTPUT typemap now returns Python tuples instead of lists. Lists can be returned as before by using the L_OUTPUT type. If compatibility with older versions is needed, run SWIG with the -DOUTPUT_LIST option. 2. The BOTH typemap has been renamed to INOUT. For backwards compatibility, the "BOTH" method still exists however. 3. Output typemaps now generate less code than before. Changes to typemaps.i may break existing Python scripts that assume output in the form of a list. *** POTENTIAL INCOMPATIBILITY *** 12/31/97: Fixed long overdue problems with the testing scripts and certain makefiles that required the use of the bash shell. Everything should work properly with the standard Bourne shell (sh) now. 12/31/97: Modified typemaps to allow $basetype as a valid local variable. This allows for all sorts of bizarre hackish typemaps that do cool things. Patch contributed by Dominique Dumont. 12/31/97: Switched accessor functions generated for member data to C preprocessor macros (except in cases involving typemaps or char *). 12/31/97: Fixed a bug related to C++ member data involving references. 12/31/97: Changed accessor functions for C++ member functions to preprocessor macros. This cleans up the wrapper code and results in fewer function definitions. 12/31/97: Changed the default C constructor to use calloc() instead of malloc() 12/30/97: Changed the creation of constants in the Perl5 module. For all practical purposes, they should work in exactly the same way as before except that they now require much less wrapper code. Modules containing large numbers of constants may see greater than a 50% reduction in wrapper code size. 12/30/97: Modified the Python module to be more intelligent about the creation of constants. SWIG no longer generates redundant global variables and the size of the module initialization function should be reduced. (Many thanks to Jim Fulton). 12/29/97: Fixed a bug in C++ code generation related to member functions, default arguments, and references. 12/29/97: Fixed configure script and a few makefiles to support Python 1.5 12/29/97: Added 'embed15.i' library file. This file should be used to statically link versions of Python 1.5. To make it the default, simply copy 'swig_lib/python/embed15.i' to 'swig_lib/python/embed.i' Version 1.1 Patch 3 (November 24, 1997) ======================================== 11/23/97: Fixed a bug in the Perl5 module with shadow classes and static class functions that return class instances. Note : The fix for this bug requires a slight restructuring of of the .pm files created by SWIG. 11/23/97: Fixed a bug in the Tcl/Tcl8 modules related to variable linking of character arrays. If you declared a global variable 'char foo[10]', the generated wrapper code would either cause a segmentation fault immediately upon loading or weird memory corruption elsewhere. This should now be fixed although character arrays can only be read-only. 11/23/97: Fixed a bug with the %import directive that caused it to fail if files were imported from directories other than the current working directory. 11/23/97: Fixed incorrect diagnostic message in the ASCII documentation module. 11/23/97: Changed the behavior of the -o option when used with shadow classes. If -o was used to specify both the pathname and filename of SWIG's output such as swig -o /home/swig/wrapper.c -shadow -perl5 foo.i The wrapper code would be placed the file specified with -o, but the .pm file and documentation would be placed in the directory where SWIG was run. Now, these files are placed in the same directory as the file specified with the -o option. This change is also needed for proper operation on the Macintosh. 11/23/97: Added a 'this()' method to Perl5 shadow classes. This can be used to return the normal pointer value from a shadow class that is represented as a tied hash. To use just invoke as a method like this : $l = new List; # Create an object $ptr = $l->this(); # Get the normal pointer value *** NEW FEATURE *** 11/23/97: Fixed the Tcl 8 pointer.i library file (which was completely broken in 1.1p2). 11/23/97: Modified the Perl5 type-checker to fix a few problems with global variables of pointer types and to allow tied hashes to be used interchangably with normal pointer values. 11/23/97: Modified the typemap mechanism to allow output typemaps of type 'void'. These were ignored previously, but now if you specify, %typemap(lang,out) void { ... return a void ... } You can change or assign a return value to the function. 11/23/97: Fixed processing of 'bool' datatypes in the Python module. 11/23/97: Fixed minor parsing error with C++ initializers. For example, class B : public A { public: B() : A() { ... }; ... } 11/23/97: Fixed the Tcl8 module so that C functions that call back into Tcl don't corrupt the return result object (SWIG was gathering the result object too early which leads to problems if subsequent Tcl calls are made). 11/23/97: Fixed a code generation bug in the Python module when two or more output parameters were used as the first arguments of a function. For example : %include typemaps.i void foo(double *OUTPUT, double *OUTPUT, double a); Previously, doing this resulted in the creation of an extraneous comma in the output, resulting in a C syntax error. 11/22/97: Fixed a bug when template handling that was stripping whitespace around nested templates. For example : Foo > was getting munged into Foo> which is a syntax error in in the C++ compiler. 11/22/97: Fixed bugs in the Borland C++ makefiles. 11/22/97: Fixed memory corruption bug when processing integer arguments in Tcl8 module. 11/21/97: Fixed a bug in the Runtime/Makefile related to Tcl 8. 11/21/97: Fixed a bug with the %new directive and Perl5 shadow classes. No longer generates a perl syntax error. 11/9/97 : Changed a strncpy() to strcpy() in the pointer type-checker. This results in a substantial performance improvement in type-checking. 10/29/97: Fixed a bug in the code generation of default arguments and user-defined types. For example : void foo(Vector a, Vector b = d); should now work properly. Version 1.1 Patch 2 (September 4, 1997) ======================================= 9/4/97 : Fixed problem with handling of virtual functions that was introduced by some changes in the C++ module. Version 1.1 Patch 1 (August 27, 1997) ===================================== 8/26/97 : Fixed compilation and run-time bugs with Tcl 8.0 final. 8/21/97 : Fixed code generation bug with arrays appearing as arguments to C++ member functions. For example : class Foo { public: void Bar(int a[20][20]); }; There is still a bug using arrays with added methods however. 8/20/97 : Fixed a bug with generating the code for added methods involving pass-by-value. 8/19/97 : Modified the typemapper to substitute the '$arg' value when declaring local variables. For example : %typemap(in) double * (double temp_$arg) { ... do something ... } When applied to a real function such as the following : void foo(double *a, double *b, double *result); three local variables will be created as follows : double temp_a; double temp_b; double temp_result; This can be used when writing multiple typemaps that need to access the same local variables. 7/27/97 : Fixed a variety of problems with the %apply directive and arrays. The following types of declarations should now work : %apply double [ANY] { Real [ANY] }; %apply double [4] { double [10] }; A generic version of apply like this : %apply double { Real }; should now work--even if arrays involving doubles and Reals are used later. 7/27/97 : Changed warning message about "Array X has been converted to Y" to only appear if running SWIG in verbose mode. 7/27/97 : Added the variables $parmname and $basemangle to the typemap generator. $parmname is the name of the parameter used when the typemap was matched. It may be "" if no parameter was used. $basemangle is a mangled version of the base datatype. Sometimes used for array handling. 7/27/97 : Changed the behavior of output arguments with Python shadow classes. Originally, if a function returned an object 'Foo', the shadow class mechanism would create code like this : def return_foo(): val = FooPtr(shadowc.return_foo()) val.this = 1 return val The problem with this is that typemaps allow a user to redefine the output behavior of a function--as a result, we can no longer make any assumptions about the return type being a pointer or even being a single value for that matter (it could be a list, tuple, etc...). If SWIG detects the use of output typemaps (either "out" or "argout") it returns the result unmodified like this : def return_foo(): val = shadowc.return_foo() return val In this case, it is up to the user to figure out what to do with the return value (including the possibility of converting it into a Python class). 7/26/97 : Fixed a parsing problem with types like 'unsigned long int', 'unsigned short int', etc... 7/24/97 : Minor bug fix to Tcl 8 module to parse enums properly. Also fixed a memory corruption problem in the type-checker. (patch contributed by Henry Rowley. 7/24/97 : Added Python-tuple typemaps contributed by Robin Dunn. 7/24/97 : Incorporated some changes to the Python module in support of Mark Hammond's COM support. I'm not entirely sure they work yet however. Needs documentation and testing. 7/24/97 : Fixed code generation bugs when structures had array members and typemaps were used. For example : %typemap(memberin) double [20][20] { ... get a double [20][20] ... } struct Foo { double a[20][20]; } Originally, this would generate a compiler-type error when the wrapper code was compiled. Now, a helper function like this is generated : double *Foo_a_set(Foo *a, double val[20][20]) { ... memberin typemap here ... return (double *) val; } When writing typemaps, one can assume that the source variable is an array of the *same* type as the structure member. This may break some codes that managed to work around the array bug. *** POTENTIAL INCOMPATIBILITY *** 7/13/97 : Fixed bug in Perl5 module when using C global variables that are pointers. When used in function calls and other operations, the value of the pointer would be invalid---causing core dumps and other problems. SWIG implements global variables using Perl magic variables. As it turns out, the error was caused by the fact that the pointer-extraction code was somehow bypassing the procedure used to resolve magical variables (hence, leaving the value undefined). To fix the problem, SWIG now explicitly resolves magic before extracting pointer values. 7/12/97 : Eliminated the last remnants of free() and malloc() from the SWIG compiler. 7/12/97 : Fixed parsing problems with typemaps involving arrays and temporary variables of arrays. Also made it possible for SWIG to handle typemaps like this : %typemap(in) double [ANY] (double temp[$dim0]) { ... store data in temp[$dim0] ... } Not only does this typemap match any double [] array, it creates a local variable with precisely the right dimensions. (ie. $dim0 gets filled in with the real number of dimensions). Of course, off the record, this will be a way to add more functionality to the typemaps.i libraries. 7/9/97 : Fixed some problems with Perl5, static linking, and shadow classes. When statically linking multiple modules together, write a top-level interface file like this when shadow classes are not used : %module swig, foo, bar, glob; %include perlmain.i When shadow classes are used, the module names have an extra 'c' appended so it should read as : %module swig, fooc, barc, globc; %include perlmain.i When linking multiple modules, consider using the SWIG runtime library. 7/8/97 : Incorporated fixed versions of the Borland C++ Makefiles. 7/8/97 : First cut at trying to eliminate excessive compiler warnings. As it turns out, alot of warnings go away if you just make declarations like this clientData = clientData; in the resulting wrapper code. Most compilers should just ignore this code (at least would can hope). 7/8/97 : Fixed bizarre code generation bug with typemaps and C++ classes. In some cases, typemaps containing printf formatting strings such as %typemap(memberout) int * { printf("%d",42); } Would generate completely bogus code with garbage replacing the '%d'. Caused by one faulty use of printf (wasn't able to find any other occurrences). 7/7/97 : Fixed bug in Python shadow class generation with non-member functions that are returning more than one value. 7/7/97 : Incorporated modifications to make SWIG work with Guile 1.2. Still need to test it out, but it is rumored to work. 7/2/97 : Fixed some bugs related to output arguments and Python shadow classes. If an output argument is detected, SWIG assumes that the result is a list and handles it appropriately. If the normal return type of an function is an object, it will be converted into a shadow class as before, but with the assumption that it is the first element of a list. *** NOTE : This behavior has been subsequently changed *** 6/29/97 : Changed EXPORT to SWIGEXPORT in all of the language modules. Should provide better compatibility with Windows. 6/29/97 : Modified Python shadow classes so that output arguments work correctly (when typemaps are used). Version 1.1 (June 24, 1997) =========================== 6/24/97 : Fixed Objective-C constructor bug when working with Perl5 shadow classes. 6/23/97 : Fixed some parsing problems with Objective-C. Declarations such as the following should work now : - foo : (int) a with: (int) b; 6/22/97 : Added SWIG Runtime library. This library contains the SWIG pointer type-checker and support functions that are normally included in every module. By using the library, it is easier to work with multiple SWIG generated modules. 6/22/97 : Fixed minor bug in Perl5 module related to static linking of multiple modules. 6/22/97 : Fixed some bugs with the %import directive. When used with Perl5 shadow classes, this generates a 'require' statement to load in external modules. 6/22/97 : Added -swiglib option. This prints out the location of the SWIG library and exits. This option is only really useful to configuration tools that are looking for SWIG and its library location (e.g. autoconf, configure, etc...). 6/21/97 : Fixed export bug with Perl5.004 on Windows-NT. 6/20/97 : Minor change to code generation of class/structure members in order to work better with typemaps. Should have no noticable impact on existing SWIG modules. 6/19/97 : Added -t option. This allows SWIG to load a typemap file before processing any declarations. For example : swig -t typemaps.i -python example.i At most, only one typemap file can be specified in this manner. *** NEW FEATURE *** 6/18/97 : Need a Makefile fast? Type swig [-tcl, -perl5, -python] -co Makefile and you will get a Makefile specific to that target language. You just need to modify it for your application and you're ready to run. 6/18/97 : Completed the -ci option. This option checks a file into the SWIG library. It should be used in conjunction with a language option. For example : swig -tcl -ci foobar.i Checks the file foobar.i into the Tcl part of the library. In order to check a file into the general library (accessible to all languages modules), do the following swig -ci -o ../foobar.i foobar.i (Admittedly this looks a little strange but is unavoidable). The check-in option is primarily designed for SWIG maintenance and library development. The command will fail if the user does not have write permission to the SWIG library. Third party library extensions can easily install themselves by simply providing a shell script that uses 'swig -ci' to install the appropriate library files. It is not necessary to know where the SWIG library is located if you use this mechanism. *** NEW FEATURE *** 6/16/97 : Fixed a bug in shadow class generation when %name() was applied to a class definition. Unfortunately, fixing the bug required a change in the Language C API by adding an extra argument to the Language::cpp_class_decl() function. This may break SWIG C++ extensions. *** POTENTIAL INCOMPATIBILITY *** 6/15/97 : Added a warning message if no module name is specified with the %module directive or -module option. 6/15/97 : Fixed line number bug when reporting errors for undefined base classes. 6/15/97 : Added new %rename directive. This allows the forward declaration of a renaming. For example : %rename OldName NewName; .... later ... int OldName(int); Unlike %name, %rename will rename any occurrence of the old name. This applies to functions, variables, class members and so forth. There is no way to disable %rename once set, but you can change the name by redeclaring it to something else. *** NEW FEATURE *** 6/15/97 : Improved the implementation of the %name directive so that it could be used with conditional compilation : #ifdef SWIG %name(NewName) #endif int OldName(int); 6/15/97 : Added support for functions with no return datatype. In this case, SWIG assumes a return type of 'int'. 6/11/97 : Improved error reporting in the parser. It should be a little less sensitive to errors that occur inside class definitions now. Also reports errors for function pointers. 6/11/97 : Made '$' a legal symbol in identifiers. This is to support some Objective-C libraries. Some compilers (such as gcc) may also allow identifiers to contain a $ in C/C++ code as well (this is an obscure feature of C). When '$' appears in identifier, SWIG remaps it to the string '_S_' when creating the scripting language function. Thus a function 'foo$bar' would be called 'foo_S_bar'. 6/11/97 : Fixed bug in Python shadow classes with __repr__ method. If supplied by the user, it was ignored, but now it should work. 6/9/97 : Fixed the Tcl 8.0 module to work with Tcl 8.0b1. SWIG is no longer compatible with *any* alpha release of Tcl 8.0. *** POTENTIAL INCOMPATIBILITY *** 6/7/97 : Put a maximal error count in (currently set to 20). SWIG will bail out if it generates more errors than this (useful for preventing SWIG from printing 4000 syntax errors when it gets confused). 6/7/97 : Fixed segmentation fault when parsing variable length arguments. 6/7/97 : Minor change to Perl5 module. C++ static functions are now put in the same package as their class when using shadow classes. 6/7/97 : Centralized the naming of functions, members, wrappers etc... By centralizing the naming scheme, it should be possible to make some multi-file optimizations. Also, it should be possible to change SWIG's naming scheme (perhaps a new feature to be added later). 6/2/97 : Added 'arginit' typemap. This can be used to assign initial values to function arguments. Doing so makes it somewhat easier to detect improper argument passing when working with other typemaps. 6/2/97 : Fixed code generation bug when read-only variables were inherited into other classes. Under inheritance, the variables would become writable, but this has now been corrected. 5/30/97 : An empty %name() directive is no longer allowed or supported. This directive was originally used to strip the prefix off of a class or structure. Unfortunately, this never really seemed to work right and it complicated the C++ code generator significantly. As far as I can tell no one uses it, so it is now history. *** POTENTIAL INCOMPATIBILITY *** 5/28/97 : Fixed a parsing bug with #define and C++ comments. Declarations such as the following now work properly : #define CONST 4 // A Comment 5/28/97 : Made some performance improvements to the SWIG String class. (only affects the SWIG compiler itself). 5/28/97 : Modified the parser to skip template definitions and issue a warning message. 5/28/97 : Preliminary support for parameterized types added (ie. templates). Types such as the following should pass through the SWIG compiler void foo(vector *a, vector *b); When used, the entire name 'vector' becomes the name of the datatype. Due to space limitations in datatype representations, the name should not exceed 96 characters. Note : This is only part of what is needed for template support. Template class definitions are not yet supported by SWIG. The template notation above may also be used when specifying Objective-C protocol lists. *** NEW FEATURE *** 5/24/97 : First cut at Objective-C support added. As it turns out, almost everything can be handled with only a few minor modifications to the C++ module. *** NEW FEATURE *** 5/23/97 : Fixed repeated definition bug in multiple inheritance handling when multiple base classes share a common base class (ie. the evil diamond). 5/21/97 : Fixed rather embarrassing typo that worked its way into the Tests/Build directory. 5/19/97 : Fixed code generation bug when using native methods and shadow classes with Python and Perl5 modules. 5/19/97 : Modified the %apply directive slightly so that it would work with pointers a little better. For example : %apply unsigned long { DWORD }; Applies *all* typemaps associated with "unsigned long" to "DWORD". This now includes pointers to the two datatypes. For example, a typemap applied to "unsigned long **" would also be applied to any occurrence of "DWORD **" as well. 5/19/97 : Fixed an ownership assignment bug in the Perl5 module when class members were returning new objects belonging to different classes. 5/17/97 : Added a few more typemap variables. $name - Name of function/variable/member $basetype - Base datatype (type without pointers) $argnum - Argument number 5/16/97 : Fixed embarrassing underscore error in local variable allocator. 5/16/97 : Fixed namespace clash bug in parameterized typemaps when creating arrays as new local variables. 5/15/97 : Fixed some bugs with inheritance of added methods across multiple files. SWIG now uses names of base classes when generating such functions. 5/14/97 : Finished support for default typemaps. Primarily used internally, they can be used to match the basic built-in datatypes used inside of SWIG. You can specify them in interface files as well like this : %typemap(tcl,in) int SWIG_DEFAULT_TYPE { $target = atoi($target); } Unlike normal typemaps, this default map will get applied to *all* integer datatypes encountered, including those renamed with typedef, etc... 5/13/97 : Fixed substring bug in type checker. 5/12/97 : Fixed bug in parameterized typemaps when declaring local variables of structures. Version 1.1 Beta6 (May 9, 1997) =============================== 5/9/97 : Fixed bizarre NULL pointer handling bug in Perl5 module. 5/8/97 : Fixed mysterious segmentation fault when running SWIG on an empty file. 5/7/97 : The code generator will now replace the special symbol "$cleanup" with the cleanup code specified with the "freearg" typemap. This change needed to properly manage memory and exceptions. 5/5/97 : Added the 'typemaps.i' library file. This contains a variety of common typemaps for input values, pointers, and so on. 5/5/97 : Changed behavior of "argout" typemap in Python module. Old versions automatically turned the result into a Python list. The new version does nothing, leaving the implementation up to the user. This provides more flexibility but may break older codes that rely on typemaps. *** POTENTIAL INCOMPATIBILITY *** 5/5/97 : Fixed bug in Python module related to the interaction of "argout" and "ignore" typemaps. 5/5/97 : Fixed bug in Python module that would generate incorrect code if all function arguments are "ignored". 5/4/97 : Added %apply and %clear directives. These form a higher level interface to the typemap mechanism. In a nutshell, they can be used to change the processing of various datatypes without ever having to write a typemap. See the SWIG documentation for more details. ** NEW FEATURE ** 5/4/97 : Added a local variable extension to the typemap handler. For example : %typemap(tcl,in) double *(double temp) { temp = atof($source); $target = &temp; } In this case, 'temp' is a local variable that exists in the entire wrapper function (not just the typemap code). This mechanism provides better support for certain types of argument handling and also makes it possible to write thread-safe typemaps. Any number local variables can be declared by supplying a comma separated list. Local variables are guaranteed to be unique, even if the same typemap is applied many times in a given function. ** Not currently supported in Perl4 or Guile modules. 5/2/97 : Fixed processing of %ifdef, %endif, %if, etc... (These are SWIG equivalents of the C preprocessor directives that can pass through the C preprocessor without modification). 5/2/97 : Fixed major (but subtle) bug in the run-time type checker related to searching and type-checking for C++ inheritance. To make a long story short, if you had two classes named "Foo" and "FooObject" the type checker would sometimes get confused and be unable to locate "Foo" in an internal table. 5/2/97 : Fixed some bugs in the -co option. 4/24/97 : Pointer library added to the SWIG library. 4/19/97 : Added the %new directive. This is a "hint" that can be used to tell SWIG that a function is returning a new object. For example : %new Foo *create_foo(); This tells SWIG that create_foo() is creating a new object and returning a pointer to it. Many language modules may choose to ignore the hint, but when working with shadow classes, the %new is used to handle proper ownership of objects. %new can also be used with dynamically allocated strings. For example : %new char *create_string(); When used, all of the language modules will automatically cleanup the returned string--eliminating memory leaks. ** NEW FEATURE ** 4/19/97 : Added a new typemap "newfree". This is used in conjunction with the %new directive and can be used to change the method by which a new object returned by a function is deleted. 4/19/97 : The symbol "__cplusplus" is now defined in the SWIG interpreter when running with the -c++ option. 4/17/97 : Added support for static member functions when used inside the %addmethods directive. 4/15/97 : Added a special typemap symbol PREVIOUS that can be used to restore a previous typemap. For example : %typemap(tcl,in) int * = PREVIOUS; This is primarily used in library files. 4/13/97 : Added %pragma directive for Perl5 module. Two new pragmas are available : %pragma(perl5) code = "string" %pragma(perl5) include = "file.pl" Both insert code into the .pm file created by SWIG. This can be used to automatically customize the .pm file created by SWIG. 4/13/97 : Scanner modified to only recognize C++ keywords when the -c++ option has been specified. This provides support for C programs that make use of these keywords for identifiers. SWIG may need to be explicitly run with the -c++ option when compiling C++ code (this was allowed, but not recommended in previous versions). **POTENTIAL INCOMPATIBILITY** 4/11/97 : Fixed a rather nasty bug in the Perl5 module related to using variable linking with complex datatypes and pointers. On Unix, code would work (somehow), but would cause an access violation under Windows-NT. The fix should correct the problem, but there may still be a problem using global variables of complex datatypes in conjunction with shadow classes. Fortunately, this sort of thing seems to be relatively rare (considering that the bug has been around for more than a year - yikes!). 4/11/97 : Fixed bizarre constant evaluation bug in Perl5 code generation when running under Windows-NT. 4/8/97 : Bug when using default arguments and C++ references fixed. 4/8/97 : Fixed code generation bugs in Python and Perl5 modules related to using class renaming (applying the %name directive to a class definition) and shadow classes. 4/7/97 : Fixed minor bugs in swigptr.swg, tcl8ptr.swg, and perl5ptr.swg to prevent infinite loops when weird datatypes are passed. 3/29/97 : 'Makefile.win' added. This is used to build most of the examples in the Examples directory under Windows NT/95. 3/27/97 : Fixes to SWIG's error return codes. SWIG now returns non-zero exit codes for certain kinds of errors (which makes it more friendly to makefiles). An overhaul of the error handling is on the to-do list and will probably show up in a later release. 3/25/97 : Bug fix. "freearg" and "argout" typemaps have been fixed in the Perl5 module. In previous versions, function input parameters and function output parameters shared the same memory space--causing all sorts of nasty problems when trying to pass perl values by reference. SWIG now internally makes a "copy" (which is really just a pointer) of affected parameters and uses that. This is done transparently so there is no noticable impact on any SWIG generated modules. This change is probably only noticable to expert users. 3/25/97 : Added type-check to verbose and stat mode. SWIG will now generate a list of all datatypes that were used but undefined (useful for tracking down weird bugs). This is enabled with the -v option (which is now officially known as "overly verbose" mode) or the -stat option. 3/25/97 : Slight change to the parser to make include guards work correctly. For example : #ifndef INTERFACE_I #define INTERFACE_I %module foobar.i ... declarations ... #endif 3/24/97 : %checkout directive added. This allows an interface file to extract files from the SWIG library and place them in the current directory. This can be used to extract scripts and other helper code that might be associated with library files. For example : %checkout array.tcl Will look for a file "array.tcl" in the library and copy it to the current directory. If the file already exists in the directory, this directive does nothing (it will not overwrite an existing file). This only an experimental feature for now. 3/24/97 : SWIG will now look in the SWIG Library for a file if it can't find it in the current directory. As a result, it is easy to make modules from SWIG library files. For example, if you want to make a Python module from the SWIG timers library, just type this in any directory : swig -python timers.i You will get the files timers_wrap.c and timers_wrap.doc in the current directory that you can now compile. The file remains in the SWIG library (although you can check it out using the -co option). *** New Feature *** 3/24/97 : -co option added to SWIG to allow easy access to the SWIG library. When used, this instructs SWIG to check out a library file and place it in the current directory. For example : unix > swig -co array.i array.i checked out from the SWIG library unix > Once in your directory you can customize the file to suit your particular purposes. The checkout option makes it easy to grab library files without knowing anything about the SWIG installation, but it also makes it possible to start including scripts, C code, and other miscellaneous files in the library. For example, you could put a cool script in the library and check it out whenever you wanted to use it. *** New Feature *** 3/24/97 : #pragma export directives added to Tcl output for compiling shared libraries on the Mac. 3/24/97 : Minor changes to wish.i and tclsh.i library files to provide support for the Macintosh. 3/19/97 : SWIG's policy towards NULL pointers has been relaxed. The policy of requiring a special compiler directive -DALLOW_NULL to use NULL pointers is no longer supported. While this may seem "unsafe", it turns out that you can use a "check" typemap to achieve some safety. For example : %typemap(perl5,check) Node * { if (!$target) croak("NULL Pointers not allowed."); } This prevents any NULL value of a "Node *" pointer to be passed to a function. (I think this is much cleaner than the old -DALLOW_NULL hack anyways). 3/19/97 : Fixed pointer handling errors in Perl5 module. Modules no longer core dump when a Perl reference is inadvertently passed in as a C pointer. 3/18/97 : Added a "check" typemap. This can be used to check the validity of function input values. For example : %typemap(perl5,check) int posint { if ($target < 0) croak("Argument is not a positive integer"); } 3/18/97 : Added an $arg variable to Tcl typemaps. This makes it easier to return argument values by "reference". 3/18/97 : Fixed a code generation bug when using C++ references and the %addmethods directive. 3/18/97 : Fixed a few glitches in the typemap module with respect to chaining. For example : %typemap(tcl,in) int { $in // Inserts prexisting typemap printf("Received a %d\n", $target); } This has been allowed for quite some time, but didn't work if no existing typemap was defined. Now, it still doesn't work if no existing typemap is defined, but it issues a warning message. There is some support using default typemaps, but none of the language modules take advantage of it. This should be considered experimental at this time. Version 1.1b5 Patch 1 (March 16, 1997) ====================================== 3/16/97 : Fixed references bug with C++ code generation. 3/16/97 : Fixed initialization bug in the documentation system that was causing weird problems. 3/16/97 : Fixed fatal bug with -c option in the Python module. 3/13/97 : Fixed bug in the documentation system involving the %text directive and sorting. In the old system, %text entries would float to the top of a section because they were "nameless". Now they are attached to the previous declaration and will stay in the proper location relative to the previous entry. Version 1.1b5 (March 12, 1997) ============================== 3/11/97 : Fixed compilation problems introduced by Tcl/Tk 8.0a2. *** INCOMPATIBILITY *** SWIG no longer works with Tcl/Tk 8.0a1. 3/10/97 : Fixed bug with ignored arguments and C++ member functions in the Python module. 3/9/97 : Parsing bugs with nested class definitions and privately declared nested class definitions fixed. 3/9/97 : Fixed a few minor code generation bugs with C++ classes and constructors. In some cases, the resulting wrapper code would not compile properly. SWIG now attempts to use the default copy constructor instead. 3/8/97 : Added a -l option to SWIG that allows additional SWIG library files to be grabbed without having them specified in the interface file. This makes it easier to keep the interface file clean and move certain options into a Makefile. For example : swig -tcl example.i # Build a normal Tcl extension swig -tcl -lwish.i example.i # Build it as a wish extension # by including the 'wish.i' file. swig -python example.i # Build a dynamically loaded extension swig -python -lembed.i example.i # Build a static extension These kinds of options could previously be accomplished with conditional compilation such as : %module example ... #ifdef STATIC %include embed.i #endif 3/8/97 : Incorporated changes to Guile module to use the new gh interface in FSF Guile 1.0. The older gscm interface used in Cygnus Guile releases is no longer supported by SWIG. 3/8/97 : Cleaned up the Tcl Netscape plugin example. It should work with version 1.1 of the plugin now. 3/8/97 : Added better array support to the typemap module. The keyword ANY can now be used to match any array dimension. For example : %typemap(tcl,in) double [ANY] { ... get an array ... } This will match any single-dimensional double array. The array dimension is passed in the variables $dim0, $dim1, ... $dim9. For example : %typemap(tcl,in) double [ANY][ANY][ANY] { printf("Received a double[%d][%d][%d]\n",$dim0,$dim1,$dim2); } Any typemap involving a specific array dimension will override any specified with the ANY tag. Thus, a %typemap(tcl,in) double [5][4][ANY] {} would override a double [ANY][ANY][ANY]. However, overuse of the ANY tag in arrays of high-dimensions may not work as you expect due to the pattern matching rule used. For example, which of the following typemaps has precedence? %typemap(in) double [ANY][5] {} // Avoid this! %typemap(in) double [5][ANY] {} 3/7/97 : Fixed a number of bugs related to multi-dimensional array handling. Typedefs involving multi-dimensional arrays now works correctly. For example : typedef double MATRIX[4][4]; ... extern double foo(MATRIX a); Typecasting of pointers into multi-dimensional arrays is now implemented properly when making C/C++ function calls. 3/6/97 : Fixed potentially dangerous bug in the Tcl Object-oriented interface. Well, actually, didn't fix it but issued a Tcl error instead. The bug would manifest itself as follows: % set l [List] # Create an object ... % set m [List -this $l] # Make $m into an object assuming $l # contains a pointer. # Since $m == $l, $l gets destroyed # (since its the same command name) % $m insert Foo Segmentation fault # Note : the list no longer exists! Now, an error will be generated instead of redefining the command. As in : % set l [List] ... % set m [List -this $l] Object name already exists! Use catch{} to ignore the error. 3/3/97 : Better support for enums added. Datatypes of 'enum MyEnum' and typedefs such as 'typedef enum MyEnum Foo;' now work. 3/3/97 : Parser modified to ignore constructor initializers such as : class Foo : public Bar { int a,b; public: Foo(int i) : a(0), b(i), Bar(i,0) { }; }; 3/3/97 : Modified parser to ignore C++ exception specifications such as : int foo(double) throw(X,Y); 3/3/97 : Added %import directive. This works exactly like %extern except it tells the language module that the declarations are coming from a separate module. This is usually only needed when working with shadow classes. 3/2/97 : Changed pointer type-checker to be significantly more efficient when working with derived datatypes. This has been accomplished by storing type-mappings in sorted order, using binary search schemes, and caching recently used datatypes. For SWIG generated C++ modules that make a large number of C function calls with derived types, this could result in speedups of between 100 and 50000 percent. However, due to the required sorting operation, module loading time may increased slightly when there are lots of datatypes. 3/2/97 : Fixed some C++ compilation problems with Python embed.i library files. 2/27/97 : Slight change to C++ code generation to use copy constructors when returning complex data type by value. 2/26/97 : Fixed bug in Python module with -c option. 2/26/97 : Slight tweak of parser to allow trailing comma in enumerations such as enum Value (ALE, STOUT, LAGER, }; 2/25/97 : Fixed code generation bug in Tcl module when using the %name() directive on a classname. 2/25/97 : Finished code-size optimization of C++ code generation with inheritance of attributes. Inherited attributes now only generate one set of wrapper functions that are re-used in any derived classes. This could provide big code size improvements in some scripting language interfaces. 2/25/97 : Perl5 module modified to support both the Unix and Windows versions. The windows version has been tested with the Activeware port of Perl 5.003 running under Windows 95. The C source generated by SWIG should compile without modification under both versions of Perl, but is now even more hideous than before. 2/25/97 : Modified parser to allow scope resolution operation to appear in expressions and default arguments as in : void foo(int a = Bar::defvalue); 2/25/97 : Fixed bug when resolving symbols inside C++ classes. For example : class Foo { public: enum Value {ALE, STOUT, LAGER}; ... void defarg(Value v = STOUT); }; 2/24/97 : Fixed bug with member functions returning void *. 2/23/97 : Modified Python module to be better behaved under Windows - Module initialization function is now properly exported. It should not be neccessary to explicitly export this function yourself. - Bizarre compilation problems when compiling the SWIG wrapper code as ANSI C under Visual C++ 4.x fixed. - Tested with both the stock Python-1.4 distribution and Pythonwin running under Win95. 2/19/97 : Fixed typedef handling bug in Perl5 shadow classes. 2/19/97 : Added exception support. To use it, do the following : %except(lang) { ... try part of the exception ... $function ... catch part of exception ... } $function is a SWIG variable that will be replaced by the actual C/C++ function call in a wrapper function. Thus, a real exception specification might look like this : %except(perl5) { try { $function } catch (char *& sz) { ... process an exception ... } catch(...) { croak("Unknown exception. Bailing out..."); } } 2/19/97 : Added support for managing generic code fragments (needed for exceptions). 2/19/97 : Fixed some really obscure typemap scoping bugs in the C++ handler. 2/18/97 : Cleaned up perlmain.i file by removing some problematic, but seemingly unnecessary declarations. 2/18/97 : Optimized handling of member functions under inheritance. SWIG can now use wrapper functions generated for a base class instead of regenerating wrappers for the same functions in a derived class. This could make a drastic reduction in wrapper code size for C++ applications with deep inheritance hierarchies and lots of functions. 2/18/97 : Additional methods specified with %addmethods can now be inherited along with normal C++ member functions. 2/18/97 : Minor internal fixes to make SWIG's string handling a little safer. 2/16/97 : Moved some code generation of Tcl shadow classes to library files. 2/16/97 : Fixed documentation error of '-configure' method in Tcl modules. 2/16/97 : Modified Perl5 module slightly to allow typemaps to use Perl references. 2/12/97 : Fixed argument checking bug that was introduced by default arguments (function calls with too many arguments would still be executed). Functions now must have the same number of arguments as C version (with possibility of default/optional arguments still supported). 2/12/97 : Fixed default argument bug in Perl5 module when generating wrapper functions involving default arguments of complex datatypes. 2/12/97 : Fixed typemap scoping problems. For example : %typemap(tcl,in) double { .. get a double .. } class Foo { public: double bar(double); } %typemap(tcl,in) double { .. new get double .. } Would apply the second typemap to all functions in Foo due to delayed generation of C++ wrapper code (clearly this is not the desired effect). Problem has been fixed by assigning unique numerical identifiers to every datatype in an interface file and recording the "range of effect" of each typemap. 2/11/97 : Added support for "ignore" and "default" typemaps. Only use if you absolutely know what you're doing. 2/9/97 : Added automatic creation of constructors and destructors for C structs and C++ classes that do not specify any sort of constructor or destructor. This feature can be enabled by running SWIG with the '-make_default' option or by inserting the following pragma into an interface file : %pragma make_default The following pragma disables automatic constructor generation %pragma no_default 2/9/97 : Added -make_default option for producing default constructors and destructors for classes without them. 2/9/97 : Changed the syntax of the SWIG %pragma directive to %pragma option=value or %pragma(lang) option=value. This change makes the syntax a little more consistent between general pragmas and language-specific pragmas. The old syntax still works, but will probably be phased out (a warning message is currently printed). 2/9/97 : Improved Tcl support of global variables that are of structures, classes, and unions. 2/9/97 : Fixed C++ compilation problem in Python 'embed.i' library file. 2/9/97 : Fixed missing return value in perlmain.i library file. 2/9/97 : Fixed Python shadow classes to return an AttributeError when undefined attributes are accessed (older versions returned a NameError). 2/9/97 : Fixed bug when %addmethods is used after a class definition whose last section is protected or private. 2/8/97 : Made slight changes in include file processing to support the Macintosh. 2/8/97 : Extended swigmain.cxx to provide a rudimentary Macintosh interface. It's a really bad interface, but works until something better is written. 1/29/97 : Fixed type-casting bug introduced by 1.1b4 when setting/getting the value of global variables involving complex data types. 1/29/97 : Removed erroneous white space before an #endif in the code generated by the Python module (was causing errors on DEC Alpha compilers). 1/26/97 : Fixed errors when using default/optional arguments in Python shadow shadow classes. 1/23/97 : Fixed bug with nested %extern declarations. 1/21/97 : Fixed problem with typedef involving const datatypes. 1/21/97 : Somewhat obscure, but serious bug with having multiple levels of typedefs fixed. For example : typedef char *String; typedef String Name; Version 1.1 Beta4 (January 16, 1997) ==================================== Note : SWIG 1.1b3 crashed and burned shortly after take off due to a few major run-time problems that surfaced after release. This release should fix most, if not all, of those problems. 1/16/97 : Fixed major memory management bug on Linux 1/14/97 : Fixed bug in functions returning constant C++ references. 1/14/97 : Modified C++ module to handle datatypes better. 1/14/97 : Modified parser to allow a *single* scope resolution operator in datatypes. Ie : Foo::bar. SWIG doesn't yet handle nested classes, so this should be sufficient for now. 1/14/97 : Modified parser to allow typedef inside a C++ class. 1/14/97 : Fixed some problems related to datatypes defined inside a C++ class. SWIG was not generating correct code, but a new scoping mechanism and method for handling datatypes inside a C++ class have been added. 1/14/97 : Changed enumerations to use the value name instead of any values that might have appeared in the interface file. This makes the code a little more friendly to C++ compilers. 1/14/97 : Removed typedef bug that made all enumerations equivalent to each other in the type checker (since it generated alot of unnecessary code). Version 1.1 Beta3 (January 9, 1997) =================================== Note : A *huge* number of changes related to ongoing modifications. 1. Support for C++ multiple inheritance added. 2. Typemaps added. 3. Some support for nested structure definitions added. 4. Default argument handling added. 5. -c option added for building bare wrapper code modules. 6. Rewrote Pointer type-checking to support multiple inheritance correctly. 7. Tcl 8.0 module added. 8. Perl4 and Guile modules resurrected from the dead (well, they at least work again). 9. New Object Oriented Tcl interface added. 10. Bug fixes to Perl5 shadow classes. 11. Cleaned up many of the internal modules of the parser. 12. Tons of examples and testing modules added. 13. Fixed bugs related to use of "const" return values. 14. Fixed bug with C++ member functions returning void *. 15. Changed SWIG configuration script. Version 1.1 Beta2 (December 3, 1996) ==================================== 1. Completely rewrote the SWIG documentation system. The changes involved are too numerous to mention. Basically, take everything you knew about the old system, throw them out, and read the file Doc/doc.ps. 2. Limited support for #if defined() added. 3. Type casts are now allowed in constant expressions. ie #define A (int) 3 4. Added support for typedef lists. For example : typedef struct { double x,y,z; } Vector, *VectorPtr; 5. New SWIG directives (related to documentation system) %style %localstyle %subsection %subsubsection 6. Reorganized the C++ handling and made it a little easier to work with internally. 7. Fixed problem with inheriting data members in Python shadow classes. 8. Fixed symbol table problems with shadow classes in both Python and Perl. 9. Fixed annoying segmentation fault bug in wrapper code generated for Perl5. 10. Fixed bug with %addmethods directive. Now it can be placed anywhere in a class. 11. More test cases added to the SWIG self-test. Documentation tests are now performed along with other things. 12. Reorganized the SWIG library a little bit and set it up to self-document itself using SWIG. 13. Lots and lots of minor bug fixes (mostly obscure, but bugs nonetheless). Version 1.1 Beta1 (October 30, 1996) ==================================== 1. Added new %extern directive for handling multiple files 2. Perl5 shadow classes added 3. Rewrote conditional compilation to work better 4. Added 'bool' datatype 5. %{,%} block is now optional. 6. Fixed some bugs in the Python shadow class module 7. Rewrote all of the SWIG tests to be more informative (and less scary). 8. Rewrote parameter list handling to be more memory efficient and flexible. 9. Changed parser to ignore 'static' declarations. 10. Initializers are now ignored. For example : struct FooBar a = {3,4,5}; 11. Somewhat better parsing of arrays (although it's usually just a better error message now). 12. Lot's of minor bug fixes. Version 1.0 Final (August 31, 1996) =================================== 1. Fixed minor bug in C++ module 2. Fixed minor bug in pointer type-checker when using -DALLOW_NULL. 3. Fixed configure script to work with Python 1.4beta3 4. Changed configure script to allow compilation without yacc or bison. Version 1.0 Final (August 28, 1996) =================================== 1. Changed parser to support more C/C++ datatypes (well, more variants). Types like "unsigned", "short int", "long int", etc... now work. 2. "unions" added to parser. 3. Use of "typedef" as in : typedef struct { double x,y,z; } Vector; Now works correctly. The name of the typedef is used as the structure name. 4. Conditional compilation with #ifdef, #else, #endif, etc... added. 5. New %disabledoc, %enabledoc directives allow documentation to selectively be disabled for certain parts of a wrapper file. 6. New Python module supports better variable linking, constants, and shadow classes. 7. Perl5 module improved with better compatibility with XS and xsubpp. SWIG pointers and now created so that they are compatible with xsubpp pointers. 8. Support for [incr Tcl] namespaces added to Tcl module. 9. %pragma directive added. 10. %addmethods directive added. 11. %native directive added to allow pre-existing wrapper functions to be used. 12. Wrote configure script for SWIG installation. 13. Function pointers now allowed with typedef statements. 14. %typedef modified to insert a corresponding C typedef into the output file. 15. Fixed some problems related to C++ references. 16. New String and WrapperFunction classes add to make generating wrapper code easier. 17. Fixed command line option processing to eliminate core dumps and to allow help messages. 18. Lot's of minor bug fixes to almost all code modules Version 1.0 Beta 3 (Patch 1) July 17, 1996 ========================================== 1.0 Final is not quite ready yet, but this release fixes a number of immediate problems : 1. Compiler errors when using -strict 1 type checking have been fixed. 2. Pointer type checker now recognizes pointers of the form _0_Type correctly. 3. A few minor fixes were made in the Makefile Version 1.0 Beta 3 (June 14, 1996) ================================== There are lots of changes in this release : 1. SWIG is now invoked using the "swig" command instead of "wrap". Hey, swig sounds cooler. 2. The SWIG_LIB environment variable can be set to change the location where SWIG looks for library files. 3. C++ support has been added. You should use the -c++ option to enable it. 4. The %init directive has been replaced by the %module directive. %module constructs a valid name for the initialization function for whatever target language you're using (actually this makes SWIG files a little cleaner). The old %init directive still works. 5. The syntax of the %name directive has been changed. Use of the old one should generate a warning message, but may still work. 6. To support Tcl/Tk on non-unix platforms, SWIG imports a file called swigtcl.cfg from the $(SWIG_LIB)/tcl directory. I don't have access to an NT machine, but this file is supposedly allows SWIG to produce wrapper code that compiles on both UNIX and non UNIX machines. If this doesn't work, you'll have to edit the file swigtcl.cfg. Please let me know if this doesn't work so I can update the file as necessary. 7. The SWIG run-time typechecker has been improved. You can also now redefine how it works by supplying a file called "swigptr.cfg" in the same directory as your SWIG interface files. By default, SWIG reads this file from $(SWIG_LIB)/config. 8. The documentation system has been changed to support the following : - Documentation order is printed in interface file order by default. This can be overridden by putting an %alpha directive in the beginning of the interface file. - You can supply additional documentation text using %text %{ put your text here %} - A few minor bugs were fixed. 9. A few improvements have been made to the handling of command line options (but it's still not finished). 10. Lots of minor bug fixes in most of the language modules have been made. 11. Filenames have been changed to 8.3 for compatibility with a SWIG port to non-unix platforms (work in progress). 12. C++ file suffix is now .cxx (for same reason). 13. The documentation has been upgraded significantly and is now around 100 pages. I added new examples and a section on C++. The documentation now includes a Table of Contents. 14. The SWIG Examples directory is still woefully sparse, but is getting better. Special notice about C++ ------------------------ This is the first version of SWIG to support C++ parsing. Currently the C++ is far from complete, but seems to work for simple cases. No work has been done to add special C++ processing to any of the target languages. See the user manual for details about how C++ is handled. If you find problems with the C++ implementation, please let me know. Expect major improvements in this area. Note : I have only successfully used SWIG and C++ with Tcl and Python. Notice about Version 1.0Final ----------------------------- Version 1.0B3 is the last Beta release before version 1.0 Final is released. I have frozen the list of features supported in version 1.0 and will only fix bugs as they show up. Work on SWIG version 2.0 is already in progress, but is going to result in rather significant changes to SWIG's internal structure (hopefully for the better). No anticipated date for version 2.0 is set, but if you've got an idea, let me know. Version 1.0 Beta 2 (April 26, 1996) =================================== This release is identical to Beta1 except a few minor bugs are fixed and the SWIG library has been updated to work with Tcl 7.5/Tk 4.1. A tcl7.5 examples directory is now included. - Fixed a bug in the Makefile that didn't install the libraries correctly. - SWIG Library files are now updated to work with Tcl 7.5 and Tk 4.1. - Minor bug fixes in other modules. Version 1.0 Beta 1 (April 10, 1996). ===================================== This is the first "semi-official" release of SWIG. It has a number of substantial improvements over the Alpha release. These notes are in no particular order--hope I remembered everything.... 1. Tcl/Tk SWIG is known to work with Tcl7.3, Tk3.6 and later versions. I've also tested SWIG with expect-5.19. Normally SWIG expects to use the header files "tcl.h" and "tk.h". Newer versions of Tcl/Tk use version numbers. You can specify these in SWIG as follows : % wrap -htcl tcl7.4.h -htk tk4.0.h example.i Of course, I prefer to simply set up symbolic links between "tcl.h" and the most recent stable version on the machine. 2. Perl4 This implementation has been based on Perl-4.035. SWIG's interface to Perl4 is based on the documentation provided in the "Programming Perl" book by Larry Wall, and files located in the "usub" directory of the Perl4 distribution. In order to compile with Perl4, you'll need to link with the uperl.o file found in the Perl4 source directory. You may want to move this file to a more convenient location. 3. Perl5 This is a somewhat experimental implementation, but is alot less buggy than the alpha release. SWIG operates independently of the XS language and xsubpp supplied with Perl5. Currently SWIG produces the necessary C code and .pm file needed to dynamically load a module into Perl5. To support Perl5's notion of modules and packages (as with xsubpp), you can use the following command line options : % wrap -perl5 -module MyModule -package MyPackage example.i Note : In order for dynamic loading to be effective, you need to be careful about naming. For a module named "MyModule", you'll need to create a shared object file called "MyModule.so" using something like % ld -shared my_obj.o -o MyModule.so The use of the %init directive must match the module name since Perl5 calls a function "boot_ModuleName" in order to initialize things. See the Examples directory for some examples of how to get things to work. 4. Python1.3 This is the first release supporting Python. The Python port is experimental and may be rewritten. Variable linkage is done through functions which is sort of a kludge. I also think it would be nice to import SWIG pointers into Python as a new object (instead of strings). Of course, this needs a little more work. 5. Guile3 If you really want to live on the edge, pick up a copy of Guile-iii and play around with this. This is highly experimental---especially since I'm not sure what the official state of Guile is these days. This implementation may change at any time should I suddenly figure out better ways to do things. 6. Extending SWIG SWIG is written in C++ although I tend to think of the code as mostly being ANSI C with a little inheritance thrown in. Each target language is implemented as a C++ class that can be plugged into the system. If you want to add your own modifications, see Appendix C of the user manual. Then take a look at the "user" directory which contains some code for building your own extenions. 7. The SWIG library The SWIG library is still incomplete. Some of the files mentioned in the user manual are unavailable. These files will be made available when they are ready. Subscribe to the SWIG mailing list for announcements and updates. 8. SWIG Documentation I have sometimes experienced problems viewing the SWIG documentation in some postscript viewers. However, the documentation seems to print normally. I'm working on making much of the documentation online, but this takes time. Version 0.1 Alpha (February 9, 1996) ==================================== 1. Run-time type-checking of SWIG pointers. Pointers are now represented as strings with both numeric and encoded type information. This makes it a little harder to shoot yourself in the foot (and it eliminates some segmentation faults and other oddities). 2. Python 1.3 now supported. 3. #define and enum can be used to install constants. 4. Completely rewrote the %include directive and made it alot more powerful. 5. Restructured the SWIG library to make it work better. 6. Various bug fixes to Tcl, Perl4, Perl5, and Guile implementations. 7. Better implementation of %typedef directive. 8. Made some changes to SWIG's class structure to make it easier to expand. SWIG is now built into a library file that you can use to make your own extenions. 9. Made extensive changes to the documentation. 10. Minor changes to the SWIG parser to make it use less memory. Also took out some extraneous rules that were undocumented and didn't work in the first place. 11. The SWIG library files "tclsh", "wish", "expect", etc... in the first release have been restructured and renamed to "tclsh.i", "wish.i", and so on. swig-3.0.8/preinst-swig.in0000775000175000017500000000035612641054563015353 0ustar williamwilliam#!/bin/sh # Convenience script for running SWIG before it is installed. # Intended for ad-hoc usage and not by the test-suite or examples. builddir=`dirname "$0"` SWIG_LIB='@SWIG_LIB_PREINST@' export SWIG_LIB exec "$builddir/swig" "$@" swig-3.0.8/CCache/0000775000175000017500000000000012641164620013463 5ustar williamwilliamswig-3.0.8/CCache/README.swig0000664000175000017500000000072012641054563015316 0ustar williamwilliamThis directory contains a version of ccache. The initial version was based on ccache-2.4 plus debian patches 01-02, 04-14, see the debian/patches subdirectory. The ccache-win32-2.4 modifications to ccache-2.4 have also been merged in. Changes have been made to support cacheing the output from SWIG. The ability to cache c/c++ compiler output has been retained. Additional features added are the CCACHE_VERBOSE and CCACHE_SWIG environment variables, see docs. swig-3.0.8/CCache/ccache_swig_config.h.in0000664000175000017500000000005112641054563020025 0ustar williamwilliam#define SWIG_VERSION "@PACKAGE_VERSION@" swig-3.0.8/CCache/snprintf.c0000664000175000017500000005346612641054563015514 0ustar williamwilliam/* * Copyright Patrick Powell 1995 * This code is based on code written by Patrick Powell (papowell@astart.com) * It may be used for any purpose as long as this notice remains intact * on all source code distributions */ /************************************************************** * Original: * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 * A bombproof version of doprnt (dopr) included. * Sigh. This sort of thing is always nasty do deal with. Note that * the version here does not include floating point... * * snprintf() is used instead of sprintf() as it does limit checks * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from * causing nast effects. * * More Recently: * Brandon Long 9/15/96 for mutt 0.43 * This was ugly. It is still ugly. I opted out of floating point * numbers, but the formatter understands just about everything * from the normal C string format, at least as far as I can tell from * the Solaris 2.5 printf(3S) man page. * * Brandon Long 10/22/97 for mutt 0.87.1 * Ok, added some minimal floating point support, which means this * probably requires libm on most operating systems. Don't yet * support the exponent (e,E) and sigfig (g,G). Also, fmtint() * was pretty badly broken, it just wasn't being exercised in ways * which showed it, so that's been fixed. Also, formated the code * to mutt conventions, and removed dead code left over from the * original. Also, there is now a builtin-test, just compile with: * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm * and run snprintf for results. * * Thomas Roessler 01/27/98 for mutt 0.89i * The PGP code was using unsigned hexadecimal formats. * Unfortunately, unsigned formats simply didn't work. * * Michael Elkins 03/05/98 for mutt 0.90.8 * The original code assumed that both snprintf() and vsnprintf() were * missing. Some systems only have snprintf() but not vsnprintf(), so * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. * * Andrew Tridgell (tridge@samba.org) Oct 1998 * fixed handling of %.0f * added test for HAVE_LONG_DOUBLE * * tridge@samba.org, idra@samba.org, April 2001 * got rid of fcvt code (twas buggy and made testing harder) * added C99 semantics * **************************************************************/ #ifndef NO_CONFIG_H /* for some tests */ #include "config.h" #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_CTYPE_H #include #endif #include #include #ifdef HAVE_STDLIB_H #include #endif #if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) /* only include stdio.h if we are not re-defining snprintf or vsnprintf */ #include /* make the compiler happy with an empty file */ void dummy_snprintf(void) {} #else #ifdef HAVE_LONG_DOUBLE #define LDOUBLE long double #else #define LDOUBLE double #endif #ifdef HAVE_LONG_LONG #define LLONG long long #else #define LLONG long #endif static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args); static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max); static void fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags); static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); /* * dopr(): poor man's version of doprintf */ /* format read states */ #define DP_S_DEFAULT 0 #define DP_S_FLAGS 1 #define DP_S_MIN 2 #define DP_S_DOT 3 #define DP_S_MAX 4 #define DP_S_MOD 5 #define DP_S_CONV 6 #define DP_S_DONE 7 /* format flags - Bits */ #define DP_F_MINUS (1 << 0) #define DP_F_PLUS (1 << 1) #define DP_F_SPACE (1 << 2) #define DP_F_NUM (1 << 3) #define DP_F_ZERO (1 << 4) #define DP_F_UP (1 << 5) #define DP_F_UNSIGNED (1 << 6) /* Conversion Flags */ #define DP_C_SHORT 1 #define DP_C_LONG 2 #define DP_C_LDOUBLE 3 #define DP_C_LLONG 4 #define char_to_int(p) ((p)- '0') #ifndef MAX #define MAX(p,q) (((p) >= (q)) ? (p) : (q)) #endif static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args) { char ch; LLONG value; LDOUBLE fvalue; char *strvalue; int min; int max; int state; int flags; int cflags; size_t currlen; state = DP_S_DEFAULT; currlen = flags = cflags = min = 0; max = -1; ch = *format++; while (state != DP_S_DONE) { if (ch == '\0') state = DP_S_DONE; switch(state) { case DP_S_DEFAULT: if (ch == '%') state = DP_S_FLAGS; else dopr_outch (buffer, &currlen, maxlen, ch); ch = *format++; break; case DP_S_FLAGS: switch (ch) { case '-': flags |= DP_F_MINUS; ch = *format++; break; case '+': flags |= DP_F_PLUS; ch = *format++; break; case ' ': flags |= DP_F_SPACE; ch = *format++; break; case '#': flags |= DP_F_NUM; ch = *format++; break; case '0': flags |= DP_F_ZERO; ch = *format++; break; default: state = DP_S_MIN; break; } break; case DP_S_MIN: if (isdigit((unsigned char)ch)) { min = 10*min + char_to_int (ch); ch = *format++; } else if (ch == '*') { min = va_arg (args, int); ch = *format++; state = DP_S_DOT; } else { state = DP_S_DOT; } break; case DP_S_DOT: if (ch == '.') { state = DP_S_MAX; ch = *format++; } else { state = DP_S_MOD; } break; case DP_S_MAX: if (isdigit((unsigned char)ch)) { if (max < 0) max = 0; max = 10*max + char_to_int (ch); ch = *format++; } else if (ch == '*') { max = va_arg (args, int); ch = *format++; state = DP_S_MOD; } else { state = DP_S_MOD; } break; case DP_S_MOD: switch (ch) { case 'h': cflags = DP_C_SHORT; ch = *format++; break; case 'l': cflags = DP_C_LONG; ch = *format++; if (ch == 'l') { /* It's a long long */ cflags = DP_C_LLONG; ch = *format++; } break; case 'L': cflags = DP_C_LDOUBLE; ch = *format++; break; default: break; } state = DP_S_CONV; break; case DP_S_CONV: switch (ch) { case 'd': case 'i': if (cflags == DP_C_SHORT) value = va_arg (args, int); else if (cflags == DP_C_LONG) value = va_arg (args, long int); else if (cflags == DP_C_LLONG) value = va_arg (args, LLONG); else value = va_arg (args, int); fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); break; case 'o': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (long)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); break; case 'u': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (LLONG)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); break; case 'X': flags |= DP_F_UP; case 'x': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (LLONG)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); break; case 'f': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); /* um, floating point? */ fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); break; case 'E': flags |= DP_F_UP; case 'e': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'G': flags |= DP_F_UP; case 'g': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'c': dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); break; case 's': strvalue = va_arg (args, char *); if (!strvalue) strvalue = "(NULL)"; if (max == -1) { max = strlen(strvalue); } if (min > 0 && max >= 0 && min > max) max = min; fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); break; case 'p': strvalue = (char *)va_arg(args, void *); fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); break; case 'n': if (cflags == DP_C_SHORT) { short int *num; num = va_arg (args, short int *); *num = currlen; } else if (cflags == DP_C_LONG) { long int *num; num = va_arg (args, long int *); *num = (long int)currlen; } else if (cflags == DP_C_LLONG) { LLONG *num; num = va_arg (args, LLONG *); *num = (LLONG)currlen; } else { int *num; num = va_arg (args, int *); *num = currlen; } break; case '%': dopr_outch (buffer, &currlen, maxlen, ch); break; case 'w': /* not supported yet, treat as next char */ ch = *format++; break; default: /* Unknown, skip */ break; } ch = *format++; state = DP_S_DEFAULT; flags = cflags = min = 0; max = -1; break; case DP_S_DONE: break; default: /* hmm? */ break; /* some picky compilers need this */ } } if (maxlen != 0) { if (currlen < maxlen - 1) buffer[currlen] = '\0'; else if (maxlen > 0) buffer[maxlen - 1] = '\0'; } return currlen; } static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max) { int padlen, strln; /* amount to pad */ int cnt = 0; #ifdef DEBUG_SNPRINTF printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value); #endif if (value == 0) { value = ""; } for (strln = 0; value[strln]; ++strln); /* strlen */ padlen = min - strln; if (padlen < 0) padlen = 0; if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justify */ while ((padlen > 0) && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, ' '); --padlen; ++cnt; } while (*value && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, *value++); ++cnt; } while ((padlen < 0) && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; ++cnt; } } /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ static void fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags) { int signvalue = 0; unsigned long uvalue; char convert[20]; int place = 0; int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero pad */ int caps = 0; if (max < 0) max = 0; uvalue = value; if(!(flags & DP_F_UNSIGNED)) { if( value < 0 ) { signvalue = '-'; uvalue = -value; } else { if (flags & DP_F_PLUS) /* Do a sign (+/i) */ signvalue = '+'; else if (flags & DP_F_SPACE) signvalue = ' '; } } if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ do { convert[place++] = (caps? "0123456789ABCDEF":"0123456789abcdef") [uvalue % (unsigned)base ]; uvalue = (uvalue / (unsigned)base ); } while(uvalue && (place < 20)); if (place == 20) place--; convert[place] = 0; zpadlen = max - place; spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); if (zpadlen < 0) zpadlen = 0; if (spadlen < 0) spadlen = 0; if (flags & DP_F_ZERO) { zpadlen = MAX(zpadlen, spadlen); spadlen = 0; } if (flags & DP_F_MINUS) spadlen = -spadlen; /* Left Justifty */ #ifdef DEBUG_SNPRINTF printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", zpadlen, spadlen, min, max, place); #endif /* Spaces */ while (spadlen > 0) { dopr_outch (buffer, currlen, maxlen, ' '); --spadlen; } /* Sign */ if (signvalue) dopr_outch (buffer, currlen, maxlen, signvalue); /* Zeros */ if (zpadlen > 0) { while (zpadlen > 0) { dopr_outch (buffer, currlen, maxlen, '0'); --zpadlen; } } /* Digits */ while (place > 0) dopr_outch (buffer, currlen, maxlen, convert[--place]); /* Left Justified spaces */ while (spadlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); ++spadlen; } } static LDOUBLE abs_val(LDOUBLE value) { LDOUBLE result = value; if (value < 0) result = -value; return result; } static LDOUBLE POW10(int exp) { LDOUBLE result = 1; while (exp) { result *= 10; exp--; } return result; } static LLONG ROUND(LDOUBLE value) { LLONG intpart; intpart = (LLONG)value; value = value - intpart; if (value >= 0.5) intpart++; return intpart; } /* a replacement for modf that doesn't need the math library. Should be portable, but slow */ static double my_modf(double x0, double *iptr) { int i; long l; double x = x0; double f = 1.0; for (i=0;i<100;i++) { l = (long)x; if (l <= (x+1) && l >= (x-1)) break; x *= 0.1; f *= 10.0; } if (i == 100) { /* yikes! the number is beyond what we can handle. What do we do? */ (*iptr) = 0; return 0; } if (i != 0) { double i2; double ret; ret = my_modf(x0-l*f, &i2); (*iptr) = l*f + i2; return ret; } (*iptr) = l; return x - (*iptr); } static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; double ufvalue; char iconvert[311]; char fconvert[311]; int iplace = 0; int fplace = 0; int padlen = 0; /* amount to pad */ int zpadlen = 0; int caps = 0; int index; double intpart; double fracpart; double temp; /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 */ if (max < 0) max = 6; ufvalue = abs_val (fvalue); if (fvalue < 0) { signvalue = '-'; } else { if (flags & DP_F_PLUS) { /* Do a sign (+/i) */ signvalue = '+'; } else { if (flags & DP_F_SPACE) signvalue = ' '; } } #if 0 if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ #endif #if 0 if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */ #endif /* * Sorry, we only support 16 digits past the decimal because of our * conversion method */ if (max > 16) max = 16; /* We "cheat" by converting the fractional part to integer by * multiplying by a factor of 10 */ temp = ufvalue; my_modf(temp, &intpart); fracpart = ROUND((POW10(max)) * (ufvalue - intpart)); if (fracpart >= POW10(max)) { intpart++; fracpart -= POW10(max); } /* Convert integer part */ do { temp = intpart; my_modf(intpart*0.1, &intpart); temp = temp*0.1; index = (int) ((temp -intpart +0.05)* 10.0); /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ /* printf ("%llf, %f, %x\n", temp, intpart, index); */ iconvert[iplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; } while (intpart && (iplace < 311)); if (iplace == 311) iplace--; iconvert[iplace] = 0; /* Convert fractional part */ if (fracpart) { do { temp = fracpart; my_modf(fracpart*0.1, &fracpart); temp = temp*0.1; index = (int) ((temp -fracpart +0.05)* 10.0); /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */ /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */ fconvert[fplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; } while(fracpart && (fplace < 311)); if (fplace == 311) fplace--; } fconvert[fplace] = 0; /* -1 for decimal point, another -1 if we are printing a sign */ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; if (padlen < 0) padlen = 0; if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justifty */ if ((flags & DP_F_ZERO) && (padlen > 0)) { if (signvalue) { dopr_outch (buffer, currlen, maxlen, signvalue); --padlen; signvalue = 0; } while (padlen > 0) { dopr_outch (buffer, currlen, maxlen, '0'); --padlen; } } while (padlen > 0) { dopr_outch (buffer, currlen, maxlen, ' '); --padlen; } if (signvalue) dopr_outch (buffer, currlen, maxlen, signvalue); while (iplace > 0) dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); #ifdef DEBUG_SNPRINTF printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen); #endif /* * Decimal point. This should probably use locale to find the correct * char to print out. */ if (max > 0) { dopr_outch (buffer, currlen, maxlen, '.'); while (fplace > 0) dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); } while (zpadlen > 0) { dopr_outch (buffer, currlen, maxlen, '0'); --zpadlen; } while (padlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; } } static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) { if (*currlen < maxlen) { buffer[(*currlen)] = c; } (*currlen)++; } /* yes this really must be a ||. Don't muck with this (tridge) */ #if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) int vsnprintf (char *str, size_t count, const char *fmt, va_list args) { return dopr(str, count, fmt, args); } #endif /* yes this really must be a ||. Don't muck wiith this (tridge) * * The logic for these two is that we need our own definition if the * OS *either* has no definition of *sprintf, or if it does have one * that doesn't work properly according to the autoconf test. Perhaps * these should really be smb_snprintf to avoid conflicts with buggy * linkers? -- mbp */ #if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_SNPRINTF) int snprintf(char *str,size_t count,const char *fmt,...) { size_t ret; va_list ap; va_start(ap, fmt); ret = vsnprintf(str, count, fmt, ap); va_end(ap); return ret; } #endif #endif #ifndef HAVE_VASPRINTF int vasprintf(char **ptr, const char *format, va_list ap) { int ret; ret = vsnprintf(0, 0, format, ap); if (ret <= 0) return ret; (*ptr) = (char *)malloc(ret+1); if (!*ptr) return -1; ret = vsnprintf(*ptr, ret+1, format, ap); return ret; } #endif #ifndef HAVE_ASPRINTF int asprintf(char **ptr, const char *format, ...) { va_list ap; int ret; *ptr = 0; va_start(ap, format); ret = vasprintf(ptr, format, ap); va_end(ap); return ret; } #endif #ifndef HAVE_VSYSLOG #ifdef HAVE_SYSLOG void vsyslog (int facility_priority, char *format, va_list arglist) { char *msg = 0; vasprintf(&msg, format, arglist); if (!msg) return; syslog(facility_priority, "%s", msg); free(msg); } #endif /* HAVE_SYSLOG */ #endif /* HAVE_VSYSLOG */ #ifdef TEST_SNPRINTF int sprintf(char *str,const char *fmt,...); int main (void) { char buf1[1024]; char buf2[1024]; char *fp_fmt[] = { "%1.1f", "%-1.5f", "%1.5f", "%123.9f", "%10.5f", "% 10.5f", "%+22.9f", "%+4.9f", "%01.3f", "%4f", "%3.1f", "%3.2f", "%.0f", "%f", "-16.16f", 0 }; double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 0.9996, 1.996, 4.136, 0}; char *int_fmt[] = { "%-1.5d", "%1.5d", "%123.9d", "%5.5d", "%10.5d", "% 10.5d", "%+22.33d", "%01.3d", "%4d", "%d", 0 }; long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; char *str_fmt[] = { "10.5s", "5.10s", "10.1s", "0.10s", "10.0s", "1.10s", "%s", "%.1s", "%.10s", "%10s", 0 }; char *str_vals[] = {"hello", "a", "", "a longer string", 0}; int x, y; int fail = 0; int num = 0; printf ("Testing snprintf format codes against system sprintf...\n"); for (x = 0; fp_fmt[x] ; x++) { for (y = 0; fp_nums[y] != 0 ; y++) { int l1 = snprintf(0, 0, fp_fmt[x], fp_nums[y]); int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); sprintf (buf2, fp_fmt[x], fp_nums[y]); if (strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", fp_fmt[x], buf1, buf2); fail++; } if (l1 != l2) { printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]); fail++; } num++; } } for (x = 0; int_fmt[x] ; x++) { for (y = 0; int_nums[y] != 0 ; y++) { int l1 = snprintf(0, 0, int_fmt[x], int_nums[y]); int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); sprintf (buf2, int_fmt[x], int_nums[y]); if (strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", int_fmt[x], buf1, buf2); fail++; } if (l1 != l2) { printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]); fail++; } num++; } } for (x = 0; str_fmt[x] ; x++) { for (y = 0; str_vals[y] != 0 ; y++) { int l1 = snprintf(0, 0, str_fmt[x], str_vals[y]); int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); sprintf (buf2, str_fmt[x], str_vals[y]); if (strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", str_fmt[x], buf1, buf2); fail++; } if (l1 != l2) { printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]); fail++; } num++; } } printf ("%d tests failed out of %d.\n", fail, num); printf("seeing how many digits we support\n"); { double v0 = 0.12345678901234567890123456789012345678901; for (x=0; x<100; x++) { snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x)); sprintf(buf2, "%1.1f", v0*pow(10, x)); if (strcmp(buf1, buf2)) { printf("we seem to support %d digits\n", x-1); break; } } } return 0; } #endif /* SNPRINTF_TEST */ swig-3.0.8/CCache/ccache.h0000664000175000017500000001101212641054563015041 0ustar williamwilliam#include "ccache_swig_config.h" #define CCACHE_VERSION SWIG_VERSION #ifndef _WIN32 #include "config.h" #else #include #define PACKAGE_NAME "ccache-swig.exe" #endif #include #include #include #include #include #include #ifndef _WIN32 #include #include #else #define _WIN32_WINNT 0x0500 #include #include #endif #include #include #include #include #include #include #include #include #include #ifdef HAVE_PWD_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef ENABLE_ZLIB #include #endif #define STATUS_NOTFOUND 3 #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 #define MYNAME PACKAGE_NAME #define LIMIT_MULTIPLE 0.8 /* default maximum cache size */ #ifndef DEFAULT_MAXSIZE #define DEFAULT_MAXSIZE (1000*1000) #endif /* file copy mode */ #ifdef ENABLE_ZLIB #define COPY_UNCOMPRESSED 0 #define COPY_FROM_CACHE 1 #define COPY_TO_CACHE 2 #endif enum stats { STATS_NONE=0, STATS_STDOUT, STATS_STATUS, STATS_ERROR, STATS_TOCACHE, STATS_PREPROCESSOR, STATS_COMPILER, STATS_MISSING, STATS_CACHED, STATS_ARGS, STATS_LINK, STATS_NUMFILES, STATS_TOTALSIZE, STATS_MAXFILES, STATS_MAXSIZE, STATS_NOTC, STATS_DEVICE, STATS_NOINPUT, STATS_ENVIRONMMENT, STATS_MULTIPLE, STATS_CONFTEST, STATS_UNSUPPORTED, STATS_OUTSTDOUT, STATS_END }; typedef unsigned uint32; #include "mdfour.h" void hash_start(void); void hash_string(const char *s); void hash_int(int x); void hash_file(const char *fname); char *hash_result(void); void hash_buffer(const char *s, int len); void cc_log(const char *format, ...); void fatal(const char *msg); void copy_fd(int fd_in, int fd_out); int safe_rename(const char* oldpath, const char* newpath); int move_file(const char *src, const char *dest); int test_if_compressed(const char *filename); int commit_to_cache(const char *src, const char *dest, int hardlink); int retrieve_from_cache(const char *src, const char *dest, int hardlink); int create_dir(const char *dir); int create_cachedirtag(const char *dir); void x_asprintf(char **ptr, const char *format, ...); char *x_strdup(const char *s); void *x_realloc(void *ptr, size_t size); void *x_malloc(size_t size); void traverse(const char *dir, void (*fn)(const char *, struct stat *)); char *str_basename(const char *s); char *dirname(char *s); int lock_fd(int fd); size_t file_size(struct stat *st); int safe_open(const char *fname); char *x_realpath(const char *path); char *gnu_getcwd(void); int create_empty_file(const char *fname); const char *get_home_directory(void); int x_utimes(const char *filename); #ifdef _WIN32 void perror_win32(LPTSTR pszFunction); #endif void stats_update(enum stats stat); void stats_zero(void); void stats_summary(void); void stats_tocache(size_t size, size_t numfiles); void stats_read(const char *stats_file, unsigned counters[STATS_END]); int stats_set_limits(long maxfiles, long maxsize); size_t value_units(const char *s); void display_size(unsigned v); void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); int unify_hash(const char *fname); #ifndef HAVE_VASPRINTF int vasprintf(char **, const char *, va_list ); #endif #ifndef HAVE_ASPRINTF int asprintf(char **ptr, const char *format, ...); #endif #ifndef HAVE_SNPRINTF int snprintf(char *,size_t ,const char *, ...); #endif void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles); void cleanup_all(const char *dir); void wipe_all(const char *dir); #ifdef _WIN32 char *argvtos(char **argv); #endif int execute(char **argv, const char *path_stdout, const char *path_stderr); char *find_executable(const char *name, const char *exclude_name); void display_execute_args(char **argv); typedef struct { char **argv; int argc; } ARGS; ARGS *args_init(int , char **); void args_add(ARGS *args, const char *s); void args_add_prefix(ARGS *args, const char *s); void args_pop(ARGS *args, int n); void args_strip(ARGS *args, const char *prefix); void args_remove_first(ARGS *args); extern int ccache_verbose; #if HAVE_COMPAR_FN_T #define COMPAR_FN_T __compar_fn_t #else typedef int (*COMPAR_FN_T)(const void *, const void *); #endif /* work with silly DOS binary open */ #ifndef O_BINARY #define O_BINARY 0 #endif /* mkstemp() on some versions of cygwin don't handle binary files, so override */ /* Seems okay in Cygwin 1.7.0 #ifdef __CYGWIN__ #undef HAVE_MKSTEMP #endif */ swig-3.0.8/CCache/packaging/0000775000175000017500000000000012641054563015413 5ustar williamwilliamswig-3.0.8/CCache/packaging/ccache.spec0000664000175000017500000000133512641054563017477 0ustar williamwilliamSummary: Compiler Cache Name: ccache Version: 2.3 Release: 1 Group: Development/Languages License: GPL URL: http://ccache.samba.org/ Source: ccache-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-root %description ccache caches gcc output files %prep %setup -q %build %configure make install -d -m 0755 $RPM_BUILD_ROOT%{_bindir} install -m 0755 ccache $RPM_BUILD_ROOT%{_bindir} install -d -m 0755 $RPM_BUILD_ROOT%{_mandir}/man1 install -m 0644 ccache.1 $RPM_BUILD_ROOT%{_mandir}/man1 %files %defattr(-,root,root) %doc README %{_mandir}/man1/ccache.1* %{_bindir}/ccache %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %changelog * Mon Apr 01 2002 Peter Jones - Created the package swig-3.0.8/CCache/packaging/README0000664000175000017500000000037312641054563016276 0ustar williamwilliamThese packaging files are contributd by users of ccache. I do not maintain them, and they may well need updating before you use them. I don't distribute binary packages of ccache myself, but if you wish to add ccache to a distribution then that's OK swig-3.0.8/CCache/ccache.yo0000664000175000017500000004202712641054563015253 0ustar williamwilliamwhenman( COMMENT(html output not great if included when using html2doc) manpage(ccache-swig)(1)()()() ) whenhtml(htmlcommand( ccache-swig(1) manpage

Using SWIG with ccache - ccache-swig(1) manpage

)) manpagename(ccache-swig)(a fast compiler cache) whenhtml(htmlcommand( ccache-swig - a fast compiler cache )) manpagesynopsis() ccache-swig [OPTION] ccache-swig [COMPILER OPTIONS] [COMPILER OPTIONS] manpagedescription() ccache-swig is a compiler cache. It speeds up re-compilation of C/C++/SWIG code by caching previous compiles and detecting when the same compile is being done again. ccache-swig is ccache plus support for SWIG. ccache and ccache-swig are used interchangeably in this document. manpagesection(OPTIONS SUMMARY) Here is a summary of the options to ccache-swig. verb( -s show statistics summary -z zero statistics -c run a cache cleanup -C clear the cache completely -F set maximum files in cache -M set maximum size of cache (use G, M or K) -h this help page -V print version number ) manpageoptions() These options only apply when you invoke ccache as "ccache-swig". When invoked as a compiler none of these options apply. In that case your normal compiler options apply and you should refer to your compilers documentation. startdit() dit(bf(-h)) Print a options summary page dit(bf(-s)) Print the current statistics summary for the cache. The statistics are stored spread across the subdirectories of the cache. Using "ccache-swig -s" adds up the statistics across all subdirectories and prints the totals. dit(bf(-z)) Zero the cache statistics. dit(bf(-V)) Print the ccache version number dit(bf(-c)) Clean the cache and re-calculate the cache file count and size totals. Normally the -c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps statistics up to date on each compile. This option is mostly useful if you manually modify the cache contents or believe that the cache size statistics may be inaccurate. dit(bf(-C)) Clear the entire cache, removing all cached files. dit(bf(-F )) This sets the maximum number of files allowed in the cache. The value is stored inside the cache directory and applies to all future compiles. Due to the way the value is stored the actual value used is always rounded down to the nearest multiple of 16. dit(bf(-M )) This sets the maximum cache size. You can specify a value in gigabytes, megabytes or kilobytes by appending a G, M or K to the value. The default is gigabytes. The actual value stored is rounded down to the nearest multiple of 16 kilobytes. enddit() manpagesection(INSTALLATION) There are two ways to use ccache. You can either prefix your compile commands with "ccache-swig" or you can create a symbolic link between ccache-swig and the names of your compilers. The first method is most convenient if you just want to try out ccache or wish to use it for some specific projects. The second method is most useful for when you wish to use ccache for all your compiles. To install for usage by the first method just copy ccache-swig to somewhere in your path. To install for the second method do something like this: verb( cp ccache-swig /usr/local/bin/ ln -s /usr/local/bin/ccache-swig /usr/local/bin/gcc ln -s /usr/local/bin/ccache-swig /usr/local/bin/g++ ln -s /usr/local/bin/ccache-swig /usr/local/bin/cc ln -s /usr/local/bin/ccache-swig /usr/local/bin/swig ) This will work as long as /usr/local/bin comes before the path to gcc (which is usually in /usr/bin). After installing you may wish to run "which gcc" to make sure that the correct link is being used. Note! Do not use a hard link, use a symbolic link. A hardlink will cause "interesting" problems. manpagesection(EXTRA OPTIONS) When run as a compiler front end ccache usually just takes the same command line options as the compiler you are using. The only exception to this is the option '--ccache-skip'. That option can be used to tell ccache that the next option is definitely not a input filename, and should be passed along to the compiler as-is. The reason this can be important is that ccache does need to parse the command line and determine what is an input filename and what is a compiler option, as it needs the input filename to determine the name of the resulting object file (among other things). The heuristic ccache uses in this parse is that any string on the command line that exists as a file is treated as an input file name (usually a C file). By using --ccache-skip you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option. manpagesection(ENVIRONMENT VARIABLES) ccache uses a number of environment variables to control operation. In most cases you won't need any of these as the defaults will be fine. startdit() dit(bf(CCACHE_DIR)) the CCACHE_DIR environment variable specifies where ccache will keep its cached compiler output. The default is "$HOME/.ccache". dit(bf(CCACHE_TEMPDIR)) the CCACHE_TEMPDIR environment variable specifies where ccache will put temporary files. The default is the same as CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same filesystem as the CCACHE_DIR path, so that renames of files between the two directories can work. dit(bf(CCACHE_LOGFILE)) If you set the CCACHE_LOGFILE environment variable then ccache will write some log information on cache hits and misses in that file. This is useful for tracking down problems. dit(bf(CCACHE_VERBOSE)) If you set the CCACHE_VERBOSE environment variable then ccache will display on stdout all the compiler invocations that it makes. This can useful for debugging unexpected problems. dit(bf(CCACHE_PATH)) You can optionally set CCACHE_PATH to a colon separated path where ccache will look for the real compilers. If you don't do this then ccache will look for the first executable matching the compiler name in the normal PATH that isn't a symbolic link to ccache itself. dit(bf(CCACHE_CC)) You can optionally set CCACHE_CC to force the name of the compiler to use. If you don't do this then ccache works it out from the command line. dit(bf(CCACHE_PREFIX)) This option adds a prefix to the command line that ccache runs when invoking the compiler. Also see the section below on using ccache with distcc. dit(bf(CCACHE_DISABLE)) If you set the environment variable CCACHE_DISABLE then ccache will just call the real compiler, bypassing the cache completely. dit(bf(CCACHE_READONLY)) the CCACHE_READONLY environment variable tells ccache to attempt to use existing cached object files, but not to try to add anything new to the cache. If you are using this because your CCACHE_DIR is read-only, then you may find that you also need to set CCACHE_TEMPDIR as otherwise ccache will fail to create the temporary files. dit(bf(CCACHE_CPP2)) If you set the environment variable CCACHE_CPP2 then ccache will not use the optimisation of avoiding the 2nd call to the pre-processor by compiling the pre-processed output that was used for finding the hash in the case of a cache miss. This is primarily a debugging option, although it is possible that some unusual compilers will have problems with the intermediate filename extensions used in this optimisation, in which case this option could allow ccache to be used. dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable CCACHE_NOCOMPRESS then there is no compression used on files that go into the cache. However, this setting has no effect on how files are retrieved from the cache, compressed results will still be usable. dit(bf(CCACHE_NOSTATS)) If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile. dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows you to choose the number of levels of hash in the cache directory. The default is 2. The minimum is 1 and the maximum is 8. dit(bf(CCACHE_HARDLINK)) If you set the environment variable CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy. Using hard links is faster, but can confuse programs like 'make' that rely on modification times. Hard links are never made for compressed cache files. dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached results, even if it finds them. New results are still cached, but existing cache entries are ignored. dit(bf(CCACHE_UMASK)) This sets the umask for ccache and all child processes (such as the compiler). This is mostly useful when you wish to share your cache with other users. Note that this also affects the file permissions set on the object files created from your compilations. dit(bf(CCACHE_HASHDIR)) This tells ccache to hash the current working directory when calculating the hash that is used to distinguish two compiles. This prevents a problem with the storage of the current working directory in the debug info of a object file, which can lead ccache to give a cached object file that has the working directory in the debug info set incorrectly. This option is off by default as the incorrect setting of this debug info rarely causes problems. If you strike problems with gdb not using the correct directory then enable this option. dit(bf(CCACHE_UNIFY)) If you set the environment variable CCACHE_UNIFY then ccache will use the C/C++ unifier when hashing the pre-processor output if -g is not used in the compile. The unifier is slower than a normal hash, so setting this environment variable loses a little bit of speed, but it means that ccache can take advantage of not recompiling when the changes to the source code consist of reformatting only. Note that using CCACHE_UNIFY changes the hash, so cached compiles with CCACHE_UNIFY set cannot be used when CCACHE_UNIFY is not set and vice versa. The reason the unifier is off by default is that it can give incorrect line number information in compiler warning messages. dit(bf(CCACHE_EXTENSION)) Normally ccache tries to automatically determine the extension to use for intermediate C pre-processor files based on the type of file being compiled. Unfortunately this sometimes doesn't work, for example when using the aCC compiler on HP-UX. On systems like this you can use the CCACHE_EXTENSION option to override the default. On HP-UX set this environment variable to "i" if you use the aCC compiler. dit(bf(CCACHE_STRIPC)) If you set the environment variable CCACHE_STRIPC then ccache will strip the -c option when invoking the preprocessor. This option is primarily for the Sun Workshop C++ compiler as without this option an unwarranted warning is displayed: CC: Warning: "-E" redefines product from "object" to "source (stdout)" when -E and -c is used together. dit(bf(CCACHE_SWIG)) When using SWIG as the compiler and it does not have 'swig' in the executable name, then the CCACHE_SWIG environment variable needs to be set in order for ccache to work correctly with SWIG. The use of CCACHE_CPP2 is also recommended for SWIG due to some preprocessor quirks, however, use of CCACHE_CPP2 can often be skipped -- check your generated code with and without this option set. Known problems are using preprocessor directives within %inline blocks and the use of '#pragma SWIG'. enddit() manpagesection(CACHE SIZE MANAGEMENT) By default ccache has a one gigabyte limit on the cache size and no maximum number of files. You can set a different limit using the "ccache -M" and "ccache -F" options, which set the size and number of files limits. When these limits are reached ccache will reduce the cache to 20% below the numbers you specified in order to avoid doing the cache clean operation too often. manpagesection(CACHE COMPRESSION) By default on most platforms ccache will compress all files it puts into the cache using the zlib compression. While this involves a negligible performance slowdown, it significantly increases the number of files that fit in the cache. You can turn off compression setting the CCACHE_NOCOMPRESS environment variable. manpagesection(HOW IT WORKS) The basic idea is to detect when you are compiling exactly the same code a 2nd time and use the previously compiled output. You detect that it is the same code by forming a hash of: itemization( it() the pre-processor output from running the compiler with -E it() the command line options it() the real compilers size and modification time it() any stderr output generated by the compiler ) These are hashed using md4 (a strong hash) and a cache file is formed based on that hash result. When the same compilation is done a second time ccache is able to supply the correct compiler output (including all warnings etc) from the cache. ccache has been carefully written to always produce exactly the same compiler output that you would get without the cache. If you ever discover a case where ccache changes the output of your compiler then please let me know. manpagesection(USING CCACHE WITH DISTCC) distcc is a very useful program for distributing compilation across a range of compiler servers. It is often useful to combine distcc with ccache, so that compiles that are done are sped up by distcc, but that ccache avoids the compile completely where possible. To use distcc with ccache I recommend using the CCACHE_PREFIX option. You just need to set the environment variable CCACHE_PREFIX to 'distcc' and ccache will prefix the command line used with the compiler with the command 'distcc'. manpagesection(SHARING A CACHE) A group of developers can increase the cache hit rate by sharing a cache directory. The hard links however cause unwanted side effects, as all links to a cached file share the file's modification timestamp. This results in false dependencies to be triggered by timestamp-based build systems whenever another user links to an existing file. Typically, users will see that their libraries and binaries are relinked without reason. To share a cache without side effects, the following conditions need to be met: itemization( it() Use the same bf(CCACHE_DIR) environment variable setting it() Unset the bf(CCACHE_HARDLINK) environment variable it() Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in the group. it() Make sure that all users have write permission in the entire cache directory (and that you trust all users of the shared cache). it() Make sure that the setgid bit is set on all directories in the cache. This tells the filesystem to inherit group ownership for new directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might be useful for this. it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with versions of ccache that do not support compression. ) manpagesection(HISTORY) ccache was inspired by the compilercache shell script script written by Erik Thiele and I would like to thank him for an excellent piece of work. See url(http://www.erikyyy.de/compilercache/)(http://www.erikyyy.de/compilercache/) for the Erik's scripts. ccache-swig is a port of the original ccache with support added for use with SWIG. I wrote ccache because I wanted to get a bit more speed out of a compiler cache and I wanted to remove some of the limitations of the shell-script version. manpagesection(DIFFERENCES FROM COMPILERCACHE) The biggest differences between Erik's compilercache script and ccache are: itemization( it() ccache is written in C, which makes it a bit faster (calling out to external programs is mostly what slowed down the scripts). it() ccache can automatically find the real compiler it() ccache keeps statistics on hits/misses it() ccache can do automatic cache management it() ccache can cache compiler output that includes warnings. In many cases this gives ccache a much higher cache hit rate. it() ccache can handle a much wider ranger of compiler options it() ccache avoids a double call to cpp on a cache miss ) manpagesection(CREDITS) Thanks to the following people for their contributions to ccache itemization( it() Erik Thiele for the original compilercache script it() Luciano Rocha for the idea of compiling the pre-processor output to avoid a 2nd cpp pass it() Paul Russell for many suggestions and the debian packaging ) manpageauthor() ccache was written by Andrew Tridgell url(http://samba.org/~tridge/)(http://samba.org/~tridge/). ccache was adapted to create ccache-swig for use with SWIG by William Fulton. If you wish to report a problem or make a suggestion then please email the SWIG developers on the swig-devel mailing list, see url(http://www.swig.org/mail.html)(http://www.swig.org/mail.html) ccache is released under the GNU General Public License version 2 or later. Please see the file COPYING for license details. whenhtml(htmlcommand( )) swig-3.0.8/CCache/unify.c0000664000175000017500000001603012641054563014765 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* C/C++ unifier the idea is that changes that don't affect the resulting C code should not change the hash. This is achieved by folding white-space and other non-semantic fluff in the input into a single unified format. This unifier was design to match the output of the unifier in compilercache, which is flex based. The major difference is that this unifier is much faster (about 2x) and more forgiving of syntactic errors. Continuing on syntactic errors is important to cope with C/C++ extensions in the local compiler (for example, inline assembly systems). */ #include "ccache.h" static char *s_tokens[] = { "...", ">>=", "<<=", "+=", "-=", "*=", "/=", "%=", "&=", "^=", "|=", ">>", "<<", "++", "--", "->", "&&", "||", "<=", ">=", "==", "!=", ";", "{", "<%", "}", "%>", ",", ":", "=", "(", ")", "[", "<:", "]", ":>", ".", "&", "!", "~", "-", "+", "*", "/", "%", "<", ">", "^", "|", "?", 0 }; #define C_ALPHA 1 #define C_SPACE 2 #define C_TOKEN 4 #define C_QUOTE 8 #define C_DIGIT 16 #define C_HEX 32 #define C_FLOAT 64 #define C_SIGN 128 static struct { unsigned char type; unsigned char num_toks; char *toks[7]; } tokens[256]; /* build up the table used by the unifier */ static void build_table(void) { unsigned char c; int i; static int done; if (done) return; done = 1; memset(tokens, 0, sizeof(tokens)); for (c=0;c<128;c++) { if (isalpha(c) || c == '_') tokens[c].type |= C_ALPHA; if (isdigit(c)) tokens[c].type |= C_DIGIT; if (isspace(c)) tokens[c].type |= C_SPACE; if (isxdigit(c)) tokens[c].type |= C_HEX; } tokens['\''].type |= C_QUOTE; tokens['"'].type |= C_QUOTE; tokens['l'].type |= C_FLOAT; tokens['L'].type |= C_FLOAT; tokens['f'].type |= C_FLOAT; tokens['F'].type |= C_FLOAT; tokens['U'].type |= C_FLOAT; tokens['u'].type |= C_FLOAT; tokens['-'].type |= C_SIGN; tokens['+'].type |= C_SIGN; for (i=0;s_tokens[i];i++) { c = s_tokens[i][0]; tokens[c].type |= C_TOKEN; tokens[c].toks[tokens[c].num_toks] = s_tokens[i]; tokens[c].num_toks++; } } /* buffer up characters before hashing them */ static void pushchar(unsigned char c) { static unsigned char buf[64]; static int len; if (c == 0) { if (len > 0) { hash_buffer((char *)buf, len); len = 0; } hash_buffer(NULL, 0); return; } buf[len++] = c; if (len == 64) { hash_buffer((char *)buf, len); len = 0; } } /* hash some C/C++ code after unifying */ static void unify(unsigned char *p, size_t size) { size_t ofs; unsigned char q; int i; build_table(); for (ofs=0; ofs 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) { do { ofs++; } while (ofs < size && p[ofs] != '\n'); ofs++; } else { do { pushchar(p[ofs]); ofs++; } while (ofs < size && p[ofs] != '\n'); pushchar('\n'); ofs++; } continue; } if (tokens[p[ofs]].type & C_ALPHA) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && (tokens[p[ofs]].type & (C_ALPHA|C_DIGIT))); pushchar('\n'); continue; } if (tokens[p[ofs]].type & C_DIGIT) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.')); if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) { do { pushchar(p[ofs]); ofs++; } while (ofs < size && (tokens[p[ofs]].type & C_HEX)); } if (ofs < size && (p[ofs] == 'E' || p[ofs] == 'e')) { pushchar(p[ofs]); ofs++; while (ofs < size && (tokens[p[ofs]].type & (C_DIGIT|C_SIGN))) { pushchar(p[ofs]); ofs++; } } while (ofs < size && (tokens[p[ofs]].type & C_FLOAT)) { pushchar(p[ofs]); ofs++; } pushchar('\n'); continue; } if (tokens[p[ofs]].type & C_SPACE) { do { ofs++; } while (ofs < size && (tokens[p[ofs]].type & C_SPACE)); continue; } if (tokens[p[ofs]].type & C_QUOTE) { q = p[ofs]; pushchar(p[ofs]); do { ofs++; while (ofs < size-1 && p[ofs] == '\\') { pushchar(p[ofs]); pushchar(p[ofs+1]); ofs+=2; } pushchar(p[ofs]); } while (ofs < size && p[ofs] != q); pushchar('\n'); ofs++; continue; } if (tokens[p[ofs]].type & C_TOKEN) { q = p[ofs]; for (i=0;i= ofs+len && memcmp(&p[ofs], s, len) == 0) { int j; for (j=0;s[j];j++) { pushchar(s[j]); ofs++; } pushchar('\n'); break; } } if (i < tokens[q].num_toks) { continue; } } pushchar(p[ofs]); pushchar('\n'); ofs++; } pushchar(0); } /* hash a file that consists of preprocessor output, but remove any line number information from the hash */ int unify_hash(const char *fname) { #ifdef _WIN32 HANDLE file; HANDLE section; DWORD filesize_low; char *map; int ret = -1; file = CreateFileA(fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (file != INVALID_HANDLE_VALUE) { filesize_low = GetFileSize(file, NULL); if (!(filesize_low == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)) { section = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL); CloseHandle(file); if (section != NULL) { map = MapViewOfFile(section, FILE_MAP_READ, 0, 0, 0); CloseHandle(section); if (map != NULL) ret = 0; } } } if (ret == -1) { cc_log("Failed to open preprocessor output %s\n", fname); stats_update(STATS_PREPROCESSOR); return -1; } /* pass it through the unifier */ unify((unsigned char *)map, filesize_low); UnmapViewOfFile(map); return 0; #else int fd; struct stat st; char *map; fd = open(fname, O_RDONLY|O_BINARY); if (fd == -1 || fstat(fd, &st) != 0) { cc_log("Failed to open preprocessor output %s\n", fname); stats_update(STATS_PREPROCESSOR); return -1; } /* we use mmap() to make it easy to handle arbitrarily long lines in preprocessor output. I have seen lines of over 100k in length, so this is well worth it */ map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (map == (char *)-1) { cc_log("Failed to mmap %s\n", fname); stats_update(STATS_PREPROCESSOR); return -1; } close(fd); /* pass it through the unifier */ unify((unsigned char *)map, st.st_size); munmap(map, st.st_size); return 0; #endif } swig-3.0.8/CCache/execute.c0000664000175000017500000001431412641054563015300 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" #ifdef _WIN32 char *argvtos(char **argv) { int i, len; char *ptr, *str; for (i = 0, len = 0; argv[i]; i++) { len += strlen(argv[i]) + 3; } str = ptr = (char *)malloc(len + 1); if (str == NULL) return NULL; for (i = 0; argv[i]; i++) { len = strlen(argv[i]); *ptr++ = '"'; memcpy(ptr, argv[i], len); ptr += len; *ptr++ = '"'; *ptr++ = ' '; } *ptr = 0; return str; } #endif /* execute a compiler backend, capturing all output to the given paths the full path to the compiler to run is in argv[0] */ int execute(char **argv, const char *path_stdout, const char *path_stderr) { #ifdef _WIN32 #if 1 PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; BOOL ret; DWORD exitcode; char *args; HANDLE fd_out, fd_err; SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; /* TODO: needs moving after possible exit() below, but before stdout is redirected */ if (ccache_verbose) { display_execute_args(argv); } fd_out = CreateFile(path_stdout, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fd_out == INVALID_HANDLE_VALUE) { return STATUS_NOCACHE; } fd_err = CreateFile(path_stderr, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fd_err == INVALID_HANDLE_VALUE) { return STATUS_NOCACHE; } ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&sinfo, sizeof(STARTUPINFO)); sinfo.cb = sizeof(STARTUPINFO); sinfo.hStdError = fd_err; sinfo.hStdOutput = fd_out; sinfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE); sinfo.dwFlags |= STARTF_USESTDHANDLES; args = argvtos(argv); ret = CreateProcessA(argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL, &sinfo, &pinfo); free(args); CloseHandle(fd_out); CloseHandle(fd_err); if (ret == 0) return -1; WaitForSingleObject(pinfo.hProcess, INFINITE); GetExitCodeProcess(pinfo.hProcess, &exitcode); CloseHandle(pinfo.hProcess); CloseHandle(pinfo.hThread); return exitcode; #else /* possibly slightly faster */ /* needs fixing to quote commandline options to handle spaces in CCACHE_DIR etc */ int status = -2; int fd, std_od = -1, std_ed = -1; /* TODO: needs moving after possible exit() below, but before stdout is redirected */ if (ccache_verbose) { display_execute_args(argv); } unlink(path_stdout); std_od = _dup(1); fd = _open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { exit(STATUS_NOCACHE); } _dup2(fd, 1); _close(fd); unlink(path_stderr); fd = _open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); std_ed = _dup(2); if (fd == -1) { exit(STATUS_NOCACHE); } _dup2(fd, 2); _close(fd); /* Spawn process (_exec* familly doesn't return) */ status = _spawnv(_P_WAIT, argv[0], (const char **)argv); /* Restore descriptors */ if (std_od != -1) _dup2(std_od, 1); if (std_ed != -1) _dup2(std_ed, 2); _flushall(); return (status>0); #endif #else pid_t pid; int status; pid = fork(); if (pid == -1) fatal("Failed to fork"); if (pid == 0) { int fd; /* TODO: needs moving after possible exit() below, but before stdout is redirected */ if (ccache_verbose) { display_execute_args(argv); } unlink(path_stdout); fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { exit(STATUS_NOCACHE); } dup2(fd, 1); close(fd); unlink(path_stderr); fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { exit(STATUS_NOCACHE); } dup2(fd, 2); close(fd); exit(execv(argv[0], argv)); } if (waitpid(pid, &status, 0) != pid) { fatal("waitpid failed"); } if (WEXITSTATUS(status) == 0 && WIFSIGNALED(status)) { return -1; } return WEXITSTATUS(status); #endif } /* find an executable by name in $PATH. Exclude any that are links to exclude_name */ char *find_executable(const char *name, const char *exclude_name) { #if _WIN32 (void)exclude_name; DWORD ret; char namebuf[MAX_PATH]; ret = SearchPathA(getenv("CCACHE_PATH"), name, ".exe", sizeof(namebuf), namebuf, NULL); if (ret != 0) { return x_strdup(namebuf); } return NULL; #else char *path; char *tok; struct stat st1, st2; if (*name == '/') { return x_strdup(name); } path = getenv("CCACHE_PATH"); if (!path) { path = getenv("PATH"); } if (!path) { cc_log("no PATH variable!?\n"); stats_update(STATS_ENVIRONMMENT); return NULL; } path = x_strdup(path); /* search the path looking for the first compiler of the right name that isn't us */ for (tok=strtok(path,":"); tok; tok = strtok(NULL, ":")) { char *fname; x_asprintf(&fname, "%s/%s", tok, name); /* look for a normal executable file */ if (access(fname, X_OK) == 0 && lstat(fname, &st1) == 0 && stat(fname, &st2) == 0 && S_ISREG(st2.st_mode)) { /* if its a symlink then ensure it doesn't point at something called exclude_name */ if (S_ISLNK(st1.st_mode)) { char *buf = x_realpath(fname); if (buf) { char *p = str_basename(buf); if (strcmp(p, exclude_name) == 0) { /* its a link to "ccache" ! */ free(p); free(buf); continue; } free(buf); free(p); } } /* found it! */ free(path); return fname; } free(fname); } return NULL; #endif } void display_execute_args(char **argv) { if (argv) { printf("ccache executing: "); while (*argv) { printf("%s ", *argv); ++argv; } printf("\n"); fflush(stdout); } } swig-3.0.8/CCache/util.c0000664000175000017500000004140412641054563014613 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" static FILE *logfile; /* log a message to the CCACHE_LOGFILE location */ void cc_log(const char *format, ...) { va_list ap; extern char *cache_logfile; if (!cache_logfile) return; if (!logfile) logfile = fopen(cache_logfile, "a"); if (!logfile) return; va_start(ap, format); vfprintf(logfile, format, ap); va_end(ap); fflush(logfile); } /* something went badly wrong! */ void fatal(const char *msg) { cc_log("FATAL: %s\n", msg); exit(1); } int safe_rename(const char* oldpath, const char* newpath) { /* safe_rename is for creating entries in the cache. Works like rename(), but it never overwrites an existing cache entry. This avoids corruption on NFS. */ #ifndef _WIN32 int status = link(oldpath, newpath); if( status == 0 || errno == EEXIST ) #else int status = CreateHardLinkA(newpath, oldpath, NULL) ? 0 : -1; if( status == 0 || GetLastError() == ERROR_ALREADY_EXISTS ) #endif { return unlink( oldpath ); } else { return -1; } } #ifndef ENABLE_ZLIB /* copy all data from one file descriptor to another */ void copy_fd(int fd_in, int fd_out) { char buf[10240]; int n; while ((n = read(fd_in, buf, sizeof(buf))) > 0) { if (write(fd_out, buf, n) != n) { fatal("Failed to copy fd"); } } } #ifndef HAVE_MKSTEMP /* cheap and nasty mkstemp replacement */ int mkstemp(char *template) { mktemp(template); return open(template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); } #endif /* move a file using rename */ int move_file(const char *src, const char *dest) { return safe_rename(src, dest); } /* copy a file - used when hard links don't work the copy is done via a temporary file and atomic rename */ static int copy_file(const char *src, const char *dest) { int fd1, fd2; char buf[10240]; int n; char *tmp_name; mode_t mask; x_asprintf(&tmp_name, "%s.XXXXXX", dest); fd1 = open(src, O_RDONLY|O_BINARY); if (fd1 == -1) { free(tmp_name); return -1; } fd2 = mkstemp(tmp_name); if (fd2 == -1) { close(fd1); free(tmp_name); return -1; } while ((n = read(fd1, buf, sizeof(buf))) > 0) { if (write(fd2, buf, n) != n) { close(fd2); close(fd1); unlink(tmp_name); free(tmp_name); return -1; } } close(fd1); /* get perms right on the tmp file */ #ifndef _WIN32 mask = umask(0); fchmod(fd2, 0666 & ~mask); umask(mask); #else (void)mask; #endif /* the close can fail on NFS if out of space */ if (close(fd2) == -1) { unlink(tmp_name); free(tmp_name); return -1; } unlink(dest); if (rename(tmp_name, dest) == -1) { unlink(tmp_name); free(tmp_name); return -1; } free(tmp_name); return 0; } /* copy a file to the cache */ static int copy_file_to_cache(const char *src, const char *dest) { return copy_file(src, dest); } /* copy a file from the cache */ static int copy_file_from_cache(const char *src, const char *dest) { return copy_file(src, dest); } #else /* ENABLE_ZLIB */ /* copy all data from one file descriptor to another possibly decompressing it */ void copy_fd(int fd_in, int fd_out) { char buf[10240]; int n; gzFile gz_in; gz_in = gzdopen(dup(fd_in), "rb"); if (!gz_in) { fatal("Failed to copy fd"); } while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { if (write(fd_out, buf, n) != n) { fatal("Failed to copy fd"); } } } static int _copy_file(const char *src, const char *dest, int mode) { int fd_in, fd_out; gzFile gz_in, gz_out = NULL; char buf[10240]; int n, ret; char *tmp_name; mode_t mask; struct stat st; x_asprintf(&tmp_name, "%s.XXXXXX", dest); if (getenv("CCACHE_NOCOMPRESS")) { mode = COPY_UNCOMPRESSED; } /* open source file */ fd_in = open(src, O_RDONLY); if (fd_in == -1) { return -1; } gz_in = gzdopen(fd_in, "rb"); if (!gz_in) { close(fd_in); return -1; } /* open destination file */ fd_out = mkstemp(tmp_name); if (fd_out == -1) { gzclose(gz_in); free(tmp_name); return -1; } if (mode == COPY_TO_CACHE) { /* The gzip file format occupies at least 20 bytes. So it will always occupy an entire filesystem block, even for empty files. Since most stderr files will be empty, we turn off compression in this case to save space. */ if (fstat(fd_in, &st) != 0) { gzclose(gz_in); close(fd_out); free(tmp_name); return -1; } if (file_size(&st) == 0) { mode = COPY_UNCOMPRESSED; } } if (mode == COPY_TO_CACHE) { gz_out = gzdopen(dup(fd_out), "wb"); if (!gz_out) { gzclose(gz_in); close(fd_out); free(tmp_name); return -1; } } while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { if (mode == COPY_TO_CACHE) { ret = gzwrite(gz_out, buf, n); } else { ret = write(fd_out, buf, n); } if (ret != n) { gzclose(gz_in); if (gz_out) { gzclose(gz_out); } close(fd_out); unlink(tmp_name); free(tmp_name); return -1; } } gzclose(gz_in); if (gz_out) { gzclose(gz_out); } /* get perms right on the tmp file */ mask = umask(0); fchmod(fd_out, 0666 & ~mask); umask(mask); /* the close can fail on NFS if out of space */ if (close(fd_out) == -1) { unlink(tmp_name); free(tmp_name); return -1; } unlink(dest); if (rename(tmp_name, dest) == -1) { unlink(tmp_name); free(tmp_name); return -1; } free(tmp_name); return 0; } /* move a file to the cache, compressing it */ int move_file(const char *src, const char *dest) { int ret; ret = _copy_file(src, dest, COPY_TO_CACHE); if (ret != -1) unlink(src); return ret; } /* copy a file to the cache, compressing it */ static int copy_file_to_cache(const char *src, const char *dest) { return _copy_file(src, dest, COPY_TO_CACHE); } /* copy a file from the cache, decompressing it */ static int copy_file_from_cache(const char *src, const char *dest) { return _copy_file(src, dest, COPY_FROM_CACHE); } #endif /* ENABLE_ZLIB */ /* test if a file is zlib compressed */ int test_if_compressed(const char *filename) { FILE *f; f = fopen(filename, "rb"); if (!f) { return 0; } /* test if file starts with 1F8B, which is zlib's * magic number */ if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) { fclose(f); return 0; } fclose(f); return 1; } /* copy file to the cache with error checking taking into account compression and hard linking if desired */ int commit_to_cache(const char *src, const char *dest, int hardlink) { int ret = -1; struct stat st; if (stat(src, &st) == 0) { unlink(dest); if (hardlink) { #ifdef _WIN32 ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1; #else ret = link(src, dest); #endif } if (ret == -1) { ret = copy_file_to_cache(src, dest); if (ret == -1) { cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno)); stats_update(STATS_ERROR); } } } else { cc_log("failed to put %s in the cache (%s)\n", src, strerror(errno)); stats_update(STATS_ERROR); } return ret; } /* copy file out of the cache with error checking taking into account compression and hard linking if desired */ int retrieve_from_cache(const char *src, const char *dest, int hardlink) { int ret = 0; x_utimes(src); if (strcmp(dest, "/dev/null") == 0) { ret = 0; } else { unlink(dest); /* only make a hardlink if the cache file is uncompressed */ if (hardlink && test_if_compressed(src) == 0) { #ifdef _WIN32 ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1; #else ret = link(src, dest); #endif } else { ret = copy_file_from_cache(src, dest); } } /* the cached file might have been deleted by some external process */ if (ret == -1 && errno == ENOENT) { cc_log("hashfile missing for %s\n", dest); stats_update(STATS_MISSING); return -1; } if (ret == -1) { ret = copy_file_from_cache(src, dest); if (ret == -1) { cc_log("failed to retrieve %s -> %s (%s)\n", src, dest, strerror(errno)); stats_update(STATS_ERROR); return -1; } } return ret; } /* make sure a directory exists */ int create_dir(const char *dir) { struct stat st; if (stat(dir, &st) == 0) { if (S_ISDIR(st.st_mode)) { return 0; } errno = ENOTDIR; return 1; } #ifdef _WIN32 if (mkdir(dir) != 0 && errno != EEXIST) { return 1; } #else if (mkdir(dir, 0777) != 0 && errno != EEXIST) { return 1; } #endif return 0; } char const CACHEDIR_TAG[] = "Signature: 8a477f597d28d172789f06886806bc55\n" "# This file is a cache directory tag created by ccache.\n" "# For information about cache directory tags, see:\n" "# http://www.brynosaurus.com/cachedir/\n"; int create_cachedirtag(const char *dir) { char *filename; struct stat st; FILE *f; x_asprintf(&filename, "%s/CACHEDIR.TAG", dir); if (stat(filename, &st) == 0) { if (S_ISREG(st.st_mode)) { goto success; } errno = EEXIST; goto error; } f = fopen(filename, "w"); if (!f) goto error; if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) { goto error; } if (fclose(f)) goto error; success: free(filename); return 0; error: free(filename); return 1; } /* this is like asprintf() but dies if the malloc fails note that we use vsnprintf in a rather poor way to make this more portable */ void x_asprintf(char **ptr, const char *format, ...) { va_list ap; *ptr = NULL; va_start(ap, format); if (vasprintf(ptr, format, ap) == -1) { fatal("out of memory in x_asprintf"); } va_end(ap); if (!ptr) fatal("out of memory in x_asprintf"); } /* this is like strdup() but dies if the malloc fails */ char *x_strdup(const char *s) { char *ret; ret = strdup(s); if (!ret) { fatal("out of memory in strdup\n"); } return ret; } /* this is like malloc() but dies if the malloc fails */ void *x_malloc(size_t size) { void *ret; ret = malloc(size); if (!ret) { fatal("out of memory in malloc\n"); } return ret; } /* this is like realloc() but dies if the malloc fails */ void *x_realloc(void *ptr, size_t size) { void *p2; #if 1 /* Avoid invalid read in memcpy below */ p2 = realloc(ptr, size); if (!p2) { fatal("out of memory in x_realloc"); } #else if (!ptr) return x_malloc(size); p2 = malloc(size); if (!p2) { fatal("out of memory in x_realloc"); } if (ptr) { /* Note invalid read as the memcpy reads beyond the memory allocated by ptr */ memcpy(p2, ptr, size); free(ptr); } #endif return p2; } /* revsusive directory traversal - used for cleanup fn() is called on all files/dirs in the tree */ void traverse(const char *dir, void (*fn)(const char *, struct stat *)) { DIR *d; struct dirent *de; d = opendir(dir); if (!d) return; while ((de = readdir(d))) { char *fname; struct stat st; if (strcmp(de->d_name,".") == 0) continue; if (strcmp(de->d_name,"..") == 0) continue; if (strlen(de->d_name) == 0) continue; x_asprintf(&fname, "%s/%s", dir, de->d_name); #ifdef _WIN32 if (stat(fname, &st)) #else if (lstat(fname, &st)) #endif { if (errno != ENOENT) { perror(fname); } free(fname); continue; } if (S_ISDIR(st.st_mode)) { traverse(fname, fn); } fn(fname, &st); free(fname); } closedir(d); } /* return the base name of a file - caller frees */ char *str_basename(const char *s) { char *p = strrchr(s, '/'); if (p) { s = (p+1); } #ifdef _WIN32 p = strrchr(s, '\\'); if (p) { s = (p+1); } #endif return x_strdup(s); } /* return the dir name of a file - caller frees */ char *dirname(char *s) { char *p; s = x_strdup(s); p = strrchr(s, '/'); #ifdef _WIN32 p = strrchr(s, '\\'); #endif if (p) { *p = 0; } return s; } /* http://www.ecst.csuchico.edu/~beej/guide/ipc/flock.html http://cvs.php.net/viewvc.cgi/php-src/win32/flock.c?revision=1.2&view=markup Should return 0 for success, >0 otherwise */ int lock_fd(int fd) { #ifdef _WIN32 # if 1 return _locking(fd, _LK_NBLCK, 1); # else HANDLE fl = (HANDLE)_get_osfhandle(fd); OVERLAPPED o; memset(&o, 0, sizeof(o)); return (LockFileEx(fl, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &o)) ? 0 : GetLastError(); # endif #else struct flock fl; int ret; fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 1; fl.l_pid = 0; /* not sure why we would be getting a signal here, but one user claimed it is possible */ do { ret = fcntl(fd, F_SETLKW, &fl); } while (ret == -1 && errno == EINTR); return ret; #endif } /* return size on disk of a file */ size_t file_size(struct stat *st) { #ifdef _WIN32 return (st->st_size + 1023) & ~1023; #else size_t size = st->st_blocks * 512; if ((size_t)st->st_size > size) { /* probably a broken stat() call ... */ size = (st->st_size + 1023) & ~1023; } return size; #endif } /* a safe open/create for read-write */ int safe_open(const char *fname) { int fd = open(fname, O_RDWR|O_BINARY); if (fd == -1 && errno == ENOENT) { fd = open(fname, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0666); if (fd == -1 && errno == EEXIST) { fd = open(fname, O_RDWR|O_BINARY); } } return fd; } /* display a kilobyte unsigned value in M, k or G */ void display_size(unsigned v) { if (v > 1024*1024) { printf("%8.1f Gbytes", v/((double)(1024*1024))); } else if (v > 1024) { printf("%8.1f Mbytes", v/((double)(1024))); } else { printf("%8u Kbytes", v); } } /* return a value in multiples of 1024 give a string that can end in K, M or G */ size_t value_units(const char *s) { char m; double v = atof(s); m = s[strlen(s)-1]; switch (m) { case 'G': case 'g': default: v *= 1024*1024; break; case 'M': case 'm': v *= 1024; break; case 'K': case 'k': v *= 1; break; } return (size_t)v; } /* a sane realpath() function, trying to cope with stupid path limits and a broken API */ char *x_realpath(const char *path) { #ifdef _WIN32 char namebuf[MAX_PATH]; DWORD ret; ret = GetFullPathNameA(path, sizeof(namebuf), namebuf, NULL); if (ret == 0 || ret >= sizeof(namebuf)) { return NULL; } return x_strdup(namebuf); #else int maxlen; char *ret, *p; #ifdef PATH_MAX maxlen = PATH_MAX; #elif defined(MAXPATHLEN) maxlen = MAXPATHLEN; #elif defined(_PC_PATH_MAX) maxlen = pathconf(path, _PC_PATH_MAX); #endif if (maxlen < 4096) maxlen = 4096; ret = x_malloc(maxlen); #if HAVE_REALPATH p = realpath(path, ret); #else /* yes, there are such systems. This replacement relies on the fact that when we call x_realpath we only care about symlinks */ { int len = readlink(path, ret, maxlen-1); if (len == -1) { free(ret); return NULL; } ret[len] = 0; p = ret; } #endif if (p) { p = x_strdup(p); free(ret); return p; } free(ret); return NULL; #endif } /* a getcwd that will returns an allocated buffer */ char *gnu_getcwd(void) { unsigned size = 128; while (1) { char *buffer = (char *)x_malloc(size); if (getcwd(buffer, size) == buffer) { return buffer; } free(buffer); if (errno != ERANGE) { return 0; } size *= 2; } } /* create an empty file */ int create_empty_file(const char *fname) { int fd; fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { return -1; } close(fd); return 0; } /* return current users home directory or die */ const char *get_home_directory(void) { #ifdef _WIN32 static char home_path[MAX_PATH] = {0}; HRESULT ret; /* we already have the path */ if (home_path[0] != 0) { return home_path; } /* get the path to "Application Data" folder */ ret = SHGetFolderPathA(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, home_path); if (SUCCEEDED(ret)) { return home_path; } fprintf(stderr, "ccache: Unable to determine home directory\n"); return NULL; #else const char *p = getenv("HOME"); if (p) { return p; } #ifdef HAVE_GETPWUID { struct passwd *pwd = getpwuid(getuid()); if (pwd) { return pwd->pw_dir; } } #endif fatal("Unable to determine home directory"); return NULL; #endif } int x_utimes(const char *filename) { #ifdef HAVE_UTIMES return utimes(filename, NULL); #else return utime(filename, NULL); #endif } #ifdef _WIN32 /* perror for Win32 API calls, using GetLastError() instead of errno */ void perror_win32(LPTSTR pszFunction) { LPTSTR pszMessage; DWORD dwLastError = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwLastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&pszMessage, 0, NULL ); fprintf(stderr, "%s: %s\n", pszFunction, pszMessage); LocalFree(pszMessage); } #endif swig-3.0.8/CCache/debian/0000775000175000017500000000000012641054563014711 5ustar williamwilliamswig-3.0.8/CCache/debian/update-ccache0000664000175000017500000000171512641054563017326 0ustar williamwilliam#!/bin/sh # # Update compiler links to ccache (in /usr/local/bin) # # The idea is that /usr/local/bin is ahead of /usr/bin in your PATH, so adding # the link /usr/local/bin/cc -> /usr/bin/ccache means that it is run instead of # /usr/bin/cc # # Written by: Behan Webster # DIRECTORY=/usr/local/bin CCACHE=/usr/bin/ccache CCDIR=/usr/lib/ccache usage() { echo "Usage: `basename $0` [--directory ] [--remove]" exit 0 } while [ $# -gt 0 ] ; do case "$1" in -d*|--d*|--directory) DIRECTORY=$2; shift; shift;; -h*|--h*|--help) usage;; -r*|--r*|--remove) REMOVE=1; shift;; -t*|--t*|--test) TEST=echo; shift;; esac done for FILE in `cd $CCDIR; ls` ; do LINK=$DIRECTORY/$FILE if [ -z "$REMOVE" ] ; then # Add link $TEST ln -fs $CCACHE $LINK else # Remove link if [ -L "$LINK" ] ; then $TEST rm -f $LINK fi fi done # vim: sw=4 ts=4 swig-3.0.8/CCache/debian/patches/0000775000175000017500000000000012641054563016340 5ustar williamwilliamswig-3.0.8/CCache/debian/patches/11_utimes.diff0000664000175000017500000000460212641054563021003 0ustar williamwilliam--- ccache.c 2004-09-13 03:38:30.000000000 -0700 +++ ccache.c 2006-06-09 16:29:16.695117780 -0700 @@ -481,8 +481,13 @@ /* update timestamps for LRU cleanup also gives output_file a sensible mtime when hard-linking (for make) */ +#ifdef HAVE_UTIMES + utimes(hashname, NULL); + utimes(stderr_file, NULL); +#else utime(hashname, NULL); utime(stderr_file, NULL); +#endif if (strcmp(output_file, "/dev/null") == 0) { ret = 0; --- ccache.h 2004-09-13 03:38:30.000000000 -0700 +++ ccache.h 2006-06-09 16:28:16.601658626 -0700 @@ -22,6 +22,9 @@ #ifdef HAVE_PWD_H #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif #define STATUS_NOTFOUND 3 #define STATUS_FATAL 4 --- config.h.in 2003-09-27 21:48:17.000000000 -0700 +++ config.h.in 2006-06-09 16:25:43.000000000 -0700 @@ -19,6 +19,9 @@ /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME +/* Define to 1 if you have the `getpwuid' function. */ +#undef HAVE_GETPWUID + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -31,6 +34,9 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_PWD_H + /* Define to 1 if you have the `realpath' function. */ #undef HAVE_REALPATH @@ -60,6 +66,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H @@ -69,6 +78,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `utimes' function. */ +#undef HAVE_UTIMES + /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF --- configure.in 2004-09-13 03:38:30.000000000 -0700 +++ configure.in 2006-06-09 16:25:15.541288184 -0700 @@ -27,10 +27,11 @@ AC_HEADER_TIME AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h) +AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h) AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) AC_CHECK_FUNCS(gethostname getpwuid) +AC_CHECK_FUNCS(utimes) AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ AC_TRY_COMPILE( swig-3.0.8/CCache/debian/patches/10_lru_cleanup.diff0000664000175000017500000000105712641054563022006 0ustar williamwilliam--- ccache.c (révision 8804) +++ ccache.c (copie de travail) @@ -481,6 +481,9 @@ return; } + /* update timestamps for LRU cleanup + also gives output_file a sensible mtime when hard-linking (for make) */ + utime(hashname, NULL); utime(stderr_file, NULL); if (strcmp(output_file, "/dev/null") == 0) { @@ -513,10 +516,6 @@ failed(); } } - if (ret == 0) { - /* update the mtime on the file so that make doesn't get confused */ - utime(output_file, NULL); - } /* get rid of the intermediate preprocessor file */ if (i_tmpfile) { swig-3.0.8/CCache/debian/patches/03_long_options.diff0000664000175000017500000001150412641054563022207 0ustar williamwilliamIndex: ccache.c =================================================================== --- ccache.c (révision 7695) +++ ccache.c (copie de travail) @@ -22,6 +22,7 @@ */ #include "ccache.h" +#include /* the base cache directory */ char *cache_dir = NULL; @@ -885,14 +886,14 @@ printf("\tcompiler [compile options] (via symbolic link)\n"); printf("\nOptions:\n"); - printf("-s show statistics summary\n"); - printf("-z zero statistics\n"); - printf("-c run a cache cleanup\n"); - printf("-C clear the cache completely\n"); - printf("-F set maximum files in cache\n"); - printf("-M set maximum size of cache (use G, M or K)\n"); - printf("-h this help page\n"); - printf("-V print version number\n"); + printf("-s, --show-stats show statistics summary\n"); + printf("-z, --zero-stats zero statistics\n"); + printf("-c, --cleanup run a cache cleanup\n"); + printf("-C, --clear clear the cache completely\n"); + printf("-F , --max-files= set maximum files in cache\n"); + printf("-M , --max-size= set maximum size of cache (use G, M or K)\n"); + printf("-h, --help this help page\n"); + printf("-V, --version print version number\n"); } /* the main program when not doing a compile */ @@ -901,7 +902,21 @@ int c; size_t v; - while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { + static struct option long_options[] = + { + {"show-stats", no_argument, 0, 's'}, + {"zero-stats", no_argument, 0, 'z'}, + {"cleanup", no_argument, 0, 'c'}, + {"clear", no_argument, 0, 'C'}, + {"max-files", required_argument, 0, 'F'}, + {"max-size", required_argument, 0, 'M'}, + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, + {0, 0, 0, 0} + }; + int option_index = 0; + + while ((c = getopt_long(argc, argv, "hszcCF:M:V", long_options, &option_index)) != -1) { switch (c) { case 'V': printf("ccache version %s\n", CCACHE_VERSION); Index: ccache.1 =================================================================== --- ccache.1 (révision 7695) +++ ccache.1 (copie de travail) @@ -23,14 +23,14 @@ .nf --s show statistics summary --z zero statistics --c run a cache cleanup --C clear the cache completely --F set maximum files in cache --M set maximum size of cache (use G, M or K) --h this help page --V print version number +\-s, \-\-show-stats show statistics summary +\-z, \-\-zero-stats zero statistics +\-c, \-\-cleanup run a cache cleanup +\-C, \-\-clear clear the cache completely +\-F , \-\-max-files= set maximum files in cache +\-M , \-\-max-size= set maximum size of cache (use G, M or K) +\-h, \-\-help this help page +\-V, \-\-version print version number .fi @@ -43,22 +43,22 @@ normal compiler options apply and you should refer to your compilers documentation\&. .PP -.IP "\fB-h\fP" +.IP "\fB-h, --help\fP" Print a options summary page .IP -.IP "\fB-s\fP" +.IP "\fB-s, --show-stats\fP" Print the current statistics summary for the cache\&. The statistics are stored spread across the subdirectories of the cache\&. Using "ccache -s" adds up the statistics across all subdirectories and prints the totals\&. .IP -.IP "\fB-z\fP" +.IP "\fB-z, --zero-stats\fP" Zero the cache statistics\&. .IP -.IP "\fB-V\fP" +.IP "\fB-V, --version\fP" Print the ccache version number .IP -.IP "\fB-c\fP" +.IP "\fB-c, --cleanup\fP" Clean the cache and re-calculate the cache file count and size totals\&. Normally the -c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps @@ -66,16 +66,16 @@ if you manually modify the cache contents or believe that the cache size statistics may be inaccurate\&. .IP -.IP "\fB-C\fP" +.IP "\fB-C, --clear\fP" Clear the entire cache, removing all cached files\&. .IP -.IP "\fB-F maxfiles\fP" +.IP "\fB-F , --max-files=\fP" This sets the maximum number of files allowed in the cache\&. The value is stored inside the cache directory and applies to all future compiles\&. Due to the way the value is stored the actual value used is always rounded down to the nearest multiple of 16\&. .IP -.IP "\fB-M maxsize\fP" +.IP "\fB-M , --max-size=\fP" This sets the maximum cache size\&. You can specify a value in gigabytes, megabytes or kilobytes by appending a G, M or K to the value\&. The default is gigabytes\&. The actual value stored is swig-3.0.8/CCache/debian/patches/01_no_home.diff0000664000175000017500000000414212641054563021117 0ustar williamwilliam--- ccache.c +++ ccache.c @@ -836,6 +836,13 @@ { /* find the real compiler */ find_compiler(argc, argv); + + /* use the real compiler if HOME is not set */ + if (!cache_dir) { + cc_log("Unable to determine home directory\n"); + cc_log("ccache is disabled\n"); + failed(); + } /* we might be disabled */ if (getenv("CCACHE_DISABLE")) { @@ -895,6 +902,13 @@ printf("-V print version number\n"); } +static void check_cache_dir(void) +{ + if (!cache_dir) { + fatal("Unable to determine home directory"); + } +} + /* the main program when not doing a compile */ static int ccache_main(int argc, char *argv[]) { @@ -914,31 +928,37 @@ exit(0); case 's': + check_cache_dir(); stats_summary(); break; case 'c': + check_cache_dir(); cleanup_all(cache_dir); printf("Cleaned cache\n"); break; case 'C': + check_cache_dir(); wipe_all(cache_dir); printf("Cleared cache\n"); break; case 'z': + check_cache_dir(); stats_zero(); printf("Statistics cleared\n"); break; case 'F': + check_cache_dir(); v = atoi(optarg); stats_set_limits(v, -1); printf("Set cache file limit to %u\n", (unsigned)v); break; case 'M': + check_cache_dir(); v = value_units(optarg); stats_set_limits(-1, v); printf("Set cache size limit to %uk\n", (unsigned)v); @@ -983,7 +1003,10 @@ cache_dir = getenv("CCACHE_DIR"); if (!cache_dir) { - x_asprintf(&cache_dir, "%s/.ccache", get_home_directory()); + const char *home_directory = get_home_directory(); + if (home_directory) { + x_asprintf(&cache_dir, "%s/.ccache", home_directory); + } } temp_dir = getenv("CCACHE_TEMPDIR"); @@ -1023,7 +1046,7 @@ } /* make sure the cache dir exists */ - if (create_dir(cache_dir) != 0) { + if (cache_dir && (create_dir(cache_dir) != 0)) { fprintf(stderr,"ccache: failed to create %s (%s)\n", cache_dir, strerror(errno)); exit(1); --- util.c +++ util.c @@ -448,7 +448,7 @@ } } #endif - fatal("Unable to determine home directory"); + cc_log("Unable to determine home directory"); return NULL; } swig-3.0.8/CCache/debian/patches/05_nfs_fix.diff0000664000175000017500000000230712641054563021134 0ustar williamwilliam--- ccache.1.orig 2007-05-20 17:30:57.000000000 +1200 +++ ccache.1 2007-05-20 17:31:27.000000000 +1200 @@ -367,12 +367,6 @@ .IP o ccache avoids a double call to cpp on a cache miss .PP -.SH "BUGS" -.PP -When the cache is stored on an NFS filesystem, the filesystem must be -exported with the \fBno_subtree_check\fP option to make renames between -directories reliable\&. -.PP .SH "CREDITS" .PP Thanks to the following people for their contributions to ccache --- util.c.patched 2007-05-20 18:19:11.000000000 +1200 +++ util.c 2007-05-20 18:20:55.000000000 +1200 @@ -58,9 +58,26 @@ } } +static int safe_rename(const char* oldpath, const char* newpath) +{ + /* safe_rename is for creating entries in the cache. + + Works like rename(), but it never overwrites an existing + cache entry. This avoids corruption on NFS. */ + int status = link( oldpath, newpath ); + if( status == 0 || errno == EEXIST ) + { + return unlink( oldpath ); + } + else + { + return -1; + } +} + /* move a file using rename */ int move_file(const char *src, const char *dest) { - return rename(src, dest); + return safe_rename(src, dest); } /* copy a file - used when hard links don't work swig-3.0.8/CCache/debian/patches/06_md.diff0000664000175000017500000000422512641054563020102 0ustar williamwilliam--- ccache.c Mon Sep 13 11:38:30 2004 +++ ccache.c Thu Jun 21 22:17:32 2007 @@ -627,6 +627,13 @@ static void process_args(int argc, char int found_S_opt = 0; struct stat st; char *e; + /* is gcc being asked to output dependencies? */ + int generating_dependencies = 0; + /* is the dependency makefile name overridden with -MF? */ + int dependency_filename_specified = 0; + /* is the dependency makefile target name specified with -MQ or -MF? */ + int dependency_target_specified = 0; + stripped_args = args_init(0, NULL); @@ -702,6 +709,18 @@ static void process_args(int argc, char continue; } + /* These options require special handling, because they + behave differently with gcc -E, when the output + file is not specified. */ + + if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) { + generating_dependencies = 1; + } else if (strcmp(argv[i], "-MF") == 0) { + dependency_filename_specified = 1; + } else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) { + dependency_target_specified = 1; + } + /* options that take an argument */ { const char *opts[] = {"-I", "-include", "-imacros", "-iprefix", @@ -812,6 +831,41 @@ static void process_args(int argc, char } p[1] = found_S_opt ? 's' : 'o'; p[2] = 0; + } + + /* If dependencies are generated, configure the preprocessor */ + + if (generating_dependencies && output_file) { + if (!dependency_filename_specified) { + char *default_depfile_name = x_strdup(output_file); + char *p = strrchr(default_depfile_name, '.'); + + if (p) { + if (strlen(p) < 2) { + stats_update(STATS_ARGS); + failed(); + return; + } + *p = 0; + } + else { + int len = p - default_depfile_name; + + p = x_malloc(len + 3); + strncpy(default_depfile_name, p, len - 1); + free(default_depfile_name); + default_depfile_name = p; + } + + strcat(default_depfile_name, ".d"); + args_add(stripped_args, "-MF"); + args_add(stripped_args, default_depfile_name); + } + + if (!dependency_target_specified) { + args_add(stripped_args, "-MT"); + args_add(stripped_args, output_file); + } } /* cope with -o /dev/null */ swig-3.0.8/CCache/debian/patches/14_hardlink_doc.diff0000664000175000017500000000366612641054563022132 0ustar williamwilliamIndex: ccache.1 =================================================================== RCS file: /cvsroot/ccache/ccache.1,v retrieving revision 1.26 diff -u -r1.26 ccache.1 --- ccache.1 24 Nov 2005 21:10:08 -0000 1.26 +++ ccache.1 21 Jul 2007 21:03:32 -0000 @@ -330,7 +330,7 @@ .IP o Use the same \fBCCACHE_DIR\fP environment variable setting .IP o -Set the \fBCCACHE_NOLINK\fP environment variable +Unset the \fBCCACHE_HARDLINK\fP environment variable .IP o Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in Index: ccache.yo =================================================================== RCS file: /cvsroot/ccache/ccache.yo,v retrieving revision 1.27 diff -u -r1.27 ccache.yo --- ccache.yo 24 Nov 2005 21:54:09 -0000 1.27 +++ ccache.yo 21 Jul 2007 21:03:32 -0000 @@ -289,7 +289,7 @@ itemize( it() Use the same bf(CCACHE_DIR) environment variable setting - it() Set the bf(CCACHE_NOLINK) environment variable + it() Unset the bf(CCACHE_HARDLINK) environment variable it() Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in the group. Index: web/ccache-man.html =================================================================== RCS file: /cvsroot/ccache/web/ccache-man.html,v retrieving revision 1.25 diff -u -r1.25 ccache-man.html --- web/ccache-man.html 13 Sep 2004 10:38:17 -0000 1.25 +++ web/ccache-man.html 21 Jul 2007 21:03:32 -0000 @@ -256,7 +256,7 @@ following conditions need to be met:

  • Use the same CCACHE_DIR environment variable setting -
  • Set the CCACHE_NOLINK environment variable +
  • Unset the CCACHE_HARDLINK environment variable
  • Make sure everyone sets the CCACHE_UMASK environment variable to 002, this ensures that cached files are accessible to everyone in the group. swig-3.0.8/CCache/debian/patches/CREDITS0000664000175000017500000000317212641054563017363 0ustar williamwilliam01_no_home.diff: Francois Marier Made especially for the Debian package. 02_ccache_compressed.diff: Lars Gustäbel http://www.gustaebel.de/lars/ccache/ (downloaded on 2007-05-20) 03_long_options.diff: Francois Marier Made especially for the Debian package. 04_ignore_profile.diff: Ted Percival http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=20;filename=ccache-profile.patch;att=1;bug=215849 05_nfs_fix.diff: John Coiner http://lists.samba.org/archive/ccache/2007q1/000265.html 06_md.diff: Andrea Bittau http://darkircop.org/ccache/ccache-2.4-md.patch (downloaded on 2007-06-30) 07_cachedirtag.diff: Karl Chen http://lists.samba.org/archive/ccache/2008q1/000316.html (downloaded on 2008-02-02) 08_manpage_hyphens.diff: Francois Marier Made especially for the Debian package. 09_respect_ldflags.diff: Lisa Seelye http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-respectflags.patch?rev=1.1&view=markup 10_lru_cleanup.diff: RW http://lists.samba.org/archive/ccache/2008q2/000339.html (downloaded on 2008-04-11) 11_utimes.diff: Robin H. Johnson http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-utimes.patch?rev=1.1&view=markup 12_cachesize_permissions.diff: Francois Marier Made especially for the Debian package to fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332527 swig-3.0.8/CCache/debian/patches/13_html_links.diff0000664000175000017500000000222612641054563021643 0ustar williamwilliam--- web/index.html~ 2004-09-13 13:38:30.000000000 +0300 +++ web/index.html 2004-09-26 01:04:38.458008118 +0300 @@ -29,10 +29,10 @@
  • fixed handling of HOME environment variable
-See the manual page for details +See the manual page for details on the new options.

-You can get this release from the download directory +You can get this release from the download directory

NOTE! This release changes the hash input slighly, so you will probably find that you will not get any hits against your existing @@ -87,7 +87,7 @@

Documentation

-See the manual page +See the manual page

Performance

@@ -116,7 +116,7 @@

Download

You can download the latest release from the download directory.

+href="http://ccache.samba.org/ftp/ccache/">download directory.

For the bleeding edge, you can fetch ccache via CVS or rsync. To fetch via cvs use the following command: swig-3.0.8/CCache/debian/patches/07_cachedirtag.diff0000664000175000017500000000361012641054563021736 0ustar williamwilliamIndex: ccache.c =================================================================== --- ccache.c (révision 7695) +++ ccache.c (copie de travail) @@ -1029,6 +1029,14 @@ exit(1); } + if (!getenv("CCACHE_READONLY")) { + if (create_cachedirtag(cache_dir) != 0) { + fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", + cache_dir, strerror(errno)); + exit(1); + } + } + ccache(argc, argv); return 1; } Index: ccache.h =================================================================== --- ccache.h (révision 7695) +++ ccache.h (copie de travail) @@ -81,6 +81,7 @@ int copy_file(const char *src, const char *dest); int create_dir(const char *dir); +int create_cachedirtag(const char *dir); void x_asprintf(char **ptr, const char *format, ...); char *x_strdup(const char *s); void *x_realloc(void *ptr, size_t size); Index: util.c =================================================================== --- util.c (révision 7695) +++ util.c (copie de travail) @@ -138,6 +138,39 @@ return 0; } +char const CACHEDIR_TAG[] = + "Signature: 8a477f597d28d172789f06886806bc55\n" + "# This file is a cache directory tag created by ccache.\n" + "# For information about cache directory tags, see:\n" + "# http://www.brynosaurus.com/cachedir/\n"; + +int create_cachedirtag(const char *dir) +{ + char *filename; + struct stat st; + FILE *f; + x_asprintf(&filename, "%s/CACHEDIR.TAG", dir); + if (stat(filename, &st) == 0) { + if (S_ISREG(st.st_mode)) { + goto success; + } + errno = EEXIST; + goto error; + } + f = fopen(filename, "w"); + if (!f) goto error; + if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) { + goto error; + } + if (fclose(f)) goto error; +success: + free(filename); + return 0; +error: + free(filename); + return 1; +} + /* this is like asprintf() but dies if the malloc fails note that we use vsnprintf in a rather poor way to make this more portable swig-3.0.8/CCache/debian/patches/12_cachesize_permissions.diff0000664000175000017500000000374512641054563024076 0ustar williamwilliam--- stats.c (révision 8804) +++ stats.c (copie de travail) @@ -286,7 +286,7 @@ /* set the per directory limits */ -void stats_set_limits(long maxfiles, long maxsize) +int stats_set_limits(long maxfiles, long maxsize) { int dir; unsigned counters[STATS_END]; @@ -298,7 +298,9 @@ maxsize /= 16; } - create_dir(cache_dir); + if (create_dir(cache_dir) != 0) { + return 1; + } /* set the limits in each directory */ for (dir=0;dir<=0xF;dir++) { @@ -306,7 +308,9 @@ int fd; x_asprintf(&cdir, "%s/%1x", cache_dir, dir); - create_dir(cdir); + if (create_dir(cdir) != 0) { + return 1; + } x_asprintf(&fname, "%s/stats", cdir); free(cdir); @@ -326,6 +330,8 @@ } free(fname); } + + return 0; } /* set the per directory sizes */ --- ccache.c (révision 8804) +++ ccache.c (copie de travail) @@ -935,15 +934,23 @@ case 'F': check_cache_dir(); v = atoi(optarg); - stats_set_limits(v, -1); - printf("Set cache file limit to %u\n", (unsigned)v); + if (stats_set_limits(v, -1) == 0) { + printf("Set cache file limit to %u\n", (unsigned)v); + } else { + printf("Could not set cache file limit.\n"); + exit(1); + } break; case 'M': check_cache_dir(); v = value_units(optarg); - stats_set_limits(-1, v); - printf("Set cache size limit to %uk\n", (unsigned)v); + if (stats_set_limits(-1, v) == 0) { + printf("Set cache size limit to %uk\n", (unsigned)v); + } else { + printf("Could not set cache size limit.\n"); + exit(1); + } break; default: --- ccache.h (révision 8804) +++ ccache.h (copie de travail) @@ -101,7 +101,7 @@ void stats_summary(void); void stats_tocache(size_t size); void stats_read(const char *stats_file, unsigned counters[STATS_END]); -void stats_set_limits(long maxfiles, long maxsize); +int stats_set_limits(long maxfiles, long maxsize); size_t value_units(const char *s); void display_size(unsigned v); void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); swig-3.0.8/CCache/debian/patches/09_respect_ldflags.diff0000664000175000017500000000053612641054563022647 0ustar williamwilliam--- Makefile.in.orig 2008-03-23 17:01:19.000000000 +1300 +++ Makefile.in 2008-03-23 17:03:03.000000000 +1300 @@ -21,7 +21,7 @@ docs: ccache.1 web/ccache-man.html ccache$(EXEEXT): $(OBJS) $(HEADERS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ccache.1: ccache.yo -yodl2man -o ccache.1 ccache.yo swig-3.0.8/CCache/debian/patches/04_ignore_profile.diff0000664000175000017500000000077712641054563022513 0ustar williamwilliamdiff -ru ccache-2.4/ccache.c ccache-2.4-tp/ccache.c --- ccache.c 2007-05-20 03:14:19.000000000 +1000 +++ ccache.c 2007-05-20 03:17:54.000000000 +1000 @@ -641,6 +641,9 @@ /* these are too hard */ if (strcmp(argv[i], "-fbranch-probabilities")==0 || + strcmp(argv[i], "-fprofile-arcs") == 0 || + strcmp(argv[i], "-ftest-coverage") == 0 || + strcmp(argv[i], "--coverage") == 0 || strcmp(argv[i], "-M") == 0 || strcmp(argv[i], "-MM") == 0 || strcmp(argv[i], "-x") == 0) { swig-3.0.8/CCache/debian/patches/08_manpage_hyphens.diff0000664000175000017500000000722712641054563022657 0ustar williamwilliamIndex: ccache.1 =================================================================== --- ccache.1 (révision 7695) +++ ccache.1 (copie de travail) @@ -49,7 +49,7 @@ .IP "\fB-s\fP" Print the current statistics summary for the cache\&. The statistics are stored spread across the subdirectories of the -cache\&. Using "ccache -s" adds up the statistics across all +cache\&. Using "ccache \-s" adds up the statistics across all subdirectories and prints the totals\&. .IP .IP "\fB-z\fP" @@ -60,7 +60,7 @@ .IP .IP "\fB-c\fP" Clean the cache and re-calculate the cache file count and -size totals\&. Normally the -c option should not be necessary as ccache +size totals\&. Normally the \-c option should not be necessary as ccache keeps the cache below the specified limits at runtime and keeps statistics up to date on each compile\&. This option is mostly useful if you manually modify the cache contents or believe that the cache @@ -100,9 +100,9 @@ cp ccache /usr/local/bin/ - ln -s /usr/local/bin/ccache /usr/local/bin/gcc - ln -s /usr/local/bin/ccache /usr/local/bin/g++ - ln -s /usr/local/bin/ccache /usr/local/bin/cc + ln \-s /usr/local/bin/ccache /usr/local/bin/gcc + ln \-s /usr/local/bin/ccache /usr/local/bin/g++ + ln \-s /usr/local/bin/ccache /usr/local/bin/cc .fi @@ -118,7 +118,7 @@ .PP When run as a compiler front end ccache usually just takes the same command line options as the compiler you are using\&. The only exception -to this is the option \&'--ccache-skip\&'\&. That option can be used to tell +to this is the option \&'\-\-ccache-skip\&'\&. That option can be used to tell ccache that the next option is definitely not a input filename, and should be passed along to the compiler as-is\&. .PP @@ -128,7 +128,7 @@ of the resulting object file (among other things)\&. The heuristic ccache uses in this parse is that any string on the command line that exists as a file is treated as an input file name (usually a C -file)\&. By using --ccache-skip you can force an option to not be +file)\&. By using \-\-ccache-skip you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option\&. .PP @@ -238,7 +238,7 @@ .IP "\fBCCACHE_UNIFY\fP" If you set the environment variable CCACHE_UNIFY then ccache will use the C/C++ unifier when hashing the pre-processor -output if -g is not used in the compile\&. The unifier is slower than a +output if \-g is not used in the compile\&. The unifier is slower than a normal hash, so setting this environment variable loses a little bit of speed, but it means that ccache can take advantage of not recompiling when the changes to the source code consist of @@ -262,7 +262,7 @@ .PP By default ccache has a one gigabyte limit on the cache size and no maximum number of files\&. You can set a different limit using the -"ccache -M" and "ccache -F" options, which set the size and number of +"ccache \-M" and "ccache \-F" options, which set the size and number of files limits\&. .PP When these limits are reached ccache will reduce the cache to 20% @@ -276,7 +276,7 @@ that it is the same code by forming a hash of: .PP .IP o -the pre-processor output from running the compiler with -E +the pre-processor output from running the compiler with \-E .IP o the command line options .IP o @@ -331,7 +331,7 @@ .IP o Make sure that the setgid bit is set on all directories in the cache\&. This tells the filesystem to inherit group ownership for new -directories\&. The command "chmod g+s `find $CCACHE_DIR -type d`" might +directories\&. The command "chmod g+s `find $CCACHE_DIR \-type d`" might be useful for this\&. .PP .SH "HISTORY" swig-3.0.8/CCache/debian/patches/02_ccache-compressed.diff0000664000175000017500000007377112641054563023062 0ustar williamwilliamIndex: ccache.1 =================================================================== RCS file: /home/cvsroot/lars/ccache/ccache.1,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.6 diff -u -r1.1.1.1.2.1 -r1.6 --- ccache.1 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ ccache.1 21 Nov 2004 18:19:28 -0000 1.6 @@ -210,7 +210,8 @@ CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy\&. Using hard links is faster, but can confuse programs like -\&'make\&' that rely on modification times\&. +\&'make\&' that rely on modification times\&. Hard links are never made for +compressed cache files\&. .IP .IP "\fBCCACHE_RECACHE\fP" This forces ccache to not use any cached @@ -257,6 +258,11 @@ the default\&. On HP-UX set this environment variable to "i" if you use the aCC compiler\&. .IP +.IP "\fBCCACHE_NOCOMPRESS\fP" +If you set the environment variable +CCACHE_NOCOMPRESS then there is no compression used on files that go +into the cache\&. +.IP .PP .SH "CACHE SIZE MANAGEMENT" .PP @@ -269,6 +275,14 @@ below the numbers you specified in order to avoid doing the cache clean operation too often\&. .PP +.SH "CACHE COMPRESSION" +.PP +By default ccache will compress all files it puts into the cache +using the zlib compression\&. While this involves a negligible +performance slowdown, it significantly increases the number of files +that fit in the cache\&. You can turn off compression setting the +CCACHE_NOCOMPRESS environment variable\&. +.PP .SH "HOW IT WORKS" .PP The basic idea is to detect when you are compiling exactly the same Index: ccache.c =================================================================== RCS file: /home/cvsroot/lars/ccache/ccache.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.9 diff -u -r1.1.1.1.2.1 -r1.9 --- ccache.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ ccache.c 21 Nov 2004 18:19:28 -0000 1.9 @@ -199,7 +199,7 @@ fd = open(tmp_stderr, O_RDONLY | O_BINARY); if (fd != -1) { if (strcmp(output_file, "/dev/null") == 0 || - rename(tmp_hashname, output_file) == 0 || errno == ENOENT) { + move_file(tmp_hashname, output_file) == 0 || errno == ENOENT) { if (cpp_stderr) { /* we might have some stderr from cpp */ int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); @@ -231,14 +231,25 @@ x_asprintf(&path_stderr, "%s.stderr", hashname); if (stat(tmp_stderr, &st1) != 0 || - stat(tmp_hashname, &st2) != 0 || - rename(tmp_hashname, hashname) != 0 || - rename(tmp_stderr, path_stderr) != 0) { + stat(tmp_hashname, &st2) != 0 || + move_file(tmp_hashname, hashname) != 0 || + move_file(tmp_stderr, path_stderr) != 0) { cc_log("failed to rename tmp files - %s\n", strerror(errno)); stats_update(STATS_ERROR); failed(); } +#if ENABLE_ZLIB + /* do an extra stat on the cache files for + the size statistics */ + if (stat(path_stderr, &st1) != 0 || + stat(hashname, &st2) != 0) { + cc_log("failed to stat cache files - %s\n", strerror(errno)); + stats_update(STATS_ERROR); + failed(); + } +#endif + cc_log("Placed %s into cache\n", output_file); stats_tocache(file_size(&st1) + file_size(&st2)); @@ -474,7 +485,13 @@ } /* the user might be disabling cache hits */ +#ifndef ENABLE_ZLIB + /* if the cache file is compressed we must recache */ + if ((first && getenv("CCACHE_RECACHE")) || + test_if_compressed(hashname) == 1) { +#else if (first && getenv("CCACHE_RECACHE")) { +#endif close(fd_stderr); unlink(stderr_file); free(stderr_file); @@ -487,7 +504,9 @@ ret = 0; } else { unlink(output_file); - if (getenv("CCACHE_HARDLINK")) { + /* only make a hardlink if the cache file is uncompressed */ + if (getenv("CCACHE_HARDLINK") && + test_if_compressed(hashname) == 0) { ret = link(hashname, output_file); } else { ret = copy_file(hashname, output_file); Index: ccache.h =================================================================== RCS file: /home/cvsroot/lars/ccache/ccache.h,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.7 diff -u -r1.1.1.1.2.1 -r1.7 --- ccache.h 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ ccache.h 21 Nov 2004 18:19:28 -0000 1.7 @@ -23,6 +23,10 @@ #include #endif +#ifdef ENABLE_ZLIB +#include +#endif + #define STATUS_NOTFOUND 3 #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 @@ -36,6 +40,13 @@ #define DEFAULT_MAXSIZE (1000*1000) #endif +/* file copy mode */ +#ifdef ENABLE_ZLIB +#define COPY_UNCOMPRESSED 0 +#define COPY_FROM_CACHE 1 +#define COPY_TO_CACHE 2 +#endif + enum stats { STATS_NONE=0, STATS_STDOUT, @@ -79,6 +90,8 @@ void copy_fd(int fd_in, int fd_out); int copy_file(const char *src, const char *dest); +int move_file(const char *src, const char *dest); +int test_if_compressed(const char *filename); int create_dir(const char *dir); void x_asprintf(char **ptr, const char *format, ...); Index: ccache.yo =================================================================== RCS file: /home/cvsroot/lars/ccache/ccache.yo,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.5 diff -u -r1.1.1.1.2.1 -r1.5 --- ccache.yo 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ ccache.yo 21 Nov 2004 18:19:28 -0000 1.5 @@ -169,6 +169,11 @@ this optimisation, in which case this option could allow ccache to be used. +dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable +CCACHE_NOCOMPRESS then there is no compression used on files that go +into the cache. However, this setting has no effect on how files are +retrieved from the cache, compressed results will still be usable. + dit(bf(CCACHE_NOSTATS)) If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile. @@ -181,7 +186,8 @@ CCACHE_HARDLINK then ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy. Using hard links is faster, but can confuse programs like -'make' that rely on modification times. +'make' that rely on modification times. Hard links are never made for +compressed cache files. dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached results, even if it finds them. New results are still cached, but @@ -236,6 +242,14 @@ below the numbers you specified in order to avoid doing the cache clean operation too often. +manpagesection(CACHE COMPRESSION) + +By default ccache will compress all files it puts into the cache +using the zlib compression. While this involves a negligible +performance slowdown, it significantly increases the number of files +that fit in the cache. You can turn off compression setting the +CCACHE_NOCOMPRESS environment variable. + manpagesection(HOW IT WORKS) The basic idea is to detect when you are compiling exactly the same @@ -294,6 +308,8 @@ cache. This tells the filesystem to inherit group ownership for new directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might be useful for this. + it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with + versions of ccache that do not support compression. ) manpagesection(HISTORY) Index: config.h.in =================================================================== RCS file: /home/cvsroot/lars/ccache/config.h.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- config.h.in 30 Apr 2004 13:13:41 -0000 1.1.1.1 +++ config.h.in 4 May 2004 20:49:26 -0000 1.2 @@ -98,3 +98,6 @@ /* Define _GNU_SOURCE so that we get all necessary prototypes */ #undef _GNU_SOURCE + +/* Define to 1 if you like to have zlib compression for the ccache. */ +#undef ENABLE_ZLIB Index: configure =================================================================== RCS file: /home/cvsroot/lars/ccache/configure,v retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1.2.1 configure --- configure 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ configure 21 Nov 2004 18:24:42 -0000 @@ -836,6 +836,11 @@ cat <<\_ACEOF +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-zlib enable zlib support for ccache compression + Some influential environment variables: CC C compiler command CFLAGS C compiler flags @@ -936,7 +941,7 @@ else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd "$ac_popdir" + cd $ac_popdir done fi @@ -1859,7 +1864,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -1917,7 +1923,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2033,7 +2040,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2087,7 +2095,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2132,7 +2141,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2176,7 +2186,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2609,7 +2620,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2681,7 +2693,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2735,7 +2748,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2806,7 +2820,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2860,7 +2875,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2927,7 +2943,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2997,7 +3014,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3078,7 +3096,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3248,7 +3267,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3319,7 +3339,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3509,7 +3530,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3611,7 +3633,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3676,7 +3699,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3775,6 +3799,229 @@ fi +# Check whether --enable-zlib or --disable-zlib was given. +if test "${enable_zlib+set}" = set; then + enableval="$enable_zlib" + +else + enable_zlib=yes +fi; + +if test x"$enable_zlib" = x"yes"; then + if test "${ac_cv_header_zlib_h+set}" = set; then + echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking zlib.h usability" >&5 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking zlib.h presence" >&5 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for zlib.h" >&5 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 +if test "${ac_cv_header_zlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_zlib_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 + +fi +if test $ac_cv_header_zlib_h = yes; then + echo "$as_me:$LINENO: checking for gzdopen in -lz" >&5 +echo $ECHO_N "checking for gzdopen in -lz... $ECHO_C" >&6 +if test "${ac_cv_lib_z_gzdopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gzdopen (); +int +main () +{ +gzdopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_z_gzdopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_z_gzdopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzdopen" >&5 +echo "${ECHO_T}$ac_cv_lib_z_gzdopen" >&6 +if test $ac_cv_lib_z_gzdopen = yes; then + LIBS="-lz $LIBS"; cat >>confdefs.h <<\_ACEOF +#define ENABLE_ZLIB 1 +_ACEOF + +fi + +fi + + +fi + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -4568,6 +4815,11 @@ *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -4606,12 +4858,6 @@ fi;; esac done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub Index: configure.in =================================================================== RCS file: /home/cvsroot/lars/ccache/configure.in,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.4 diff -u -r1.1.1.1.2.1 -r1.4 --- configure.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ configure.in 21 Nov 2004 18:19:28 -0000 1.4 @@ -68,5 +68,14 @@ AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) fi +dnl Check for zlib. +AC_ARG_ENABLE([zlib], + AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, + [enable_zlib=yes]) + +if test x"$enable_zlib" = x"yes"; then + AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB))) +fi + AC_CONFIG_FILES([Makefile]) AC_OUTPUT Index: util.c =================================================================== RCS file: /home/cvsroot/lars/ccache/util.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.11 diff -u -r1.1.1.1.2.1 -r1.11 --- util.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ util.c 21 Nov 2004 18:19:28 -0000 1.11 @@ -44,6 +44,7 @@ exit(1); } +#ifndef ENABLE_ZLIB /* copy all data from one file descriptor to another */ void copy_fd(int fd_in, int fd_out) { @@ -57,6 +58,11 @@ } } +/* move a file using rename */ +int move_file(const char *src, const char *dest) { + return rename(src, dest); +} + /* copy a file - used when hard links don't work the copy is done via a temporary file and atomic rename */ @@ -120,6 +126,174 @@ return 0; } +#else /* ENABLE_ZLIB */ + +/* copy all data from one file descriptor to another + possibly decompressing it +*/ +void copy_fd(int fd_in, int fd_out) { + char buf[10240]; + int n; + gzFile gz_in; + + gz_in = gzdopen(dup(fd_in), "rb"); + + if (!gz_in) { + fatal("Failed to copy fd"); + } + + while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { + if (write(fd_out, buf, n) != n) { + fatal("Failed to copy fd"); + } + } +} + +static int _copy_file(const char *src, const char *dest, int mode) { + int fd_in, fd_out; + gzFile gz_in, gz_out = NULL; + char buf[10240]; + int n, ret; + char *tmp_name; + mode_t mask; + struct stat st; + + x_asprintf(&tmp_name, "%s.XXXXXX", dest); + + if (getenv("CCACHE_NOCOMPRESS")) { + mode = COPY_UNCOMPRESSED; + } + + /* open source file */ + fd_in = open(src, O_RDONLY); + if (fd_in == -1) { + return -1; + } + + gz_in = gzdopen(fd_in, "rb"); + if (!gz_in) { + close(fd_in); + return -1; + } + + /* open destination file */ + fd_out = mkstemp(tmp_name); + if (fd_out == -1) { + gzclose(gz_in); + free(tmp_name); + return -1; + } + + if (mode == COPY_TO_CACHE) { + /* The gzip file format occupies at least 20 bytes. So + it will always occupy an entire filesystem block, + even for empty files. + Since most stderr files will be empty, we turn off + compression in this case to save space. + */ + if (fstat(fd_in, &st) != 0) { + gzclose(gz_in); + close(fd_out); + free(tmp_name); + return -1; + } + if (file_size(&st) == 0) { + mode = COPY_UNCOMPRESSED; + } + } + + if (mode == COPY_TO_CACHE) { + gz_out = gzdopen(dup(fd_out), "wb"); + if (!gz_out) { + gzclose(gz_in); + close(fd_out); + free(tmp_name); + return -1; + } + } + + while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { + if (mode == COPY_TO_CACHE) { + ret = gzwrite(gz_out, buf, n); + } else { + ret = write(fd_out, buf, n); + } + if (ret != n) { + gzclose(gz_in); + if (gz_out) { + gzclose(gz_out); + } + close(fd_out); + unlink(tmp_name); + free(tmp_name); + return -1; + } + } + + gzclose(gz_in); + if (gz_out) { + gzclose(gz_out); + } + + /* get perms right on the tmp file */ + mask = umask(0); + fchmod(fd_out, 0666 & ~mask); + umask(mask); + + /* the close can fail on NFS if out of space */ + if (close(fd_out) == -1) { + unlink(tmp_name); + free(tmp_name); + return -1; + } + + unlink(dest); + + if (rename(tmp_name, dest) == -1) { + unlink(tmp_name); + free(tmp_name); + return -1; + } + + free(tmp_name); + + return 0; +} + +/* move a file to the cache, compressing it */ +int move_file(const char *src, const char *dest) { + int ret; + + ret = _copy_file(src, dest, COPY_TO_CACHE); + if (ret != -1) unlink(src); + return ret; +} + +/* copy a file from the cache, decompressing it */ +int copy_file(const char *src, const char *dest) { + return _copy_file(src, dest, COPY_FROM_CACHE); +} +#endif /* ENABLE_ZLIB */ + +/* test if a file is zlib compressed */ +int test_if_compressed(const char *filename) { + FILE *f; + + f = fopen(filename, "rb"); + if (!f) { + return 0; + } + + /* test if file starts with 1F8B, which is zlib's + * magic number */ + if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) { + fclose(f); + return 0; + } + + fclose(f); + return 1; +} /* make sure a directory exists */ int create_dir(const char *dir) Index: manage-cache.sh =================================================================== RCS file: manage-cache.sh diff -N manage-cache.sh --- manage-cache.sh 1 Jan 1970 00:00:00 -0000 +++ manage-cache.sh-cache.sh 12 May 2004 19:22:20 -0000 1.1 @@ -0,0 +1,68 @@ +#!/bin/bash +# +# 2004-05-12 lars@gustaebel.de + +CCACHE_DIR=${CCACHE_DIR:-$HOME/.ccache} + +echo "Do you want to compress or decompress the ccache in $CCACHE_DIR?" +read -p "Type c or d: " mode + +if [ "$mode" != "c" ] && [ "$mode" != "d" ] +then + exit 1 +fi + +is_compressed() { + test "$(head -c 2 $1)" = $'\x1f\x8b' + return $? +} + +tmpfile=$(mktemp) + +for dir in 0 1 2 3 4 5 6 7 8 9 a b c d e f +do + # process ccache subdir + echo -n "$dir " + + # find cache files + find $CCACHE_DIR/$dir -type f -name '*-*' | + sort > $tmpfile + + oldsize=$(cat $CCACHE_DIR/$dir/stats | cut -d ' ' -f 13) + newsize=0 + + while read file + do + # empty files will be ignored since compressing + # them makes them bigger + test $(stat -c %s $file) -eq 0 && continue + + if [ $mode = c ] + then + if ! is_compressed $file + then + gzip $file + mv $file.gz $file + fi + else + if is_compressed $file + then + mv $file $file.gz + gzip -d $file.gz + fi + fi + + # calculate new size statistic for this subdir + let newsize=$newsize+$(stat -c "%B*%b" $file)/1024 + done < $tmpfile + + # update statistic file + read -a numbers < $CCACHE_DIR/$dir/stats + numbers[12]=$newsize + echo "${numbers[*]} " > $CCACHE_DIR/$dir/stats +done +echo + +# clean up +rm $tmpfile + Index: Makefile.in =================================================================== RCS file: /home/cvsroot/lars/ccache/Makefile.in,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.12 diff -u -r1.1.1.1.2.1 -r1.12 --- Makefile.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 +++ Makefile.in 21 Nov 2004 18:19:28 -0000 1.12 @@ -11,6 +11,7 @@ CFLAGS=@CFLAGS@ -I. EXEEXT=@EXEEXT@ +LIBS= @LIBS@ OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ cleanup.o snprintf.o unify.o HEADERS = ccache.h mdfour.h @@ -20,7 +21,7 @@ docs: ccache.1 web/ccache-man.html ccache$(EXEEXT): $(OBJS) $(HEADERS) - $(CC) $(CFLAGS) -o $@ $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) ccache.1: ccache.yo -yodl2man -o ccache.1 ccache.yo swig-3.0.8/CCache/debian/watch0000664000175000017500000000007312641054563015742 0ustar williamwilliamversion=2 http://samba.org/ftp/ccache/ccache-(.*)\.tar\.gz swig-3.0.8/CCache/debian/rules0000664000175000017500000001160112641054563015765 0ustar williamwilliam#!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) confflags += --build $(DEB_HOST_GNU_TYPE) else confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) endif ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) CFLAGS += -g endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif config.status: configure dh_testdir # Apply Debian specific patches cp $(CURDIR)/ccache.c $(CURDIR)/ccache.c.unpatched cp $(CURDIR)/util.c $(CURDIR)/util.c.unpatched cp $(CURDIR)/ccache.1 $(CURDIR)/ccache.1.unpatched cp $(CURDIR)/ccache.h $(CURDIR)/ccache.h.unpatched cp $(CURDIR)/ccache.yo $(CURDIR)/ccache.yo.unpatched cp $(CURDIR)/config.h.in $(CURDIR)/config.h.in.unpatched cp $(CURDIR)/configure $(CURDIR)/configure.unpatched cp $(CURDIR)/configure.in $(CURDIR)/configure.in.unpatched cp $(CURDIR)/Makefile.in $(CURDIR)/Makefile.in.unpatched if test ! -f patch-stamp; then \ for patch in $(CURDIR)/debian/patches/*.diff ;\ do \ echo APPLYING PATCH\: $${patch##*/};\ patch -p0 < $$patch ;\ done ;\ touch patch-stamp ;\ fi chmod +x $(CURDIR)/manage-cache.sh ./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info build: build-stamp build-stamp: config.status dh_testdir $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp # Unapply patches -test -r $(CURDIR)/ccache.c.unpatched && mv $(CURDIR)/ccache.c.unpatched $(CURDIR)/ccache.c -test -r $(CURDIR)/util.c.unpatched && mv $(CURDIR)/util.c.unpatched $(CURDIR)/util.c -test -r $(CURDIR)/ccache.1.unpatched && mv $(CURDIR)/ccache.1.unpatched $(CURDIR)/ccache.1 -test -r $(CURDIR)/ccache.h.unpatched && mv $(CURDIR)/ccache.h.unpatched $(CURDIR)/ccache.h -test -r $(CURDIR)/ccache.yo.unpatched && mv $(CURDIR)/ccache.yo.unpatched $(CURDIR)/ccache.yo -test -r $(CURDIR)/config.h.in.unpatched && mv $(CURDIR)/config.h.in.unpatched $(CURDIR)/config.h.in -test -r $(CURDIR)/configure.unpatched && mv $(CURDIR)/configure.unpatched $(CURDIR)/configure -test -r $(CURDIR)/configure.in.unpatched && mv $(CURDIR)/configure.in.unpatched $(CURDIR)/configure.in -test -r $(CURDIR)/Makefile.in.unpatched && mv $(CURDIR)/Makefile.in.unpatched $(CURDIR)/Makefile.in -rm -f $(CURDIR)/manage-cache.sh -rm -f patch-stamp [ ! -f Makefile ] || $(MAKE) distclean dh_clean # Update config.sub and config.guess -test -r /usr/share/misc/config.sub && \ cp -f /usr/share/misc/config.sub config.sub -test -r /usr/share/misc/config.guess && \ cp -f /usr/share/misc/config.guess config.guess install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/ccache. $(MAKE) install prefix=$(CURDIR)/debian/ccache/usr ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++ set -e; for ver in 2.95 3.0 3.2 3.3 3.4 4.0 4.1 4.2 4.3; do \ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc-$$ver; \ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc-$$ver; \ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++-$$ver; \ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++-$$ver; \ done ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/cc ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/c++ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-c++ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-cc ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-g++ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-gcc # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installdocs dh_installexamples dh_installmenu dh_installcron dh_installman dh_installinfo dh_installchangelogs dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install swig-3.0.8/CCache/debian/docs0000664000175000017500000000000712641054563015561 0ustar williamwilliamREADME swig-3.0.8/CCache/debian/compat0000664000175000017500000000000212641054563016107 0ustar williamwilliam6 swig-3.0.8/CCache/debian/copyright0000664000175000017500000000240612641054563016646 0ustar williamwilliamThis package was debianized by Paul Russell on Sun, 31 Mar 2002 14:08:57 +0200. It was downloaded from http://ccache.samba.org/ftp/ccache/ The ccache-zlib patch was downloaded from http://www.gustaebel.de/lars/ccache/ Upstream Author: Andrew Tridgell Copyright: 2002-2005 Andrew Tridgell This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA You are free to distribute this software under the terms of the GNU General Public License. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL file. swig-3.0.8/CCache/debian/README.Debian0000664000175000017500000000401012641054563016745 0ustar williamwilliamInstalling ccache ----------------- The recommended way to use this with Debian is to either create "cc" and "gcc" symlinks to /usr/bin/ccache in your private bin directory (which must be before the real cc and gcc in your path), or use CC="ccache gcc" on the make command line. Another option is to just prepend /usr/lib/ccache in your PATH environment variable, like export PATH="/usr/lib/ccache:$PATH" Note that ccache works with both native and cross compilers. Ignoring whitespace ------------------- If you wish to set up ccache so that it ignores blank lines, have a look at the CCACHE_UNIFY option. However, please note that this option is off by default since the reported line numbers may not match the source files anymore. NFS Issues ---------- (from John Coiner on the ccache mailing list) When CCache creates a hardlinked output file, it calls utime() to update the timestamp on the object, so that Make realizes that the object has changed. On NFS, utime() has no coherency guarantee, AFAIK. When utime() runs on host A, and our parallel implementation of Make is running on host B, sometimes Make doesn't see the new timestamp soon enough -- and neglects to relink the final binary. That's a one-way ticket to Silent Mysterious Failure Town. Instead of relying on the object file timestamp, we create a dummy file with a reliable timestamp: objs/foo.o objs/foo.o.built : if ( ccache gcc -o foo.o -c foo.c ) ; \ then touch objs/foo.o.built ; \ else exit 1; \ fi binary : objs/foo.o.built gcc -o binary objs/foo.o NFS does make a coherency guarantee, that if a file is written and close()d on host A, and subsequently open()ed on host B, that the second open() will reflect all modifications and attributes from the close(). Since Make does open() when checking timestamps, and the dummy file is close()d when it's created, the binary will always relink after the object is recompiled. -- Francois Marier Sun, 20 May 2007 17:35:36 +1200 swig-3.0.8/CCache/debian/control0000664000175000017500000000131612641054563016315 0ustar williamwilliamSource: ccache Section: devel Priority: optional Maintainer: Francois Marier Build-Depends: debhelper (>> 6), autotools-dev, zlib1g-dev Standards-Version: 3.7.3 Homepage: http://ccache.samba.org Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/ccache/ Vcs-Browser: http://svn.debian.org/wsvn/collab-maint/deb-maint/ccache/ Package: ccache Architecture: any Depends: ${shlibs:Depends} Suggests: distcc Description: Compiler results cacher, for fast recompiles ccache is a compiler cache. It speeds up re-compilation of C/C++ code by caching previous compiles and detecting when the same compile is being done again. . This is similar to, but faster than, the compilercache package. swig-3.0.8/CCache/debian/dirs0000664000175000017500000000005212641054563015572 0ustar williamwilliamusr/bin usr/lib/ccache usr/share/man/man1 swig-3.0.8/CCache/debian/NEWS0000664000175000017500000000164212641054563015413 0ustar williamwilliamccache (2.4-8) unstable; urgency=high zlib compression is now enabled by default in order to increase the amount of object files that can fit in the cache. The impact on performance is supposed to be almost negligible (see http://www.gustaebel.de/lars/ccache/). If you do want to disable it however, simply export the CCACHE_NOCOMPRESS environment variable. Note that a zlib-enabled ccache will still read your existing uncompressed cache. If you want to compress/uncompress your cache, see the manage-cache.sh script under /usr/share/doc/ccache/examples/. -- Francois Marier Sun, 20 May 2007 19:45:07 +1200 ccache (2.4-1) unstable; urgency=low * This release changes the hash input slighly, so you will probably find that you will not get any hits against your existing cache when you upgrade. -- Francois Marier Sat, 11 Jun 2005 13:54:33 -0400 swig-3.0.8/CCache/debian/examples0000664000175000017500000000004512641054563016451 0ustar williamwilliamdebian/update-ccache manage-cache.sh swig-3.0.8/CCache/debian/changelog0000664000175000017500000001637712641054563016601 0ustar williamwilliamccache (2.4-15) unstable; urgency=low * Add a new patch which improve the consistency of timestamps on cached objects to make sure clean-up is based on least recently used objects. * Patch the set_limit call so that non-writable cache directories return an error when attempting to size the max(files|size) (closes: #332527) -- Francois Marier Sun, 13 Apr 2008 15:07:05 +1200 ccache (2.4-14) unstable; urgency=low * Mention the long options everywhere in the manpage * Merge Gentoo patches: - respect user's LDFLAGS - use utimes() for timestamp if possible -- Francois Marier Sun, 23 Mar 2008 16:30:11 +1300 ccache (2.4-13) unstable; urgency=low * Update CACHEDIR.TAG patch to avoid creating the tag file when the CCACHE_READONLY environment variable is set. (closes: #464356) * Mention the GNU-style long options in the manpage -- Francois Marier Thu, 07 Feb 2008 10:50:42 +1300 ccache (2.4-12) unstable; urgency=low * Add symlink for gcc 4.3 (closes: #463590) * Add support for the CACHEDIR.TAG spec, thanks to Karl Chen. (see http://www.brynosaurus.com/cachedir/) * Fix hyphens in manpage (lintian notice) * Bump Standards-Version up to 3.7.3 (no changes) * Bump debhelper compatibility to 6 -- Francois Marier Sat, 02 Feb 2008 10:37:22 +1300 ccache (2.4-11) unstable; urgency=low * Add the collab-maint repo to debian/control -- Francois Marier Tue, 20 Nov 2007 15:26:37 +1300 ccache (2.4-10) unstable; urgency=low * Document where the patches are from in debian/patches/CREDITS * debian/rules: - Fixed "make distclean" lintian warning - Removed commented-out entries * Set debhelper compatibility to 5 * Add homepage field in debian/control * Add symlinks for MinGW (closes: #445782) * Bump the version to 5 in the debhelper dependency -- Francois Marier Fri, 19 Oct 2007 16:04:37 +1300 ccache (2.4-9) unstable; urgency=low * Add a symlink for gcc 4.2 (closes: #431007) * Fix dependencies when using -o (closes: #217713) -- Francois Marier Sat, 30 Jun 2007 17:58:44 +1200 ccache (2.4-8) unstable; urgency=low * Enable zlib compression of the cache by default (closes: #409848). Thanks to Sami Liedes for suggesting this. * Disable ccache when profiling (closes: #215849). Thanks to Ted Percival for the Patch. * Fix NFS renaming issues and add instructions to the README. Thanks to John Coiner and instructions. * Put all patches in debian/patches and apply them at build time. -- Francois Marier Sun, 20 May 2007 19:42:34 +1200 ccache (2.4-7) unstable; urgency=low * Use the real compiler when HOME is not set (closes: #396350) * Include user script under doc/examples (closes: #392435) Thanks to Behan Webster! * Add support for GNU --long options (closes: #297126) -- Francois Marier Sat, 18 Nov 2006 00:50:59 -0500 ccache (2.4-6) unstable; urgency=low * Include symlinks for gcc 4.1 (closes: #372838) * Update watch file -- Francois Marier Tue, 13 Jun 2006 22:17:37 -0400 ccache (2.4-5) unstable; urgency=low * Document the fact that cross-compiling is supported (closes: #349221) * Bump Standards-Version up to 3.7.2 (no changes) -- Francois Marier Sun, 4 Jun 2006 01:20:07 -0400 ccache (2.4-4) unstable; urgency=low * Mention another way to use ccache in README.Debian (thanks to Benjamin Drieu for the suggestion) (closes: #267632) * Update FSF address * Fix watch file -- Francois Marier Sat, 26 Nov 2005 00:15:13 -0500 ccache (2.4-3) unstable; urgency=low * Actually use the configuration flags in debian/rules * Bump Standards-Version up to 3.6.2 (no changes) -- Francois Marier Sun, 26 Jun 2005 13:33:19 -0400 ccache (2.4-2) unstable; urgency=low * Add gcc and g++ symlinks to /usr/lib/ccache (closes: #313490) * Remove invalid entry from Depends -- Francois Marier Wed, 15 Jun 2005 20:51:03 -0400 ccache (2.4-1) unstable; urgency=low * New maintainer (closes: #312867) * New upstream version: (closes: #273753, #239640) - New CCACHE_READONLY and CCACHE_TEMPDIR options - Fixed handling of hard-linked compilers on AIX - Fixed handling of HOME environment variable (closes: #299880) - Show cache directory in stats output * Fix copyright file * Add 'distcc' to Suggests (closes: #269158) * Add a note about whitespace in README.Debian (closes: #229116) * Update rules to add symmlinks for gcc 3.4 & 4.0 (closes: #261177) * Acknowledge NMUs (closes: #200185, #177129, #174417) -- Francois Marier Sun, 12 Jun 2005 12:05:34 -0400 ccache (2.3-1.1) unstable; urgency=low * Non-maintainer upload during BSP * Re-apply patch for #200185 ccache: Incorrect symlinks in /usr/lib/ccache (Closes: #200185) -- Frank Lichtenheld Fri, 19 Mar 2004 11:14:50 +0100 ccache (2.3-1) unstable; urgency=low * New upstream release: obsoletes existing caches. * Tweak package description in arbitrary way (closes: #181721) -- Paul Russell Mon, 29 Sep 2003 02:53:20 +0200 ccache (2.2-2) unstable; urgency=low * Insert more symlinks in ccache dir (closes: #197468) -- Paul Russell Mon, 16 Jun 2003 10:52:50 +0100 ccache (2.2-1) unstable; urgency=low * New upstream release (closes: #150755) * Insert more symlinks in ccache dir (closes: #144462) -- Paul Russell Mon, 17 Feb 2003 07:19:36 +0100 ccache (2.1.1-2) unstable; urgency=low * Restored /usr/lib/ccache symlinks (closes: #179393) * Fixed manpage typo (closes: #179564) * With thanks to Andreas Rottmann. -- Paul Russell Wed, 5 Feb 2003 10:01:10 +0100 ccache (2.1.1-1) unstable; urgency=low * NMU (with maintainer consent). * New upstream release (closes: #174417, #177129). * debian/control: + Build-Depend on and use dephelper 4 (DH_COMPAT = 4). + Bumped Standards-Version to 3.5.8. + No full stop on short package description (fixes linda warning). * debian/copright: + Make lintian feel comfortable; fixes warnings: - copyright-should-refer-to-common-license-file-for-gpl - copyright-lists-upstream-authors-with-dh_make-boilerplate * Built with g++ 3.2 :-). -- Andreas Rottmann Thu, 16 Jan 2003 11:42:38 +0100 ccache (1.9-1) unstable; urgency=low * New upstream release (closes: #144920) -- Paul Russell Mon, 13 May 2002 10:01:09 +0200 ccache (1.8-1) unstable; urgency=low * New upstream release (closes: #145401) -- Paul Russell Fri, 3 May 2002 02:26:32 +0200 ccache (1.7-1) unstable; urgency=low * New upstream release * Install symlinks in /usr/lib/ccache (closes: #141337) -- Paul Russell Wed, 10 Apr 2002 17:51:21 +0200 ccache (1.4-1) unstable; urgency=low * New upstream release -- Paul Russell Wed, 3 Apr 2002 03:41:46 +0200 ccache (1.2-1) unstable; urgency=low * Initial Release. -- Paul Russell Sun, 31 Mar 2002 14:08:57 +0200 swig-3.0.8/CCache/install-sh0000775000175000017500000001124512641054563015476 0ustar williamwilliam#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 swig-3.0.8/CCache/ccache.c0000664000175000017500000010345112641054563015045 0ustar williamwilliam/* a re-implementation of the compilercache scripts in C The idea is based on the shell-script compilercache by Erik Thiele Copyright (C) Andrew Tridgell 2002 Copyright (C) Martin Pool 2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" /* verbose mode */ int ccache_verbose = 0; /* the base cache directory */ char *cache_dir = NULL; /* the directory for temporary files */ static char *temp_dir = NULL; /* the debug logfile name, if set */ char *cache_logfile = NULL; /* the argument list after processing */ static ARGS *stripped_args; /* the original argument list */ static ARGS *orig_args; /* the output filename being compiled to */ static char *output_file; /* the source file */ static char *input_file; /* the name of the file containing the cached object code */ static char *hashname; /* the extension of the file after pre-processing */ static const char *i_extension; /* the name of the temporary pre-processor file */ static char *i_tmpfile; /* are we compiling a .i or .ii file directly? */ static int direct_i_file; /* the name of the cpp stderr file */ static char *cpp_stderr; /* the name of the statistics file */ char *stats_file = NULL; /* can we safely use the unification hashing backend? */ static int enable_unify; /* should we strip -c when running the preprocessor only? */ static int strip_c_option; /* customisation for using the SWIG compiler */ static int swig; /* a list of supported file extensions, and the equivalent extension for code that has been through the pre-processor */ static struct { char *extension; char *i_extension; } extensions[] = { {"c", "i"}, {"C", "ii"}, {"m", "mi"}, {"cc", "ii"}, {"CC", "ii"}, {"cpp", "ii"}, {"CPP", "ii"}, {"cxx", "ii"}, {"CXX", "ii"}, {"c++", "ii"}, {"C++", "ii"}, {"i", "i"}, {"ii", "ii"}, {NULL, NULL}}; /* something went badly wrong - just execute the real compiler */ static void failed(void) { char *e; /* delete intermediate pre-processor file if needed */ if (i_tmpfile) { if (!direct_i_file) { unlink(i_tmpfile); } free(i_tmpfile); i_tmpfile = NULL; } /* delete the cpp stderr file if necessary */ if (cpp_stderr) { unlink(cpp_stderr); free(cpp_stderr); cpp_stderr = NULL; } /* strip any local args */ args_strip(orig_args, "--ccache-"); if ((e=getenv("CCACHE_PREFIX"))) { char *p = find_executable(e, MYNAME); if (!p) { cc_log("could not find executable (%s)\n", e); perror(e); exit(1); } args_add_prefix(orig_args, p); } if (ccache_verbose) { display_execute_args(orig_args->argv); } if (swig) { putenv("CCACHE_OUTFILES"); } #ifndef _WIN32 execv(orig_args->argv[0], orig_args->argv); cc_log("execv returned (%s)!\n", strerror(errno)); perror(orig_args->argv[0]); exit(1); #else /* execv on Windows causes the 'non-regular' testcase to fail, so use Win32 API instead */ { PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; BOOL ret; DWORD exitcode; char *args; ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&sinfo, sizeof(STARTUPINFO)); sinfo.cb = sizeof(STARTUPINFO); args = argvtos(orig_args->argv); ret = CreateProcessA(orig_args->argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL, &sinfo, &pinfo); if (!ret) { exitcode = 1; cc_log("CreateProcessA failed starting %s\n", orig_args->argv[0]); perror_win32(orig_args->argv[0]); } else { WaitForSingleObject(pinfo.hProcess, INFINITE); GetExitCodeProcess(pinfo.hProcess, &exitcode); CloseHandle(pinfo.hProcess); CloseHandle(pinfo.hThread); } free(args); exit(exitcode); } #endif } /* return a string to be used to distinguish temporary files this also tries to cope with NFS by adding the local hostname */ static const char *tmp_string(void) { static char *ret; if (!ret) { char hostname[200]; strcpy(hostname, "unknown"); #if HAVE_GETHOSTNAME gethostname(hostname, sizeof(hostname)-1); #endif hostname[sizeof(hostname)-1] = 0; if (asprintf(&ret, "%s.%u", hostname, (unsigned)getpid()) == -1) { fatal("could not allocate tmp_string"); } } return ret; } /* update cached file sizes and count helper function for to_cache() */ static void to_cache_stats_helper(struct stat *pstat, char *cached_filename, char *tmp_outfiles, int *files_size, int *cached_files_count) { #if ENABLE_ZLIB /* do an extra stat on the cache file for the size statistics */ if (stat(cached_filename, pstat) != 0) { cc_log("failed to stat cache files - %s\n", strerror(errno)); stats_update(STATS_ERROR); if (tmp_outfiles) { unlink(tmp_outfiles); } failed(); } #else (void)cached_filename; (void)tmp_outfiles; #endif (*files_size) += file_size(pstat); (*cached_files_count)++; } /* run the real compiler and put the result in cache */ static void to_cache(ARGS *args) { char *path_stderr; char *tmp_stdout, *tmp_stderr, *tmp_outfiles; struct stat st1; int status; int cached_files_count = 0; int files_size = 0; x_asprintf(&tmp_stdout, "%s/tmp.stdout.%s", temp_dir, tmp_string()); x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string()); if (strip_c_option && !swig) { args_add(stripped_args, "-c"); } if (output_file) { args_add(args, "-o"); args_add(args, output_file); } /* Turn off DEPENDENCIES_OUTPUT when running cc1, because * otherwise it will emit a line like * * tmp.stdout.vexed.732.o: /home/mbp/.ccache/tmp.stdout.vexed.732.i * * unsetenv() is on BSD and Linux but not portable. */ putenv("DEPENDENCIES_OUTPUT"); /* Give SWIG a filename for it to create and populate with a list of files that it generates */ if (swig) { char *ccache_outfiles; x_asprintf(&ccache_outfiles, "CCACHE_OUTFILES=%s", tmp_outfiles); unlink(tmp_outfiles); if (getenv("CCACHE_OUTFILES") || putenv(ccache_outfiles) == -1) { cc_log("CCACHE_OUTFILES env variable already set or could not be set\n"); stats_update(STATS_ERROR); failed(); } } if (getenv("CCACHE_CPP2")) { args_add(args, input_file); } else { if (swig) { args_add(args, "-nopreprocess"); } args_add(args, i_tmpfile); } status = execute(args->argv, tmp_stdout, tmp_stderr); args_pop(args, 3); if (stat(tmp_stdout, &st1) != 0 || st1.st_size != 0) { cc_log("compiler produced stdout for %s\n", input_file); stats_update(STATS_STDOUT); unlink(tmp_stdout); unlink(tmp_stderr); unlink(tmp_outfiles); if (!swig) unlink(output_file); failed(); } unlink(tmp_stdout); if (status != 0) { int fd; cc_log("compile of %s gave status = %d\n", input_file, status); stats_update(STATS_STATUS); fd = open(tmp_stderr, O_RDONLY | O_BINARY); if (fd != -1) { if (cpp_stderr) { /* we might have some stderr from cpp */ int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); if (fd2 != -1) { copy_fd(fd2, 2); close(fd2); unlink(cpp_stderr); cpp_stderr = NULL; } } /* we can use a quick method of getting the failed output */ copy_fd(fd, 2); close(fd); unlink(tmp_stderr); if (i_tmpfile && !direct_i_file) { unlink(i_tmpfile); } exit(status); } unlink(tmp_stderr); unlink(tmp_outfiles); if (!swig) unlink(output_file); failed(); } else { int hardlink = (getenv("CCACHE_NOCOMPRESS") != 0) && (getenv("CCACHE_HARDLINK") != 0); if (swig) { /* read the list of generated files and copy each of them into the cache */ FILE *file; file = fopen(tmp_outfiles, "r"); if (file) { char out_filename[FILENAME_MAX + 1]; char out_filename_cache[FILENAME_MAX + 1]; while (fgets(out_filename, FILENAME_MAX, file)) { char *linefeed = strchr(out_filename, '\n'); if (linefeed) { char *potential_cr = linefeed - 1; if (potential_cr >= out_filename && *potential_cr == '\r') *potential_cr = 0; *linefeed = 0; if (cached_files_count == 0) { strcpy(out_filename_cache, hashname); } else { sprintf(out_filename_cache, "%s.%d", hashname, cached_files_count); } if (commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) { fclose(file); unlink(tmp_outfiles); failed(); } to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count); } else { cached_files_count = 0; break; } } fclose(file); if (cached_files_count == 0) { cc_log("failed to copy output files to cache - internal error\n"); stats_update(STATS_ERROR); unlink(tmp_outfiles); failed(); } /* also copy the (uncompressed) file containing the list of generated files into the cache */ sprintf(out_filename_cache, "%s.outfiles", hashname); if (stat(tmp_outfiles, &st1) != 0 || safe_rename(tmp_outfiles, out_filename_cache) != 0) { cc_log("failed to copy outfiles file to cache - %s\n", strerror(errno)); stats_update(STATS_ERROR); unlink(tmp_outfiles); failed(); } to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count); unlink(tmp_outfiles); } else { cc_log("failed to open temp outfiles file - %s\n", strerror(errno)); stats_update(STATS_ERROR); failed(); } } else { if (commit_to_cache(output_file, hashname, hardlink) != 0) { failed(); } to_cache_stats_helper(&st1, hashname, 0, &files_size, &cached_files_count); } } x_asprintf(&path_stderr, "%s.stderr", hashname); if (stat(tmp_stderr, &st1) != 0 || move_file(tmp_stderr, path_stderr) != 0) { cc_log("failed to rename tmp files - %s\n", strerror(errno)); stats_update(STATS_ERROR); failed(); } to_cache_stats_helper(&st1, path_stderr, 0, &files_size, &cached_files_count); cc_log("Placed %d files for %s into cache\n", cached_files_count, input_file); stats_tocache(files_size, cached_files_count); free(tmp_stderr); free(tmp_stdout); free(tmp_outfiles); free(path_stderr); } /* find the hash for a command. The hash includes all argument lists, plus the output from running the compiler with -E */ static void find_hash(ARGS *args) { int i; char *path_stdout, *path_stderr; char *hash_dir; char *s; struct stat st; int status; int nlevels = 2; char *input_base; char *tmp; if ((s = getenv("CCACHE_NLEVELS"))) { nlevels = atoi(s); if (nlevels < 1) nlevels = 1; if (nlevels > 8) nlevels = 8; } hash_start(); /* when we are doing the unifying tricks we need to include the input file name in the hash to get the warnings right */ if (enable_unify || swig) { hash_string(input_file); } if (swig) { if (output_file) { hash_string(output_file); } } else { /* we have to hash the extension, as a .i file isn't treated the same by the compiler as a .ii file */ hash_string(i_extension); } /* first the arguments */ for (i=1;iargc;i++) { /* some arguments don't contribute to the hash. The theory is that these arguments will change the output of -E if they are going to have any effect at all, or they only affect linking */ if (i < args->argc-1) { if (strcmp(args->argv[i], "-I") == 0 || strcmp(args->argv[i], "-include") == 0 || strcmp(args->argv[i], "-L") == 0 || strcmp(args->argv[i], "-D") == 0 || strcmp(args->argv[i], "-idirafter") == 0 || strcmp(args->argv[i], "-isystem") == 0) { i++; continue; } } if (strncmp(args->argv[i], "-I", 2) == 0 || strncmp(args->argv[i], "-L", 2) == 0 || strncmp(args->argv[i], "-D", 2) == 0 || strncmp(args->argv[i], "-idirafter", 10) == 0 || strncmp(args->argv[i], "-isystem", 8) == 0) { continue; } if (strncmp(args->argv[i], "--specs=", 8) == 0 && stat(args->argv[i]+8, &st) == 0) { /* if given a explicit specs file, then hash that file, but don't include the path to it in the hash */ hash_file(args->argv[i]+8); continue; } /* all other arguments are included in the hash */ hash_string(args->argv[i]); } /* the compiler driver size and date. This is a simple minded way to try and detect compiler upgrades. It is not 100% reliable */ if (stat(args->argv[0], &st) != 0) { cc_log("Couldn't stat the compiler!? (argv[0]='%s')\n", args->argv[0]); stats_update(STATS_COMPILER); failed(); } /* also include the hash of the compiler name - as some compilers use hard links and behave differently depending on the real name */ if (st.st_nlink > 1) { hash_string(str_basename(args->argv[0])); } hash_int(st.st_size); hash_int(st.st_mtime); /* possibly hash the current working directory */ if (getenv("CCACHE_HASHDIR")) { char *cwd = gnu_getcwd(); if (cwd) { hash_string(cwd); free(cwd); } } /* ~/hello.c -> tmp.hello.123.i limit the basename to 10 characters in order to cope with filesystem with small maximum filename length limits */ input_base = str_basename(input_file); tmp = strchr(input_base, '.'); if (tmp != NULL) { *tmp = 0; } if (strlen(input_base) > 10) { input_base[10] = 0; } /* now the run */ x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", temp_dir, input_base, tmp_string(), i_extension); x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string()); if (!direct_i_file) { /* run cpp on the input file to obtain the .i */ args_add(args, "-E"); args_add(args, input_file); status = execute(args->argv, path_stdout, path_stderr); args_pop(args, 2); } else { /* we are compiling a .i or .ii file - that means we can skip the cpp stage and directly form the correct i_tmpfile */ path_stdout = x_strdup(input_file); if (create_empty_file(path_stderr) != 0) { cc_log("failed to create empty stderr file\n"); stats_update(STATS_ERROR); failed(); } status = 0; } if (status != 0) { if (!direct_i_file) { unlink(path_stdout); } unlink(path_stderr); cc_log("the preprocessor gave %d\n", status); stats_update(STATS_PREPROCESSOR); failed(); } /* if the compilation is with -g then we have to include the whole of the preprocessor output, which means we are sensitive to line number information. Otherwise we can discard line number info, which makes us less sensitive to reformatting changes Note! I have now disabled the unification code by default as it gives the wrong line numbers for warnings. Pity. */ if (!enable_unify) { hash_file(path_stdout); } else { if (unify_hash(path_stdout) != 0) { stats_update(STATS_ERROR); failed(); } } hash_file(path_stderr); i_tmpfile = path_stdout; if (!getenv("CCACHE_CPP2")) { /* if we are using the CPP trick then we need to remember this stderr data and output it just before the main stderr from the compiler pass */ cpp_stderr = path_stderr; } else { unlink(path_stderr); free(path_stderr); } /* we use a N level subdir for the cache path to reduce the impact on filesystems which are slow for large directories */ s = hash_result(); x_asprintf(&hash_dir, "%s/%c", cache_dir, s[0]); x_asprintf(&stats_file, "%s/stats", hash_dir); for (i=1; i= out_filename && *potential_cr == '\r') *potential_cr = 0; *linefeed = 0; if (retrieved_files_count == 0) { strcpy(out_filename_cache, hashname); } else { sprintf(out_filename_cache, "%s.%d", hashname, retrieved_files_count); } passfail = retrieve_from_cache(out_filename_cache, out_filename, hardlink); if (passfail == -1) { break; } retrieved_files_count++; } else { cc_log("failed to copy output files from cache - internal error\n"); stats_update(STATS_ERROR); passfail = -1; break; } } if (retrieved_files_count == 0) { cc_log("failed to copy output files from cache - internal error\n"); stats_update(STATS_ERROR); passfail = -1; } fclose(file); } else { cc_log("failed to open cached outfiles file - %s\n", strerror(errno)); stats_update(STATS_ERROR); } } else { passfail = retrieve_from_cache(hashname, output_file, hardlink); } if (passfail == -1) { close(fd_stderr); unlink(stderr_file); free(stderr_file); return; } free(stderr_file); } /* get rid of the intermediate preprocessor file */ if (i_tmpfile) { if (!direct_i_file) { unlink(i_tmpfile); } free(i_tmpfile); i_tmpfile = NULL; } /* send the cpp stderr, if applicable */ fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY); if (fd_cpp_stderr != -1) { copy_fd(fd_cpp_stderr, 2); close(fd_cpp_stderr); unlink(cpp_stderr); free(cpp_stderr); cpp_stderr = NULL; } /* send the stderr */ copy_fd(fd_stderr, 2); close(fd_stderr); /* and exit with the right status code */ if (first) { cc_log("got cached result for %s\n", input_file); stats_update(STATS_CACHED); } exit(0); } /* find the real compiler. We just search the PATH to find a executable of the same name that isn't a link to ourselves */ static void find_compiler(int argc, char **argv) { char *base; char *path; orig_args = args_init(argc, argv); base = str_basename(argv[0]); /* we might be being invoked like "ccache gcc -c foo.c" */ if (strcmp(base, MYNAME) == 0) { args_remove_first(orig_args); free(base); if (strchr(argv[1],'/') #ifdef _WIN32 || strchr(argv[1],'\\') #endif ) { /* a full path was given */ return; } base = str_basename(argv[1]); } /* support user override of the compiler */ if ((path=getenv("CCACHE_CC"))) { base = x_strdup(path); } orig_args->argv[0] = find_executable(base, MYNAME); /* can't find the compiler! */ if (!orig_args->argv[0]) { stats_update(STATS_COMPILER); cc_log("could not find compiler (%s)\n", base); perror(base); exit(1); } } /* check a filename for C/C++ extension. Return the pre-processor extension */ static const char *check_extension(const char *fname, int *direct_i) { int i; const char *p; if (direct_i) { *direct_i = 0; } if (swig) return "ii"; /* any file extension is acceptable as input for SWIG */ p = strrchr(fname, '.'); if (!p) return NULL; p++; for (i=0; extensions[i].extension; i++) { if (strcmp(p, extensions[i].extension) == 0) { if (direct_i && strcmp(p, extensions[i].i_extension) == 0) { *direct_i = 1; } p = getenv("CCACHE_EXTENSION"); if (p) return p; return extensions[i].i_extension; } } return NULL; } /* process the compiler options to form the correct set of options for obtaining the preprocessor output */ static void process_args(int argc, char **argv) { int i; int found_c_opt = 0; int found_S_opt = 0; struct stat st; char *e; /* is gcc being asked to output dependencies? */ int generating_dependencies = 0; /* is the dependency makefile name overridden with -MF? */ int dependency_filename_specified = 0; /* is the dependency makefile target name specified with -MQ or -MF? */ int dependency_target_specified = 0; stripped_args = args_init(0, NULL); args_add(stripped_args, argv[0]); /* -c not required for SWIG */ if (swig) { found_c_opt = 1; } for (i=1; iargv[0]); if (strstr(basename, "swig") || getenv("CCACHE_SWIG")) { swig = 1; } free(basename); } /* the main ccache driver function */ static void ccache(int argc, char *argv[]) { /* find the real compiler */ find_compiler(argc, argv); /* use the real compiler if HOME is not set */ if (!cache_dir) { cc_log("Unable to determine home directory\n"); cc_log("ccache is disabled\n"); failed(); } /* we might be disabled */ if (getenv("CCACHE_DISABLE")) { cc_log("ccache is disabled\n"); failed(); } if (getenv("CCACHE_STRIPC")) { strip_c_option = 1; } if (getenv("CCACHE_UNIFY")) { enable_unify = 1; } detect_swig(); /* process argument list, returning a new set of arguments for pre-processing */ process_args(orig_args->argc, orig_args->argv); /* run with -E to find the hash */ find_hash(stripped_args); /* if we can return from cache at this point then do */ from_cache(1); if (getenv("CCACHE_READONLY")) { cc_log("read-only set - doing real compile\n"); failed(); } /* run real compiler, sending output to cache */ to_cache(stripped_args); /* return from cache */ from_cache(0); /* oh oh! */ cc_log("secondary from_cache failed!\n"); stats_update(STATS_ERROR); failed(); } static void usage(void) { printf("%s, a compiler cache including support for SWIG. Version %s\n", MYNAME, CCACHE_VERSION); printf("Copyright Andrew Tridgell, 2002\n\n"); printf("Usage:\n"); printf("\t" MYNAME " [options]\n"); printf("\t" MYNAME " compiler [compile options]\n"); printf("\tcompiler [compile options] (via symbolic link)\n"); printf("\nOptions:\n"); printf("-s show statistics summary\n"); printf("-z zero statistics\n"); printf("-c run a cache cleanup\n"); printf("-C clear the cache completely\n"); printf("-F set maximum files in cache\n"); printf("-M set maximum size of cache (use G, M or K)\n"); printf("-h this help page\n"); printf("-V print version number\n"); } static void check_cache_dir(void) { if (!cache_dir) { fatal("Unable to determine home directory"); } } /* the main program when not doing a compile */ static int ccache_main(int argc, char *argv[]) { int c; size_t v; while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { switch (c) { case 'V': printf("%s version %s\n", MYNAME, CCACHE_VERSION); printf("Copyright Andrew Tridgell 2002\n"); printf("Released under the GNU GPL v2 or later\n"); exit(0); case 'h': usage(); exit(0); case 's': check_cache_dir(); stats_summary(); break; case 'c': check_cache_dir(); cleanup_all(cache_dir); printf("Cleaned cache\n"); break; case 'C': check_cache_dir(); wipe_all(cache_dir); printf("Cleared cache\n"); break; case 'z': check_cache_dir(); stats_zero(); printf("Statistics cleared\n"); break; case 'F': check_cache_dir(); v = atoi(optarg); if (stats_set_limits(v, -1) == 0) { printf("Set cache file limit to %u\n", (unsigned)v); } else { printf("Could not set cache file limit.\n"); exit(1); } break; case 'M': check_cache_dir(); v = value_units(optarg); if (stats_set_limits(-1, v) == 0) { printf("Set cache size limit to %uk\n", (unsigned)v); } else { printf("Could not set cache size limit.\n"); exit(1); } break; default: usage(); exit(1); } } return 0; } /* Make a copy of stderr that will not be cached, so things like distcc can send networking errors to it. */ static void setup_uncached_err(void) { char *buf; int uncached_fd; uncached_fd = dup(2); if (uncached_fd == -1) { cc_log("dup(2) failed\n"); stats_update(STATS_ERROR); failed(); } /* leak a pointer to the environment */ x_asprintf(&buf, "UNCACHED_ERR_FD=%d", uncached_fd); if (putenv(buf) == -1) { cc_log("putenv failed\n"); stats_update(STATS_ERROR); failed(); } } int main(int argc, char *argv[]) { char *p; cache_dir = getenv("CCACHE_DIR"); if (!cache_dir) { const char *home_directory = get_home_directory(); if (home_directory) { x_asprintf(&cache_dir, "%s/.ccache", home_directory); } } cache_logfile = getenv("CCACHE_LOGFILE"); if (getenv("CCACHE_VERBOSE")) { ccache_verbose = 1; } setup_uncached_err(); /* the user might have set CCACHE_UMASK */ p = getenv("CCACHE_UMASK"); if (p) { mode_t mask; errno = 0; mask = strtol(p, NULL, 8); if (errno == 0) { umask(mask); } } /* check if we are being invoked as "ccache" */ if (strlen(argv[0]) >= strlen(MYNAME) && strcmp(argv[0] + strlen(argv[0]) - strlen(MYNAME), MYNAME) == 0) { if (argc < 2) { usage(); exit(1); } /* if the first argument isn't an option, then assume we are being passed a compiler name and options */ if (argv[1][0] == '-') { return ccache_main(argc, argv); } } /* make sure the cache dir exists */ if (cache_dir && (create_dir(cache_dir) != 0)) { fprintf(stderr,"ccache: failed to create %s (%s)\n", cache_dir, strerror(errno)); exit(1); } temp_dir = getenv("CCACHE_TEMPDIR"); if (!temp_dir) { x_asprintf(&temp_dir, "%s/temp", cache_dir); /* make sure temp dir exists if not supplied by user */ if (temp_dir && create_dir(temp_dir) != 0) { fprintf(stderr,"ccache: failed to create %s (%s)\n", temp_dir, strerror(errno)); exit(1); } } if (!getenv("CCACHE_READONLY")) { if (create_cachedirtag(cache_dir) != 0) { fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", cache_dir, strerror(errno)); exit(1); } } ccache(argc, argv); return 1; } swig-3.0.8/CCache/test.sh0000775000175000017500000002636212641054563015016 0ustar williamwilliam#!/bin/sh # a simple test suite for ccache # tridge@samba.org if test -n "$CC"; then COMPILER="$CC" else COMPILER=cc fi if test -n "$SWIG"; then SWIG="$SWIG" else SWIG=swig fi # fix: Remove ccache from $PATH if it exists # as it will influence the unit tests PATH="`echo $PATH | \ sed -e 's!:/usr\(/local\)*/lib\([0-9]\)*/ccache\(/\)*!!g'`" CCACHE=../ccache-swig TESTDIR=test.$$ test_failed() { reason="$1" echo $1 $CCACHE -s cd .. rm -rf $TESTDIR echo TEST FAILED exit 1 } randcode() { outfile="$1" nlines=$2 i=0; ( while [ $i -lt $nlines ]; do echo "int foo$nlines$i(int x) { return x; }" i=`expr $i + 1` done ) >> "$outfile" } genswigcode() { outfile="$1" nlines=$2 i=0; ( echo "%module swigtest$2;" while [ $i -lt $nlines ]; do echo "int foo$nlines$i(int x);" echo "struct Bar$nlines$i { int y; };" i=`expr $i + 1` done ) >> "$outfile" } getstat() { stat="$1" value=`$CCACHE -s | grep "$stat" | cut -c34-40` echo $value } checkstat() { stat="$1" expected_value="$2" value=`getstat "$stat"` # echo "exp: $expected_value got: $value $testname" if [ "$expected_value" != "$value" ]; then test_failed "SUITE: $testsuite TEST: $testname - Expected $stat to be $expected_value got $value" fi } basetests() { echo "starting testsuite $testsuite" rm -rf "$CCACHE_DIR" checkstat 'cache hit' 0 checkstat 'cache miss' 0 j=1 rm -f *.c while [ $j -lt 32 ]; do randcode test$j.c $j j=`expr $j + 1` done testname="BASIC" $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 0 checkstat 'cache miss' 1 testname="BASIC2" $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 1 checkstat 'cache miss' 1 testname="debug" $CCACHE_COMPILE -c test1.c -g checkstat 'cache hit' 1 checkstat 'cache miss' 2 testname="debug2" $CCACHE_COMPILE -c test1.c -g checkstat 'cache hit' 2 checkstat 'cache miss' 2 testname="output" $CCACHE_COMPILE -c test1.c -o foo.o checkstat 'cache hit' 3 checkstat 'cache miss' 2 testname="link" $CCACHE_COMPILE test1.c -o test 2> /dev/null checkstat 'called for link' 1 testname="multiple" $CCACHE_COMPILE -c test1.c test2.c checkstat 'multiple source files' 1 testname="find" $CCACHE blahblah -c test1.c 2> /dev/null checkstat "couldn't find the compiler" 1 testname="bad" $CCACHE_COMPILE -c test1.c -I 2> /dev/null checkstat 'bad compiler arguments' 1 testname="c/c++" ln -f test1.c test1.ccc $CCACHE_COMPILE -c test1.ccc 2> /dev/null checkstat 'not a C/C++ file' 1 testname="unsupported" $CCACHE_COMPILE -M foo -c test1.c > /dev/null 2>&1 checkstat 'unsupported compiler option' 1 testname="stdout" $CCACHE echo foo -c test1.c > /dev/null checkstat 'compiler produced stdout' 1 testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1 rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" $CCACHE_COMPILE -c -O2 2> /dev/null checkstat 'no input file' 1 testname="CCACHE_DISABLE" CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null checkstat 'cache hit' 3 $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 4 testname="CCACHE_CPP2" CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 4 checkstat 'cache miss' 3 CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 5 checkstat 'cache miss' 3 testname="CCACHE_NOSTATS" CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 5 checkstat 'cache miss' 3 testname="CCACHE_RECACHE" CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 5 checkstat 'cache miss' 4 # strictly speaking should be 6 - RECACHE causes a double counting! checkstat 'files in cache' 8 $CCACHE -c > /dev/null checkstat 'files in cache' 6 testname="CCACHE_HASHDIR" CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 5 checkstat 'cache miss' 5 CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O checkstat 'cache hit' 6 checkstat 'cache miss' 5 checkstat 'files in cache' 8 testname="comments" echo '/* a silly comment */' > test1-comment.c cat test1.c >> test1-comment.c $CCACHE_COMPILE -c test1-comment.c rm -f test1-comment* checkstat 'cache hit' 6 checkstat 'cache miss' 6 testname="CCACHE_UNIFY" CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 6 checkstat 'cache miss' 7 mv test1.c test1-saved.c echo '/* another comment */' > test1.c cat test1-saved.c >> test1.c CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c mv test1-saved.c test1.c checkstat 'cache hit' 7 checkstat 'cache miss' 7 testname="cache-size" for f in *.c; do $CCACHE_COMPILE -c $f done checkstat 'cache hit' 8 checkstat 'cache miss' 37 checkstat 'files in cache' 72 $CCACHE -F 48 -c > /dev/null if [ `getstat 'files in cache'` -gt 48 ]; then test_failed '-F test failed' fi testname="cpp call" $CCACHE_COMPILE -c test1.c -E > test1.i checkstat 'cache hit' 8 checkstat 'cache miss' 37 testname="direct .i compile" $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 8 checkstat 'cache miss' 38 $CCACHE_COMPILE -c test1.i checkstat 'cache hit' 9 checkstat 'cache miss' 38 $CCACHE_COMPILE -c test1.i checkstat 'cache hit' 10 checkstat 'cache miss' 38 # removed these tests as some compilers (including newer versions of gcc) # determine which language to use based on .ii/.i extension, and C++ may # not be installed # testname="direct .ii file" # mv test1.i test1.ii # $CCACHE_COMPILE -c test1.ii # checkstat 'cache hit' 10 # checkstat 'cache miss' 39 # $CCACHE_COMPILE -c test1.ii # checkstat 'cache hit' 11 # checkstat 'cache miss' 39 testname="stripc" # This test might not be portable CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 10 checkstat 'cache miss' 39 CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c checkstat 'cache hit' 11 checkstat 'cache miss' 39 testname="zero-stats" $CCACHE -z > /dev/null checkstat 'cache hit' 0 checkstat 'cache miss' 0 testname="clear" $CCACHE -C > /dev/null checkstat 'files in cache' 0 rm -f test1.c } swigtests() { echo "starting swig testsuite $testsuite" rm -rf "$CCACHE_DIR" checkstat 'cache hit' 0 checkstat 'cache miss' 0 j=1 rm -f *.i genswigcode testswig1.i 1 testname="BASIC" $CCACHE_COMPILE -java testswig1.i checkstat 'cache hit' 0 checkstat 'cache miss' 1 checkstat 'files in cache' 6 testname="BASIC2" $CCACHE_COMPILE -java testswig1.i checkstat 'cache hit' 1 checkstat 'cache miss' 1 testname="output" $CCACHE_COMPILE -java testswig1.i -o foo_wrap.c checkstat 'cache hit' 1 checkstat 'cache miss' 2 testname="bad" $CCACHE_COMPILE -java testswig1.i -I 2> /dev/null checkstat 'bad compiler arguments' 1 testname="stdout" $CCACHE_COMPILE -v -java testswig1.i > /dev/null checkstat 'compiler produced stdout' 1 testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1 rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" $CCACHE_COMPILE -java 2> /dev/null checkstat 'no input file' 1 testname="CCACHE_DISABLE" CCACHE_DISABLE=1 $CCACHE_COMPILE -java testswig1.i 2> /dev/null checkstat 'cache hit' 1 $CCACHE_COMPILE -java testswig1.i checkstat 'cache hit' 2 testname="CCACHE_CPP2" CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 2 checkstat 'cache miss' 3 CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 3 checkstat 'cache miss' 3 testname="CCACHE_NOSTATS" CCACHE_NOSTATS=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 3 checkstat 'cache miss' 3 testname="CCACHE_RECACHE" CCACHE_RECACHE=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 3 checkstat 'cache miss' 4 # strictly speaking should be 3x6=18 instead of 4x6=24 - RECACHE causes a double counting! checkstat 'files in cache' 24 $CCACHE -c > /dev/null checkstat 'files in cache' 18 testname="CCACHE_HASHDIR" CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 3 checkstat 'cache miss' 5 CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 4 checkstat 'cache miss' 5 checkstat 'files in cache' 24 testname="cpp call" $CCACHE_COMPILE -java -E testswig1.i > testswig1-preproc.i checkstat 'cache hit' 4 checkstat 'cache miss' 5 testname="direct .i compile" $CCACHE_COMPILE -java testswig1.i checkstat 'cache hit' 5 checkstat 'cache miss' 5 # No cache hit due to different input file name, -nopreprocess should not be given twice to SWIG $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i checkstat 'cache hit' 5 checkstat 'cache miss' 6 $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i checkstat 'cache hit' 6 checkstat 'cache miss' 6 testname="stripc" CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O testswig1.i checkstat 'cache hit' 7 checkstat 'cache miss' 6 CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O -O testswig1.i checkstat 'cache hit' 7 checkstat 'cache miss' 7 rm -f testswig1-preproc.i rm -f testswig1.i } ###### # main program rm -rf $TESTDIR mkdir $TESTDIR cd $TESTDIR || exit 1 unset CCACHE_DIR unset CCACHE_TEMPDIR unset CCACHE_LOGFILE unset CCACHE_VERBOSE unset CCACHE_PATH unset CCACHE_CC unset CCACHE_PREFIX unset CCACHE_DISABLE unset CCACHE_READONLY unset CCACHE_CPP2 unset CCACHE_NOCOMPRESS unset CCACHE_NOSTATS unset CCACHE_NLEVELS unset CCACHE_HARDLINK unset CCACHE_RECACHE unset CCACHE_UMASK unset CCACHE_HASHDIR unset CCACHE_UNIFY unset CCACHE_EXTENSION unset CCACHE_STRIPC unset CCACHE_SWIG CCACHE_DIR="ccache dir" # with space in directory name (like Windows default) mkdir "$CCACHE_DIR" export CCACHE_DIR testsuite="base" CCACHE_COMPILE="$CCACHE $COMPILER" basetests CCACHE_COMPILE="$CCACHE $SWIG" swigtests if test -z "$NOSOFTLINKSTEST"; then testsuite="link" ln -s $CCACHE $COMPILER CCACHE_COMPILE="./$COMPILER" basetests rm "./$COMPILER" ln -s $CCACHE $SWIG CCACHE_COMPILE="./$SWIG" swigtests rm "./$SWIG" else echo "skipping testsuite link" fi testsuite="hardlink" CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $COMPILER" basetests CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $SWIG" swigtests testsuite="cpp2" CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $COMPILER" basetests CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $SWIG" swigtests testsuite="nlevels4" CCACHE_COMPILE="env CCACHE_NLEVELS=4 $CCACHE $COMPILER" basetests testsuite="nlevels1" CCACHE_COMPILE="env CCACHE_NLEVELS=1 $CCACHE $COMPILER" basetests cd .. rm -rf $TESTDIR echo test done - OK exit 0 swig-3.0.8/CCache/configure.ac0000664000175000017500000000460412641054563015761 0ustar williamwilliamdnl Process this file with autoconf to produce a configure script. AC_INIT([ccache-swig], [0.0]) # Get version from SWIG in ccache_swig_config.h.in AC_PREREQ(2.52) AC_CONFIG_SRCDIR([ccache.h]) AC_MSG_NOTICE([Configuring ccache]) AC_CONFIG_HEADER(config.h) dnl Checks for programs. AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_ARG_PROGRAM # for program_transform_name AC_DEFINE([_GNU_SOURCE], 1, [Define _GNU_SOURCE so that we get all necessary prototypes]) # If GCC, turn on warnings. if test "x$GCC" = "xyes" then CFLAGS="$CFLAGS -Wall -W" else CFLAGS="$CFLAGS -O" fi AC_HEADER_DIRENT AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h) AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) AC_CHECK_FUNCS(gethostname getpwuid) AC_CHECK_FUNCS(utimes) AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ AC_TRY_COMPILE( [#include ], [ void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } ], ccache_cv_COMPAR_FN_T=yes,ccache_cv_COMPAR_FN_T=no)]) if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then AC_DEFINE(HAVE_COMPAR_FN_T, 1, [ ]) fi dnl Note: This could be replaced by AC_FUNC_SNPRINTF() in the autoconf macro archive AC_CACHE_CHECK([for C99 vsnprintf],ccache_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include #include void foo(const char *format, ...) { va_list ap; int len; char buf[5]; va_start(ap, format); len = vsnprintf(0, 0, format, ap); va_end(ap); if (len != 5) exit(1); if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); exit(0); } main() { foo("hello"); } ], ccache_cv_HAVE_C99_VSNPRINTF=yes,ccache_cv_HAVE_C99_VSNPRINTF=no,ccache_cv_HAVE_C99_VSNPRINTF=cross)]) if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) fi dnl Check for zlib. dnl Note: This could be replaced by CHECK_ZLIB() in the autoconf macro archive AC_ARG_ENABLE([zlib], AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, [enable_zlib=yes]) if test x"$enable_zlib" = x"yes"; then AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, [LIBS="-lz $LIBS" AC_DEFINE([ENABLE_ZLIB], 1, [Define to 1 if you would like to have zlib compression for ccache.]) ] )) fi AC_CONFIG_FILES([Makefile]) AC_OUTPUT swig-3.0.8/CCache/mdfour.h0000664000175000017500000000231112641054563015131 0ustar williamwilliam/* Unix SMB/Netbios implementation. Version 1.9. a implementation of MD4 designed for use in the SMB authentication protocol Copyright (C) Andrew Tridgell 1997-1998. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ struct mdfour { uint32 A, B, C, D; uint32 totalN; unsigned char tail[64]; unsigned tail_len; }; void mdfour_begin(struct mdfour *md); void mdfour_update(struct mdfour *md, const unsigned char *in, int n); void mdfour_result(struct mdfour *md, unsigned char *out); void mdfour(unsigned char *out, const unsigned char *in, int n); swig-3.0.8/CCache/Makefile.in0000664000175000017500000000541112641054563015535 0ustar williamwilliamdatarootdir = @datarootdir@ srcdir=@srcdir@ VPATH=@srcdir@ prefix=@prefix@ exec_prefix=@exec_prefix@ bindir=@bindir@ mandir=@mandir@ INSTALLCMD=@INSTALL@ PACKAGE_NAME=@PACKAGE_NAME@ # Soft link test can be skipped on systems that don't support soft linking NOSOFTLINKSTEST= CC=@CC@ CFLAGS=@CFLAGS@ -I. SWIG=swig SWIG_LIB=../$(srcdir)/../Lib EXEEXT=@EXEEXT@ # Use standard autoconf approach to transform executable name using --program-prefix and --program-suffix transform = @program_transform_name@ LIBS= @LIBS@ OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ cleanup.o snprintf.o unify.o HEADERS = ccache.h mdfour.h all: $(PACKAGE_NAME)$(EXEEXT) # Regenerate Makefile if Makefile.in or config.status have changed. Makefile: $(srcdir)/Makefile.in ./config.status $(SHELL) ./config.status # Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile docs: $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html $(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(srcdir)/$(PACKAGE_NAME).1: $(srcdir)/ccache.yo -yodl2man -o $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/ccache.yo $(srcdir)/web/ccache-man.html: $(srcdir)/ccache.yo yodl2html -o $(srcdir)/web/ccache-man.html $(srcdir)/ccache.yo install: $(PACKAGE_NAME)$(EXEEXT) @echo "Installing $(PACKAGE_NAME)" @echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)" ${INSTALLCMD} -d $(DESTDIR)${bindir} ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) install-docs: $(srcdir)/$(PACKAGE_NAME).1 @echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1" ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 ${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 uninstall: $(PACKAGE_NAME)$(EXEEXT) rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) uninstall-docs: $(srcdir)/$(PACKAGE_NAME).1 rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 clean: /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) test: test.sh SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' $(srcdir)/test.sh check: test distclean: clean /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h /bin/rm -rf autom4te.cache maintainer-clean: distclean /bin/rm -f $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html # FIXME: To fix this, test.sh needs to be able to take ccache from the # installed prefix, not from the source dir. installcheck: @echo "WARNING! This is not really \"installcheck\" yet." $(MAKE) check swig-3.0.8/CCache/mdfour.c0000664000175000017500000001401312641054563015126 0ustar williamwilliam/* a implementation of MD4 designed for use in the SMB authentication protocol Copyright (C) Andrew Tridgell 1997-1998. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" /* NOTE: This code makes no attempt to be fast! It assumes that a int is at least 32 bits long */ static struct mdfour *m; #define MASK32 (0xffffffff) #define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z)))) #define G(X,Y,Z) ((((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))) #define H(X,Y,Z) (((X)^(Y)^(Z))) #define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32))) #define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s) #define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s) #define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s) /* this applies md4 to 64 byte chunks */ static void mdfour64(uint32 *M) { uint32 AA, BB, CC, DD; uint32 A,B,C,D; A = m->A; B = m->B; C = m->C; D = m->D; AA = A; BB = B; CC = C; DD = D; ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7); ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19); ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7); ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19); ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7); ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19); ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7); ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19); ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5); ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13); ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5); ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13); ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5); ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13); ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5); ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13); ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9); ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15); ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9); ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15); ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9); ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15); ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9); ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15); A += AA; B += BB; C += CC; D += DD; A &= MASK32; B &= MASK32; C &= MASK32; D &= MASK32; m->A = A; m->B = B; m->C = C; m->D = D; } static void copy64(uint32 *M, const unsigned char *in) { int i; for (i=0;i<16;i++) M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | (in[i*4+1]<<8) | (in[i*4+0]<<0); } static void copy4(unsigned char *out,uint32 x) { out[0] = x&0xFF; out[1] = (x>>8)&0xFF; out[2] = (x>>16)&0xFF; out[3] = (x>>24)&0xFF; } void mdfour_begin(struct mdfour *md) { md->A = 0x67452301; md->B = 0xefcdab89; md->C = 0x98badcfe; md->D = 0x10325476; md->totalN = 0; md->tail_len = 0; } static void mdfour_tail(const unsigned char *in, int n) { unsigned char buf[128]; uint32 M[16]; uint32 b; m->totalN += n; b = m->totalN * 8; memset(buf, 0, 128); if (n) memcpy(buf, in, n); buf[n] = 0x80; if (n <= 55) { copy4(buf+56, b); copy64(M, buf); mdfour64(M); } else { copy4(buf+120, b); copy64(M, buf); mdfour64(M); copy64(M, buf+64); mdfour64(M); } } void mdfour_update(struct mdfour *md, const unsigned char *in, int n) { uint32 M[16]; m = md; if (in == NULL) { mdfour_tail(md->tail, md->tail_len); return; } if (md->tail_len) { int len = 64 - md->tail_len; if (len > n) len = n; memcpy(md->tail+md->tail_len, in, len); md->tail_len += len; n -= len; in += len; if (md->tail_len == 64) { copy64(M, md->tail); mdfour64(M); m->totalN += 64; md->tail_len = 0; } } while (n >= 64) { copy64(M, in); mdfour64(M); in += 64; n -= 64; m->totalN += 64; } if (n) { memcpy(md->tail, in, n); md->tail_len = n; } } void mdfour_result(struct mdfour *md, unsigned char *out) { m = md; copy4(out, m->A); copy4(out+4, m->B); copy4(out+8, m->C); copy4(out+12, m->D); } void mdfour(unsigned char *out, const unsigned char *in, int n) { struct mdfour md; mdfour_begin(&md); mdfour_update(&md, in, n); mdfour_update(&md, NULL, 0); mdfour_result(&md, out); } #ifdef TEST_MDFOUR static void file_checksum1(char *fname) { int fd, i; struct mdfour md; unsigned char buf[1024], sum[16]; unsigned chunk; fd = open(fname,O_RDONLY|O_BINARY); if (fd == -1) { perror("fname"); exit(1); } chunk = 1 + random() % (sizeof(buf) - 1); mdfour_begin(&md); while (1) { int n = read(fd, buf, chunk); if (n >= 0) { mdfour_update(&md, buf, n); } if (n < chunk) break; } close(fd); mdfour_update(&md, NULL, 0); mdfour_result(&md, sum); for (i=0;i<16;i++) printf("%02x", sum[i]); printf("\n"); } #if 0 #include "../md4.h" static void file_checksum2(char *fname) { int fd, i; MDstruct md; unsigned char buf[64], sum[16]; fd = open(fname,O_RDONLY|O_BINARY); if (fd == -1) { perror("fname"); exit(1); } MDbegin(&md); while (1) { int n = read(fd, buf, sizeof(buf)); if (n <= 0) break; MDupdate(&md, buf, n*8); } if (!md.done) { MDupdate(&md, buf, 0); } close(fd); memcpy(sum, md.buffer, 16); for (i=0;i<16;i++) printf("%02x", sum[i]); printf("\n"); } #endif int main(int argc, char *argv[]) { file_checksum1(argv[1]); #if 0 file_checksum2(argv[1]); #endif return 0; } #endif swig-3.0.8/CCache/args.c0000664000175000017500000000454012641054563014572 0ustar williamwilliam/* convenient routines for argument list handling Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ccache.h" ARGS *args_init(int init_argc, char **init_args) { ARGS *args; int i; args = (ARGS *)x_malloc(sizeof(ARGS)); args->argc = 0; args->argv = (char **)x_malloc(sizeof(char *)); args->argv[0] = NULL; for (i=0;iargv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); args->argv[args->argc] = x_strdup(s); args->argc++; args->argv[args->argc] = NULL; } /* pop the last element off the args list */ void args_pop(ARGS *args, int n) { while (n--) { args->argc--; free(args->argv[args->argc]); args->argv[args->argc] = NULL; } } /* remove the first element of the argument list */ void args_remove_first(ARGS *args) { free(args->argv[0]); memmove(&args->argv[0], &args->argv[1], args->argc * sizeof(args->argv[0])); args->argc--; } /* add an argument into the front of the argument list */ void args_add_prefix(ARGS *args, const char *s) { args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); memmove(&args->argv[1], &args->argv[0], (args->argc+1) * sizeof(args->argv[0])); args->argv[0] = x_strdup(s); args->argc++; } /* strip any arguments beginning with the specified prefix */ void args_strip(ARGS *args, const char *prefix) { int i; for (i=0; iargc; ) { if (strncmp(args->argv[i], prefix, strlen(prefix)) == 0) { free(args->argv[i]); memmove(&args->argv[i], &args->argv[i+1], args->argc * sizeof(args->argv[i])); args->argc--; } else { i++; } } } swig-3.0.8/CCache/README0000664000175000017500000000125512641054563014352 0ustar williamwilliamThis is a re-implementation of "compilercache" in C The original compilercache scripts were by Erik Thiele (erikyyy@erikyyy.de) and I would like to thank him for an excellent piece of work. See http://www.erikyyy.de/compilercache/ for the original shell scripts. I wrote ccache because I wanted to get a bit more speed out of a compiler cache and I wanted to remove some of the limitations of the shell-script version. Please see the manual page and documentation at http://ccache.samba.org/ INSTALLATION ------------ Please run: ./configure make make install then read the ccache manual page ----------- Andrew Tridgell http://samba.org/~tridge/ bugs@ccache.samba.org swig-3.0.8/CCache/web/0000775000175000017500000000000012641054563014244 5ustar williamwilliamswig-3.0.8/CCache/web/index.html0000664000175000017500000001237712641054563016253 0ustar williamwilliam ccache

ccache

ccache is a compiler cache. It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache. This often results in a 5 to 10 times speedup in common compilations.

The idea came from Erik Thiele wrote the original compilercache program as a bourne shell script. ccache is a re-implementation of Erik's idea in C with more features and better performance.

Latest release

The latest release is ccache 2.4.
  • Added CCACHE_READONLY option
  • Added CCACHE_TEMPDIR option
  • fixed handling of hard-linked compilers on AIX
  • added O_BINARY support, to try and support win32 compiles
  • show cache directory in stats output
  • fixed handling of HOME environment variable
See the manual page for details on the new options.

You can get this release from the download directory

NOTE! This release changes the hash input slighly, so you will probably find that you will not get any hits against your existing cache when you upgrade.

Why bother?

Why bother with a compiler cache? If you ever run "make clean; make" then you can probably benefit from ccache. It is very common for developers to do a clean build of a project for a whole host of reasons, and this throws away all the information from your previous compiles.

By using ccache you can get exactly the same effect as "make clean; make" but much faster. It also helps a lot when doing RPM builds, as RPM can make doing incremental builds tricky.

I put the effort into writing ccache for 2 reasons. The first is the Samba build farm (http://build.samba.org/) which constantly does clean builds of Samba on about 30 machines after each CVS commit. On some of those machines the build took over an hour. By using ccache we get the same effect as clean builds but about 6 times faster.

The second reason is the autobuild system I used to run for Quantum. That system builds our whole Linux based OS from scratch after every CVS commit to catch compilation problems quickly. Using ccache those builds are much faster.

Is it safe?

Yes. The most important aspect of a compiler cache is to always produce exactly the same output that the real compiler would produce. The includes providing exactly the same object files and exactly the same compiler warnings that would be produced if you use the real compiler. The only way you should be able to tell that you are using ccache is the speed.

I have coded ccache very carefully to try to provide these guarantees.

Features

  • keeps statistics on hits/misses
  • automatic cache size management
  • can cache compiles that generate warnings
  • easy installation
  • very low overhead
  • uses hard links where possible to avoid copies

Documentation

See the manual page

Performance

Here are some results for compiling Samba on my Linux laptop. I have also included the results of using Erik's compilercache program (version 1.0.10) for comparison.

    ccache  compilercache
normal 13m 4s 13m 4s
uncached 13m 15s 15m 41s
cached 2m 45s 4m 26s

How to use it

You can use ccache in two ways. The first is just to prefix your compile commands with "ccache". For example, you could change the "CC=gcc" line in your Makefile to be "CC=ccache gcc".

Alternatively, you can create symbolic links from your compilers name to ccache. This allows you to use ccache without any changes to your build system.

Download

You can download the latest release from the download directory.

For the bleeding edge, you can fetch ccache via CVS or rsync. To fetch via cvs use the following command:

  cvs -d :pserver:cvs@pserver.samba.org:/cvsroot co ccache
To fetch via rsync use this command:
  rsync -Pavz samba.org::ftp/unpacked/ccache .

Related projects

Here are some related programs you may find interesting
  • distcc - a distributed compilation system
  • cachecc1 - a gcc specific cache
  • gocache - a cross platform compiler cache

Mailing list

A mailing list is available for discussion of ccache.


Andrew Tridgell
bugs@ccache.samba.org
swig-3.0.8/CCache/cleanup.c0000664000175000017500000001205112641054563015261 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* functions to cleanup the cache directory when it gets too large */ #include "ccache.h" static struct files { char *fname; time_t mtime; size_t size; } **files; static unsigned allocated; static unsigned num_files; static size_t total_size; static size_t total_files; static size_t size_threshold; static size_t files_threshold; /* file comparison function to try to delete the oldest files first */ static int files_compare(struct files **f1, struct files **f2) { if ((*f2)->mtime == (*f1)->mtime) { return strcmp((*f2)->fname, (*f1)->fname); } if ((*f2)->mtime > (*f1)->mtime) { return -1; } return 1; } /* this builds the list of files in the cache */ static void traverse_fn(const char *fname, struct stat *st) { char *p; if (!S_ISREG(st->st_mode)) return; p = str_basename(fname); if (strcmp(p, "stats") == 0) { free(p); return; } free(p); if (num_files == allocated) { allocated = 10000 + num_files*2; files = (struct files **)x_realloc(files, sizeof(struct files *)*allocated); } files[num_files] = (struct files *)x_malloc(sizeof(struct files)); files[num_files]->fname = x_strdup(fname); files[num_files]->mtime = st->st_mtime; files[num_files]->size = file_size(st) / 1024; total_size += files[num_files]->size; num_files++; } /* sort the files we've found and delete the oldest ones until we are below the thresholds */ static void sort_and_clean(size_t minfiles) { unsigned i; size_t adjusted_minfiles = minfiles; if (num_files > 1) { /* sort in ascending data order */ qsort(files, num_files, sizeof(struct files *), (COMPAR_FN_T)files_compare); } /* ensure newly cached files (minfiles) are kept - instead of matching the filenames of those newly cached, a faster and simpler approach assumes these are the most recent in the cache and if any other cached files have an identical time stamp, they will also be kept - this approach would not be needed if the cleanup was done at exit. */ if (minfiles != 0 && minfiles < num_files) { unsigned minfiles_index = num_files - minfiles; time_t minfiles_time = files[minfiles_index]->mtime; for (i=1; i<=minfiles_index; i++) { if (files[minfiles_index-i]->mtime == minfiles_time) adjusted_minfiles++; else break; } } /* delete enough files to bring us below the threshold */ for (i=0;ifname) != 0 && errno != ENOENT) { fprintf(stderr, "unlink %s - %s\n", files[i]->fname, strerror(errno)); continue; } total_size -= files[i]->size; } total_files = num_files - i; } /* cleanup in one cache subdir */ void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles) { unsigned i; size_threshold = maxsize * LIMIT_MULTIPLE; files_threshold = maxfiles * LIMIT_MULTIPLE; num_files = 0; total_size = 0; /* build a list of files */ traverse(dir, traverse_fn); /* clean the cache */ sort_and_clean(minfiles); stats_set_sizes(dir, total_files, total_size); /* free it up */ for (i=0;ifname); free(files[i]); files[i] = NULL; } if (files) free(files); allocated = 0; files = NULL; num_files = 0; total_size = 0; } /* cleanup in all cache subdirs */ void cleanup_all(const char *dir) { unsigned counters[STATS_END]; char *dname, *sfile; int i; for (i=0;i<=0xF;i++) { x_asprintf(&dname, "%s/%1x", dir, i); x_asprintf(&sfile, "%s/%1x/stats", dir, i); memset(counters, 0, sizeof(counters)); stats_read(sfile, counters); cleanup_dir(dname, counters[STATS_MAXFILES], counters[STATS_MAXSIZE], 0); free(dname); free(sfile); } } /* traverse function for wiping files */ static void wipe_fn(const char *fname, struct stat *st) { char *p; if (!S_ISREG(st->st_mode)) return; p = str_basename(fname); if (strcmp(p, "stats") == 0) { free(p); return; } free(p); unlink(fname); } /* wipe all cached files in all subdirs */ void wipe_all(const char *dir) { char *dname; int i; for (i=0;i<=0xF;i++) { x_asprintf(&dname, "%s/%1x", dir, i); traverse(dir, wipe_fn); free(dname); } /* and fix the counters */ cleanup_all(dir); } swig-3.0.8/CCache/COPYING0000664000175000017500000004307612641054563014534 0ustar williamwilliam GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. swig-3.0.8/CCache/stats.c0000664000175000017500000002147512641054563015002 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* routines to handle the stats files the stats file is stored one per cache subdirectory to make this more scalable */ #include "ccache.h" extern char *stats_file; extern char *cache_dir; #define STATS_VERSION 1 #define FLAG_NOZERO 1 /* don't zero with the -z option */ #define FLAG_ALWAYS 2 /* always show, even if zero */ static struct { enum stats stat; char *message; void (*fn)(unsigned ); unsigned flags; } stats_info[] = { { STATS_CACHED, "cache hit ", NULL, FLAG_ALWAYS }, { STATS_TOCACHE, "cache miss ", NULL, FLAG_ALWAYS }, { STATS_LINK, "called for link ", NULL, 0 }, { STATS_MULTIPLE, "multiple source files ", NULL, 0 }, { STATS_STDOUT, "compiler produced stdout ", NULL, 0 }, { STATS_STATUS, "compile failed ", NULL, 0 }, { STATS_ERROR, "ccache internal error ", NULL, 0 }, { STATS_PREPROCESSOR, "preprocessor error ", NULL, 0 }, { STATS_COMPILER, "couldn't find the compiler ", NULL, 0 }, { STATS_MISSING, "cache file missing ", NULL, 0 }, { STATS_ARGS, "bad compiler arguments ", NULL, 0 }, { STATS_NOTC, "not a C/C++ file ", NULL, 0 }, { STATS_CONFTEST, "autoconf compile/link ", NULL, 0 }, { STATS_UNSUPPORTED, "unsupported compiler option ", NULL, 0 }, { STATS_OUTSTDOUT, "output to stdout ", NULL, 0 }, { STATS_DEVICE, "output to a non-regular file ", NULL, 0 }, { STATS_NOINPUT, "no input file ", NULL, 0 }, { STATS_ENVIRONMMENT, "error due to bad env variable ", NULL, 0 }, { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS }, { STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS }, { STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO }, { STATS_MAXSIZE, "max cache size ", display_size, FLAG_NOZERO }, { STATS_NONE, NULL, NULL, 0 } }; /* parse a stats file from a buffer - adding to the counters */ static void parse_stats(unsigned counters[STATS_END], char *buf) { int i; char *p, *p2; p = buf; for (i=0;i= (int)sizeof(buf)-1) fatal("stats too long?!"); } len += snprintf(buf+len, sizeof(buf)-(len+1), "\n"); if (len >= (int)sizeof(buf)-1) fatal("stats too long?!"); lseek(fd, 0, SEEK_SET); if (write(fd, buf, len) == -1) fatal("could not write stats"); } /* fill in some default stats values */ static void stats_default(unsigned counters[STATS_END]) { counters[STATS_MAXSIZE] += DEFAULT_MAXSIZE / 16; } /* read in the stats from one dir and add to the counters */ static void stats_read_fd(int fd, unsigned counters[STATS_END]) { char buf[1024]; int len; len = read(fd, buf, sizeof(buf)-1); if (len <= 0) { stats_default(counters); return; } buf[len] = 0; parse_stats(counters, buf); } /* update the stats counter for this compile */ static void stats_update_size(enum stats stat, size_t size, size_t numfiles) { int fd; unsigned counters[STATS_END]; int need_cleanup = 0; if (getenv("CCACHE_NOSTATS")) return; if (!stats_file) { if (!cache_dir) return; x_asprintf(&stats_file, "%s/stats", cache_dir); } /* open safely to try to prevent symlink races */ fd = safe_open(stats_file); /* still can't get it? don't bother ... */ if (fd == -1) return; memset(counters, 0, sizeof(counters)); if (lock_fd(fd) != 0) return; /* read in the old stats */ stats_read_fd(fd, counters); /* update them */ counters[stat]++; /* on a cache miss we up the file count and size */ if (stat == STATS_TOCACHE) { counters[STATS_NUMFILES] += numfiles; counters[STATS_TOTALSIZE] += size; } /* and write them out */ write_stats(fd, counters); close(fd); /* we might need to cleanup if the cache has now got too big */ if (counters[STATS_MAXFILES] != 0 && counters[STATS_NUMFILES] > counters[STATS_MAXFILES]) { need_cleanup = 1; } if (counters[STATS_MAXSIZE] != 0 && counters[STATS_TOTALSIZE] > counters[STATS_MAXSIZE]) { need_cleanup = 1; } if (need_cleanup) { char *p = dirname(stats_file); cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE], numfiles); free(p); } } /* record a cache miss */ void stats_tocache(size_t size, size_t numfiles) { /* convert size to kilobytes */ size = size / 1024; stats_update_size(STATS_TOCACHE, size, numfiles); } /* update a normal stat */ void stats_update(enum stats stat) { stats_update_size(stat, 0, 0); } /* read in the stats from one dir and add to the counters */ void stats_read(const char *stats_file, unsigned counters[STATS_END]) { int fd; fd = open(stats_file, O_RDONLY|O_BINARY); if (fd == -1) { stats_default(counters); return; } lock_fd(fd); stats_read_fd(fd, counters); close(fd); } /* sum and display the total stats for all cache dirs */ void stats_summary(void) { int dir, i; unsigned counters[STATS_END]; memset(counters, 0, sizeof(counters)); /* add up the stats in each directory */ for (dir=-1;dir<=0xF;dir++) { char *fname; if (dir == -1) { x_asprintf(&fname, "%s/stats", cache_dir); } else { x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir); } stats_read(fname, counters); free(fname); /* oh what a nasty hack ... */ if (dir == -1) { counters[STATS_MAXSIZE] = 0; } } printf("cache directory %s\n", cache_dir); /* and display them */ for (i=0;stats_info[i].message;i++) { enum stats stat = stats_info[i].stat; if (counters[stat] == 0 && !(stats_info[i].flags & FLAG_ALWAYS)) { continue; } printf("%s ", stats_info[i].message); if (stats_info[i].fn) { stats_info[i].fn(counters[stat]); printf("\n"); } else { printf("%8u\n", counters[stat]); } } } /* zero all the stats structures */ void stats_zero(void) { int dir, fd; unsigned i; char *fname; unsigned counters[STATS_END]; x_asprintf(&fname, "%s/stats", cache_dir); unlink(fname); free(fname); for (dir=0;dir<=0xF;dir++) { x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir); fd = safe_open(fname); if (fd == -1) { free(fname); continue; } memset(counters, 0, sizeof(counters)); lock_fd(fd); stats_read_fd(fd, counters); for (i=0;stats_info[i].message;i++) { if (!(stats_info[i].flags & FLAG_NOZERO)) { counters[stats_info[i].stat] = 0; } } write_stats(fd, counters); close(fd); free(fname); } } /* set the per directory limits */ int stats_set_limits(long maxfiles, long maxsize) { int dir; unsigned counters[STATS_END]; if (maxfiles != -1) { maxfiles /= 16; } if (maxsize != -1) { maxsize /= 16; } if (create_dir(cache_dir) != 0) { return 1; } /* set the limits in each directory */ for (dir=0;dir<=0xF;dir++) { char *fname, *cdir; int fd; x_asprintf(&cdir, "%s/%1x", cache_dir, dir); if (create_dir(cdir) != 0) { return 1; } x_asprintf(&fname, "%s/stats", cdir); free(cdir); memset(counters, 0, sizeof(counters)); fd = safe_open(fname); if (fd != -1) { lock_fd(fd); stats_read_fd(fd, counters); if (maxfiles != -1) { counters[STATS_MAXFILES] = maxfiles; } if (maxsize != -1) { counters[STATS_MAXSIZE] = maxsize; } write_stats(fd, counters); close(fd); } free(fname); } return 0; } /* set the per directory sizes */ void stats_set_sizes(const char *dir, size_t num_files, size_t total_size) { int fd; unsigned counters[STATS_END]; char *stats_file; create_dir(dir); x_asprintf(&stats_file, "%s/stats", dir); memset(counters, 0, sizeof(counters)); fd = safe_open(stats_file); if (fd != -1) { lock_fd(fd); stats_read_fd(fd, counters); counters[STATS_NUMFILES] = num_files; counters[STATS_TOTALSIZE] = total_size; write_stats(fd, counters); close(fd); } free(stats_file); } swig-3.0.8/CCache/configure0000775000175000017500000044435312641164616015414 0ustar williamwilliam#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for ccache-swig 0.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ccache-swig' PACKAGE_TARNAME='ccache-swig' PACKAGE_VERSION='0.0' PACKAGE_STRING='ccache-swig 0.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="ccache.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS EGREP GREP INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_zlib ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures ccache-swig 0.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/ccache-swig] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of ccache-swig 0.0:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-zlib enable zlib support for ccache compression Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF ccache-swig configure 0.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by ccache-swig $as_me 0.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Get version from SWIG in ccache_swig_config.h.in { $as_echo "$as_me:${as_lineno-$LINENO}: Configuring ccache" >&5 $as_echo "$as_me: Configuring ccache" >&6;} ac_config_headers="$ac_config_headers config.h" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # for program_transform_name $as_echo "#define _GNU_SOURCE 1" >>confdefs.h # If GCC, turn on warnings. if test "x$GCC" = "xyes" then CFLAGS="$CFLAGS -Wall -W" else CFLAGS="$CFLAGS -O" fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } if eval \${$as_ac_Header+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$as_ac_Header=yes" else eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$as_ac_Header { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in ctype.h strings.h stdlib.h string.h pwd.h sys/time.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in realpath snprintf vsnprintf vasprintf asprintf mkstemp do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in gethostname getpwuid do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in utimes do : ac_fn_c_check_func "$LINENO" "utimes" "ac_cv_func_utimes" if test "x$ac_cv_func_utimes" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UTIMES 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compar_fn_t in stdlib.h" >&5 $as_echo_n "checking for compar_fn_t in stdlib.h... " >&6; } if ${ccache_cv_COMPAR_FN_T+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ccache_cv_COMPAR_FN_T=yes else ccache_cv_COMPAR_FN_T=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ccache_cv_COMPAR_FN_T" >&5 $as_echo "$ccache_cv_COMPAR_FN_T" >&6; } if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then $as_echo "#define HAVE_COMPAR_FN_T 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C99 vsnprintf" >&5 $as_echo_n "checking for C99 vsnprintf... " >&6; } if ${ccache_cv_HAVE_C99_VSNPRINTF+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ccache_cv_HAVE_C99_VSNPRINTF=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include void foo(const char *format, ...) { va_list ap; int len; char buf[5]; va_start(ap, format); len = vsnprintf(0, 0, format, ap); va_end(ap); if (len != 5) exit(1); if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); exit(0); } main() { foo("hello"); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ccache_cv_HAVE_C99_VSNPRINTF=yes else ccache_cv_HAVE_C99_VSNPRINTF=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ccache_cv_HAVE_C99_VSNPRINTF" >&5 $as_echo "$ccache_cv_HAVE_C99_VSNPRINTF" >&6; } if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then $as_echo "#define HAVE_C99_VSNPRINTF 1" >>confdefs.h fi # Check whether --enable-zlib was given. if test "${enable_zlib+set}" = set; then : enableval=$enable_zlib; else enable_zlib=yes fi if test x"$enable_zlib" = x"yes"; then ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzdopen in -lz" >&5 $as_echo_n "checking for gzdopen in -lz... " >&6; } if ${ac_cv_lib_z_gzdopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gzdopen (); int main () { return gzdopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_z_gzdopen=yes else ac_cv_lib_z_gzdopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzdopen" >&5 $as_echo "$ac_cv_lib_z_gzdopen" >&6; } if test "x$ac_cv_lib_z_gzdopen" = xyes; then : LIBS="-lz $LIBS" $as_echo "#define ENABLE_ZLIB 1" >>confdefs.h fi fi fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by ccache-swig $as_me 0.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ ccache-swig config.status 0.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi swig-3.0.8/CCache/config.h.in0000664000175000017500000000610712641164617015520 0ustar williamwilliam/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you would like to have zlib compression for ccache. */ #undef ENABLE_ZLIB /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF /* */ #undef HAVE_C99_VSNPRINTF /* */ #undef HAVE_COMPAR_FN_T /* Define to 1 if you have the header file. */ #undef HAVE_CTYPE_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the `getpwuid' function. */ #undef HAVE_GETPWUID /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mkstemp' function. */ #undef HAVE_MKSTEMP /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_PWD_H /* Define to 1 if you have the `realpath' function. */ #undef HAVE_REALPATH /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `utimes' function. */ #undef HAVE_UTIMES /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define _GNU_SOURCE so that we get all necessary prototypes */ #undef _GNU_SOURCE swig-3.0.8/CCache/hash.c0000664000175000017500000000332312641054563014557 0ustar williamwilliam/* Copyright (C) Andrew Tridgell 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* simple front-end functions to mdfour code */ #include "ccache.h" static struct mdfour md; void hash_buffer(const char *s, int len) { mdfour_update(&md, (unsigned char *)s, len); } void hash_start(void) { mdfour_begin(&md); } void hash_string(const char *s) { hash_buffer(s, strlen(s)); } void hash_int(int x) { hash_buffer((char *)&x, sizeof(x)); } /* add contents of a file to the hash */ void hash_file(const char *fname) { char buf[1024]; int fd, n; fd = open(fname, O_RDONLY|O_BINARY); if (fd == -1) { cc_log("Failed to open %s\n", fname); fatal("hash_file"); } while ((n = read(fd, buf, sizeof(buf))) > 0) { hash_buffer(buf, n); } close(fd); } /* return the hash result as a static string */ char *hash_result(void) { unsigned char sum[16]; static char ret[53]; int i; hash_buffer(NULL, 0); mdfour_result(&md, sum); for (i=0;i<16;i++) { sprintf(&ret[i*2], "%02x", (unsigned)sum[i]); } sprintf(&ret[i*2], "-%u", (unsigned)md.totalN); return ret; } swig-3.0.8/INSTALL0000664000175000017500000002200512641054563013411 0ustar williamwilliamBasic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. (Caching is disabled by default to prevent problems with accidental use of stale cache files.) If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You only need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for variables by setting them in the environment. You can do that on the command line like this: ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix *Note Environment Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not support the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it cannot guess the host type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are _building_ compiler tools for cross-compiling, you should use the `--target=TYPE' option to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the host platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. In this case, you should also specify the build platform with `--build=TYPE', because, in this case, it may not be possible to guess the build platform (it sometimes involves compiling and running simple test programs, and this can't be done if the compiler is a cross compiler). Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Environment Variables ===================== Variables not defined in a site shell script can be set in the environment passed to configure. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc will cause the specified gcc to be used as the C compiler (unless it is overridden in the site shell script). `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. swig-3.0.8/LICENSE-GPL0000664000175000017500000010451312641054563014012 0ustar williamwilliam GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . swig-3.0.8/swig.spec.in0000664000175000017500000000473712641054563014626 0ustar williamwilliam# You can build the package from Git using something like: # tar -czf swig-@PACKAGE_VERSION@.tar.gz swig-@PACKAGE_VERSION@ && rpmbuild -tb swig-@PACKAGE_VERSION@.tar.gz # @configure_input@ %define ver @PACKAGE_VERSION@ %define rel 1 %define prefix /usr %define home_page http://www.swig.org %define docprefix %{prefix}/share ###################################################################### # Usually, nothing needs to be changed below here between releases ###################################################################### Summary: Simplified Wrapper and Interface Generator Name: swig Version: %{ver} Release: %{rel} URL: %{home_page} Source0: %{name}-%{version}.tar.gz License: BSD Group: Development/Tools BuildRoot: %{_tmppath}/%{name}-root %description SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is primarily used with common scripting languages such as Perl, Python, Tcl/Tk, and Ruby, however the list of supported languages also includes non-scripting languages such as Java, OCAML and C#. Also several interpreted and compiled Scheme implementations (Guile, MzScheme, Chicken) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG can also export its parse tree in the form of XML and Lisp s-expressions. %prep %setup -q -n %{name}-%{version} %build # so we can build package from Git source too [ ! -r configure ] && ./autogen.sh %configure make %install rm -rf ${RPM_BUILD_ROOT} make DESTDIR=$RPM_BUILD_ROOT install %clean rm -rf ${RPM_BUILD_ROOT} %files %defattr(-,root,root) %doc ANNOUNCE CHANGES INSTALL LICENSE LICENSE-GPL LICENSE-UNIVERSITIES README RELEASENOTES %doc Doc/* %{_bindir}/* %{prefix}/share/* %changelog * Thu Sep 16 2004 Marcelo Matus - Small fixes needed after removing the runtime package * Tue Jul 20 2004 William Fulton - Update for SWIG-1.3.22 - Removed runtime package * Wed Mar 03 2004 Robert H De Vries - Update to work with Fedora Core 1 rpm 4.2.1 * Wed Jul 24 2002 Sam Liddicott - Added runtime package of runtime libs * Mon Sep 10 2001 Tony Seward - Merge Red Hat's and Dustin Mitchell's .spec files. - Install all of the examples in the documentation directory. - Auto create the list of installed files. swig-3.0.8/Examples/0000775000175000017500000000000012641054563014137 5ustar williamwilliamswig-3.0.8/Examples/perl5/0000775000175000017500000000000012641054563015166 5ustar williamwilliamswig-3.0.8/Examples/perl5/constants2/0000775000175000017500000000000012641054563017264 5ustar williamwilliamswig-3.0.8/Examples/perl5/constants2/runme.pl0000664000175000017500000000114412641054563020747 0ustar williamwilliam# file: runme.pl use example; print "ICONST = ", example::ICONST, " (should be 42)\n"; print "FCONST = ", example::FCONST, " (should be 2.1828)\n"; print "CCONST = ", example::CCONST, " (should be 'x')\n"; print "CCONST2 = ", example::CCONST2," (this should be on a new line)\n"; print "SCONST = ", example::SCONST, " (should be 'Hello World')\n"; print "SCONST2 = ", example::SCONST2, " (should be '\"Hello World\"')\n"; print "EXPR = ", example::EXPR, " (should be 48.5484)\n"; print "iconst = ", example::iconst, " (should be 37)\n"; print "fconst = ", example::fconst, " (should be 3.14)\n"; swig-3.0.8/Examples/perl5/constants2/example.i0000664000175000017500000000113512641054563021071 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.8/Examples/perl5/constants2/Makefile0000664000175000017500000000132312641054563020723 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -const check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/constants/0000775000175000017500000000000012641054563017202 5ustar williamwilliamswig-3.0.8/Examples/perl5/constants/runme.pl0000664000175000017500000000164612641054563020674 0ustar williamwilliam# file: runme.pl use example; print "ICONST = ", $example::ICONST, " (should be 42)\n"; print "FCONST = ", $example::FCONST, " (should be 2.1828)\n"; print "CCONST = ", $example::CCONST, " (should be 'x')\n"; print "CCONST2 = ", $example::CCONST2," (this should be on a new line)\n"; print "SCONST = ", $example::SCONST, " (should be 'Hello World')\n"; print "SCONST2 = ", $example::SCONST2, " (should be '\"Hello World\"')\n"; print "EXPR = ", $example::EXPR, " (should be 48.5484)\n"; print "iconst = ", $example::iconst, " (should be 37)\n"; print "fconst = ", $example::fconst, " (should be 3.14)\n"; if ($example::EXTERN) { print "EXTERN = ", example.EXTERN, " (Arg! This shouldn't print anything)\n"; } else { print "EXTERN isn't defined (good)\n"; } if ($example::FOO) { print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)\n"; } else { print "FOO isn't defined (good)\n"; } swig-3.0.8/Examples/perl5/constants/example.i0000664000175000017500000000113512641054563021007 0ustar williamwilliam/* File : example.i */ %module example /* A few preprocessor macros */ #define ICONST 42 #define FCONST 2.1828 #define CCONST 'x' #define CCONST2 '\n' #define SCONST "Hello World" #define SCONST2 "\"Hello World\"" /* This should work just fine */ #define EXPR ICONST + 3*(FCONST) /* This shouldn't do anything */ #define EXTERN extern /* Neither should this (BAR isn't defined) */ #define FOO (ICONST + BAR) /* The following directives also produce constants */ %constant int iconst = 37; %constant double fconst = 3.14; swig-3.0.8/Examples/perl5/constants/Makefile0000664000175000017500000000131412641054563020641 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/constants/index.html0000664000175000017500000000310612641054563021177 0ustar williamwilliam SWIG:Examples:perl5:constants SWIG/Examples/perl5/constants/

Wrapping C Constants

When SWIG encounters C preprocessor macros and C declarations that look like constants, it creates Perl5 variables with an identical value. Click here to see a SWIG interface with some constant declarations in it.

Accessing Constants from Perl

Click here to see a script that prints out the values of the constants contained in the above file.

Key points

  • The values of preprocessor macros are converted into Perl constants.
  • Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
  • Character constants such as 'x' are converted into Perl strings.
  • C string literals such as "Hello World" are converted into Perl strings.
  • Macros that are not fully defined are simply ignored. For example:
    #define EXTERN extern
    
    is ignored because SWIG has no idea what type of variable this would be.

  • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
  • Certain C declarations involving 'const' are also turned into Perl constants.

  • The constants that appear in a SWIG interface file do not have to appear in any sort of matching C source file since the creation of a constant does not require linkage to a stored value (i.e., a value held in a C global variable or memory location).

swig-3.0.8/Examples/perl5/xmlstring/0000775000175000017500000000000012641054563017215 5ustar williamwilliamswig-3.0.8/Examples/perl5/xmlstring/example.h0000664000175000017500000000071112641054563021020 0ustar williamwilliam#include class XMLChTest { XMLCh *_val; public: XMLChTest() : _val(0) { } void set(const XMLCh *v) { size_t len = XERCES_CPP_NAMESPACE::XMLString::stringLen(v); delete[] _val; _val = new XMLCh[len + 1]; for (int i = 0; i < len; ++i) { _val[i] = v[i]; } _val[len] = 0; } const XMLCh *get() { return _val; } XMLCh get_first() { return _val[0]; } }; swig-3.0.8/Examples/perl5/xmlstring/runme.pl0000664000175000017500000000016712641054563020704 0ustar williamwilliamuse example; $e1 = new example::XMLChTest(); $e1->set("hello"); print $e1->get(),"\n"; print $e1->get_first(),"\n"; swig-3.0.8/Examples/perl5/xmlstring/example.i0000664000175000017500000000013112641054563021015 0ustar williamwilliam%module example %include %{ #include "example.h" %} %include example.h swig-3.0.8/Examples/perl5/xmlstring/xmlstring.i0000664000175000017500000000665012641054563021425 0ustar williamwilliam%include %fragment("","header") %{ #include #include #include %} %fragment("SWIG_UTF8Transcoder","header",fragment="") { SWIGINTERN XERCES_CPP_NAMESPACE::XMLTranscoder* SWIG_UTF8Transcoder() { using namespace XERCES_CPP_NAMESPACE; static int init = 0; static XMLTranscoder* UTF8_TRANSCODER = NULL; static XMLCh* UTF8_ENCODING = NULL; if (!init) { XMLTransService::Codes failReason; XMLPlatformUtils::Initialize(); // first we must create the transservice UTF8_ENCODING = XMLString::transcode("UTF-8"); UTF8_TRANSCODER = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(UTF8_ENCODING, failReason, 1024); init = 1; } return UTF8_TRANSCODER; } } %fragment("SWIG_AsXMLChPtrAndSize","header",fragment="SWIG_AsCharPtrAndSize",fragment="SWIG_UTF8Transcoder") { SWIGINTERN int SWIG_AsXMLChPtrAndSize(SV *obj, XMLCh **val, size_t* psize, int *alloc) { if (!val) { return SWIG_AsCharPtrAndSize(obj, 0, 0, 0); } else { size_t size; char *cptr = 0; int calloc = SWIG_OLDOBJ; int res = SWIG_AsCharPtrAndSize(obj, &cptr, &size, &calloc); if (SWIG_IsOK(res)) { STRLEN length = size - 1; if (SvUTF8(obj)) { unsigned int charsEaten = 0; unsigned char* sizes = %new_array(size, unsigned char); *val = %new_array(size, XMLCh); unsigned int chars_stored = SWIG_UTF8Transcoder()->transcodeFrom((const XMLByte*) cptr, (unsigned int) length, (XMLCh*) *val, (unsigned int) length, charsEaten, (unsigned char*)sizes ); %delete_array(sizes); // indicate the end of the string (*val)[chars_stored] = '\0'; } else { *val = XERCES_CPP_NAMESPACE::XMLString::transcode(cptr); } if (psize) *psize = size; if (alloc) *alloc = SWIG_NEWOBJ; if (calloc == SWIG_NEWOBJ) %delete_array(cptr); return SWIG_NEWOBJ; } else { return res; } } } } %fragment("SWIG_FromXMLChPtrAndSize","header",fragment="SWIG_UTF8Transcoder") { SWIGINTERNINLINE SV * SWIG_FromXMLChPtrAndSize(const XMLCh* input, size_t size) { SV *output = sv_newmortal(); unsigned int charsEaten = 0; int length = size; // string length XMLByte* res = %new_array(length * UTF8_MAXLEN, XMLByte); // output string unsigned int total_chars = SWIG_UTF8Transcoder()->transcodeTo((const XMLCh*) input, (unsigned int) length, (XMLByte*) res, (unsigned int) length*UTF8_MAXLEN, charsEaten, XERCES_CPP_NAMESPACE::XMLTranscoder::UnRep_Throw ); res[total_chars] = '\0'; sv_setpv((SV*)output, (char *)res ); SvUTF8_on((SV*)output); %delete_array(res); return output; } } %fragment("SWIG_XMLStringNLen","header") { size_t SWIG_XMLStringNLen(const XMLCh* s, size_t maxlen) { const XMLCh *p; for (p = s; maxlen-- && *p; p++) ; return p - s; } } %init { if (!SWIG_UTF8Transcoder()) { croak("ERROR: XML::Xerces: INIT: Could not create UTF-8 transcoder"); } } %include %typemaps_string(%checkcode(UNISTRING), %checkcode(UNICHAR), XMLCh, XMLCh, SWIG_AsXMLChPtrAndSize, SWIG_FromXMLChPtrAndSize, XERCES_CPP_NAMESPACE::XMLString::stringLen, SWIG_XMLStringNLen, "", INT_MIN, INT_MAX); swig-3.0.8/Examples/perl5/xmlstring/example.cxx0000664000175000017500000000002512641054563021371 0ustar williamwilliam#include "example.h" swig-3.0.8/Examples/perl5/xmlstring/Makefile0000664000175000017500000000137412641054563020662 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lxerces-c -lxerces-depdom -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS=$(LIBS) CXX="g++ -g3" perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/variables/0000775000175000017500000000000012641054563017136 5ustar williamwilliamswig-3.0.8/Examples/perl5/variables/example.h0000664000175000017500000000007512641054563020744 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-3.0.8/Examples/perl5/variables/runme.pl0000664000175000017500000000373412641054563020630 0ustar williamwilliam# file: runme.pl use example; # Try to set the values of some global variables $example::ivar = 42; $example::svar = -31000; $example::lvar = 65537; $example::uivar = 123456; $example::usvar = 61000; $example::ulvar = 654321; $example::scvar = -13; $example::ucvar = 251; $example::cvar = "S"; $example::fvar = 3.14159; $example::dvar = 2.1828; $example::strvar = "Hello World"; $example::iptrvar= example::new_int(37); $example::ptptr = example::new_Point(37,42); $example::name = "Bill"; # Now print out the values of the variables print "Variables (values printed from Perl)\n"; print "ivar = $example::ivar\n"; print "svar = $example::svar\n"; print "lvar = $example::lvar\n"; print "uivar = $example::uivar\n"; print "usvar = $example::usvar\n"; print "ulvar = $example::ulvar\n"; print "scvar = $example::scvar\n"; print "ucvar = $example::ucvar\n"; print "fvar = $example::fvar\n"; print "dvar = $example::dvar\n"; print "cvar = $example::cvar\n"; print "strvar = $example::strvar\n"; print "cstrvar = $example::cstrvar\n"; print "iptrvar = $example::iptrvar\n"; print "name = $example::name\n"; print "ptptr = $example::ptptr", example::Point_print($example::ptptr), "\n"; print "pt = $example::pt", example::Point_print($example::pt), "\n"; print "\nVariables (values printed from C)\n"; example::print_vars(); print "\nI'm going to try and update a structure variable.\n"; $example::pt = $example::ptptr; print "The new value is "; example::pt_print(); print "You should see the value", example::Point_print($example::ptptr), "\n"; print "\nNow I'm going to try and modify some read only variables\n"; print " Trying to set 'status'\n"; eval { $example::status = 0; }; if (!$@) { die("status"); } print " get error for 'status'\n"; print " Tring to set 'path'\n"; eval { $example::path = "Whoa!";}; if (!$@) { die("path"); } print " get error for 'path'\n"; swig-3.0.8/Examples/perl5/variables/example.i0000664000175000017500000000203012641054563020736 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} #pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK /* Some global variable declarations */ %inline %{ extern int ivar; extern short svar; extern long lvar; extern unsigned int uivar; extern unsigned short usvar; extern unsigned long ulvar; extern signed char scvar; extern unsigned char ucvar; extern char cvar; extern float fvar; extern double dvar; extern char *strvar; extern const char cstrvar[]; extern int *iptrvar; extern char name[256]; extern Point *ptptr; extern Point pt; %} /* Some read-only variables */ %immutable; %inline %{ extern int status; extern char path[256]; %} %mutable; /* Some helper functions to make it easier to test */ %inline %{ extern void print_vars(); extern int *new_int(int value); extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} swig-3.0.8/Examples/perl5/variables/example.c0000664000175000017500000000456012641054563020742 0ustar williamwilliam/* File : example.c */ /* I'm a file containing some C global variables */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include #include #include "example.h" int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; unsigned short usvar = 0; unsigned long ulvar = 0; signed char scvar = 0; unsigned char ucvar = 0; char cvar = 0; float fvar = 0; double dvar = 0; char *strvar = 0; const char cstrvar[] = "Goodbye"; int *iptrvar = 0; char name[256] = "Dave"; char path[256] = "/home/beazley"; /* Global variables involving a structure */ Point *ptptr = 0; Point pt = { 10, 20 }; /* A variable that we will make read-only in the interface */ int status = 1; /* A debugging function to print out their values */ void print_vars() { printf("ivar = %d\n", ivar); printf("svar = %d\n", svar); printf("lvar = %ld\n", lvar); printf("uivar = %u\n", uivar); printf("usvar = %u\n", usvar); printf("ulvar = %lu\n", ulvar); printf("scvar = %d\n", scvar); printf("ucvar = %u\n", ucvar); printf("fvar = %g\n", fvar); printf("dvar = %g\n", dvar); printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } /* A function to create an integer (to test iptrvar) */ int *new_int(int value) { int *ip = (int *) malloc(sizeof(int)); *ip = value; return ip; } /* A function to create a point */ Point *new_Point(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); p->x = x; p->y = y; return p; } char * Point_print(Point *p) { static char buffer[256]; if (p) { sprintf(buffer,"(%d,%d)", p->x,p->y); } else { sprintf(buffer,"null"); } return buffer; } void pt_print() { printf("(%d, %d)\n", pt.x, pt.y); } swig-3.0.8/Examples/perl5/variables/Makefile0000664000175000017500000000132612641054563020600 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/variables/index.html0000664000175000017500000000434112641054563021135 0ustar williamwilliam SWIG:Examples:perl5:variables SWIG/Examples/perl5/variables/

Wrapping C Global Variables

When a C global variable appears in an interface file, SWIG tries to wrap it using a technique known as "variable linking." The idea is pretty simple---we try to create a Perl variable that magically retrieves or updates the value of the underlying C variable when it is accessed. Click here to see a SWIG interface with some variable declarations in it.

Manipulating Variables from Perl

Accessing a C global variable from Perl is easy---just reference it like a normal Perl variable. Click here to see a script that updates and prints some global variables.

Creating read-only variables

The %immutable and %mutable directives can be used to specify a collection of read-only variables. For example:
%immutable;
int    status;
double blah;
...
%mutable;
The %immutable directive remains in effect until it is explicitly disabled using the %mutable directive.

Notes:

  • When a global variable has the type "char *", SWIG manages it as a character string. However, whenever the value of such a variable is set from Perl, the old value is destroyed using free() or delete (the choice of which depends on whether or not SWIG was run with the -c++ option).
  • signed char and unsigned char are handled as small 8-bit integers.
  • String array variables such as 'char name[256]' are managed as Perl strings, but when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
  • When structures and classes are used as global variables, they are mapped into pointers. Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global.
  • Variables are linked using Perl's magic mechanism. Take a look at the Advanced Perl Programming book to find out more about this feature.

swig-3.0.8/Examples/perl5/check.list0000664000175000017500000000024212641054563017136 0ustar williamwilliam# see top-level Makefile.in callback class constants constants2 extend funcptr import java multimap multiple_inheritance pointer reference simple value variables swig-3.0.8/Examples/perl5/import/0000775000175000017500000000000012641054563016500 5ustar williamwilliamswig-3.0.8/Examples/perl5/import/bar.dsp0000664000175000017500000001150212641054563017753 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=bar - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "bar.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "bar - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"bar.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "bar - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"bar.dll" !ENDIF # Begin Target # Name "bar - Win32 Debug" # Name "bar - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\bar_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\bar.h # End Source File # End Group # Begin Source File SOURCE=.\bar.i !IF "$(CFG)" == "bar - Win32 Debug" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "bar - Win32 Release" # Begin Custom Build InputPath=.\bar.i InputName=bar "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.8/Examples/perl5/import/base.h0000664000175000017500000000044712641054563017570 0ustar williamwilliam#include class Base { public: Base() { } virtual ~Base() { } virtual void A() { printf("I'm Base::A\n"); } void B() { printf("I'm Base::B\n"); } virtual Base *toBase() { return static_cast(this); } }; swig-3.0.8/Examples/perl5/import/foo.h0000664000175000017500000000050512641054563017434 0ustar williamwilliam#include "base.h" class Foo : public Base { public: Foo() { } ~Foo() { } virtual void A() { printf("I'm Foo::A\n"); } void B() { printf("I'm Foo::B\n"); } virtual Base *toBase() { return static_cast(this); } static Foo *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.8/Examples/perl5/import/bar.i0000664000175000017500000000010612641054563017413 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-3.0.8/Examples/perl5/import/spam.h0000664000175000017500000000061412641054563017612 0ustar williamwilliam#include "bar.h" class Spam : public Bar { public: Spam() { } ~Spam() { } virtual void A() { printf("I'm Spam::A\n"); } void B() { printf("I'm Spam::B\n"); } virtual Base *toBase() { return static_cast(this); } virtual Bar *toBar() { return static_cast(this); } static Spam *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.8/Examples/perl5/import/example.dsw0000664000175000017500000000206412641054563020654 0ustar williamwilliamMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "bar"=.\bar.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "base"=.\base.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "foo"=.\foo.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "spam"=.\spam.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### swig-3.0.8/Examples/perl5/import/foo.dsp0000664000175000017500000001150212641054563017772 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=foo - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "foo.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "foo - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"foo.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "foo - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"foo.dll" !ENDIF # Begin Target # Name "foo - Win32 Debug" # Name "foo - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\foo_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\foo.h # End Source File # End Group # Begin Source File SOURCE=.\foo.i !IF "$(CFG)" == "foo - Win32 Debug" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "foo - Win32 Release" # Begin Custom Build InputPath=.\foo.i InputName=foo "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.8/Examples/perl5/import/spam.dsp0000664000175000017500000001153412641054563020154 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=spam - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "spam.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "spam - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"spam.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "spam - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"spam.dll" !ENDIF # Begin Target # Name "spam - Win32 Debug" # Name "spam - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\spam_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\spam.h # End Source File # End Group # Begin Source File SOURCE=.\spam.i !IF "$(CFG)" == "spam - Win32 Debug" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "spam - Win32 Release" # Begin Custom Build InputPath=.\spam.i InputName=spam "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.8/Examples/perl5/import/runme.pl0000664000175000017500000000357112641054563020171 0ustar williamwilliam# file: runme.pl # Test various properties of classes defined in separate modules print "Testing the %import directive\n"; use baseclass; use foo; use bar; use spam; # Create some objects print "Creating some objects\n"; $a = new baseclass::Base(); $b = new foo::Foo(); $c = new bar::Bar(); $d = new spam::Spam(); # Try calling some methods print "Testing some methods\n"; print "Should see 'Base::A' ---> "; $a->A(); print "Should see 'Base::B' ---> "; $a->B(); print "Should see 'Foo::A' ---> "; $b->A(); print "Should see 'Foo::B' ---> "; $b->B(); print "Should see 'Bar::A' ---> "; $c->A(); print "Should see 'Bar::B' ---> "; $c->B(); print "Should see 'Spam::A' ---> "; $d->A(); print "Should see 'Spam::B' ---> "; $d->B(); # Try some casts print "\nTesting some casts\n"; $x = $a->toBase(); print "Should see 'Base::A' ---> "; $x->A(); print "Should see 'Base::B' ---> "; $x->B(); $x = $b->toBase(); print "Should see 'Foo::A' ---> "; $x->A(); print "Should see 'Base::B' ---> "; $x->B(); $x = $c->toBase(); print "Should see 'Bar::A' ---> "; $x->A(); print "Should see 'Base::B' ---> "; $x->B(); $x = $d->toBase(); print "Should see 'Spam::A' ---> "; $x->A(); print "Should see 'Base::B' ---> "; $x->B(); $x = $d->toBar(); print "Should see 'Bar::B' ---> "; $x->B(); print "\nTesting some dynamic casts\n"; $x = $d->toBase(); print " Spam -> Base -> Foo : "; $y = foo::Foo::fromBase($x); if ($y) { print "bad swig\n"; } else { print "good swig\n"; } print " Spam -> Base -> Bar : "; $y = bar::Bar::fromBase($x); if ($y) { print "good swig\n"; } else { print "bad swig\n"; } print " Spam -> Base -> Spam : "; $y = spam::Spam::fromBase($x); if ($y) { print "good swig\n"; } else { print "bad swig\n"; } print " Foo -> Spam : "; #print $b; $y = spam::Spam::fromBase($b); print $y; if ($y) { print "bad swig\n"; } else { print "good swig\n"; } swig-3.0.8/Examples/perl5/import/Makefile0000664000175000017500000000176612641054563020152 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/import/bar.h0000664000175000017500000000050612641054563017416 0ustar williamwilliam#include "base.h" class Bar : public Base { public: Bar() { } ~Bar() { } virtual void A() { printf("I'm Bar::A\n"); } void B() { printf("I'm Bar::B\n"); } virtual Base *toBase() { return static_cast(this); } static Bar *fromBase(Base *b) { return dynamic_cast(b); } }; swig-3.0.8/Examples/perl5/import/base.dsp0000664000175000017500000001154612641054563020131 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=base - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "base.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "base - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"baseclass.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "base - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"baseclass.dll" !ENDIF # Begin Target # Name "base - Win32 Debug" # Name "base - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\base_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\base.h # End Source File # End Group # Begin Source File SOURCE=.\base.i !IF "$(CFG)" == "base - Win32 Debug" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "base - Win32 Release" # Begin Custom Build InputPath=.\base.i InputName=base "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.8/Examples/perl5/import/README0000664000175000017500000000241712641054563017364 0ustar williamwilliamThis example tests the %import directive and working with multiple modules. Use 'perl runme.pl' to run a test. Overview: --------- The example defines 4 different extension modules--each wrapping a separate C++ class. base.i - Base class foo.i - Foo class derived from Base bar.i - Bar class derived from Base spam.i - Spam class derived from Bar Each module uses %import to refer to another module. For example, the 'foo.i' module uses '%import base.i' to get definitions for its base class. If everything is okay, all of the modules will load properly and type checking will work correctly. Caveat: Some compilers, for example gcc-3.2.x, generate broken vtables with the inline methods in this test. This is not a SWIG problem and can usually be solved with non-inlined destructors compiled into separate shared objects/DLLs. Unix: ----- - Run make - Run the test as described above Windows: -------- - Use the Visual C++ 6 workspace file (example.dsw). Build the runtime project DLL first followed by the other 4 DLLs as they all have a dependency on the runtime DLL. The Batch build option in the Build menu is usually the easiest way to do this. Only use the Release builds not the Debug builds. - Run the test as described above swig-3.0.8/Examples/perl5/import/foo.i0000664000175000017500000000010512641054563017431 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-3.0.8/Examples/perl5/import/spam.i0000664000175000017500000000011012641054563017602 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-3.0.8/Examples/perl5/import/base.i0000664000175000017500000000007312641054563017564 0ustar williamwilliam%module baseclass %{ #include "base.h" %} %include base.h swig-3.0.8/Examples/perl5/callback/0000775000175000017500000000000012641054563016722 5ustar williamwilliamswig-3.0.8/Examples/perl5/callback/example.h0000664000175000017500000000102012641054563020517 0ustar williamwilliam/* File : example.h */ #include #include class Callback { public: virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; class Caller { private: Callback *_callback; public: Caller(): _callback(0) {} ~Caller() { delCallback(); } void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; swig-3.0.8/Examples/perl5/callback/runme.pl0000664000175000017500000000175212641054563020412 0ustar williamwilliam# file: runme.pl # This file illustrates the cross language polymorphism using directors. use example; { package PlCallback; use base 'example::Callback'; sub run { print "PlCallback->run()\n"; } } # Create an Caller instance $caller = example::Caller->new(); # Add a simple C++ callback (caller owns the callback, so # we disown it first by clearing the .thisown flag). print "Adding and calling a normal C++ callback\n"; print "----------------------------------------\n"; $callback = example::Callback->new(); $callback->DISOWN(); $caller->setCallback($callback); $caller->call(); $caller->delCallback(); print "\n"; print "Adding and calling a Perl callback\n"; print "----------------------------------\n"; # Add a Perl callback (caller owns the callback, so we # disown it first by calling DISOWN). $callback = PlCallback->new(); $callback->DISOWN(); $caller->setCallback($callback); $caller->call(); $caller->delCallback(); # All done. print "\n"; print "perl exit\n"; swig-3.0.8/Examples/perl5/callback/example.i0000664000175000017500000000054212641054563020530 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} /* turn on director wrapping Callback */ %feature("director") Callback; /* Caller::setCallback(Callback *cb) gives ownership of the cb to the * Caller object. The wrapper code should understand this. */ %apply SWIGTYPE *DISOWN { Callback *cb }; %include "example.h" swig-3.0.8/Examples/perl5/callback/example.cxx0000664000175000017500000000006012641054563021075 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.8/Examples/perl5/callback/Makefile0000664000175000017500000000130612641054563020362 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/callback/index.html0000664000175000017500000000044012641054563020715 0ustar williamwilliam SWIG:Examples:perl5:callback SWIG/Examples/perl/callback/

Implementing C++ callbacks in Perl

This example illustrates how to use directors to implement C++ callbacks.


swig-3.0.8/Examples/perl5/extend/0000775000175000017500000000000012641054563016455 5ustar williamwilliamswig-3.0.8/Examples/perl5/extend/example.h0000664000175000017500000000260512641054563020264 0ustar williamwilliam/* File : example.h */ #include #include #include #include #include class Employee { private: std::string name; public: Employee(const char* n): name(n) {} virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getName() { return name; } virtual std::string getPosition() const { return "Employee"; } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } }; class Manager: public Employee { public: Manager(const char* n): Employee(n) {} virtual std::string getPosition() const { return "Manager"; } }; class EmployeeList { std::vector list; public: EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; std::vector::iterator i; for (i=list.begin(); i!=list.end(); i++) { std::cout << " " << (*i)->getTitle() << std::endl; } } const Employee *get_item(int i) { return list[i]; } ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { delete *i; } std::cout << "~EmployeeList empty." << std::endl; } }; swig-3.0.8/Examples/perl5/extend/runme.pl0000664000175000017500000000604412641054563020144 0ustar williamwilliam# file: runme.pl # This file illustrates the cross language polymorphism using directors. use example; # CEO class, which overrides Employee::getPosition(). { package CEO; use base 'example::Manager'; sub getPosition { return "CEO"; } } # Create an instance of our employee extension class, CEO. The calls to # getName() and getPosition() are standard, the call to getTitle() uses # the director wrappers to call CEO->getPosition. $e = CEO->new("Alice") $e = CEO->new("Alice"); print $e->getName(), " is a ", $e->getPosition(), "\n"; printf "Just call her \"%s\"\n", $e->getTitle(); print "----------------------\n"; # Create a new EmployeeList instance. This class does not have a C++ # director wrapper, but can be used freely with other classes that do. $list = example::EmployeeList->new(); # EmployeeList owns its items, so we must surrender ownership of objects # we add. This involves calling the DISOWN method to tell the # C++ director to start reference counting. $e->DISOWN(); $list->addEmployee($e); print "----------------------\n"; # Now we access the first four items in list (three are C++ objects that # EmployeeList's constructor adds, the last is our CEO). The virtual # methods of all these instances are treated the same. For items 0, 1, and # 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls # getPosition which resolves in Perl. The call to getPosition is # slightly different, however, from the $e->getPosition() call above, since # now the object reference has been "laundered" by passing through # EmployeeList as an Employee*. Previously, Perl resolved the call # immediately in CEO, but now Perl thinks the object is an instance of # class Employee (actually EmployeePtr). So the call passes through the # Employee proxy class and on to the C wrappers and C++ director, # eventually ending up back at the CEO implementation of getPosition(). # The call to getTitle() for item 3 runs the C++ Employee::getTitle() # method, which in turn calls getPosition(). This virtual method call # passes down through the C++ director class to the Perl implementation # in CEO. All this routing takes place transparently. print "(position, title) for items 0-3:\n"; printf " %s, \"%s\"\n", $list->get_item(0)->getPosition(), $list->get_item(0)->getTitle(); printf " %s, \"%s\"\n", $list->get_item(1)->getPosition(), $list->get_item(1)->getTitle(); printf " %s, \"%s\"\n", $list->get_item(2)->getPosition(), $list->get_item(2)->getTitle(); printf " %s, \"%s\"\n", $list->get_item(3)->getPosition(), $list->get_item(3)->getTitle(); print "----------------------\n"; # Time to delete the EmployeeList, which will delete all the Employee* # items it contains. The last item is our CEO, which gets destroyed as its # reference count goes to zero. The Perl destructor runs, and is still # able to call self.getName() since the underlying C++ object still # exists. After this destructor runs the remaining C++ destructors run as # usual to destroy the object. undef $list; print "----------------------\n"; # All done. print "perl exit\n"; swig-3.0.8/Examples/perl5/extend/example.i0000664000175000017500000000070612641054563020265 0ustar williamwilliam/* File : example.i */ %module(directors="1") example %{ #include "example.h" %} %include "std_vector.i" %include "std_string.i" /* turn on director wrapping for Manager */ %feature("director") Employee; %feature("director") Manager; /* EmployeeList::addEmployee(Employee *p) gives ownership of the * employee to the EmployeeList object. The wrapper code should * understand this. */ %apply SWIGTYPE *DISOWN { Employee *p }; %include "example.h" swig-3.0.8/Examples/perl5/extend/example.cxx0000664000175000017500000000006012641054563020630 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-3.0.8/Examples/perl5/extend/Makefile0000664000175000017500000000130612641054563020115 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/extend/index.html0000664000175000017500000000044012641054563020450 0ustar williamwilliam SWIG:Examples:perl5:extend SWIG/Examples/perl5/extend/

Extending a simple C++ class

This example illustrates the extending of a C++ class with cross language polymorphism.


swig-3.0.8/Examples/perl5/class/0000775000175000017500000000000012641054563016273 5ustar williamwilliamswig-3.0.8/Examples/perl5/class/example.h0000664000175000017500000000134312641054563020100 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; } double x, y; void move(double dx, double dy); virtual double area() = 0; virtual double perimeter() = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { } virtual double area(); virtual double perimeter(); }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { } virtual double area(); virtual double perimeter(); }; typedef Square TSquare; class CFoo { public: static Square MakeSquare(void) {return Square(4.0);} static TSquare MakeTSquare(void) {return Square(4.0);} }; swig-3.0.8/Examples/perl5/class/runme.pl0000664000175000017500000000264412641054563017764 0ustar williamwilliam# file: runme.pl # This file illustrates the low-level C++ interface # created by SWIG. In this case, all of our C++ classes # get converted into function calls. use example; # ----- Object creation ----- print "Creating some objects:\n"; $c = new example::Circle(10); print " Created circle $c\n"; $s = new example::Square(10); print " Created square $s\n"; # ----- Access a static member ----- print "\nA total of $example::Shape::nshapes shapes were created\n"; # ----- Member data access ----- # Set the location of the object. # Note: methods in the base class Shape are used since # x and y are defined there. $c->{x} = 20; $c->{y} = 30; $s->{x} = -10; $s->{y} = 5; print "\nHere is their current position:\n"; print " Circle = (",$c->{x},",", $c->{y},")\n"; print " Square = (",$s->{x},",", $s->{y},")\n"; # ----- Call some methods ----- print "\nHere are some properties of the shapes:\n"; foreach $o ($c,$s) { print " $o\n"; print " area = ", $o->area(), "\n"; print " perimeter = ", $o->perimeter(), "\n"; } # ----- Delete everything ----- print "\nGuess I'll clean up now\n"; # Note: this invokes the virtual destructor $c->DESTROY(); $s->DESTROY(); print $example::Shape::nshapes," shapes remain\n"; $square = example::CFoo::MakeSquare(); $tsquare = example::CFoo::MakeTSquare(); print "Areas ", $square->area(), " ", $tsquare->area(),"\n"; print "Goodbye\n"; swig-3.0.8/Examples/perl5/class/example.i0000664000175000017500000000021512641054563020076 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.8/Examples/perl5/class/example.cxx0000664000175000017500000000065012641054563020453 0ustar williamwilliam/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::move(double dx, double dy) { x += dx; y += dy; } int Shape::nshapes = 0; double Circle::area() { return M_PI*radius*radius; } double Circle::perimeter() { return 2*M_PI*radius; } double Square::area() { return width*width; } double Square::perimeter() { return 4*width; } swig-3.0.8/Examples/perl5/class/Makefile0000664000175000017500000000130612641054563017733 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/class/example.dsp0000664000175000017500000001213312641054563020436 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.cxx # End Source File # Begin Source File SOURCE=.\example_wrap.cxx # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\example.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -c++ -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.8/Examples/perl5/class/index.html0000664000175000017500000000551712641054563020300 0ustar williamwilliam SWIG:Examples:perl5:class SWIG/Examples/perl5/class/

Wrapping a simple C++ class

This example illustrates the most primitive form of C++ class wrapping performed by SWIG. In this case, C++ classes are simply transformed into a collection of C-style functions that provide access to class members.

The C++ Code

Suppose you have some C++ classes described by the following (and admittedly lame) header file:
/* File : example.h */

class Shape {
public:
  Shape() {
    nshapes++;
  }
  virtual ~Shape() {
    nshapes--;
  }
  double  x, y;
  void    move(double dx, double dy);
  virtual double area() = 0;
  virtual double perimeter() = 0;
  static  int nshapes;
};

class Circle : public Shape {
private:
  double radius;
public:
  Circle(double r) : radius(r) { }
  virtual double area();
  virtual double perimeter();
};

class Square : public Shape {
private:
  double width;
public:
  Square(double w) : width(w) { }
  virtual double area();
  virtual double perimeter();
};

The SWIG interface

A simple SWIG interface for this can be built by simply grabbing the header file like this:
/* File : example.i */
%module example

%{
#include "example.h"
%}

/* Let's just grab the original header file here */
%include "example.h"
Note: when creating a C++ extension, you must run SWIG with the -c++ option like this:
% swig -c++ -perl example.i

A sample Perl script

Click here to see a script that calls the C++ functions from Perl.

Key points

  • To create a new object, you call a constructor like this:
    $c = new example::Circle(10.0);
    

  • You can access member data like so:
    $c->{x} = 15;    # Set member data
    $x = $c->{x};    # Get member data
    

  • To invoke a member function, you simply do this:
    print "The area is ", $c->area();
    

  • To invoke a destructor, simply do this:
    $c->DESTROY();   # Deletes a shape
    

  • Static member variables are wrapped like so:
    $n = $example::Shape::nshapes;    # Get a static data member
    $example::Shapes::nshapes = 13;   # Set a static data member
    

General Comments

  • SWIG does know how to properly perform upcasting of objects in an inheritance hierarchy (including multiple inheritance). Therefore it is perfectly safe to pass an object of a derived class to any function involving a base class.
  • C++ Namespaces - %nspace isn't yet supported for Perl.

swig-3.0.8/Examples/perl5/multimap/0000775000175000017500000000000012641054563017016 5ustar williamwilliamswig-3.0.8/Examples/perl5/multimap/runme.pl0000664000175000017500000000060012641054563020475 0ustar williamwilliam# file: runme.pl use example; # Call our gcd() function $x = 42; $y = 105; $g = example::gcd($x,$y); print "The gcd of $x and $y is $g\n"; # Call the gcdmain() function @a = ("gcdmain","42","105"); example::gcdmain(\@a); # Call the count function print example::count("Hello World", "l"),"\n"; # Call the capitize function print example::capitalize("hello world"),"\n"; swig-3.0.8/Examples/perl5/multimap/example.i0000664000175000017500000000400712641054563020624 0ustar williamwilliam/* File : example.i */ %module example %{ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); extern int count(char *bytes, int len, char c); extern void capitalize (char *str, int len); extern void circle (double cx, double cy); extern int squareCubed (int n, int *OUTPUT); %} %include exception.i %include typemaps.i extern int gcd(int x, int y); %typemap(arginit) (int argc, char *argv[]) "$2 = 0;"; %typemap(in) (int argc, char *argv[]) { AV *tempav; SV **tv; I32 len; int i; if (!SvROK($input)) { SWIG_exception(SWIG_ValueError,"$input is not an array."); } if (SvTYPE(SvRV($input)) != SVt_PVAV) { SWIG_exception(SWIG_ValueError,"$input is not an array."); } tempav = (AV*)SvRV($input); len = av_len(tempav); $1 = (int) len+1; $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { tv = av_fetch(tempav, i, 0); $2[i] = (char *) SvPV(*tv,PL_na); } $2[i] = 0; } %typemap(freearg) (int argc, char *argv[]) { free($2); } extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { STRLEN temp; $1 = (char *) SvPV($input, temp); $2 = (int) temp; } extern int count(char *bytes, int len, char c); /* This example shows how to wrap a function that mutates a string */ %typemap(in) (char *str, int len) { STRLEN templen; char *temp; temp = (char *) SvPV($input,templen); $2 = (int) templen; $1 = (char *) malloc($2+1); memmove($1,temp,$2); } /* Return the mutated string as a new object. */ %typemap(argout) (char *str, int len) { if (argvi >= items) { EXTEND(sp,1); } $result = sv_newmortal(); sv_setpvn((SV*)ST(argvi++),$1,$2); free($1); } extern void capitalize(char *str, int len); /* A multi-valued constraint. Force two arguments to lie inside the unit circle */ %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); } } extern void circle(double cx, double cy); swig-3.0.8/Examples/perl5/multimap/example.c0000664000175000017500000000164012641054563020616 0ustar williamwilliam/* File : example.c */ #include #include #include /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } int gcdmain(int argc, char *argv[]) { int x,y; if (argc != 3) { printf("usage: gcd x y\n"); return -1; } x = atoi(argv[1]); y = atoi(argv[2]); printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); return 0; } int count(char *bytes, int len, char c) { int i; int count = 0; for (i = 0; i < len; i++) { if (bytes[i] == c) count++; } return count; } void capitalize(char *str, int len) { int i; for (i = 0; i < len; i++) { str[i] = (char)toupper(str[i]); } } void circle(double x, double y) { double a = x*x + y*y; if (a > 1.0) { printf("Bad points %g, %g\n", x,y); } else { printf("Good points %g, %g\n", x,y); } } swig-3.0.8/Examples/perl5/multimap/Makefile0000664000175000017500000000132612641054563020460 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/multimap/example.dsp0000664000175000017500000001201312641054563021156 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.8/Examples/perl5/multiple_inheritance/0000775000175000017500000000000012641054563021372 5ustar williamwilliamswig-3.0.8/Examples/perl5/multiple_inheritance/example.h0000664000175000017500000000061012641054563023173 0ustar williamwilliam/* File : example.h */ #include using namespace std; class Bar { public: virtual void bar () { cout << "bar" << endl; } virtual ~Bar() {} }; class Foo { public: virtual void foo () { cout << "foo" << endl; } virtual ~Foo() {} }; class Foo_Bar : public Foo, public Bar { public: virtual void fooBar () { cout << "foobar" << endl; } }; swig-3.0.8/Examples/perl5/multiple_inheritance/runme.pl0000664000175000017500000000035312641054563023056 0ustar williamwilliam# file: runme.pl # This file test multiple inheritance use example; $foo_Bar = new example::Foo_Bar(); print "must be foo: "; $foo_Bar->foo(); print "must be bar: "; $foo_Bar->bar(); print "must be foobar: "; $foo_Bar->fooBar(); swig-3.0.8/Examples/perl5/multiple_inheritance/example.i0000664000175000017500000000021512641054563023175 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-3.0.8/Examples/perl5/multiple_inheritance/Makefile0000664000175000017500000000126612641054563023037 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/funcptr/0000775000175000017500000000000012641054563016647 5ustar williamwilliamswig-3.0.8/Examples/perl5/funcptr/example.h0000664000175000017500000000026312641054563020454 0ustar williamwilliam/* file: example.h */ extern int do_op(int,int, int (*op)(int,int)); extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); swig-3.0.8/Examples/perl5/funcptr/runme.pl0000664000175000017500000000113312641054563020330 0ustar williamwilliam# file: runme.pl use example; $a = 37; $b = 42; # Now call our C function with a bunch of callbacks print "Trying some C callback functions\n"; print " a = $a\n"; print " b = $b\n"; print " ADD(a,b) = ", example::do_op($a,$b,$example::ADD),"\n"; print " SUB(a,b) = ", example::do_op($a,$b,$example::SUB),"\n"; print " MUL(a,b) = ", example::do_op($a,$b,$example::MUL),"\n"; print "Here is what the C callback function objects look like in Perl\n"; print " ADD = $example::ADD\n"; print " SUB = $example::SUB\n"; print " MUL = $example::MUL\n"; swig-3.0.8/Examples/perl5/funcptr/example.i0000664000175000017500000000056012641054563020455 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Wrap a function taking a pointer to a function */ extern int do_op(int a, int b, int (*op)(int, int)); /* Now install a bunch of "ops" as constants */ %constant int (*ADD)(int,int) = add; %constant int (*SUB)(int,int) = sub; %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); swig-3.0.8/Examples/perl5/funcptr/example.c0000664000175000017500000000037012641054563020446 0ustar williamwilliam/* File : example.c */ int do_op(int a, int b, int (*op)(int,int)) { return (*op)(a,b); } int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int (*funcvar)(int,int) = add; swig-3.0.8/Examples/perl5/funcptr/Makefile0000664000175000017500000000132612641054563020311 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/funcptr/index.html0000664000175000017500000000370112641054563020645 0ustar williamwilliam SWIG:Examples:perl5:funcptr SWIG/Examples/perl5/funcptr/

Pointers to Functions

Okay, just what in the heck does SWIG do with a declaration like this?

int do_op(int a, int b, int (*op)(int, int));
Well, it creates a wrapper as usual. Of course, that does raise some questions about the third argument (the pointer to a function).

In this case, SWIG will wrap the function pointer as it does for all other pointers. However, in order to actually call this function from a script, you will need to pass some kind of C function pointer object. In C, this is easy, you just supply a function name as an argument like this:

/* Some callback function */
int add(int a, int b) {
   return a+b;
} 
...
int r = do_op(x,y,add);
To make this work with SWIG, you will need to do a little extra work. Specifically, you need to create some function pointer objects using the %constant directive like this:
%constant(int (*)(int,int)) ADD = add;
Now, in a script, you would do this:
$r = do_op($x,$y, $ADD);

An Example

Here are some files that illustrate this with a simple example:

Notes

  • The value of a function pointer must correspond to a function written in C or C++. It is not possible to pass an arbitrary Perl function object in as a substitute for a C function pointer.

  • A perl function can be used as a C/C++ callback if you write some clever typemaps and are very careful about how you create your extension. This is an advanced topic not covered here.

swig-3.0.8/Examples/perl5/reference/0000775000175000017500000000000012641054563017124 5ustar williamwilliamswig-3.0.8/Examples/perl5/reference/example.h0000664000175000017500000000063512641054563020734 0ustar williamwilliam/* File : example.h */ class Vector { private: double x,y,z; public: Vector() : x(0), y(0), z(0) { } Vector(double x, double y, double z) : x(x), y(y), z(z) { } friend Vector operator+(const Vector &a, const Vector &b); char *print(); }; class VectorArray { private: Vector *items; int maxsize; public: VectorArray(int maxsize); ~VectorArray(); Vector &operator[](int); int size(); }; swig-3.0.8/Examples/perl5/reference/runme.pl0000664000175000017500000000353112641054563020611 0ustar williamwilliam# file: runme.pl # This file illustrates the manipulation of C++ references in Perl. # This uses the low-level interface. Proxy classes work differently. use example; # ----- Object creation ----- print "Creating some objects:\n"; $a = example::new_Vector(3,4,5); $b = example::new_Vector(10,11,12); print " Created",example::Vector_print($a),"\n"; print " Created",example::Vector_print($b),"\n"; # ----- Call an overloaded operator ----- # This calls the wrapper we placed around # # operator+(const Vector &a, const Vector &) # # It returns a new allocated object. print "Adding a+b\n"; $c = example::addv($a,$b); print " a+b =", example::Vector_print($c),"\n"; # Note: Unless we free the result, a memory leak will occur example::delete_Vector($c); # ----- Create a vector array ----- # Note: Using the high-level interface here print "Creating an array of vectors\n"; $va = example::new_VectorArray(10); print " va = $va\n"; # ----- Set some values in the array ----- # These operators copy the value of $a and $b to the vector array example::VectorArray_set($va,0,$a); example::VectorArray_set($va,1,$b); # This will work, but it will cause a memory leak! example::VectorArray_set($va,2,example::addv($a,$b)); # The non-leaky way to do it $c = example::addv($a,$b); example::VectorArray_set($va,3,$c); example::delete_Vector($c); # Get some values from the array print "Getting some array values\n"; for ($i = 0; $i < 5; $i++) { print " va($i) = ", example::Vector_print(example::VectorArray_get($va,$i)), "\n"; } # Watch under resource meter to check on this print "Making sure we don't leak memory.\n"; for ($i = 0; $i < 1000000; $i++) { $c = example::VectorArray_get($va,$i % 10); } # ----- Clean up ----- print "Cleaning up\n"; example::delete_VectorArray($va); example::delete_Vector($a); example::delete_Vector($b); swig-3.0.8/Examples/perl5/reference/example.i0000664000175000017500000000130612641054563020731 0ustar williamwilliam/* File : example.i */ /* This file has a few "typical" uses of C++ references. */ %module example %{ #include "example.h" %} class Vector { public: Vector(double x, double y, double z); ~Vector(); char *print(); }; /* This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} /* Wrapper around an array of vectors class */ class VectorArray { public: VectorArray(int maxsize); ~VectorArray(); int size(); /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-3.0.8/Examples/perl5/reference/example.cxx0000664000175000017500000000161412641054563021305 0ustar williamwilliam/* File : example.cxx */ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif #include "example.h" #include #include Vector operator+(const Vector &a, const Vector &b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } char *Vector::print() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; } VectorArray::~VectorArray() { delete [] items; } Vector &VectorArray::operator[](int index) { if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); } return items[index]; } int VectorArray::size() { return maxsize; } swig-3.0.8/Examples/perl5/reference/Makefile0000664000175000017500000000140612641054563020565 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = -noproxy check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/reference/index.html0000664000175000017500000000626312641054563021130 0ustar williamwilliam SWIG:Examples:perl5:reference SWIG/Examples/perl5/reference/

C++ Reference Handling

This example tests SWIG's handling of C++ references. Since C++ references are closely related to pointers (as both refer to a location in memory), SWIG simply collapses all references into pointers when creating wrappers.

Some examples

References are most commonly used as function parameter. For example, you might have an operator like this:
Vector operator+(const Vector &a, const Vector &b) {
   Vector result;
   result.x = a.x + b.x;
   result.y = a.y + b.y;
   result.z = a.z + b.z;
   return result;
}
or a function:
Vector addv(const Vector &a, const Vector &b) {
   Vector result;
   result.x = a.x + b.x;
   result.y = a.y + b.y;
   result.z = a.z + b.z;
   return result;
}
In these cases, SWIG transforms everything into a pointer and creates a wrapper that looks like this:
Vector wrap_addv(Vector *a, Vector *b) {
    return addv(*a,*b);
}
Occasionally, a reference is used as a return value of a function when the return result is to be used as an lvalue in an expression. The prototypical example is an operator like this:
Vector &operator[](int index);
or a method:
Vector &get(int index);
For functions returning references, a wrapper like this is created:
Vector *wrap_Object_get(Object *self, int index) {
    Vector &result = self->get(index);
    return &result;
}
The following header file contains some class definitions with some operators and use of references.

SWIG Interface

SWIG does NOT support overloaded operators so it can not directly build an interface to the classes in the above file. However, a number of workarounds can be made. For example, an overloaded operator can be stuck behind a function call such as the addv() function above. Array access can be handled with a pair of set/get functions like this:
class VectorArray {
public:
 ...
   %addmethods {
    Vector &get(int index) {
      return (*self)[index];
    }
    void set(int index, Vector &a) {
      (*self)[index] = a;
    }
   }
   ...
}
Click here to see a SWIG interface file with these additions.

Sample Perl script

Click here to see a script that manipulates some C++ references.

Notes:

  • C++ references primarily provide notational convenience for C++ source code. However, it doesn't much matter to Perl.

  • When a program returns a reference, a pointer is returned. Unlike return by value, memory is not allocated to hold the return result.

  • SWIG has particular trouble handling various combinations of references and pointers. This is side effect of an old parsing scheme and type representation that will be replaced in future versions.

swig-3.0.8/Examples/perl5/value/0000775000175000017500000000000012641054563016302 5ustar williamwilliamswig-3.0.8/Examples/perl5/value/example.h0000664000175000017500000000011012641054563020076 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-3.0.8/Examples/perl5/value/runme.pl0000664000175000017500000000133712641054563017771 0ustar williamwilliam# file: runme.pl use example; # Create a couple of a vectors $v = example::new_Vector(1,2,3); $w = example::new_Vector(10,11,12); print "I just created the following vectors\n"; example::vector_print($v); example::vector_print($w); # Now call some of our functions print "\nNow I'm going to compute the dot product\n"; $d = example::dot_product($v,$w); print "dot product = $d (should be 68)\n"; # Add the vectors together print "\nNow I'm going to add the vectors together\n"; $r = example::vector_add($v,$w); example::vector_print($r); print "The value should be (11,13,15)\n"; # Now I'd better clean up the return result r print "\nNow I'm going to clean up the return result\n"; example::free($r); print "Good\n"; swig-3.0.8/Examples/perl5/value/example.i0000664000175000017500000000125312641054563020110 0ustar williamwilliam// Tests SWIG's handling of pass-by-value for complex datatypes %module example %{ #include "example.h" %} /* Some functions that manipulate Vectors by value */ %inline %{ extern double dot_product(Vector a, Vector b); extern Vector vector_add(Vector a, Vector b); %} /* Include this because the vector_add() function will leak memory */ void free(void *); /* Some helper functions for our interface */ %inline %{ Vector *new_Vector(double x, double y, double z) { Vector *v = (Vector *) malloc(sizeof(Vector)); v->x = x; v->y = y; v->z = z; return v; } void vector_print(Vector *v) { printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z); } %} swig-3.0.8/Examples/perl5/value/example.c0000664000175000017500000000037512641054563020106 0ustar williamwilliam/* File : example.c */ #include "example.h" double dot_product(Vector a, Vector b) { return (a.x*b.x + a.y*b.y + a.z*b.z); } Vector vector_add(Vector a, Vector b) { Vector r; r.x = a.x + b.x; r.y = a.y + b.y; r.z = a.z + b.z; return r; } swig-3.0.8/Examples/perl5/value/Makefile0000664000175000017500000000132612641054563017744 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/value/index.html0000664000175000017500000000554412641054563020307 0ustar williamwilliam SWIG:Examples:perl5:value SWIG/Examples/perl5/value/

Passing and Returning Structures by Value

Occasionally, a C program will manipulate structures by value such as shown in the following code:

/* File : example.c */

typedef struct Vector {
   double x, y, z;
} Vector;

double dot_product(Vector a, Vector b) {
  return (a.x*b.x + a.y*b.y + a.z*b.z);
}

Vector vector_add(Vector a, Vector b) {
  Vector r;
  r.x = a.x + b.x;
  r.y = a.y + b.y;
  r.z = a.z + b.z;
  return r;
}
Since SWIG only knows how to manage pointers to structures (not their internal representation), the following translations are made when wrappers are created:
double wrap_dot_product(Vector *a, Vector *b) {
    return dot_product(*a,*b);
}

Vector *wrap_vector_add(Vector *a, Vector *b) {
    Vector *r = (Vector *) malloc(sizeof(Vector));
    *r = vector_add(*a,*b);
    return r;
}
The functions are then called using pointers from the scripting language interface. It should also be noted that any function that returns a structure by value results in an implicit memory allocation. This will be a memory leak unless you take steps to free the result (see below).

The SWIG interface

Click here to see a SWIG interface file that wraps these two functions. In this file, there are a few essential features:
  • A wrapper for the free() function is created so that we can clean up the return result created by vector_add() function.

  • The %inline directive is used to create a few helper functions for creating new Vector objects and to print out the value (for debugging purposes).

A Perl Script

Click here to see a script that uses these functions from Perl.

Notes

  • When the '-c++' option is used, the resulting wrapper code for the return value changes to the following:
    Vector *wrap_vector_add(Vector *a, Vector *b) {
        Vector *r = new Vector(vector_add(*a,*b));
        return r;
    }
    
    Similarly, it would be a mistake to use the free() function from C++. A safer approach would be to write a helper function like this:
    %inline %{
       void delete_Vector(Vector *v) {
           delete v;
       }
    %}
    

  • If you use proxy classes and are careful, the SWIG generated wrappers can automatically clean up the result of return-by-reference when the scripting variable goes out of scope.

  • Passing parameters by value like this really isn't the best C programming style. If possible, you might change your application to use pointers.

  • Similar translations are made when C++ references are used.

swig-3.0.8/Examples/perl5/simple/0000775000175000017500000000000012641054563016457 5ustar williamwilliamswig-3.0.8/Examples/perl5/simple/runme.pl0000664000175000017500000000057212641054563020146 0ustar williamwilliam# # Perl5 script for testing simple example use example; # Call our gcd() function $x = 42; $y = 105; $g = example::gcd($x,$y); print "The gcd of $x and $y is $g\n"; # Manipulate the Foo global variable # Output its current value print "Foo = $example::Foo\n"; # Change its value $example::Foo = 3.1415926; # See if the change took effect print "Foo = $example::Foo\n"; swig-3.0.8/Examples/perl5/simple/example.i0000664000175000017500000000015212641054563020262 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-3.0.8/Examples/perl5/simple/example.c0000664000175000017500000000036712641054563020264 0ustar williamwilliam/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } swig-3.0.8/Examples/perl5/simple/Makefile0000664000175000017500000000132612641054563020121 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/simple/example.dsp0000664000175000017500000001201312641054563020617 0ustar williamwilliam# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=example - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "example.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "example - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll" !ENDIF # Begin Target # Name "example - Win32 Debug" # Name "example - Win32 Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\example.c # End Source File # Begin Source File SOURCE=.\example_wrap.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\example.i !IF "$(CFG)" == "example - Win32 Debug" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -perl5 "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "example - Win32 Release" # Begin Custom Build InputPath=.\example.i InputName=example "$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on ..\..\..\swig.exe -perl5 "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Target # End Project swig-3.0.8/Examples/perl5/simple/index.html0000664000175000017500000000342312641054563020456 0ustar williamwilliam SWIG:Examples:perl5:simple SWIG/Examples/perl5/simple/

Simple Perl5 Example

This example illustrates how you can hook Perl to a very simple C program containing a function and a global variable.

The C Code

Suppose you have the following C code:
/* File : example.c */

/* A global variable */
double Foo = 3.0;

/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
  int g;
  g = y;
  while (x > 0) {
    g = x;
    x = y % x;
    y = g;
  }
  return g;
}

The SWIG interface

Here is a simple SWIG interface file:
/* File: example.i */
%module example

extern int gcd(int x, int y);
extern double Foo;

Compilation

  1. swig -perl5 example.i

  2. This produces two files: example_wrap.c and example.pm.

  3. Compile example_wrap.c and example.c to create the extension example.so.

Using the extension

Click here to see a script that calls our C functions from Perl.

Key points

  • Use the use statement to load your extension module from Perl. For example:
    use example;
    
  • C functions work just like Perl functions. For example:
    $g = example::gcd(42,105);
    
  • C global variables are accessed like ordinary Perl variables. For example:
    $a = $example::Foo;
    

swig-3.0.8/Examples/perl5/inline/0000775000175000017500000000000012641054563016444 5ustar williamwilliamswig-3.0.8/Examples/perl5/inline/runme.pl0000664000175000017500000000133312641054563020127 0ustar williamwilliamuse Inline SWIG => <<"END_CODE", SWIG_ARGS => '-c++ -proxy', CC => 'g++', LD=>'g++'; class Foo { public: int meaning() { return 42; }; }; END_CODE my $o = new Foo(); print $o->meaning(),"\n"; use Inline SWIG => ' ', SWIG_INTERFACE => <<"END_CODE", SWIG_ARGS => '-c++', CC => "g++", LD => "g++"; %include std_string.i %inline { template class Bar { Type _val; public: Bar(Type v) : _val(v) {} Type meaning() { return _val; } }; } %template(Bar_i) Bar; %template(Bar_d) Bar; %template(Bar_s) Bar; END_CODE my $o = new Bar_i(1); print $o->meaning(),"\n"; my $o = new Bar_d(2); print $o->meaning(),"\n"; my $o = new Bar_s("hello"); print $o->meaning(),"\n"; swig-3.0.8/Examples/perl5/inline/Makefile0000664000175000017500000000022112641054563020077 0ustar williamwilliamrun: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean rm -rf _Inline swig-3.0.8/Examples/perl5/inline/README0000664000175000017500000000006112641054563017321 0ustar williamwilliamThis example requires the Inline::SWIG package. swig-3.0.8/Examples/perl5/java/0000775000175000017500000000000012641054563016107 5ustar williamwilliamswig-3.0.8/Examples/perl5/java/Example.java0000664000175000017500000000075012641054563020347 0ustar williamwilliampublic class Example { public int mPublicInt; public Example() { mPublicInt = 0; } public Example(int IntVal) { mPublicInt = IntVal; } public int Add(int a, int b) { return (a+b); } public float Add(float a, float b) { return (a+b); } public String Add(String a, String b) { return (a+b); } public Example Add(Example a, Example b) { return new Example(a.mPublicInt + b.mPublicInt); } } swig-3.0.8/Examples/perl5/java/runme.pl0000664000175000017500000000072012641054563017571 0ustar williamwilliamuse example; example::JvCreateJavaVM(undef); example::JvAttachCurrentThread(undef, undef); $e1 = new example::Example(1); print $e1->{mPublicInt},"\n"; $e2 = new example::Example(2); print $e2->{mPublicInt},"\n"; $i = $e1->Add(1,2); print $i,"\n"; $d = $e2->Add(1.0,2.0); print $d,"\n"; $d = $e2->Add("1","2"); print $d,"\n"; $e3 = $e1->Add($e1,$e2); print $e3->{mPublicInt},"\n"; $s = $e2->Add("a","b"); print $s,"\n"; example::JvDetachCurrentThread() swig-3.0.8/Examples/perl5/java/example.i0000664000175000017500000000012312641054563017710 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h swig-3.0.8/Examples/perl5/java/Makefile0000664000175000017500000000137212641054563017552 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: Example.class Example.h $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean rm -f *.class Example.h Example.class Example.h: $(SRCDIR)Example.java gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java gcjh Example.class swig-3.0.8/Examples/perl5/pointer/0000775000175000017500000000000012641054563016646 5ustar williamwilliamswig-3.0.8/Examples/perl5/pointer/runme.pl0000664000175000017500000000172212641054563020333 0ustar williamwilliam# file: runme.pl use example; # First create some objects using the pointer library. print "Testing the pointer library\n"; $a = example::new_intp(); $b = example::new_intp(); $c = example::new_intp(); example::intp_assign($a,37); example::intp_assign($b,42); print " a = $a\n"; print " b = $b\n"; print " c = $c\n"; # Call the add() function with some pointers example::add($a,$b,$c); # Now get the result $r = example::intp_value($c); print " 37 + 42 = $r\n"; # Clean up the pointers example::delete_intp($a); example::delete_intp($b); example::delete_intp($c); # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. print "Trying the typemap library\n"; $r = example::subtract(37,42); print " 37 - 42 = $r\n"; # Now try the version with multiple return values print "Testing multiple return values\n"; ($q,$r) = example::divide(42,37); print " 42/37 = $q remainder $r\n"; swig-3.0.8/Examples/perl5/pointer/example.i0000664000175000017500000000121012641054563020445 0ustar williamwilliam/* File : example.i */ %module example %{ extern void add(int *, int *, int *); extern void subtract(int *, int *, int *); extern int divide(int, int, int *); %} /* This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); /* Next we'll use some typemaps */ %include typemaps.i extern void subtract(int *INPUT, int *INPUT, int *OUTPUT); /* Next we'll use typemaps and the %apply directive */ %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); swig-3.0.8/Examples/perl5/pointer/example.c0000664000175000017500000000036612641054563020452 0ustar williamwilliam/* File : example.c */ void add(int *x, int *y, int *result) { *result = *x + *y; } void subtract(int *x, int *y, int *result) { *result = *x - *y; } int divide(int n, int d, int *r) { int q; q = n/d; *r = n - q*d; return q; } swig-3.0.8/Examples/perl5/pointer/Makefile0000664000175000017500000000132612641054563020310 0ustar williamwilliamTOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean swig-3.0.8/Examples/perl5/pointer/index.html0000664000175000017500000000665512641054563020657 0ustar williamwilliam SWIG:Examples:perl5:pointer SWIG/Examples/perl5/pointer/

Simple Pointer Handling

This example illustrates a couple of techniques for handling simple pointers in SWIG. The prototypical example is a C function that operates on pointers such as this:

void add(int *x, int *y, int *r) { 
    *r = *x + *y;
}
By default, SWIG wraps this function exactly as specified and creates an interface that expects pointer objects for arguments. The only problem is how does one go about creating these objects from a script?

Possible Solutions

  • Write some helper functions to explicitly create objects. For example:
    int *new_int(int ivalue) {
      int *i = (int *) malloc(sizeof(ivalue));
      *i = ivalue;
      return i;
    }
    int get_int(int *i) {
      return *i;
    }
    
    void delete_int(int *i) {
      free(i);
    }
    
    Now, in a script you would do this:
    $a = new_int(37);
    $b = new_int(42);
    $c = new_int(0):
    add($a,$b,$c);
    $r = get_int($c);
    print "Result = $r\n";
    delete_int($a);
    delete_int($b);
    delete_int($c);
    

  • Use the SWIG pointer library. For example, in the interface file you would do this:
    %include "pointer.i"
    
    $a = ptrcreate("int",37);
    $b = ptrcreate("int",42);
    $c = ptrcreate("int");
    add($a,$b,$c);
    $r = ptrvalue($c);
    print "Result = $r\n";
    ptrfree($a);
    ptrfree($b);
    ptrfree($c);
    
    The advantage to using the pointer library is that it unifies some of the helper functions behind a common set of names. For example, the same set of functions work with int, double, float, and other fundamental types.

  • Use the SWIG typemap library. This library allows you to completely change the way arguments are processed by SWIG. For example:
    %include "typemaps.i"
    void add(int *INPUT, int *INPUT, int *OUTPUT);
    
    And in a script:
    $r = add(37,42);
    print "Result = $r\n";
    
    Needless to say, this is substantially easier.

  • A final alternative is to use the typemaps library in combination with the %apply directive. This allows you to change the names of parameters that behave as input or output parameters. For example:
    %include "typemaps.i"
    %apply int *INPUT {int *x, int *y};
    %apply int *OUTPUT {int *r};
    
    void add(int *x, int *y, int *r);
    void subtract(int *x, int *y, int *r);
    void mul(int *x, int *y, int *r);
    ... etc ...
    

Example

The following example illustrates the use of these features for pointer extraction.

Notes

  • Since pointers are used for so many different things (arrays, output values, etc...) the complexity of pointer handling can be as complicated as you want to make it.

  • More documentation on the typemaps.i and pointer.i library files can be found in the SWIG user manual. The files also contain documentation.

  • The pointer.i library is designed primarily for convenience. If you are concerned about performance, you probably want to use a different approach.

swig-3.0.8/Examples/perl5/index.html0000664000175000017500000000507212641054563017167 0ustar williamwilliam SWIG:Examples:perl5

SWIG Perl Examples

The following examples illustrate the use of SWIG with Perl.

  • simple. A minimal example showing how SWIG can be used to wrap a C function and a global variable.
  • constants. This shows how preprocessor macros and certain C declarations are turned into constants.
  • variables. This example shows how to access C global variables from Perl.
  • value. How to pass and return structures by value.
  • class. How to wrap a simple C++ class.
  • reference. C++ references.
  • pointer. Simple pointer handling.
  • funcptr. Pointers to functions.
  • callback. C++ callbacks using directors.
  • extend. Extending a simple C++ class.

Compilation Issues

  • To create a Perl extension, SWIG is run with the following options:
    % swig -perl5 interface.i
    
  • The compilation of examples is done using the file Example/Makefile. This makefile performs a manual module compilation which is platform specific. Typically, the steps look like this (Linux):
    % swig -perl5 interface.i
    % gcc -fpic -c -Dbool=char -I/usr/lib/perl5/5.00503/i386-linux/CORE interface_wrap.c
    % gcc -shared interface_wrap.o $(OBJS) -o interface.so 
    % perl
    use interface;
    ...
    
  • The politically "correct" way to compile a Perl extension module is to use MakeMaker and related tools (especially if you are considering third-party distribution). Consult a book such as Advanced Perl Programming for details.

Compatibility

The examples have been extensively tested on the following platforms:

  • Linux
  • Solaris
Please see the Windows page in the main manual for information on using the examples on Windows.

Due to wide variations in the Perl C API and differences between versions such as the ActivePerl release for Windows, the code generated by SWIG is extremely messy. If the code doesn't compile or work with your version of Perl, please let us know by contacting us on the mailing lists. Better yet, send us a patch. swig-3.0.8/Examples/android/0000775000175000017500000000000012641054563015557 5ustar williamwilliamswig-3.0.8/Examples/android/check.list0000664000175000017500000000006012641054563017525 0ustar williamwilliam# see top-level Makefile.in class extend simple swig-3.0.8/Examples/android/extend/0000775000175000017500000000000012641054563017046 5ustar williamwilliamswig-3.0.8/Examples/android/extend/res/0000775000175000017500000000000012641054563017637 5ustar williamwilliamswig-3.0.8/Examples/android/extend/res/layout/0000775000175000017500000000000012641054563021154 5ustar williamwilliamswig-3.0.8/Examples/android/extend/res/layout/main.xml0000664000175000017500000000132212641054563022620 0ustar williamwilliam