replacement for PR 698
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
Include="App/PropertyContainer.h"
|
||||
Namespace="App"
|
||||
FatherInclude="Base/PersistencePy.h"
|
||||
FatherNamespace="Base">
|
||||
FatherNamespace="Base"
|
||||
DisableNotify="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
|
||||
<UserDocu>This is a Persistence class</UserDocu>
|
||||
|
||||
@@ -45,7 +45,8 @@ PyObjectBase::PyObjectBase(void* p,PyTypeObject *T)
|
||||
#ifdef FC_LOGPYOBJECTS
|
||||
Base::Console().Log("PyO+: %s (%p)\n",T->tp_name, this);
|
||||
#endif
|
||||
StatusBits.set(0); // valid, the second bit is NOT set, i.e. it's mutable
|
||||
StatusBits.set(Valid); // valid, the second bit is NOT set, i.e. it's mutable
|
||||
StatusBits.set(Notify);
|
||||
}
|
||||
|
||||
/// destructor
|
||||
@@ -325,6 +326,9 @@ void PyObjectBase::setAttributeOf(const char* attr, PyObject* par)
|
||||
|
||||
void PyObjectBase::startNotify()
|
||||
{
|
||||
if (!shouldNotify())
|
||||
return;
|
||||
|
||||
if (attrDict) {
|
||||
// This is the attribute name to the parent structure
|
||||
// which we search for in the dict
|
||||
|
||||
@@ -193,6 +193,12 @@ class BaseExport PyObjectBase : public PyObject
|
||||
*/
|
||||
Py_Header
|
||||
|
||||
enum Status {
|
||||
Valid = 0,
|
||||
Immutable = 1,
|
||||
Notify = 2
|
||||
};
|
||||
|
||||
protected:
|
||||
/// destructor
|
||||
virtual ~PyObjectBase();
|
||||
@@ -274,21 +280,29 @@ public:
|
||||
|
||||
void setInvalid() {
|
||||
// first bit is not set, i.e. invalid
|
||||
StatusBits.reset(0);
|
||||
StatusBits.reset(Valid);
|
||||
_pcTwinPointer = 0;
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
return StatusBits.test(0);
|
||||
return StatusBits.test(Valid);
|
||||
}
|
||||
|
||||
void setConst() {
|
||||
// second bit is set, i.e. immutable
|
||||
StatusBits.set(1);
|
||||
StatusBits.set(Immutable);
|
||||
}
|
||||
|
||||
bool isConst() {
|
||||
return StatusBits.test(1);
|
||||
return StatusBits.test(Immutable);
|
||||
}
|
||||
|
||||
void setShouldNotify(bool on) {
|
||||
StatusBits.set(Notify, on);
|
||||
}
|
||||
|
||||
bool shouldNotify() const {
|
||||
return StatusBits.test(Notify);
|
||||
}
|
||||
|
||||
void startNotify();
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<xs:attribute name="Delete" type="xs:boolean" use="optional" default="false"/>
|
||||
<xs:attribute name="Reference" type="xs:boolean" use="optional"/>
|
||||
<xs:attribute name="Initialization" type="xs:boolean" use="optional" default="false"/>
|
||||
<xs:attribute name="DisableNotify" type="xs:boolean" use="optional" default="false"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Generated Thu Apr 27 15:48:35 2017 by generateDS.py.
|
||||
# Generated Thu Apr 27 21:48:12 2017 by generateDS.py.
|
||||
# Update it with: python generateDS.py -o generateModel_Module.py generateMetaModel_Module.xsd
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
@@ -219,8 +219,9 @@ class GenerateModel:
|
||||
|
||||
class PythonExport:
|
||||
subclass = None
|
||||
def __init__(self, FatherNamespace='', RichCompare=0, Name='', Reference=0, FatherInclude='', Namespace='', Initialization=0, Father='', PythonName='', Twin='', Constructor=0, TwinPointer='', Include='', NumberProtocol=0, Delete=0, Documentation=None, Methode=None, Attribute=None, Sequence=None, CustomAttributes='', ClassDeclarations=''):
|
||||
def __init__(self, FatherNamespace='', DisableNotify=0, RichCompare=0, Name='', Reference=0, FatherInclude='', Namespace='', Initialization=0, Father='', PythonName='', Twin='', Constructor=0, TwinPointer='', Include='', NumberProtocol=0, Delete=0, Documentation=None, Methode=None, Attribute=None, Sequence=None, CustomAttributes='', ClassDeclarations=''):
|
||||
self.FatherNamespace = FatherNamespace
|
||||
self.DisableNotify = DisableNotify
|
||||
self.RichCompare = RichCompare
|
||||
self.Name = Name
|
||||
self.Reference = Reference
|
||||
@@ -271,6 +272,8 @@ class PythonExport:
|
||||
def setClassdeclarations(self, ClassDeclarations): self.ClassDeclarations = ClassDeclarations
|
||||
def getFathernamespace(self): return self.FatherNamespace
|
||||
def setFathernamespace(self, FatherNamespace): self.FatherNamespace = FatherNamespace
|
||||
def getDisablenotify(self): return self.DisableNotify
|
||||
def setDisablenotify(self, DisableNotify): self.DisableNotify = DisableNotify
|
||||
def getRichcompare(self): return self.RichCompare
|
||||
def setRichcompare(self, RichCompare): self.RichCompare = RichCompare
|
||||
def getName(self): return self.Name
|
||||
@@ -309,6 +312,8 @@ class PythonExport:
|
||||
outfile.write('</%s>\n' % name_)
|
||||
def exportAttributes(self, outfile, level, name_='PythonExport'):
|
||||
outfile.write(' FatherNamespace="%s"' % (self.getFathernamespace(), ))
|
||||
if self.getDisablenotify() is not None:
|
||||
outfile.write(' DisableNotify="%s"' % (self.getDisablenotify(), ))
|
||||
if self.getRichcompare() is not None:
|
||||
outfile.write(' RichCompare="%s"' % (self.getRichcompare(), ))
|
||||
outfile.write(' Name="%s"' % (self.getName(), ))
|
||||
@@ -351,6 +356,8 @@ class PythonExport:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('FatherNamespace = "%s",\n' % (self.getFathernamespace(),))
|
||||
showIndent(outfile, level)
|
||||
outfile.write('DisableNotify = "%s",\n' % (self.getDisablenotify(),))
|
||||
showIndent(outfile, level)
|
||||
outfile.write('RichCompare = "%s",\n' % (self.getRichcompare(),))
|
||||
showIndent(outfile, level)
|
||||
outfile.write('Name = "%s",\n' % (self.getName(),))
|
||||
@@ -428,6 +435,13 @@ class PythonExport:
|
||||
def buildAttributes(self, attrs):
|
||||
if attrs.get('FatherNamespace'):
|
||||
self.FatherNamespace = attrs.get('FatherNamespace').value
|
||||
if attrs.get('DisableNotify'):
|
||||
if attrs.get('DisableNotify').value in ('true', '1'):
|
||||
self.DisableNotify = 1
|
||||
elif attrs.get('DisableNotify').value in ('false', '0'):
|
||||
self.DisableNotify = 0
|
||||
else:
|
||||
raise ValueError('Bad boolean attribute (DisableNotify)')
|
||||
if attrs.get('RichCompare'):
|
||||
if attrs.get('RichCompare').value in ('true', '1'):
|
||||
self.RichCompare = 1
|
||||
@@ -1814,6 +1828,14 @@ class SaxGeneratemodelHandler(handler.ContentHandler):
|
||||
val = attrs.get('FatherNamespace', None)
|
||||
if val is not None:
|
||||
obj.setFathernamespace(val)
|
||||
val = attrs.get('DisableNotify', None)
|
||||
if val is not None:
|
||||
if val in ('true', '1'):
|
||||
obj.setDisablenotify(1)
|
||||
elif val in ('false', '0'):
|
||||
obj.setDisablenotify(0)
|
||||
else:
|
||||
self.reportError('"DisableNotify" attribute must be boolean ("true", "1", "false", "0")')
|
||||
val = attrs.get('RichCompare', None)
|
||||
if val is not None:
|
||||
if val in ('true', '1'):
|
||||
|
||||
@@ -621,10 +621,12 @@ int @self.export.Name@::staticCallback_set@i.Name@ (PyObject *self, PyObject *va
|
||||
+ if (self.export.Reference):
|
||||
pcObject->ref();
|
||||
-
|
||||
|
||||
+ if (self.export.Initialization):
|
||||
initialization();
|
||||
-
|
||||
+ if (self.export.DisableNotify):
|
||||
this->setShouldNotify(false);
|
||||
-
|
||||
}
|
||||
|
||||
+ if not (self.export.Constructor):
|
||||
|
||||
Reference in New Issue
Block a user