summaryrefslogtreecommitdiff
path: root/python/gras/GRAS_Factory.i
diff options
context:
space:
mode:
Diffstat (limited to 'python/gras/GRAS_Factory.i')
-rw-r--r--python/gras/GRAS_Factory.i41
1 files changed, 41 insertions, 0 deletions
diff --git a/python/gras/GRAS_Factory.i b/python/gras/GRAS_Factory.i
new file mode 100644
index 0000000..e324d27
--- /dev/null
+++ b/python/gras/GRAS_Factory.i
@@ -0,0 +1,41 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+%include <gras/exception.i>
+%module (package="gras") GRAS_Factory
+
+%{
+#include <gras/factory.hpp>
+%}
+
+namespace gras
+{
+ %ignore Factory::register_make;
+ %ignore Factory::make;
+}
+
+////////////////////////////////////////////////////////////////////////
+// Export swig element comprehension
+////////////////////////////////////////////////////////////////////////
+%include <std_string.i>
+%import <PMC/PMC.i>
+%import <gras/element.i>
+%include <gras/gras.hpp>
+%include <gras/factory.hpp>
+
+////////////////////////////////////////////////////////////////////////
+// Create python methods for factories
+////////////////////////////////////////////////////////////////////////
+%pythoncode%{
+
+class StaticPyFactory(object):
+
+ def __getattr__(self, name):
+ def make(name, *args):
+ from PMC import PMC_M
+ pmcargs = PMC_M(list(args))
+ return Factory._handle_make(name, pmcargs)
+ return lambda *args: make(name, *args)
+
+PyFactory = StaticPyFactory()
+
+%}