From cf8ca0ba62e78e70b7621b0c81bf7c031eabe3ac Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 29 Jul 2013 22:14:19 -0700 Subject: gras: simplfy factory w/ macros and namespace --- python/gras/GRAS_Factory.i | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'python/gras/GRAS_Factory.i') 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) + +%} -- cgit