add native bool support
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8345 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c6baa21db4
commit
75d64a4018
3 changed files with 53 additions and 0 deletions
|
|
@ -2,6 +2,42 @@
|
|||
* Primitive Types
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* bool */
|
||||
|
||||
%fragment(SWIG_From_frag(bool),"header") {
|
||||
SWIGINTERNINLINE SV *
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
{
|
||||
SV *obj = sv_newmortal();
|
||||
if (value) {
|
||||
sv_setsv(obj, &PL_sv_yes);
|
||||
} else {
|
||||
sv_setsv(obj, &PL_sv_no);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(bool),"header",
|
||||
fragment="SWIG_CanCastAsInteger") {
|
||||
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);
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* long */
|
||||
|
||||
%fragment(SWIG_From_frag(long),"header") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue