From dc7818db818fe049af451eb2dadd1c362edacf13 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Apr 2012 18:37:53 +0000 Subject: [PATCH] Add missing Lua factory.i for patch #3219676 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13014 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/lua/factory.i | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Lib/lua/factory.i diff --git a/Lib/lua/factory.i b/Lib/lua/factory.i new file mode 100644 index 000000000..7e605c5d5 --- /dev/null +++ b/Lib/lua/factory.i @@ -0,0 +1,23 @@ +/* + 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