App: Apply clang format (part 1)
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <cassert>
|
||||
#include <cassert>
|
||||
#endif
|
||||
|
||||
#include <Base/PyObjectBase.h>
|
||||
@@ -39,167 +39,201 @@
|
||||
* PropertyData in the extension chain, there is no parent property data.
|
||||
*/
|
||||
EXTENSION_TYPESYSTEM_SOURCE_P(App::Extension)
|
||||
const App::PropertyData * App::Extension::extensionGetPropertyDataPtr(){return &propertyData;}
|
||||
const App::PropertyData & App::Extension::extensionGetPropertyData() const{return propertyData;}
|
||||
const App::PropertyData* App::Extension::extensionGetPropertyDataPtr()
|
||||
{
|
||||
return &propertyData;
|
||||
}
|
||||
const App::PropertyData& App::Extension::extensionGetPropertyData() const
|
||||
{
|
||||
return propertyData;
|
||||
}
|
||||
App::PropertyData App::Extension::propertyData;
|
||||
void App::Extension::init(){
|
||||
void App::Extension::init()
|
||||
{
|
||||
|
||||
assert(Extension::classTypeId == Base::Type::badType() && "don't init() twice!");
|
||||
|
||||
/* Set up entry in the type system. */
|
||||
Extension::classTypeId = Base::Type::createType(Base::Type::badType(), "App::Extension",
|
||||
Extension::create);
|
||||
Extension::classTypeId =
|
||||
Base::Type::createType(Base::Type::badType(), "App::Extension", Extension::create);
|
||||
}
|
||||
|
||||
using namespace App;
|
||||
|
||||
Extension::~Extension()
|
||||
{
|
||||
if (!ExtensionPythonObject.is(Py::_None())){
|
||||
if (!ExtensionPythonObject.is(Py::_None())) {
|
||||
// Remark: The API of Py::Object has been changed to set whether the wrapper owns the passed
|
||||
// Python object or not. In the constructor we forced the wrapper to own the object so we need
|
||||
// not to dec'ref the Python object any more.
|
||||
// But we must still invalidate the Python object because it need not to be
|
||||
// destructed right now because the interpreter can own several references to it.
|
||||
// Python object or not. In the constructor we forced the wrapper to own the object so we
|
||||
// need not to dec'ref the Python object any more. But we must still invalidate the Python
|
||||
// object because it need not to be destructed right now because the interpreter can own
|
||||
// several references to it.
|
||||
Base::PyObjectBase* obj = static_cast<Base::PyObjectBase*>(ExtensionPythonObject.ptr());
|
||||
// Call before decrementing the reference counter, otherwise a heap error can occur
|
||||
obj->setInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
void Extension::initExtensionType(Base::Type type) {
|
||||
void Extension::initExtensionType(Base::Type type)
|
||||
{
|
||||
|
||||
m_extensionType = type;
|
||||
if (m_extensionType.isBad())
|
||||
if (m_extensionType.isBad()) {
|
||||
throw Base::RuntimeError("Extension: Extension type not set");
|
||||
}
|
||||
}
|
||||
|
||||
void Extension::initExtension(ExtensionContainer* obj) {
|
||||
if (m_extensionType.isBad())
|
||||
void Extension::initExtension(ExtensionContainer* obj)
|
||||
{
|
||||
if (m_extensionType.isBad()) {
|
||||
throw Base::RuntimeError("Extension: Extension type not set");
|
||||
}
|
||||
|
||||
//all properties are initialised without PropertyContainer father. Now that we know it we can
|
||||
//finally finish the property initialisation
|
||||
// all properties are initialised without PropertyContainer father. Now that we know it we can
|
||||
// finally finish the property initialisation
|
||||
std::vector<Property*> list;
|
||||
extensionGetPropertyData().getPropertyList(this, list);
|
||||
for(Property* prop : list)
|
||||
for (Property* prop : list) {
|
||||
prop->setContainer(obj);
|
||||
}
|
||||
|
||||
m_base = obj;
|
||||
m_base->registerExtension( m_extensionType, this );
|
||||
m_base->registerExtension(m_extensionType, this);
|
||||
}
|
||||
|
||||
|
||||
PyObject* Extension::getExtensionPyObject() {
|
||||
PyObject* Extension::getExtensionPyObject()
|
||||
{
|
||||
|
||||
if (ExtensionPythonObject.is(Py::_None())){
|
||||
if (ExtensionPythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
auto grp = new ExtensionPy(this);
|
||||
ExtensionPythonObject = Py::Object(grp,true);
|
||||
ExtensionPythonObject = Py::Object(grp, true);
|
||||
}
|
||||
return Py::new_reference_to(ExtensionPythonObject);
|
||||
}
|
||||
|
||||
std::string Extension::name() const {
|
||||
std::string Extension::name() const
|
||||
{
|
||||
|
||||
if (m_extensionType.isBad())
|
||||
if (m_extensionType.isBad()) {
|
||||
throw Base::RuntimeError("Extension::name: Extension type not set");
|
||||
}
|
||||
|
||||
std::string temp(m_extensionType.getName());
|
||||
std::string::size_type pos = temp.find_last_of(':');
|
||||
|
||||
if (pos != std::string::npos)
|
||||
return temp.substr(pos+1);
|
||||
if (pos != std::string::npos) {
|
||||
return temp.substr(pos + 1);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Property* Extension::extensionGetPropertyByName(const char* name) const {
|
||||
Property* Extension::extensionGetPropertyByName(const char* name) const
|
||||
{
|
||||
|
||||
return extensionGetPropertyData().getPropertyByName(this, name);
|
||||
}
|
||||
|
||||
short int Extension::extensionGetPropertyType(const Property* prop) const {
|
||||
short int Extension::extensionGetPropertyType(const Property* prop) const
|
||||
{
|
||||
|
||||
return extensionGetPropertyData().getType(this, prop);
|
||||
}
|
||||
|
||||
short int Extension::extensionGetPropertyType(const char* name) const {
|
||||
short int Extension::extensionGetPropertyType(const char* name) const
|
||||
{
|
||||
|
||||
return extensionGetPropertyData().getType(this, name);
|
||||
}
|
||||
|
||||
const char* Extension::extensionGetPropertyName(const Property* prop) const {
|
||||
const char* Extension::extensionGetPropertyName(const Property* prop) const
|
||||
{
|
||||
|
||||
return extensionGetPropertyData().getName(this,prop);
|
||||
return extensionGetPropertyData().getName(this, prop);
|
||||
}
|
||||
|
||||
const char* Extension::extensionGetPropertyGroup(const Property* prop) const {
|
||||
const char* Extension::extensionGetPropertyGroup(const Property* prop) const
|
||||
{
|
||||
|
||||
return extensionGetPropertyData().getGroup(this,prop);
|
||||
return extensionGetPropertyData().getGroup(this, prop);
|
||||
}
|
||||
|
||||
const char* Extension::extensionGetPropertyGroup(const char* name) const {
|
||||
const char* Extension::extensionGetPropertyGroup(const char* name) const
|
||||
{
|
||||
|
||||
return extensionGetPropertyData().getGroup(this,name);
|
||||
return extensionGetPropertyData().getGroup(this, name);
|
||||
}
|
||||
|
||||
|
||||
const char* Extension::extensionGetPropertyDocumentation(const Property* prop) const {
|
||||
const char* Extension::extensionGetPropertyDocumentation(const Property* prop) const
|
||||
{
|
||||
|
||||
return extensionGetPropertyData().getDocumentation(this, prop);
|
||||
}
|
||||
|
||||
const char* Extension::extensionGetPropertyDocumentation(const char* name) const {
|
||||
const char* Extension::extensionGetPropertyDocumentation(const char* name) const
|
||||
{
|
||||
|
||||
return extensionGetPropertyData().getDocumentation(this, name);
|
||||
}
|
||||
|
||||
void Extension::extensionGetPropertyList(std::vector< Property* >& List) const {
|
||||
void Extension::extensionGetPropertyList(std::vector<Property*>& List) const
|
||||
{
|
||||
|
||||
extensionGetPropertyData().getPropertyList(this, List);
|
||||
}
|
||||
|
||||
void Extension::extensionGetPropertyMap(std::map< std::string, Property* >& Map) const {
|
||||
void Extension::extensionGetPropertyMap(std::map<std::string, Property*>& Map) const
|
||||
{
|
||||
|
||||
extensionGetPropertyData().getPropertyMap(this, Map);
|
||||
}
|
||||
|
||||
void Extension::initExtensionSubclass(Base::Type& toInit, const char* ClassName, const char* ParentName,
|
||||
Base::Type::instantiationMethod method) {
|
||||
void Extension::initExtensionSubclass(Base::Type& toInit,
|
||||
const char* ClassName,
|
||||
const char* ParentName,
|
||||
Base::Type::instantiationMethod method)
|
||||
{
|
||||
|
||||
// don't init twice!
|
||||
assert(toInit == Base::Type::badType());
|
||||
// get the parent class
|
||||
Base::Type parentType(Base::Type::fromName(ParentName));
|
||||
// forgot init parent!
|
||||
assert(parentType != Base::Type::badType() );
|
||||
assert(parentType != Base::Type::badType());
|
||||
|
||||
// create the new type
|
||||
toInit = Base::Type::createType(parentType, ClassName, method);
|
||||
}
|
||||
|
||||
|
||||
bool Extension::extensionHandleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName)
|
||||
bool Extension::extensionHandleChangedPropertyName(Base::XMLReader& reader,
|
||||
const char* TypeName,
|
||||
const char* PropName)
|
||||
{
|
||||
(void) reader;
|
||||
(void) TypeName;
|
||||
(void) PropName;
|
||||
(void)reader;
|
||||
(void)TypeName;
|
||||
(void)PropName;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
bool Extension::extensionHandleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop)
|
||||
bool Extension::extensionHandleChangedPropertyType(Base::XMLReader& reader,
|
||||
const char* TypeName,
|
||||
Property* prop)
|
||||
{
|
||||
(void) reader;
|
||||
(void) TypeName;
|
||||
(void) prop;
|
||||
(void)reader;
|
||||
(void)TypeName;
|
||||
(void)prop;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
namespace App {
|
||||
namespace App
|
||||
{
|
||||
EXTENSION_PROPERTY_SOURCE_TEMPLATE(App::ExtensionPython, App::ExtensionPython::Inherited)
|
||||
|
||||
// explicit template instantiation
|
||||
template class AppExport ExtensionPythonT<Extension>;
|
||||
}
|
||||
} // namespace App
|
||||
|
||||
Reference in New Issue
Block a user