From cf3be359cf095b7cad2a1a31f5905bb2e38da1b0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Nov 2014 23:27:22 +0000 Subject: [PATCH] Add c++11 strongly typed enum support for Guile --- Lib/guile/typemaps.i | 6 +++--- Source/Modules/guile.cxx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index d818613e7..a01e73f64 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -172,11 +172,11 @@ } * (int *) &($1) = scm_to_int($input); } -%typemap(out) enum SWIGTYPE { $result = scm_from_long($1); } -%typemap(varout) enum SWIGTYPE { $result = scm_from_long($1); } +%typemap(out) enum SWIGTYPE { $result = scm_from_long((int)$1); } +%typemap(varout) enum SWIGTYPE { $result = scm_from_long((int)$1); } %typemap(throws) enum SWIGTYPE { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(scm_from_long($1), SCM_UNDEFINED)); + scm_listify(scm_from_long((int)$1), SCM_UNDEFINED)); } /* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index a9e51fd1b..ce8d19c06 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -1350,7 +1350,7 @@ public: Printv(f_header, tm, "\n", NIL); } else { // Create variable and assign it a value - Printf(f_header, "static %s = %s;\n", SwigType_str(type, var_name), rvalue); + Printf(f_header, "static %s = (%s)%s;\n", SwigType_str(type, var_name), type, rvalue); } { /* Hack alert: will cleanup later -- Dave */