blob: eca9d2ec46c4a8b261f119f400d5c6bc19309e54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// 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;
}
%newobject gras::Factory::_handle_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 make method for the factory
////////////////////////////////////////////////////////////////////////
%pythoncode %{
#TODO we need to register this into the real factory
_py_factory = dict()
def register_make(name, fcn):
#TODO we need to register this into the real factory
_py_factory[name] = fcn
def make(name, *args, **kwargs):
#first try the local to python py factory #TODO real factory
if name in _py_factory: return _py_factory[name](*args, **kwargs)
from PMC import PMC_M
pmcargs = PMC_M(list(args))
return Factory._handle_make(name, pmcargs)
%}
|