Created
July 1, 2012 19:29
-
-
Save mforbes/3029324 to your computer and use it in GitHub Desktop.
SWIG example of multiple typechecks with different pecedences.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%typemap(typecheck, precedence=5000)(MyComplex) { | |
$1 = QuicklyCheckIfReallyIsMyComplex($input); | |
} | |
%typemap(typecheck, precedence=5500)(MyDouble) { | |
$1 = QuicklyCheckIfReallyIsMyDouble($input); | |
} | |
%typemap(typecheck, precedence=6000)(MyDouble) { | |
$1 = LongCheckToSeeIfCanBeConvertedToADouble($input); | |
} | |
%typemap(typecheck, precedence=6500)(MyComplex) { | |
$1 = LongCheckToSeeIfCanBeConvertedToAComplex($input); | |
} | |
%typemap(in)(MyDouble) { $1 = ProcessMyDouble($input); } | |
%typemap(in)(MyComplex) { $1 = ProcessMyComplex($input); } | |
MyDouble f(MyDouble x) { return x; } | |
MyComplex f(MyComplex x) { return x; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is compiled with:
swig -module mod -c++ -o typecheck_wrap.cpp -python typecheck_eg.i