diff options
author | Josh Blum | 2013-07-29 22:14:19 -0700 |
---|---|---|
committer | Josh Blum | 2013-07-29 22:14:19 -0700 |
commit | cf8ca0ba62e78e70b7621b0c81bf7c031eabe3ac (patch) | |
tree | 38013fffdde0f9620bbb6f9dc7a47ba770672e70 /python/gras/GRAS_Factory.i | |
parent | 311d63e3f0432c0dda45d622b618b303c41ec541 (diff) | |
download | sandhi-cf8ca0ba62e78e70b7621b0c81bf7c031eabe3ac.tar.gz sandhi-cf8ca0ba62e78e70b7621b0c81bf7c031eabe3ac.tar.bz2 sandhi-cf8ca0ba62e78e70b7621b0c81bf7c031eabe3ac.zip |
gras: simplfy factory w/ macros and namespace
Diffstat (limited to 'python/gras/GRAS_Factory.i')
-rw-r--r-- | python/gras/GRAS_Factory.i | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/python/gras/GRAS_Factory.i b/python/gras/GRAS_Factory.i index 1124963..eca9d2e 100644 --- a/python/gras/GRAS_Factory.i +++ b/python/gras/GRAS_Factory.i @@ -30,25 +30,18 @@ namespace gras %pythoncode %{ #TODO we need to register this into the real factory _py_factory = dict() -%} -%extend gras::Factory -{ - %insert("python") - %{ - @staticmethod - def register_make(name, fcn): - #TODO we need to register this into the real factory - _py_factory[name] = fcn - - @staticmethod - 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) - %} -} +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) + +%} |