[Csp-commits] APPLICATIONS/SimData/SimData Compile.py,1.3,1.4 Parse.py,1.13,1.14 __init__.py,1.2,1.3
From: <mk...@us...> - 2003-10-20 01:49:00
|
Update of /cvsroot/csp/APPLICATIONS/SimData/SimData In directory sc8-pr-cvs1:/tmp/cvs-serv13870/SimData Modified Files: Compile.py Parse.py __init__.py Log Message: Index: Compile.py =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/SimData/Compile.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Compile.py 17 Sep 2003 07:27:01 -0000 1.3 --- Compile.py 19 Oct 2003 23:53:56 -0000 1.4 *************** *** 143,149 **** print "%d warnings (severity=%d)." % (warnings, level) if level > 0: ! print "Please fix these warnings and recompile." ! print "Compiled data archive NOT written!" ! sys.exit(1) paths = master.getPaths() DEBUG(1,"Compiling all objects") --- 143,152 ---- print "%d warnings (severity=%d)." % (warnings, level) if level > 0: ! if level > getWarningLevel(): ! print "Run with '--warn=%d' to see all warnings." % level ! if not self.force: ! print "Please fix these warnings and recompile." ! print "Compiled data archive NOT written!" ! sys.exit(1) paths = master.getPaths() DEBUG(1,"Compiling all objects") *************** *** 187,190 **** --- 190,194 ---- print >>out, " --debug=level show debug messages (< level)" print >>out, " --rebuild rebuild entire archive" + print >>out, " --force ignore warnings" print >>out, " --help help message" *************** *** 223,226 **** --- 227,232 ---- elif arg == '--rebuild': self.rebuild = 1 + elif arg == '--force': + self.force = 1 elif arg in ("--help", "-h", "-help"): self.usage() *************** *** 240,243 **** --- 246,250 ---- setWarningLevel(1) self.rebuild = 0 + self.force = 0 self.infile = None self.outfile = None Index: Parse.py =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/SimData/Parse.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Parse.py 17 Sep 2003 07:27:01 -0000 1.13 --- Parse.py 19 Oct 2003 23:53:56 -0000 1.14 *************** *** 511,514 **** --- 511,515 ---- def __init__(self, id, base, name, attrs): SimpleHandler.__init__(self, id, base, name, attrs) + WARN(1, "<Curve> is deprecated, use Table1 instead.") for member in CurveHandler.members: setattr(self, "_"+member, None) *************** *** 560,563 **** --- 561,565 ---- def __init__(self, id, base, name, attrs): SimpleHandler.__init__(self, id, base, name, attrs) + WARN(1, "<Table> is deprecated, use Table2 instead.") self._keys = {} *************** *** 740,745 **** self._req_variables = self._interface.getRequiredNames() ! static = attrs.get("static", "0").upper() in ("1", "TRUE") ! self._object.setStatic(static) def endChild(self): --- 742,747 ---- self._req_variables = self._interface.getRequiredNames() ! if attrs.has_key("static"): ! WARN(1, "'static' attribute of <Object> is deprecated.") def endChild(self): Index: __init__.py =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/SimData/__init__.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** __init__.py 23 Apr 2003 09:14:22 -0000 1.2 --- __init__.py 19 Oct 2003 23:53:56 -0000 1.3 *************** *** 20,27 **** ## @file SimData.py ! ## @auther Mark Rose <mr...@st...> ## ## @module SimData ## ## Provides minimal glue code for interfacing between C++ and Python. ## Most of the hard work is done by SWIG. Python Objects must derive --- 20,31 ---- ## @file SimData.py ! ## @author Mark Rose <mr...@st...> ## ## @module SimData ## + ## @note The procedure for declaring and registering XML interfaces + ## is under revision, and the documentation here is likely to be + ## completely out of date. + ## ## Provides minimal glue code for interfacing between C++ and Python. ## Most of the hard work is done by SWIG. Python Objects must derive *************** *** 48,68 **** - # FIXME is there a more robust means of getting the class name as a - # string? str(class) changed from python2.1 to 2.2 for new-style - # classes... - def getClassName(_class): - rep = str(_class) - if rep.startswith('<class '): - # new-style: - fullname = rep.split()[1][:-2] # extract name from <class 'name'> - else: - # old-style: - fullname = rep - parts = fullname.split('.') - return parts[-1] - - ## The C++ InterfaceRegistry. - #g_InterfaceRegistry = cSimData.cvar.g_InterfaceRegistry g_InterfaceRegistry = cSimData.InterfaceRegistry.getInterfaceRegistry() --- 52,56 ---- *************** *** 76,80 **** ## store the class directly. ! class PyInterfaceProxy(cSimData.InterfaceProxy): def __init__(self, classname, _class, _baseinterface, interface): cSimData.InterfaceProxy.__init__(self, classname, _class._hash) --- 64,68 ---- ## store the class directly. ! class _____PyInterfaceProxy(cSimData.InterfaceProxy): def __init__(self, classname, _class, _baseinterface, interface): cSimData.InterfaceProxy.__init__(self, classname, _class._hash) *************** *** 196,200 **** ## of the archive. ! class XML: def __init__(self, name, variable, required): self.name = name --- 184,188 ---- ## of the archive. ! class _____XML: def __init__(self, name, variable, required): self.name = name *************** *** 203,207 **** ! def XML_INTERFACE(_class, major, minor, *args): _baseclass = None --- 191,195 ---- ! def _____XML_INTERFACE(_class, major, minor, *args): _baseclass = None *************** *** 210,214 **** if isinstance(args[0], types.ClassType): _baseclass, args = args[0], args[1:] ! _baseclass = getClassName(_baseclass) elif isinstance(args[0], types.StringType): _baseclass, args = args[0], args[1:] --- 198,202 ---- if isinstance(args[0], types.ClassType): _baseclass, args = args[0], args[1:] ! _baseclass = _baseclass.__name__ elif isinstance(args[0], types.StringType): _baseclass, args = args[0], args[1:] *************** *** 224,227 **** --- 212,388 ---- _class.getClassHash = lambda x: x.__class__._hash proxy = PyInterfaceProxy(classname, _class, _baseinterface, args).__disown__() + + + ############################################################################# + # NEW STYLE INTERFACE + ############################################################################# + + # class SIMDATA_XML: + # typeString = { + # int: "type::int32", + # float: "type::float", + # str: "type::string" + # } + # def __init__(self, name, type, var, req): + # self.name = name + # self.type = type + # self.var = var + # self.req = req + # if issubclass(type, BaseType): + # self.typeString = type().typeString() + # else: + # self.typeString = SIMDATA_XML.typeString[type] + # + # class ObjectInterface(cSimData.ObjectInterfaceBase): + # """@brief Interface for simdata::Object derived classes implemented in + # Python. + # + # This is an internal class that provides an interfacing for accessing + # and introspecting object member variables that can be initialized + # from external (XML) data sources. The interface is equivalent to + # the C++ ObjectInterface class, but the implementation is entirely + # Python specific. + # """ + # + # def __init__(self): + # """Default constructor.""" + # self.__accessors = {} + # + # def _def(self, d): + # """Define a new member variable accessor. + # + # This is an internal method used by the SIMDATA_XML function. Do + # not call it directly. + # """ + # self.__accessors[d.name] = d + # + # def variableExists(self, name): + # """Test if the interface defines a particular member variable. + # + # @param name The external name of the member variable to test. + # """ + # return self.__accessors.has_key(name) + # + # def variableRequired(self, name): + # """Test if a particular member variable must be defined in external + # data sources. + # + # Raises IndexError if the variable does not exist. + # + # @param name The external name of the member variable to test. + # """ + # return self.__accessors[name].req + # + # def set(self, obj, name, value): + # """Set a member variable of a given object. + # + # Assigns a new value to a particular member varible of the given + # object. The variable need not be previously defined, although + # it is strongly recommended that all externally accessible member + # variables be initialized during object construction. Future + # implementations may test for such initialization and raise + # exceptions when assigning to uninitialized members. Assigned + # values are tested for type compatibility. Type mismatches + # currently result in an assertion exception, although a more + # specific exception will be used eventually. + # + # @param obj The object to modify. + # @param name The external name of the member variable to set. + # @param value The value to assign. + # """ + # a = self.__accessors[name] + # assert(isinstance(value, a.type)) + # setattr(obj, a.var, value) + # + # def get(self, obj, name): + # """Get the value of a member variable of a given object. + # + # Returns the value of a particular member variable of the + # given object. Calling this method with unknown or uninitialized + # members will raise index and attribute exceptions, respectively. + # + # @param obj The object to access. + # @param name The external name of the member variable to get. + # @returns The value of the member variable. + # """ + # a = self.__accessors[name] + # return getattr(obj, a.var) + # + # def push_back(self, obj, name, value): + # """Append a value to a member variable list of a given object. + # """ + # a = self.__accessors[name] + # getattr(obj, a.var).append(value) + # + # def clear(self, obj, name): + # """Clear a member variable list of a given object. + # """ + # a = self.__accessors[name] + # assert(isinstance([], a.type)) + # setattr(obj, a.var, []) + # + # def getVariables(self): + # """Get a list of external names of all accessible member variables.""" + # return self.__accessors.keys() + # + # def variableType(self, name): + # """Get the type string of a particular member variable. + # + # @param name The external name of the member variable. + # """ + # a = self.__accessors[name] + # return a.typeString + # + # + # def __IF_init(self, IF): + # IF.__super.__init__(self, IF.__super) + # IF.__obi = ObjectInterface() + # map(IF.__obi._def, IF.__defs) + # self.addInterface(IF.__obi) + # print "Interface", IF.__classname, "registered." + # + # def __IF_getClassName(self): + # return self.__classname + # + # def __IF_getClassHash(self): + # return self.__classhash + # + # def __IF_createObject(self): + # return self.__class() + # + # __IF_methods = { + # '__init__': __IF_init, + # 'getClassName': __IF_getClassName, + # 'getClassHash': __IF_getClassHash, + # 'createObject': __IF_createObject, + # } + # + # + # def SIMDATA_INTERFACE(cl, v, su, defs, cln = None, abstract=0): + # if su is None: + # baselist = (InterfaceProxy,) + # suif = InterfaceProxy + # else: + # baselist = (su.IF,) + # suif = su.IF + # if cln is None: cln = cl.__name__ + # iname = "%s__INTERFACE" % cln + # methods = __IF_methods.copy() + # i = type(iname, baselist, methods) + # i.__version = v + # i.__super = suif + # i.__class = cl + # i.__classname = cln + # i.__classhash = "%s:%d" % (cln, int(v)) + # i.__defs = defs + # i.__abstract = abstract + # if not abstract: + # i.__singleton = i(i) + # else: + # i.__singleton = None + # cl.IF = i + # + + |