summaryrefslogtreecommitdiff
path: root/share/swig/2.0.11/lua/factory.i
diff options
context:
space:
mode:
Diffstat (limited to 'share/swig/2.0.11/lua/factory.i')
-rw-r--r--share/swig/2.0.11/lua/factory.i23
1 files changed, 23 insertions, 0 deletions
diff --git a/share/swig/2.0.11/lua/factory.i b/share/swig/2.0.11/lua/factory.i
new file mode 100644
index 0000000..7e605c5
--- /dev/null
+++ b/share/swig/2.0.11/lua/factory.i
@@ -0,0 +1,23 @@
+/*
+ A modification of factory.swg from the generic UTL library.
+*/
+
+%include <typemaps/swigmacros.swg>
+
+%define %_factory_dispatch(Type)
+if (!dcast) {
+ Type *dobj = dynamic_cast<Type *>($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