diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-04-06 20:16:05 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-04-06 20:16:05 +0000 |
| commit | 7b7e0294b0c06a8d3ec19b73486a91e12cf67adf (patch) | |
| tree | 842fb9e8768d87c73b35c0e10f5c69f10c154e09 /src | |
| parent | Merged ObjectGroup and subclasses. (diff) | |
| download | inkscape-7b7e0294b0c06a8d3ec19b73486a91e12cf67adf.tar.gz inkscape-7b7e0294b0c06a8d3ec19b73486a91e12cf67adf.zip | |
Merged more classes.
(bzr r11608.1.84)
Diffstat (limited to 'src')
44 files changed, 523 insertions, 1656 deletions
diff --git a/src/color-profile.cpp b/src/color-profile.cpp index f1d89111d..0373ab317 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -50,11 +50,8 @@ #include <glibmm/convert.h> using Inkscape::ColorProfile; -using Inkscape::ColorProfileClass; using Inkscape::ColorProfileImpl; -using Inkscape::CColorProfile; - namespace { #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -105,8 +102,6 @@ extern guint update_in_progress; #define DEBUG_MESSAGE(key, ...) #endif // DEBUG_LCMS -static SPObjectClass *cprof_parent_class; - namespace Inkscape { class ColorProfileImpl { @@ -195,82 +190,27 @@ namespace { bool rectRegistered = SPFactory::instance().registerObject("svg:color-profile", createColorProfile); } +ColorProfile::ColorProfile() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -/** - * Register ColorProfile class and return its type. - */ -GType Inkscape::colorprofile_get_type() -{ - return ColorProfile::getType(); -} - -GType ColorProfile::getType() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(ColorProfileClass), - NULL, NULL, - 0, //(GClassInitFunc) ColorProfile::classInit, - NULL, NULL, - sizeof(ColorProfile), - 16, - (GInstanceInitFunc) ColorProfile::init, - NULL, /* value_table */ - }; - type = g_type_register_static( G_TYPE_OBJECT, "ColorProfile", &info, static_cast<GTypeFlags>(0) ); - } - return type; -} - -/** - * ColorProfile vtable initialization. - */ -void ColorProfile::classInit( ColorProfileClass *klass ) -{ - SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); + this->impl = new ColorProfileImpl(); - cprof_parent_class = static_cast<SPObjectClass*>(g_type_class_ref(SP_TYPE_OBJECT)); + this->href = 0; + this->local = 0; + this->name = 0; + this->intentStr = 0; + this->rendering_intent = Inkscape::RENDERING_INTENT_UNKNOWN; } -CColorProfile::CColorProfile(ColorProfile* cp) : CObject(cp) { - this->colorprofile = cp; -} - -CColorProfile::~CColorProfile() { -} - -ColorProfile::ColorProfile() : SPObject() { - ColorProfile* cprof = this; - - cprof->ccolorprofile = new CColorProfile(cprof); - cprof->typeHierarchy.insert(typeid(ColorProfile)); - - delete cprof->cobject; - cprof->cobject = cprof->ccolorprofile; - - cprof->impl = new ColorProfileImpl(); - - cprof->href = 0; - cprof->local = 0; - cprof->name = 0; - cprof->intentStr = 0; - cprof->rendering_intent = Inkscape::RENDERING_INTENT_UNKNOWN; -} - -/** - * Callback for ColorProfile object initialization. - */ -void ColorProfile::init( ColorProfile *cprof ) -{ - new (cprof) ColorProfile(); +ColorProfile::~ColorProfile() { } /** * Callback: free object */ -void CColorProfile::release() { - ColorProfile* object = this->colorprofile; +void ColorProfile::release() { + ColorProfile* object = this; // Unregister ourselves if ( object->document ) { @@ -333,8 +273,8 @@ void ColorProfileImpl::_clearProfile() /** * Callback: set attributes from associated repr. */ -void CColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { - ColorProfile* object = this->colorprofile; +void ColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { + ColorProfile* object = this; ColorProfile *cprof = COLORPROFILE(object); g_assert(cprof->href == 0); @@ -359,8 +299,8 @@ void CColorProfile::build(SPDocument *document, Inkscape::XML::Node *repr) { /** * Callback: set attribute. */ -void CColorProfile::set(unsigned key, gchar const *value) { - ColorProfile* object = this->colorprofile; +void ColorProfile::set(unsigned key, gchar const *value) { + ColorProfile* object = this; ColorProfile *cprof = COLORPROFILE(object); @@ -478,8 +418,8 @@ void CColorProfile::set(unsigned key, gchar const *value) { /** * Callback: write attributes to associated repr. */ -Inkscape::XML::Node* CColorProfile::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - ColorProfile* object = this->colorprofile; +Inkscape::XML::Node* ColorProfile::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + ColorProfile* object = this; ColorProfile *cprof = COLORPROFILE(object); diff --git a/src/color-profile.h b/src/color-profile.h index 22a9aae09..7606705f3 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -24,28 +24,16 @@ class ColorProfileImpl; /** - * The SPColorProfile vtable. - */ -struct ColorProfileClass { - SPObjectClass parent_class; -}; - -class CColorProfile; - -/** * Color Profile. */ -class ColorProfile : public SPObject { +class ColorProfile : public SPObject, public CObject { public: ColorProfile(); - CColorProfile* ccolorprofile; + virtual ~ColorProfile(); friend cmsHPROFILE colorprofile_get_handle( SPDocument*, guint*, gchar const* ); friend class CMSSystem; - static GType getType(); - static void classInit( ColorProfileClass *klass ); - static std::vector<Glib::ustring> getBaseProfileDirs(); static std::vector<Glib::ustring> getProfileFiles(); static std::vector<std::pair<Glib::ustring, Glib::ustring> > getProfileFilesWithNames(); @@ -67,17 +55,8 @@ public: gchar* intentStr; guint rendering_intent; -private: - static void init( ColorProfile *cprof ); - public: ColorProfileImpl *impl; -}; - -class CColorProfile : public CObject { -public: - CColorProfile(ColorProfile* cp); - virtual ~CColorProfile(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -85,14 +64,8 @@ public: virtual void set(unsigned int key, const gchar* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - ColorProfile* colorprofile; }; - -GType colorprofile_get_type(); - } // namespace Inkscape #define COLORPROFILE_TYPE (Inkscape::colorprofile_get_type()) diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index 2b5e3f99d..26e92bf15 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -31,133 +31,20 @@ #include "macros.h" /* FeFuncNode class */ - -static void sp_fefuncnode_class_init(SPFeFuncNodeClass *klass); -static void sp_fefuncnode_init(SPFeFuncNode *fefuncnode); - -static SPObjectClass *feFuncNode_parent_class; - -GType -sp_fefuncR_get_type() -{ - static GType fefuncnode_type = 0; - - if (!fefuncnode_type) { - GTypeInfo fefuncnode_info = { - sizeof(SPFeFuncNodeClass), - NULL, NULL, - 0,//(GClassInitFunc) sp_fefuncnode_class_init, - NULL, NULL, - sizeof(SPFeFuncNode), - 16, - (GInstanceInitFunc) sp_fefuncnode_init, - NULL, /* value_table */ - }; - fefuncnode_type = g_type_register_static(G_TYPE_OBJECT, "SPFeFuncR", &fefuncnode_info, (GTypeFlags)0); - } - return fefuncnode_type; -} - -GType -sp_fefuncG_get_type() -{ - static GType fefuncnode_type = 0; - - if (!fefuncnode_type) { - GTypeInfo fefuncnode_info = { - sizeof(SPFeFuncNodeClass), - NULL, NULL, - 0,//(GClassInitFunc) sp_fefuncnode_class_init, - NULL, NULL, - sizeof(SPFeFuncNode), - 16, - (GInstanceInitFunc) sp_fefuncnode_init, - NULL, /* value_table */ - }; - fefuncnode_type = g_type_register_static(G_TYPE_OBJECT, "SPFeFuncG", &fefuncnode_info, (GTypeFlags)0); - } - return fefuncnode_type; -} - -GType -sp_fefuncB_get_type() -{ - static GType fefuncnode_type = 0; - - if (!fefuncnode_type) { - GTypeInfo fefuncnode_info = { - sizeof(SPFeFuncNodeClass), - NULL, NULL, - 0,//(GClassInitFunc) sp_fefuncnode_class_init, - NULL, NULL, - sizeof(SPFeFuncNode), - 16, - (GInstanceInitFunc) sp_fefuncnode_init, - NULL, /* value_table */ - }; - fefuncnode_type = g_type_register_static(G_TYPE_OBJECT, "SPFeFuncB", &fefuncnode_info, (GTypeFlags)0); - } - return fefuncnode_type; -} - -GType -sp_fefuncA_get_type() -{ - static GType fefuncnode_type = 0; - - if (!fefuncnode_type) { - GTypeInfo fefuncnode_info = { - sizeof(SPFeFuncNodeClass), - NULL, NULL, - 0,//(GClassInitFunc) sp_fefuncnode_class_init, - NULL, NULL, - sizeof(SPFeFuncNode), - 16, - (GInstanceInitFunc) sp_fefuncnode_init, - NULL, /* value_table */ - }; - fefuncnode_type = g_type_register_static(G_TYPE_OBJECT, "SPFeFuncA", &fefuncnode_info, (GTypeFlags)0); - } - return fefuncnode_type; -} - -static void -sp_fefuncnode_class_init(SPFeFuncNodeClass *klass) -{ - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - - feFuncNode_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); -} - -CFeFuncNode::CFeFuncNode(SPFeFuncNode* funcnode) : CObject(funcnode) { - this->spfefuncnode = funcnode; -} - -CFeFuncNode::~CFeFuncNode() { -} - -SPFeFuncNode::SPFeFuncNode() : SPObject() { - SPFeFuncNode* fefuncnode = this; - - fefuncnode->cfefuncnode = new CFeFuncNode(fefuncnode); - fefuncnode->typeHierarchy.insert(typeid(SPFeFuncNode)); - - delete fefuncnode->cobject; - fefuncnode->cobject = fefuncnode->cfefuncnode; - - fefuncnode->type = Inkscape::Filters::COMPONENTTRANSFER_TYPE_IDENTITY; - //fefuncnode->tableValues = NULL; - fefuncnode->slope = 1; - fefuncnode->intercept = 0; - fefuncnode->amplitude = 1; - fefuncnode->exponent = 1; - fefuncnode->offset = 0; +SPFeFuncNode::SPFeFuncNode() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; + + this->type = Inkscape::Filters::COMPONENTTRANSFER_TYPE_IDENTITY; + //this->tableValues = NULL; + this->slope = 1; + this->intercept = 0; + this->amplitude = 1; + this->exponent = 1; + this->offset = 0; } -static void -sp_fefuncnode_init(SPFeFuncNode *fefuncnode) -{ - new (fefuncnode) SPFeFuncNode(); +SPFeFuncNode::~SPFeFuncNode() { } /** @@ -165,10 +52,10 @@ sp_fefuncnode_init(SPFeFuncNode *fefuncnode) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void CFeFuncNode::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFeFuncNode::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPFeFuncNode* object = this->spfefuncnode; + SPFeFuncNode* object = this; //Read values of key attributes from XML nodes into object. object->readAttr( "type" ); @@ -187,8 +74,8 @@ void CFeFuncNode::build(SPDocument *document, Inkscape::XML::Node *repr) { /** * Drops any allocated memory. */ -void CFeFuncNode::release() { - SPFeFuncNode* object = this->spfefuncnode; +void SPFeFuncNode::release() { + SPFeFuncNode* object = this; //SPFeFuncNode *fefuncnode = SP_FEFUNCNODE(object); if ( object->document ) { @@ -224,8 +111,8 @@ static Inkscape::Filters::FilterComponentTransferType sp_feComponenttransfer_rea /** * Sets a specific value in the SPFeFuncNode. */ -void CFeFuncNode::set(unsigned int key, gchar const *value) { - SPFeFuncNode* object = this->spfefuncnode; +void SPFeFuncNode::set(unsigned int key, gchar const *value) { + SPFeFuncNode* object = this; SPFeFuncNode *feFuncNode = SP_FEFUNCNODE(object); Inkscape::Filters::FilterComponentTransferType type; @@ -290,8 +177,8 @@ void CFeFuncNode::set(unsigned int key, gchar const *value) { /** * * Receives update notifications. * */ -void CFeFuncNode::update(SPCtx *ctx, guint flags) { - SPFeFuncNode* object = this->spfefuncnode; +void SPFeFuncNode::update(SPCtx *ctx, guint flags) { + SPFeFuncNode* object = this; SPFeFuncNode *feFuncNode = SP_FEFUNCNODE(object); (void)feFuncNode; @@ -309,8 +196,8 @@ void CFeFuncNode::update(SPCtx *ctx, guint flags) { /** * Writes its settings to an incoming repr object, if any. */ -Inkscape::XML::Node* CFeFuncNode::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - SPFeFuncNode* object = this->spfefuncnode; +Inkscape::XML::Node* SPFeFuncNode::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFeFuncNode* object = this; SPFeFuncNode *fefuncnode = SP_FEFUNCNODE(object); if (!repr) { diff --git a/src/filters/componenttransfer-funcnode.h b/src/filters/componenttransfer-funcnode.h index 9e358a923..b23e52324 100644 --- a/src/filters/componenttransfer-funcnode.h +++ b/src/filters/componenttransfer-funcnode.h @@ -18,10 +18,10 @@ #include "sp-object.h" #include "display/nr-filter-component-transfer.h" -#define SP_TYPE_FEFUNCR (sp_fefuncR_get_type()) -#define SP_TYPE_FEFUNCG (sp_fefuncG_get_type()) -#define SP_TYPE_FEFUNCB (sp_fefuncB_get_type()) -#define SP_TYPE_FEFUNCA (sp_fefuncA_get_type()) +//#define SP_TYPE_FEFUNCR (sp_fefuncR_get_type()) +//#define SP_TYPE_FEFUNCG (sp_fefuncG_get_type()) +//#define SP_TYPE_FEFUNCB (sp_fefuncB_get_type()) +//#define SP_TYPE_FEFUNCA (sp_fefuncA_get_type()) // CPPIFY: Casting macros buggy, as these aren't classes. //#define SP_IS_FEFUNCR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFUNCR)) @@ -31,17 +31,20 @@ #define SP_FEFUNCNODE(obj) ((SPFeFuncNode*)obj) -#define SP_IS_FEFUNCR(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode))) -#define SP_IS_FEFUNCG(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode))) -#define SP_IS_FEFUNCB(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode))) -#define SP_IS_FEFUNCA(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode))) +//#define SP_IS_FEFUNCR(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode))) +//#define SP_IS_FEFUNCG(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode))) +//#define SP_IS_FEFUNCB(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode))) +//#define SP_IS_FEFUNCA(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode))) -class CFeFuncNode; +#define SP_IS_FEFUNCR(obj) (dynamic_cast<const SPFeFuncNode*>((SPObject*)obj)) +#define SP_IS_FEFUNCG(obj) (dynamic_cast<const SPFeFuncNode*>((SPObject*)obj)) +#define SP_IS_FEFUNCB(obj) (dynamic_cast<const SPFeFuncNode*>((SPObject*)obj)) +#define SP_IS_FEFUNCA(obj) (dynamic_cast<const SPFeFuncNode*>((SPObject*)obj)) -class SPFeFuncNode : public SPObject { +class SPFeFuncNode : public SPObject, public CObject { public: SPFeFuncNode(); - CFeFuncNode* cfefuncnode; + virtual ~SPFeFuncNode(); Inkscape::Filters::FilterComponentTransferType type; std::vector<double> tableValues; @@ -50,12 +53,6 @@ public: double amplitude; double exponent; double offset; -}; - -class CFeFuncNode : public CObject { -public: - CFeFuncNode(SPFeFuncNode* funcnode); - virtual ~CFeFuncNode(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -65,20 +62,8 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPFeFuncNode* spfefuncnode; }; -struct SPFeFuncNodeClass { - SPObjectClass parent_class; -}; - -GType sp_fefuncR_get_type(); -GType sp_fefuncG_get_type(); -GType sp_fefuncB_get_type(); -GType sp_fefuncA_get_type(); - #endif /* !SP_FECOMPONENTTRANSFER_FUNCNODE_H_SEEN */ /* diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index 541b19cec..4aef86034 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -29,39 +29,17 @@ #define SP_MACROS_SILENT #include "macros.h" -G_DEFINE_TYPE(SPFeDistantLight, sp_fedistantlight, G_TYPE_OBJECT); - -static void -sp_fedistantlight_class_init(SPFeDistantLightClass *klass) -{ -} - -CFeDistantLight::CFeDistantLight(SPFeDistantLight* distantlight) : CObject(distantlight) { - this->spfedistantlight = distantlight; -} - -CFeDistantLight::~CFeDistantLight() { -} - -SPFeDistantLight::SPFeDistantLight() : SPObject() { - SPFeDistantLight* fedistantlight = this; - - fedistantlight->cfedistantlight = new CFeDistantLight(fedistantlight); - fedistantlight->typeHierarchy.insert(typeid(SPFeDistantLight)); - - delete fedistantlight->cobject; - fedistantlight->cobject = fedistantlight->cfedistantlight; - - fedistantlight->azimuth = 0; - fedistantlight->elevation = 0; - fedistantlight->azimuth_set = FALSE; - fedistantlight->elevation_set = FALSE; +SPFeDistantLight::SPFeDistantLight() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; + + this->azimuth = 0; + this->elevation = 0; + this->azimuth_set = FALSE; + this->elevation_set = FALSE; } -static void -sp_fedistantlight_init(SPFeDistantLight *fedistantlight) -{ - new (fedistantlight) SPFeDistantLight(); +SPFeDistantLight::~SPFeDistantLight() { } /** @@ -69,10 +47,10 @@ sp_fedistantlight_init(SPFeDistantLight *fedistantlight) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void CFeDistantLight::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFeDistantLight::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPFeDistantLight* object = this->spfedistantlight; + SPFeDistantLight* object = this; //Read values of key attributes from XML nodes into object. object->readAttr( "azimuth" ); @@ -85,8 +63,8 @@ void CFeDistantLight::build(SPDocument *document, Inkscape::XML::Node *repr) { /** * Drops any allocated memory. */ -void CFeDistantLight::release() { - SPFeDistantLight* object = this->spfedistantlight; +void SPFeDistantLight::release() { + SPFeDistantLight* object = this; //SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); @@ -101,8 +79,8 @@ void CFeDistantLight::release() { /** * Sets a specific value in the SPFeDistantLight. */ -void CFeDistantLight::set(unsigned int key, gchar const *value) { - SPFeDistantLight* object = this->spfedistantlight; +void SPFeDistantLight::set(unsigned int key, gchar const *value) { + SPFeDistantLight* object = this; SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); gchar *end_ptr; switch (key) { @@ -152,8 +130,8 @@ void CFeDistantLight::set(unsigned int key, gchar const *value) { /** * * Receives update notifications. * */ -void CFeDistantLight::update(SPCtx *ctx, guint flags) { - SPFeDistantLight* object = this->spfedistantlight; +void SPFeDistantLight::update(SPCtx *ctx, guint flags) { + SPFeDistantLight* object = this; SPFeDistantLight *feDistantLight = SP_FEDISTANTLIGHT(object); (void)feDistantLight; @@ -169,8 +147,8 @@ void CFeDistantLight::update(SPCtx *ctx, guint flags) { /** * Writes its settings to an incoming repr object, if any. */ -Inkscape::XML::Node* CFeDistantLight::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - SPFeDistantLight* object = this->spfedistantlight; +Inkscape::XML::Node* SPFeDistantLight::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFeDistantLight* object = this; SPFeDistantLight *fedistantlight = SP_FEDISTANTLIGHT(object); if (!repr) { diff --git a/src/filters/distantlight.h b/src/filters/distantlight.h index d8d2fae17..21ece336d 100644 --- a/src/filters/distantlight.h +++ b/src/filters/distantlight.h @@ -17,18 +17,14 @@ #include "sp-object.h" -#define SP_TYPE_FEDISTANTLIGHT (sp_fedistantlight_get_type()) #define SP_FEDISTANTLIGHT(obj) ((SPFeDistantLight*)obj) -#define SP_IS_FEDISTANTLIGHT(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeDistantLight))) +#define SP_IS_FEDISTANTLIGHT(obj) (dynamic_cast<const SPFeDistantLight*>((SPObject*)obj)) /* Distant light class */ - -class CFeDistantLight; - -class SPFeDistantLight : public SPObject { +class SPFeDistantLight : public SPObject, public CObject { public: SPFeDistantLight(); - CFeDistantLight* cfedistantlight; + virtual ~SPFeDistantLight(); /** azimuth attribute */ gfloat azimuth; @@ -36,12 +32,6 @@ public: /** elevation attribute */ gfloat elevation; guint elevation_set : 1; -}; - -class CFeDistantLight : public CObject { -public: - CFeDistantLight(SPFeDistantLight* distantlight); - virtual ~CFeDistantLight(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -51,17 +41,8 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPFeDistantLight* spfedistantlight; -}; - -struct SPFeDistantLightClass { - SPObjectClass parent_class; }; -GType -sp_fedistantlight_get_type(); #endif /* !SP_FEDISTANTLIGHT_H_SEEN */ /* diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index fbdcc9277..478a9f9a8 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -33,36 +33,14 @@ namespace { bool mergeNodeRegistered = SPFactory::instance().registerObject("svg:feMergeNode", createMergeNode); } -G_DEFINE_TYPE(SPFeMergeNode, sp_feMergeNode, G_TYPE_OBJECT); +SPFeMergeNode::SPFeMergeNode() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -static void -sp_feMergeNode_class_init(SPFeMergeNodeClass *klass) -{ + this->input = Inkscape::Filters::NR_FILTER_SLOT_NOT_SET; } -CFeMergeNode::CFeMergeNode(SPFeMergeNode* mergenode) : CObject(mergenode) { - this->spfemergenode = mergenode; -} - -CFeMergeNode::~CFeMergeNode() { -} - -SPFeMergeNode::SPFeMergeNode() : SPObject() { - SPFeMergeNode* feMergeNode = this; - - feMergeNode->cfemergenode = new CFeMergeNode(feMergeNode); - feMergeNode->typeHierarchy.insert(typeid(SPFeMergeNode)); - - delete feMergeNode->cobject; - feMergeNode->cobject = feMergeNode->cfemergenode; - - feMergeNode->input = Inkscape::Filters::NR_FILTER_SLOT_NOT_SET; -} - -static void -sp_feMergeNode_init(SPFeMergeNode *feMergeNode) -{ - new (feMergeNode) SPFeMergeNode(); +SPFeMergeNode::~SPFeMergeNode() { } /** @@ -70,23 +48,23 @@ sp_feMergeNode_init(SPFeMergeNode *feMergeNode) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void CFeMergeNode::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPFeMergeNode* object = this->spfemergenode; +void SPFeMergeNode::build(SPDocument *document, Inkscape::XML::Node *repr) { + SPFeMergeNode* object = this; object->readAttr( "in" ); } /** * Drops any allocated memory. */ -void CFeMergeNode::release() { +void SPFeMergeNode::release() { CObject::release(); } /** * Sets a specific value in the SPFeMergeNode. */ -void CFeMergeNode::set(unsigned int key, gchar const *value) { - SPFeMergeNode* object = this->spfemergenode; +void SPFeMergeNode::set(unsigned int key, gchar const *value) { + SPFeMergeNode* object = this; SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); SPFeMerge *parent = SP_FEMERGE(object->parent); @@ -105,8 +83,8 @@ void CFeMergeNode::set(unsigned int key, gchar const *value) { /** * Receives update notifications. */ -void CFeMergeNode::update(SPCtx *ctx, guint flags) { - SPFeMergeNode* object = this->spfemergenode; +void SPFeMergeNode::update(SPCtx *ctx, guint flags) { + SPFeMergeNode* object = this; //SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -119,8 +97,8 @@ void CFeMergeNode::update(SPCtx *ctx, guint flags) { /** * Writes its settings to an incoming repr object, if any. */ -Inkscape::XML::Node* CFeMergeNode::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - SPFeMergeNode* object = this->spfemergenode; +Inkscape::XML::Node* SPFeMergeNode::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFeMergeNode* object = this; //SPFeMergeNode *feMergeNode = SP_FEMERGENODE(object); // Inkscape-only object, not copied during an "plain SVG" dump: diff --git a/src/filters/mergenode.h b/src/filters/mergenode.h index 758891155..0b533c4c2 100644 --- a/src/filters/mergenode.h +++ b/src/filters/mergenode.h @@ -17,24 +17,15 @@ #include "sp-object.h" -#define SP_TYPE_FEMERGENODE (sp_feMergeNode_get_type()) #define SP_FEMERGENODE(obj) ((SPFeMergeNode*)obj) -#define SP_IS_FEMERGENODE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeMergeNode))) +#define SP_IS_FEMERGENODE(obj) (dynamic_cast<const SPFeMergeNode*>((SPObject*)obj)) -class CFeMergeNode; - -class SPFeMergeNode : public SPObject { +class SPFeMergeNode : public SPObject, public CObject { public: SPFeMergeNode(); - CFeMergeNode* cfemergenode; + virtual ~SPFeMergeNode(); int input; -}; - -class CFeMergeNode : public CObject { -public: - CFeMergeNode(SPFeMergeNode* mergenode); - virtual ~CFeMergeNode(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -44,18 +35,8 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPFeMergeNode* spfemergenode; }; -struct SPFeMergeNodeClass { - SPObjectClass parent_class; -}; - -GType sp_feMergeNode_get_type(); - - #endif /* !SP_FEMERGENODE_H_SEEN */ /* diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index 659727d5f..2e09151ac 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -39,53 +39,32 @@ namespace { bool pointLightRegistered = SPFactory::instance().registerObject("svg:fePointLight", createPointLight); } -G_DEFINE_TYPE(SPFePointLight, sp_fepointlight, G_TYPE_OBJECT); +SPFePointLight::SPFePointLight() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -static void -sp_fepointlight_class_init(SPFePointLightClass *klass) -{ -} - -CFePointLight::CFePointLight(SPFePointLight* pointlight) : CObject(pointlight) { - this->spfepointlight = pointlight; -} + this->x = 0; + this->y = 0; + this->z = 0; -CFePointLight::~CFePointLight() { + this->x_set = FALSE; + this->y_set = FALSE; + this->z_set = FALSE; } -SPFePointLight::SPFePointLight() : SPObject() { - SPFePointLight* fepointlight = this; - - fepointlight->cfepointlight = new CFePointLight(fepointlight); - fepointlight->typeHierarchy.insert(typeid(SPFePointLight)); - - delete fepointlight->cobject; - fepointlight->cobject = fepointlight->cfepointlight; - - fepointlight->x = 0; - fepointlight->y = 0; - fepointlight->z = 0; - - fepointlight->x_set = FALSE; - fepointlight->y_set = FALSE; - fepointlight->z_set = FALSE; +SPFePointLight::~SPFePointLight() { } -static void -sp_fepointlight_init(SPFePointLight *fepointlight) -{ - new (fepointlight) SPFePointLight(); -} /** * Reads the Inkscape::XML::Node, and initializes SPPointLight variables. For this to get called, * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void CFePointLight::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFePointLight::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPFePointLight* object = this->spfepointlight; + SPFePointLight* object = this; //Read values of key attributes from XML nodes into object. object->readAttr( "x" ); @@ -99,8 +78,8 @@ void CFePointLight::build(SPDocument *document, Inkscape::XML::Node *repr) { /** * Drops any allocated memory. */ -void CFePointLight::release() { - SPFePointLight* object = this->spfepointlight; +void SPFePointLight::release() { + SPFePointLight* object = this; //SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); if ( object->document ) { @@ -114,8 +93,8 @@ void CFePointLight::release() { /** * Sets a specific value in the SPFePointLight. */ -void CFePointLight::set(unsigned int key, gchar const *value) { - SPFePointLight* object = this->spfepointlight; +void SPFePointLight::set(unsigned int key, gchar const *value) { + SPFePointLight* object = this; SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); gchar *end_ptr; @@ -184,8 +163,8 @@ void CFePointLight::set(unsigned int key, gchar const *value) { /** * * Receives update notifications. * */ -void CFePointLight::update(SPCtx *ctx, guint flags) { - SPFePointLight* object = this->spfepointlight; +void SPFePointLight::update(SPCtx *ctx, guint flags) { + SPFePointLight* object = this; SPFePointLight *fePointLight = SP_FEPOINTLIGHT(object); (void)fePointLight; @@ -203,8 +182,8 @@ void CFePointLight::update(SPCtx *ctx, guint flags) { /** * Writes its settings to an incoming repr object, if any. */ -Inkscape::XML::Node* CFePointLight::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - SPFePointLight* object = this->spfepointlight; +Inkscape::XML::Node* SPFePointLight::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFePointLight* object = this; SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); if (!repr) { diff --git a/src/filters/pointlight.h b/src/filters/pointlight.h index f749722d6..ac065d7fd 100644 --- a/src/filters/pointlight.h +++ b/src/filters/pointlight.h @@ -17,16 +17,13 @@ #include "sp-object.h" -#define SP_TYPE_FEPOINTLIGHT (sp_fepointlight_get_type()) #define SP_FEPOINTLIGHT(obj) ((SPFePointLight*)obj) -#define SP_IS_FEPOINTLIGHT(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFePointLight))) +#define SP_IS_FEPOINTLIGHT(obj) (dynamic_cast<const SPFePointLight*>((SPObject*)obj)) -class CFePointLight; - -class SPFePointLight : public SPObject { +class SPFePointLight : public SPObject, public CObject { public: SPFePointLight(); - CFePointLight* cfepointlight; + virtual ~SPFePointLight(); /** x coordinate of the light source */ gfloat x; @@ -38,14 +35,6 @@ public: gfloat z; guint z_set : 1; - //other fields -}; - -class CFePointLight : public CObject { -public: - CFePointLight(SPFePointLight* pointlight); - virtual ~CFePointLight(); - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -54,17 +43,8 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPFePointLight* spfepointlight; -}; - -struct SPFePointLightClass { - SPObjectClass parent_class; }; -GType -sp_fepointlight_get_type(); #endif /* !SP_FEPOINTLIGHT_H_SEEN */ /* diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 9e89139e3..13a45bbb8 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -39,63 +39,42 @@ namespace { bool spotLightRegistered = SPFactory::instance().registerObject("svg:feSpotLight", createSpotLight); } -G_DEFINE_TYPE(SPFeSpotLight, sp_fespotlight, G_TYPE_OBJECT); - -static void -sp_fespotlight_class_init(SPFeSpotLightClass *klass) -{ -} - -CFeSpotLight::CFeSpotLight(SPFeSpotLight* spotlight) : CObject(spotlight) { - this->spfespotlight = spotlight; +SPFeSpotLight::SPFeSpotLight() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; + + this->x = 0; + this->y = 0; + this->z = 0; + this->pointsAtX = 0; + this->pointsAtY = 0; + this->pointsAtZ = 0; + this->specularExponent = 1; + this->limitingConeAngle = 90; + + this->x_set = FALSE; + this->y_set = FALSE; + this->z_set = FALSE; + this->pointsAtX_set = FALSE; + this->pointsAtY_set = FALSE; + this->pointsAtZ_set = FALSE; + this->specularExponent_set = FALSE; + this->limitingConeAngle_set = FALSE; } -CFeSpotLight::~CFeSpotLight() { +SPFeSpotLight::~SPFeSpotLight() { } -SPFeSpotLight::SPFeSpotLight() : SPObject() { - SPFeSpotLight* fespotlight = this; - - fespotlight->cfespotlight = new CFeSpotLight(fespotlight); - fespotlight->typeHierarchy.insert(typeid(SPFeSpotLight)); - - delete fespotlight->cobject; - fespotlight->cobject = fespotlight->cfespotlight; - - fespotlight->x = 0; - fespotlight->y = 0; - fespotlight->z = 0; - fespotlight->pointsAtX = 0; - fespotlight->pointsAtY = 0; - fespotlight->pointsAtZ = 0; - fespotlight->specularExponent = 1; - fespotlight->limitingConeAngle = 90; - - fespotlight->x_set = FALSE; - fespotlight->y_set = FALSE; - fespotlight->z_set = FALSE; - fespotlight->pointsAtX_set = FALSE; - fespotlight->pointsAtY_set = FALSE; - fespotlight->pointsAtZ_set = FALSE; - fespotlight->specularExponent_set = FALSE; - fespotlight->limitingConeAngle_set = FALSE; -} - -static void -sp_fespotlight_init(SPFeSpotLight *fespotlight) -{ - new (fespotlight) SPFeSpotLight(); -} /** * Reads the Inkscape::XML::Node, and initializes SPPointLight variables. For this to get called, * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void CFeSpotLight::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFeSpotLight::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPFeSpotLight* object = this->spfespotlight; + SPFeSpotLight* object = this; //Read values of key attributes from XML nodes into object. object->readAttr( "x" ); @@ -114,8 +93,8 @@ void CFeSpotLight::build(SPDocument *document, Inkscape::XML::Node *repr) { /** * Drops any allocated memory. */ -void CFeSpotLight::release() { - SPFeSpotLight* object = this->spfespotlight; +void SPFeSpotLight::release() { + SPFeSpotLight* object = this; //SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); if ( object->document ) { @@ -129,8 +108,8 @@ void CFeSpotLight::release() { /** * Sets a specific value in the SPFeSpotLight. */ -void CFeSpotLight::set(unsigned int key, gchar const *value) { - SPFeSpotLight* object = this->spfespotlight; +void SPFeSpotLight::set(unsigned int key, gchar const *value) { + SPFeSpotLight* object = this; SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); gchar *end_ptr; @@ -282,8 +261,8 @@ void CFeSpotLight::set(unsigned int key, gchar const *value) { /** * * Receives update notifications. * */ -void CFeSpotLight::update(SPCtx *ctx, guint flags) { - SPFeSpotLight* object = this->spfespotlight; +void SPFeSpotLight::update(SPCtx *ctx, guint flags) { + SPFeSpotLight* object = this; SPFeSpotLight *feSpotLight = SP_FESPOTLIGHT(object); (void)feSpotLight; @@ -306,8 +285,8 @@ void CFeSpotLight::update(SPCtx *ctx, guint flags) { /** * Writes its settings to an incoming repr object, if any. */ -Inkscape::XML::Node* CFeSpotLight::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - SPFeSpotLight* object = this->spfespotlight; +Inkscape::XML::Node* SPFeSpotLight::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFeSpotLight* object = this; SPFeSpotLight *fespotlight = SP_FESPOTLIGHT(object); if (!repr) { diff --git a/src/filters/spotlight.h b/src/filters/spotlight.h index 6849c8e82..69c36e2d7 100644 --- a/src/filters/spotlight.h +++ b/src/filters/spotlight.h @@ -17,16 +17,13 @@ #include "sp-object.h" -#define SP_TYPE_FESPOTLIGHT (sp_fespotlight_get_type()) #define SP_FESPOTLIGHT(obj) ((SPFeSpotLight*)obj) -#define SP_IS_FESPOTLIGHT(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeSpotLight))) +#define SP_IS_FESPOTLIGHT(obj) (dynamic_cast<const SPFeSpotLight*>((SPObject*)obj)) -class CFeSpotLight; - -class SPFeSpotLight : public SPObject { +class SPFeSpotLight : public SPObject, public CObject { public: SPFeSpotLight(); - CFeSpotLight* cfespotlight; + virtual ~SPFeSpotLight(); /** x coordinate of the light source */ gfloat x; @@ -53,12 +50,6 @@ public: gfloat limitingConeAngle; guint limitingConeAngle_set : 1; //other fields -}; - -class CFeSpotLight : public CObject { -public: - CFeSpotLight(SPFeSpotLight* spotlight); - virtual ~CFeSpotLight(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -68,17 +59,8 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPFeSpotLight* spfespotlight; -}; - -struct SPFeSpotLightClass { - SPObjectClass parent_class; }; -GType -sp_fespotlight_get_type(); #endif /* !SP_FESPOTLIGHT_H_SEEN */ /* diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index 5191d612c..012bf6612 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -32,31 +32,6 @@ namespace { static void livepatheffect_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data); -static SPObjectClass *livepatheffect_parent_class; -/** - * Registers the LivePathEffect class with Gdk and returns its type number. - */ -GType -LivePathEffectObject::livepatheffect_get_type () -{ - static GType livepatheffect_type = 0; - - if (!livepatheffect_type) { - GTypeInfo livepatheffect_info = { - sizeof (LivePathEffectObjectClass), - NULL, NULL, - 0,//(GClassInitFunc) LivePathEffectObject::livepatheffect_class_init, - NULL, NULL, - sizeof (LivePathEffectObject), - 16, - (GInstanceInitFunc) LivePathEffectObject::livepatheffect_init, - NULL, - }; - livepatheffect_type = g_type_register_static (G_TYPE_OBJECT, "LivePathEffectObject", &livepatheffect_info, (GTypeFlags)0); - } - return livepatheffect_type; -} - static Inkscape::XML::NodeEventVector const livepatheffect_repr_events = { NULL, /* child_added */ NULL, /* child_removed */ @@ -66,57 +41,28 @@ static Inkscape::XML::NodeEventVector const livepatheffect_repr_events = { }; -/** - * Callback to initialize livepatheffect vtable. - */ -void -LivePathEffectObject::livepatheffect_class_init(LivePathEffectObjectClass *klass) -{ - SPObjectClass *sp_object_class = (SPObjectClass *) klass; - - livepatheffect_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); -} - -CLivePathEffectObject::CLivePathEffectObject(LivePathEffectObject* lpeo) : CObject(lpeo) { - this->livepatheffectobject = lpeo; -} - -CLivePathEffectObject::~CLivePathEffectObject() { -} - -LivePathEffectObject::LivePathEffectObject() : SPObject() { - LivePathEffectObject* lpeobj = this; - +LivePathEffectObject::LivePathEffectObject() : SPObject(), CObject(this) { #ifdef LIVEPATHEFFECT_VERBOSE g_message("Init livepatheffectobject"); #endif - lpeobj->clivepatheffectobject = new CLivePathEffectObject(lpeobj); - lpeobj->typeHierarchy.insert(typeid(LivePathEffectObject)); + delete this->cobject; + this->cobject = this; - delete lpeobj->cobject; - lpeobj->cobject = lpeobj->clivepatheffectobject; + this->effecttype = Inkscape::LivePathEffect::INVALID_LPE; + this->lpe = NULL; - lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE; - lpeobj->lpe = NULL; - - lpeobj->effecttype_set = false; + this->effecttype_set = false; } -/** - * Callback to initialize livepatheffect object. - */ -void -LivePathEffectObject::livepatheffect_init(LivePathEffectObject *lpeobj) -{ - new (lpeobj) LivePathEffectObject(); +LivePathEffectObject::~LivePathEffectObject() { } /** * Virtual build: set livepatheffect attributes from its associated XML node. */ -void CLivePathEffectObject::build(SPDocument *document, Inkscape::XML::Node *repr) { - LivePathEffectObject* object = this->livepatheffectobject; +void LivePathEffectObject::build(SPDocument *document, Inkscape::XML::Node *repr) { + LivePathEffectObject* object = this; g_assert(object != NULL); g_assert(SP_IS_OBJECT(object)); @@ -136,8 +82,8 @@ void CLivePathEffectObject::build(SPDocument *document, Inkscape::XML::Node *rep /** * Virtual release of livepatheffect members before destruction. */ -void CLivePathEffectObject::release() { - LivePathEffectObject* object = this->livepatheffectobject; +void LivePathEffectObject::release() { + LivePathEffectObject* object = this; LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); @@ -173,8 +119,8 @@ void CLivePathEffectObject::release() { /** * Virtual set: set attribute to value. */ -void CLivePathEffectObject::set(unsigned key, gchar const *value) { - LivePathEffectObject* object = this->livepatheffectobject; +void LivePathEffectObject::set(unsigned key, gchar const *value) { + LivePathEffectObject* object = this; LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); #ifdef LIVEPATHEFFECT_VERBOSE @@ -205,8 +151,8 @@ void CLivePathEffectObject::set(unsigned key, gchar const *value) { /** * Virtual write: write object attributes to repr. */ -Inkscape::XML::Node* CLivePathEffectObject::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - LivePathEffectObject* object = this->livepatheffectobject; +Inkscape::XML::Node* LivePathEffectObject::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + LivePathEffectObject* object = this; LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); diff --git a/src/live_effects/lpeobject.h b/src/live_effects/lpeobject.h index 02d3344f5..d5aaa09bf 100644 --- a/src/live_effects/lpeobject.h +++ b/src/live_effects/lpeobject.h @@ -22,21 +22,13 @@ namespace Inkscape { } } -#define TYPE_LIVEPATHEFFECT (LivePathEffectObject::livepatheffect_get_type()) #define LIVEPATHEFFECT(obj) ((LivePathEffectObject*)obj) -#define IS_LIVEPATHEFFECT(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(LivePathEffectObject))) +#define IS_LIVEPATHEFFECT(obj) (dynamic_cast<const LivePathEffectObject*>((SPObject*)obj)) -/// The LivePathEffect vtable. -struct LivePathEffectObjectClass { - SPObjectClass parent_class; -}; - -class CLivePathEffectObject; - -class LivePathEffectObject : public SPObject { +class LivePathEffectObject : public SPObject, public CObject { public: LivePathEffectObject(); - CLivePathEffectObject* clivepatheffectobject; + virtual ~LivePathEffectObject(); Inkscape::LivePathEffect::EffectType effecttype; @@ -51,29 +43,12 @@ public: //private: Inkscape::LivePathEffect::Effect *lpe; // this can be NULL in a valid LivePathEffectObject - /* C-style class functions: */ -//public: - static GType livepatheffect_get_type(); -//private: - static void livepatheffect_class_init(LivePathEffectObjectClass *klass); - static void livepatheffect_init(LivePathEffectObject *stop); -}; - - -class CLivePathEffectObject : public CObject { -public: - CLivePathEffectObject(LivePathEffectObject* lpeo); - virtual ~CLivePathEffectObject(); - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); virtual void set(unsigned int key, const gchar* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - LivePathEffectObject* livepatheffectobject; }; #endif diff --git a/src/persp3d.cpp b/src/persp3d.cpp index 97898daf2..7e5045d67 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -53,8 +53,6 @@ Persp3DImpl::Persp3DImpl() { my_counter = global_counter++; } -G_DEFINE_TYPE(Persp3D, persp3d, G_TYPE_OBJECT); - static Inkscape::XML::NodeEventVector const persp3d_repr_events = { NULL, /* child_added */ NULL, /* child_removed */ @@ -63,50 +61,25 @@ static Inkscape::XML::NodeEventVector const persp3d_repr_events = { NULL /* order_changed */ }; -/** - * Callback to initialize Persp3D vtable. - */ -static void persp3d_class_init(Persp3DClass *klass) -{ - SPObjectClass *sp_object_class = (SPObjectClass *) klass; -} +Persp3D::Persp3D() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -CPersp3D::CPersp3D(Persp3D* persp3d) : CObject(persp3d) { - this->persp3d = persp3d; + this->perspective_impl = new Persp3DImpl(); } -CPersp3D::~CPersp3D() { +Persp3D::~Persp3D() { } -Persp3D::Persp3D() : SPObject() { - Persp3D* persp = this; - - persp->cpersp3d = new CPersp3D(persp); - persp->typeHierarchy.insert(typeid(Persp3D)); - - delete persp->cobject; - persp->cobject = persp->cpersp3d; - - persp->perspective_impl = new Persp3DImpl(); -} - -/** - * Callback to initialize Persp3D object. - */ -static void -persp3d_init(Persp3D *persp) -{ - new (persp) Persp3D(); -} /** * Virtual build: set persp3d attributes from its associated XML node. */ -void CPersp3D::build(SPDocument *document, Inkscape::XML::Node *repr) { +void Persp3D::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - Persp3D* object = this->persp3d; + Persp3D* object = this; object->readAttr( "inkscape:vp_x" ); object->readAttr( "inkscape:vp_y" ); @@ -121,8 +94,8 @@ void CPersp3D::build(SPDocument *document, Inkscape::XML::Node *repr) { /** * Virtual release of Persp3D members before destruction. */ -void CPersp3D::release() { - Persp3D* object = this->persp3d; +void Persp3D::release() { + Persp3D* object = this; Persp3D *persp = SP_PERSP3D(object); delete persp->perspective_impl; @@ -135,8 +108,8 @@ void CPersp3D::release() { */ // FIXME: Currently we only read the finite positions of vanishing points; // should we move VPs into their own repr (as it's done for SPStop, e.g.)? -void CPersp3D::set(unsigned key, gchar const *value) { - Persp3D* object = this->persp3d; +void Persp3D::set(unsigned key, gchar const *value) { + Persp3D* object = this; Persp3DImpl *persp_impl = SP_PERSP3D(object)->perspective_impl; @@ -186,7 +159,7 @@ void CPersp3D::set(unsigned key, gchar const *value) { } } -void CPersp3D::update(SPCtx *ctx, guint flags) { +void Persp3D::update(SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { /* TODO: Should we update anything here? */ @@ -252,8 +225,8 @@ Persp3D *persp3d_document_first_persp(SPDocument *document) /** * Virtual write: write object attributes to repr. */ -Inkscape::XML::Node* CPersp3D::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - Persp3D* object = this->persp3d; +Inkscape::XML::Node* Persp3D::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + Persp3D* object = this; Persp3DImpl *persp_impl = SP_PERSP3D(object)->perspective_impl; diff --git a/src/persp3d.h b/src/persp3d.h index 5b472a80f..df20a9202 100644 --- a/src/persp3d.h +++ b/src/persp3d.h @@ -12,9 +12,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#define SP_TYPE_PERSP3D (persp3d_get_type ()) #define SP_PERSP3D(obj) ((Persp3D*)obj) -#define SP_IS_PERSP3D(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(Persp3D))) +#define SP_IS_PERSP3D(obj) (dynamic_cast<const Persp3D*>((SPObject*)obj)) #include <list> #include <vector> @@ -44,24 +43,12 @@ public: // friend class Persp3D; }; -class CPersp3D; - -class Persp3D : public SPObject { +class Persp3D : public SPObject, public CObject { public: Persp3D(); - CPersp3D* cpersp3d; + virtual ~Persp3D(); Persp3DImpl *perspective_impl; -}; - -struct Persp3DClass { -// SPItemClass parent_class; -}; - -class CPersp3D : public CObject { -public: - CPersp3D(Persp3D* persp3d); - virtual ~CPersp3D(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -71,15 +58,9 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - Persp3D* persp3d; }; -/* Standard GType function */ -GType persp3d_get_type (void); - // FIXME: Make more of these inline! inline Persp3D * persp3d_get_from_repr (Inkscape::XML::Node *repr) { return SP_PERSP3D(SP_ACTIVE_DOCUMENT->getObjectByRepr(repr)); diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index a385dca6a..6202c19f7 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -30,46 +30,20 @@ namespace { bool defsRegistered = SPFactory::instance().registerObject("svg:defs", createDefs); } -G_DEFINE_TYPE(SPDefs, sp_defs, G_TYPE_OBJECT); - -static void -sp_defs_class_init(SPDefsClass *dc) -{ - SPObjectClass *sp_object_class = (SPObjectClass *) dc; - -} - -SPDefs::SPDefs() : SPObject() { - SPDefs* defs = this; - - defs->cdefs = new CDefs(defs); - defs->typeHierarchy.insert(typeid(SPDefs)); - - delete defs->cobject; - defs->cobject = defs->cdefs; +SPDefs::SPDefs() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; } -static void -sp_defs_init(SPDefs* defs) -{ - new (defs) SPDefs(); +SPDefs::~SPDefs() { } -CDefs::CDefs(SPDefs* defs) : CObject(defs) { - this->spdefs = defs; -} - -CDefs::~CDefs() { -} - - - -void CDefs::release() { +void SPDefs::release() { CObject::release(); } -void CDefs::update(SPCtx *ctx, guint flags) { - SPDefs* object = this->spdefs; +void SPDefs::update(SPCtx *ctx, guint flags) { + SPDefs* object = this; if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -88,8 +62,8 @@ void CDefs::update(SPCtx *ctx, guint flags) { } } -void CDefs::modified(unsigned int flags) { - SPDefs* object = this->spdefs; +void SPDefs::modified(unsigned int flags) { + SPDefs* object = this; if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -115,8 +89,8 @@ void CDefs::modified(unsigned int flags) { } } -Inkscape::XML::Node* CDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPDefs* object = this->spdefs; +Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPDefs* object = this; if (flags & SP_OBJECT_WRITE_BUILD) { diff --git a/src/sp-defs.h b/src/sp-defs.h index b1309a601..4c87def3b 100644 --- a/src/sp-defs.h +++ b/src/sp-defs.h @@ -15,47 +15,20 @@ #include "sp-object.h" -#define SP_TYPE_DEFS (sp_defs_get_type()) #define SP_DEFS(obj) ((SPDefs*)obj) -#define SP_IS_DEFS(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPDefs))) +#define SP_IS_DEFS(obj) (dynamic_cast<const SPDefs*>((SPObject*)obj)) -GType sp_defs_get_type(void) G_GNUC_CONST; - -class CDefs; - -class SPDefs : public SPObject { +class SPDefs : public SPObject, public CObject { public: SPDefs(); - CDefs* cdefs; - -private: - friend class SPDefsClass; -}; - -class SPDefsClass { -public: - SPObjectClass parent_class; - -private: - friend class SPDefs; -}; - - -class CDefs : public CObject { -public: - CDefs(SPDefs* defs); - virtual ~CDefs(); + virtual ~SPDefs(); virtual void release(); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - -protected: - SPDefs* spdefs; }; - #endif // !SEEN_SP_DEFS_H /* diff --git a/src/sp-desc.cpp b/src/sp-desc.cpp index 0fe1f5305..e7530e501 100644 --- a/src/sp-desc.cpp +++ b/src/sp-desc.cpp @@ -26,38 +26,16 @@ namespace { bool descRegistered = SPFactory::instance().registerObject("svg:desc", createDesc); } -G_DEFINE_TYPE(SPDesc, sp_desc, SP_TYPE_OBJECT); - -static void sp_desc_class_init(SPDescClass *klass) -{ - SPObjectClass *sp_object_class = (SPObjectClass *)(klass); - -} - -CDesc::CDesc(SPDesc* desc) : CObject(desc) { - this->spdesc = desc; -} - -CDesc::~CDesc() { -} - -SPDesc::SPDesc() : SPObject() { - SPDesc* desc = this; - - desc->cdesc = new CDesc(desc); - desc->typeHierarchy.insert(typeid(SPDesc)); - - delete desc->cobject; - desc->cobject = desc->cdesc; +SPDesc::SPDesc() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; } -static void sp_desc_init(SPDesc *desc) -{ - new (desc) SPDesc(); +SPDesc::~SPDesc() { } -Inkscape::XML::Node* CDesc::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { - SPDesc* object = this->spdesc; +Inkscape::XML::Node* SPDesc::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { + SPDesc* object = this; if (!repr) { repr = object->getRepr()->duplicate(doc); diff --git a/src/sp-desc.h b/src/sp-desc.h index 2be3bf1d3..1e12296a4 100644 --- a/src/sp-desc.h +++ b/src/sp-desc.h @@ -14,35 +14,15 @@ #include "sp-object.h" -#define SP_TYPE_DESC (sp_desc_get_type ()) #define SP_DESC(obj) ((SPDesc*)obj) -#define SP_IS_DESC(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPDesc))) +#define SP_IS_DESC(obj) (dynamic_cast<const SPDesc*>((SPObject*)obj)) -class CDesc; - -class SPDesc : public SPObject { +class SPDesc : public SPObject, public CObject { public: SPDesc(); - CDesc* cdesc; -}; - -struct SPDescClass { - SPObjectClass parent_class; -}; - - -class CDesc : public CObject { -public: - CDesc(SPDesc* desc); - virtual ~CDesc(); + virtual ~SPDesc(); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -protected: - SPDesc* spdesc; }; - -GType sp_desc_get_type (void); - #endif diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index db1887715..80dc0ecdc 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -51,66 +51,45 @@ namespace { bool filterRegistered = SPFactory::instance().registerObject("svg:filter", createFilter); } -G_DEFINE_TYPE(SPFilter, sp_filter, G_TYPE_OBJECT); +SPFilter::SPFilter() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -static void -sp_filter_class_init(SPFilterClass *klass) -{ -} - -CFilter::CFilter(SPFilter* filter) : CObject(filter) { - this->spfilter = filter; -} - -CFilter::~CFilter() { -} + this->href = new SPFilterReference(this); + this->href->changedSignal().connect(sigc::bind(sigc::ptr_fun(filter_ref_changed), this)); -SPFilter::SPFilter() : SPObject() { - SPFilter* filter = this; + this->x = 0; + this->y = 0; + this->width = 0; + this->height = 0; - filter->cfilter = new CFilter(filter); - filter->typeHierarchy.insert(typeid(SPFilter)); + this->filterUnits = SP_FILTER_UNITS_OBJECTBOUNDINGBOX; + this->primitiveUnits = SP_FILTER_UNITS_USERSPACEONUSE; + this->filterUnits_set = FALSE; + this->primitiveUnits_set = FALSE; - delete filter->cobject; - filter->cobject = filter->cfilter; + this->_renderer = NULL; - filter->href = new SPFilterReference(filter); - filter->href->changedSignal().connect(sigc::bind(sigc::ptr_fun(filter_ref_changed), filter)); + this->_image_name = new std::map<gchar *, int, ltstr>; + this->_image_name->clear(); + this->_image_number_next = 0; - filter->x = 0; - filter->y = 0; - filter->width = 0; - filter->height = 0; + this->filterRes = NumberOptNumber(); - filter->filterUnits = SP_FILTER_UNITS_OBJECTBOUNDINGBOX; - filter->primitiveUnits = SP_FILTER_UNITS_USERSPACEONUSE; - filter->filterUnits_set = FALSE; - filter->primitiveUnits_set = FALSE; - - filter->_renderer = NULL; - - filter->_image_name = new std::map<gchar *, int, ltstr>; - filter->_image_name->clear(); - filter->_image_number_next = 0; - - filter->filterRes = NumberOptNumber(); - - new (&filter->modified_connection) sigc::connection(); + new (&this->modified_connection) sigc::connection(); } -static void -sp_filter_init(SPFilter *filter) -{ - new (filter) SPFilter(); +SPFilter::~SPFilter() { } + /** * Reads the Inkscape::XML::Node, and initializes SPFilter variables. For this to get called, * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void CFilter::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPFilter* object = this->spfilter; +void SPFilter::build(SPDocument *document, Inkscape::XML::Node *repr) { + SPFilter* object = this; //Read values of key attributes from XML nodes into object. object->readAttr( "style" ); // struct not derived from SPItem, we need to do this ourselves. @@ -132,8 +111,8 @@ void CFilter::build(SPDocument *document, Inkscape::XML::Node *repr) { /** * Drops any allocated memory. */ -void CFilter::release() { - SPFilter* object = this->spfilter; +void SPFilter::release() { + SPFilter* object = this; SPFilter *filter = SP_FILTER(object); if (object->document) { @@ -160,8 +139,8 @@ void CFilter::release() { /** * Sets a specific value in the SPFilter. */ -void CFilter::set(unsigned int key, gchar const *value) { - SPFilter* object = this->spfilter; +void SPFilter::set(unsigned int key, gchar const *value) { + SPFilter* object = this; SPFilter *filter = SP_FILTER(object); switch (key) { @@ -235,7 +214,7 @@ void CFilter::set(unsigned int key, gchar const *value) { /** * Receives update notifications. */ -void CFilter::update(SPCtx *ctx, guint flags) { +void SPFilter::update(SPCtx *ctx, guint flags) { //SPFilter *filter = SP_FILTER(object); if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | @@ -251,8 +230,8 @@ void CFilter::update(SPCtx *ctx, guint flags) { /** * Writes its settings to an incoming repr object, if any. */ -Inkscape::XML::Node* CFilter::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - SPFilter* object = this->spfilter; +Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + SPFilter* object = this; SPFilter *filter = SP_FILTER(object); // Original from sp-item-group.cpp @@ -371,8 +350,8 @@ static void filter_ref_modified(SPObject */*href*/, guint /*flags*/, SPFilter *f /** * Callback for child_added event. */ -void CFilter::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPFilter* object = this->spfilter; +void SPFilter::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + SPFilter* object = this; //SPFilter *f = SP_FILTER(object); CObject::child_added(child, ref); @@ -383,8 +362,8 @@ void CFilter::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) /** * Callback for remove_child event. */ -void CFilter::remove_child(Inkscape::XML::Node *child) { - SPFilter* object = this->spfilter; +void SPFilter::remove_child(Inkscape::XML::Node *child) { + SPFilter* object = this; // SPFilter *f = SP_FILTER(object); CObject::remove_child(child); diff --git a/src/sp-filter.h b/src/sp-filter.h index ea9717498..38fb18426 100644 --- a/src/sp-filter.h +++ b/src/sp-filter.h @@ -21,9 +21,8 @@ #include <glibmm/ustring.h> -#define SP_TYPE_FILTER (sp_filter_get_type()) #define SP_FILTER(obj) ((SPFilter*)obj) -#define SP_IS_FILTER(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFilter))) +#define SP_IS_FILTER(obj) (dynamic_cast<const SPFilter*>((SPObject*)obj)) #define SP_FILTER_FILTER_UNITS(f) (SP_FILTER(f)->filterUnits) #define SP_FILTER_PRIMITIVE_UNITS(f) (SP_FILTER(f)->primitiveUnits) @@ -40,13 +39,10 @@ struct ltstr { bool operator()(const char* s1, const char* s2) const; }; - -class CFilter; - -class SPFilter : public SPObject { +class SPFilter : public SPObject, public CObject { public: SPFilter(); - CFilter* cfilter; + virtual ~SPFilter(); SPFilterUnits filterUnits; guint filterUnits_set : 1; @@ -64,12 +60,6 @@ public: std::map<gchar *, int, ltstr>* _image_name; int _image_number_next; -}; - -class CFilter : public CObject { -public: - CFilter(SPFilter* filter); - virtual ~CFilter(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -82,17 +72,8 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPFilter* spfilter; -}; - -struct SPFilterClass { - SPObjectClass parent_class; }; -GType sp_filter_get_type(); - void sp_filter_set_filter_units(SPFilter *filter, SPFilterUnits filterUnits); void sp_filter_set_primitive_units(SPFilter *filter, SPFilterUnits filterUnits); SPFilterPrimitive *add_primitive(SPFilter *filter, SPFilterPrimitive *primitive); diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 6149d9af0..d91910bec 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -269,90 +269,68 @@ namespace { bool fontFaceRegistered = SPFactory::instance().registerObject("svg:font-face", createFontFace); } -G_DEFINE_TYPE(SPFontFace, sp_fontface, G_TYPE_OBJECT); - -static void sp_fontface_class_init(SPFontFaceClass *fc) -{ -} - -CFontFace::CFontFace(SPFontFace* face) : CObject(face) { - this->spfontface = face; -} - -CFontFace::~CFontFace() { -} - -SPFontFace::SPFontFace() : SPObject() { - SPFontFace* face = this; - - face->cfontface = new CFontFace(face); - face->typeHierarchy.insert(typeid(SPFontFace)); - - delete face->cobject; - face->cobject = face->cfontface; +SPFontFace::SPFontFace() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; std::vector<FontFaceStyleType> style; style.push_back(SP_FONTFACE_STYLE_ALL); - face->font_style = style; + this->font_style = style; std::vector<FontFaceVariantType> variant; variant.push_back(SP_FONTFACE_VARIANT_NORMAL); - face->font_variant = variant; + this->font_variant = variant; std::vector<FontFaceWeightType> weight; weight.push_back(SP_FONTFACE_WEIGHT_ALL); - face->font_weight = weight; + this->font_weight = weight; std::vector<FontFaceStretchType> stretch; stretch.push_back(SP_FONTFACE_STRETCH_NORMAL); - face->font_stretch = stretch; - face->font_family = NULL; - - //face->font_style = ; - //face->font_variant = ; - //face->font_weight = ; - //face->font_stretch = ; - face->font_size = NULL; - //face->unicode_range = ; - face->units_per_em = 1000; - //face->panose_1 = ; - face->stemv = 0; - face->stemh = 0; - face->slope = 0; - face->cap_height = 0; - face->x_height = 0; - face->accent_height = 0; - face->ascent = 0; - face->descent = 0; - face->widths = NULL; - face->bbox = NULL; - face->ideographic = 0; - face->alphabetic = 0; - face->mathematical = 0; - face->hanging = 0; - face->v_ideographic = 0; - face->v_alphabetic = 0; - face->v_mathematical = 0; - face->v_hanging = 0; - face->underline_position = 0; - face->underline_thickness = 0; - face->strikethrough_position = 0; - face->strikethrough_thickness = 0; - face->overline_position = 0; - face->overline_thickness = 0; - + this->font_stretch = stretch; + this->font_family = NULL; + + //this->font_style = ; + //this->font_variant = ; + //this->font_weight = ; + //this->font_stretch = ; + this->font_size = NULL; + //this->unicode_range = ; + this->units_per_em = 1000; + //this->panose_1 = ; + this->stemv = 0; + this->stemh = 0; + this->slope = 0; + this->cap_height = 0; + this->x_height = 0; + this->accent_height = 0; + this->ascent = 0; + this->descent = 0; + this->widths = NULL; + this->bbox = NULL; + this->ideographic = 0; + this->alphabetic = 0; + this->mathematical = 0; + this->hanging = 0; + this->v_ideographic = 0; + this->v_alphabetic = 0; + this->v_mathematical = 0; + this->v_hanging = 0; + this->underline_position = 0; + this->underline_thickness = 0; + this->strikethrough_position = 0; + this->strikethrough_thickness = 0; + this->overline_position = 0; + this->overline_thickness = 0; } -static void sp_fontface_init(SPFontFace *face) -{ - new (face) SPFontFace(); +SPFontFace::~SPFontFace() { } - -void CFontFace::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFontFace::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPFontFace* object = this->spfontface; + SPFontFace* object = this; object->readAttr( "font-family" ); object->readAttr( "font-style" ); @@ -396,8 +374,8 @@ static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/) /** * Callback for child_added event. */ -void CFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPFontFace* object = this->spfontface; +void SPFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + SPFontFace* object = this; SPFontFace *f = SP_FONTFACE(object); @@ -411,8 +389,8 @@ void CFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref /** * Callback for remove_child event. */ -void CFontFace::remove_child(Inkscape::XML::Node *child) { - SPFontFace* object = this->spfontface; +void SPFontFace::remove_child(Inkscape::XML::Node *child) { + SPFontFace* object = this; SPFontFace *f = SP_FONTFACE(object); @@ -422,12 +400,12 @@ void CFontFace::remove_child(Inkscape::XML::Node *child) { object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } -void CFontFace::release() { +void SPFontFace::release() { CObject::release(); } -void CFontFace::set(unsigned int key, const gchar *value) { - SPFontFace* object = this->spfontface; +void SPFontFace::set(unsigned int key, const gchar *value) { + SPFontFace* object = this; SPFontFace *face = SP_FONTFACE(object); std::vector<FontFaceStyleType> style; @@ -719,8 +697,8 @@ void CFontFace::set(unsigned int key, const gchar *value) { /** * Receives update notifications. */ -void CFontFace::update(SPCtx *ctx, guint flags) { - SPFontFace* object = this->spfontface; +void SPFontFace::update(SPCtx *ctx, guint flags) { + SPFontFace* object = this; if (flags & (SP_OBJECT_MODIFIED_FLAG)) { object->readAttr( "font-family" ); @@ -763,8 +741,8 @@ void CFontFace::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CFontFace::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPFontFace* object = this->spfontface; +Inkscape::XML::Node* SPFontFace::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPFontFace* object = this; SPFontFace *face = SP_FONTFACE(object); diff --git a/src/sp-font-face.h b/src/sp-font-face.h index 7770ec4c1..cf77f1a73 100644 --- a/src/sp-font-face.h +++ b/src/sp-font-face.h @@ -24,11 +24,8 @@ #include "sp-object.h" -G_BEGIN_DECLS - -#define SP_TYPE_FONTFACE (sp_fontface_get_type ()) #define SP_FONTFACE(obj) ((SPFontFace*)obj) -#define SP_IS_FONTFACE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFontFace))) +#define SP_IS_FONTFACE(obj) (dynamic_cast<const SPFontFace*>((SPObject*)obj)) enum FontFaceStyleType{ SP_FONTFACE_STYLE_ALL, @@ -74,12 +71,10 @@ enum FontFaceUnicodeRangeType{ FONTFACE_UNICODERANGE_FIXME_HERE, }; -class CFontFace; - -class SPFontFace : public SPObject { +class SPFontFace : public SPObject, public CObject { public: SPFontFace(); - CFontFace* cfontface; + virtual ~SPFontFace(); char* font_family; std::vector<FontFaceStyleType> font_style; @@ -114,12 +109,6 @@ public: double strikethrough_thickness; double overline_position; double overline_thickness; -}; - -class CFontFace : public CObject { -public: - CFontFace(SPFontFace* face); - virtual ~CFontFace(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -132,17 +121,6 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPFontFace* spfontface; -}; - -struct SPFontFaceClass { - SPObjectClass parent_class; }; -GType sp_fontface_get_type (void); - -G_END_DECLS - #endif //#ifndef __SP_FONTFACE_H__ diff --git a/src/sp-font.cpp b/src/sp-font.cpp index ed91dc6e7..3a8997820 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -33,12 +33,6 @@ namespace { bool fontRegistered = SPFactory::instance().registerObject("svg:font", createFont); } -G_DEFINE_TYPE(SPFont, sp_font, G_TYPE_OBJECT); - -static void sp_font_class_init(SPFontClass *fc) -{ -} - //I think we should have extra stuff here and in the set method in order to set default value as specified at http://www.w3.org/TR/SVG/fonts.html // TODO determine better values and/or make these dynamic: @@ -46,39 +40,25 @@ double FNT_DEFAULT_ADV = 90; // TODO determine proper default double FNT_DEFAULT_ASCENT = 90; // TODO determine proper default double FNT_UNITS_PER_EM = 90; // TODO determine proper default -CFont::CFont(SPFont* font) : CObject(font) { - this->spfont = font; -} +SPFont::SPFont() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -CFont::~CFont() { + this->horiz_origin_x = 0; + this->horiz_origin_y = 0; + this->horiz_adv_x = FNT_DEFAULT_ADV; + this->vert_origin_x = FNT_DEFAULT_ADV / 2.0; + this->vert_origin_y = FNT_DEFAULT_ASCENT; + this->vert_adv_y = FNT_UNITS_PER_EM; } -SPFont::SPFont() : SPObject() { - SPFont* font = this; - - font->cfont = new CFont(font); - font->typeHierarchy.insert(typeid(SPFont)); - - delete font->cobject; - font->cobject = font->cfont; - - font->horiz_origin_x = 0; - font->horiz_origin_y = 0; - font->horiz_adv_x = FNT_DEFAULT_ADV; - font->vert_origin_x = FNT_DEFAULT_ADV / 2.0; - font->vert_origin_y = FNT_DEFAULT_ASCENT; - font->vert_adv_y = FNT_UNITS_PER_EM; -} - -static void sp_font_init(SPFont *font) -{ - new (font) SPFont(); +SPFont::~SPFont() { } -void CFont::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFont::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPFont* object = this->spfont; + SPFont* object = this; object->readAttr( "horiz-origin-x" ); object->readAttr( "horiz-origin-y" ); @@ -97,8 +77,8 @@ static void sp_font_children_modified(SPFont */*sp_font*/) /** * Callback for child_added event. */ -void CFont::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPFont* object = this->spfont; +void SPFont::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + SPFont* object = this; SPFont *f = SP_FONT(object); CObject::child_added(child, ref); @@ -110,8 +90,8 @@ void CFont::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { /** * Callback for remove_child event. */ -void CFont::remove_child(Inkscape::XML::Node* child) { - SPFont* object = this->spfont; +void SPFont::remove_child(Inkscape::XML::Node* child) { + SPFont* object = this; SPFont *f = SP_FONT(object); CObject::remove_child(child); @@ -120,17 +100,17 @@ void CFont::remove_child(Inkscape::XML::Node* child) { object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } -void CFont::release() { +void SPFont::release() { //SPFont *font = SP_FONT(object); - SPFont* object = this->spfont; + SPFont* object = this; object->document->removeResource("font", object); CObject::release(); } -void CFont::set(unsigned int key, const gchar *value) { - SPFont* object = this->spfont; +void SPFont::set(unsigned int key, const gchar *value) { + SPFont* object = this; SPFont *font = SP_FONT(object); // TODO these are floating point, so some epsilon comparison would be good @@ -198,8 +178,8 @@ void CFont::set(unsigned int key, const gchar *value) { /** * Receives update notifications. */ -void CFont::update(SPCtx *ctx, guint flags) { - SPFont* object = this->spfont; +void SPFont::update(SPCtx *ctx, guint flags) { + SPFont* object = this; if (flags & (SP_OBJECT_MODIFIED_FLAG)) { object->readAttr( "horiz-origin-x" ); @@ -215,8 +195,8 @@ void CFont::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CFont::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPFont* object = this->spfont; +Inkscape::XML::Node* SPFont::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPFont* object = this; SPFont *font = SP_FONT(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { diff --git a/src/sp-font.h b/src/sp-font.h index 768104e91..26718e187 100644 --- a/src/sp-font.h +++ b/src/sp-font.h @@ -18,16 +18,13 @@ #include "sp-object.h" -#define SP_TYPE_FONT (sp_font_get_type ()) #define SP_FONT(obj) ((SPFont*)obj) -#define SP_IS_FONT(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFont))) +#define SP_IS_FONT(obj) (dynamic_cast<const SPFont*>((SPObject*)obj)) -class CFont; - -class SPFont : public SPObject { +class SPFont : public SPObject, public CObject { public: SPFont(); - CFont* cfont; + virtual ~SPFont(); double horiz_origin_x; double horiz_origin_y; @@ -35,12 +32,6 @@ public: double vert_origin_x; double vert_origin_y; double vert_adv_y; -}; - -class CFont : public CObject { -public: - CFont(SPFont* font); - virtual ~CFont(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -53,15 +44,6 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPFont* spfont; -}; - -struct SPFontClass { - SPObjectClass parent_class; }; -GType sp_font_get_type (void); - #endif //#ifndef SP_FONT_H_SEEN diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index f8aa8d213..c0d408d30 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -25,93 +25,24 @@ #include <string> #include <cstring> -static void sp_glyph_kerning_class_init(SPGlyphKerningClass *gc); -static void sp_glyph_kerning_init(SPGlyphKerning *glyph); -static SPObjectClass *parent_class; - -GType sp_glyph_kerning_h_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPGlyphKerningClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - 0, //(GClassInitFunc) sp_glyph_kerning_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPHkern), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_glyph_kerning_init, - NULL, /* value_table */ - }; - type = g_type_register_static(G_TYPE_OBJECT, "SPHkern", &info, (GTypeFlags) 0); - } - - return type; -} - -GType sp_glyph_kerning_v_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPGlyphKerningClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - 0, //(GClassInitFunc) sp_glyph_kerning_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPVkern), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_glyph_kerning_init, - NULL, /* value_table */ - }; - type = g_type_register_static(G_TYPE_OBJECT, "SPVkern", &info, (GTypeFlags) 0); - } - - return type; -} - -static void sp_glyph_kerning_class_init(SPGlyphKerningClass *gc) -{ - parent_class = (SPObjectClass*)g_type_class_peek_parent(gc); -} - -CGlyphKerning::CGlyphKerning(SPGlyphKerning* kerning) : CObject(kerning) { - this->spglyphkerning = kerning; -} - -CGlyphKerning::~CGlyphKerning() { -} - -SPGlyphKerning::SPGlyphKerning() : SPObject() { - SPGlyphKerning* glyph = this; - - glyph->cglyphkerning = new CGlyphKerning(glyph); - glyph->typeHierarchy.insert(typeid(SPGlyphKerning)); - - delete glyph->cobject; - glyph->cobject = glyph->cglyphkerning; +SPGlyphKerning::SPGlyphKerning() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; //TODO: correct these values: - glyph->u1 = NULL; - glyph->g1 = NULL; - glyph->u2 = NULL; - glyph->g2 = NULL; - glyph->k = 0; + this->u1 = NULL; + this->g1 = NULL; + this->u2 = NULL; + this->g2 = NULL; + this->k = 0; } -static void sp_glyph_kerning_init(SPGlyphKerning *glyph) -{ - new (glyph) SPGlyphKerning(); +SPGlyphKerning::~SPGlyphKerning() { } -void CGlyphKerning::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPGlyphKerning* object = this->spglyphkerning; +void SPGlyphKerning::build(SPDocument *document, Inkscape::XML::Node *repr) { + SPGlyphKerning* object = this; CObject::build(document, repr); @@ -122,7 +53,7 @@ void CGlyphKerning::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "k" ); } -void CGlyphKerning::release() { +void SPGlyphKerning::release() { CObject::release(); } @@ -145,8 +76,8 @@ bool GlyphNames::contains(const char* name){ return false; } -void CGlyphKerning::set(unsigned int key, const gchar *value) { - SPGlyphKerning* object = this->spglyphkerning; +void SPGlyphKerning::set(unsigned int key, const gchar *value) { + SPGlyphKerning* object = this; SPGlyphKerning * glyphkern = (SPGlyphKerning*) object; //even if it is a VKern this will work. I did it this way just to avoind warnings. @@ -207,8 +138,8 @@ void CGlyphKerning::set(unsigned int key, const gchar *value) { /** * * Receives update notifications. * */ -void CGlyphKerning::update(SPCtx *ctx, guint flags) { - SPGlyphKerning* object = this->spglyphkerning; +void SPGlyphKerning::update(SPCtx *ctx, guint flags) { + SPGlyphKerning* object = this; SPGlyphKerning *glyph = (SPGlyphKerning *)object; (void)glyph; @@ -226,8 +157,8 @@ void CGlyphKerning::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CGlyphKerning::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPGlyphKerning* object = this->spglyphkerning; +Inkscape::XML::Node* SPGlyphKerning::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPGlyphKerning* object = this; // SPGlyphKerning *glyph = SP_GLYPH_KERNING(object); diff --git a/src/sp-glyph-kerning.h b/src/sp-glyph-kerning.h index 08882f236..2a2eb1763 100644 --- a/src/sp-glyph-kerning.h +++ b/src/sp-glyph-kerning.h @@ -19,23 +19,21 @@ #include "sp-object.h" #include "unicoderange.h" -#define SP_TYPE_HKERN (sp_glyph_kerning_h_get_type ()) //#define SP_HKERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_HKERN, SPHkern)) //#define SP_HKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_HKERN, SPGlyphKerningClass)) //#define SP_IS_HKERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_HKERN)) //#define SP_IS_HKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_HKERN)) #define SP_HKERN(obj) ((SPHkern*)obj) -#define SP_IS_HKERN(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPHkern))) +#define SP_IS_HKERN(obj) (dynamic_cast<const SPHkern*>((SPObject*)obj)) -#define SP_TYPE_VKERN (sp_glyph_kerning_v_get_type ()) //#define SP_VKERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_VKERN, SPVkern)) //#define SP_VKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_VKERN, SPGlyphKerningClass)) //#define SP_IS_VKERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_VKERN)) //#define SP_IS_VKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_VKERN)) #define SP_VKERN(obj) ((SPVkern*)obj) -#define SP_IS_VKERN(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPVkern))) +#define SP_IS_VKERN(obj) (dynamic_cast<const SPVkern*>((SPObject*)obj)) // CPPIFY: These casting macros are buggy, as Vkern and Hkern aren't "real" classes. @@ -48,25 +46,16 @@ private: gchar* names; }; - -class CGlyphKerning; - -class SPGlyphKerning : public SPObject { +class SPGlyphKerning : public SPObject, public CObject { public: SPGlyphKerning(); - CGlyphKerning* cglyphkerning; + virtual ~SPGlyphKerning(); UnicodeRange* u1; GlyphNames* g1; UnicodeRange* u2; GlyphNames* g2; double k; -}; - -class CGlyphKerning : public CObject { -public: - CGlyphKerning(SPGlyphKerning* kerning); - virtual ~CGlyphKerning(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -76,9 +65,6 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPGlyphKerning* spglyphkerning; }; class SPHkern : public SPGlyphKerning { @@ -89,11 +75,4 @@ class SPVkern : public SPGlyphKerning { }; -struct SPGlyphKerningClass { - SPObjectClass parent_class; -}; - -GType sp_glyph_kerning_h_get_type (void); -GType sp_glyph_kerning_v_get_type (void); - #endif //#ifndef __SP_GLYPH_KERNING_H__ diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 85c7beb4f..6acef4db9 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -32,51 +32,31 @@ namespace { bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); } -G_DEFINE_TYPE(SPGlyph, sp_glyph, G_TYPE_OBJECT); - -static void sp_glyph_class_init(SPGlyphClass *gc) -{ -} - -CGlyph::CGlyph(SPGlyph* glyph) : CObject(glyph) { - this->spglyph = glyph; -} - -CGlyph::~CGlyph() { -} - -SPGlyph::SPGlyph() : SPObject() { - SPGlyph* glyph = this; - - glyph->cglyph = new CGlyph(glyph); - glyph->typeHierarchy.insert(typeid(SPGlyph)); - - delete glyph->cobject; - glyph->cobject = glyph->cglyph; +SPGlyph::SPGlyph() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; //TODO: correct these values: - new (&glyph->unicode) Glib::ustring(); - new (&glyph->glyph_name) Glib::ustring(); - glyph->d = NULL; - glyph->orientation = GLYPH_ORIENTATION_BOTH; - glyph->arabic_form = GLYPH_ARABIC_FORM_INITIAL; - glyph->lang = NULL; - glyph->horiz_adv_x = 0; - glyph->vert_origin_x = 0; - glyph->vert_origin_y = 0; - glyph->vert_adv_y = 0; + new (&this->unicode) Glib::ustring(); + new (&this->glyph_name) Glib::ustring(); + this->d = NULL; + this->orientation = GLYPH_ORIENTATION_BOTH; + this->arabic_form = GLYPH_ARABIC_FORM_INITIAL; + this->lang = NULL; + this->horiz_adv_x = 0; + this->vert_origin_x = 0; + this->vert_origin_y = 0; + this->vert_adv_y = 0; } -static void sp_glyph_init(SPGlyph *glyph) -{ - new (glyph) SPGlyph(); +SPGlyph::~SPGlyph() { } -void CGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPGlyph* object = this->spglyph; + SPGlyph* object = this; object->readAttr( "unicode" ); object->readAttr( "glyph-name" ); @@ -90,7 +70,7 @@ void CGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "vert-adv-y" ); } -void CGlyph::release() { +void SPGlyph::release() { CObject::release(); } @@ -125,8 +105,8 @@ static glyphOrientation sp_glyph_read_orientation(gchar const *value){ return GLYPH_ORIENTATION_BOTH; } -void CGlyph::set(unsigned int key, const gchar *value) { - SPGlyph* object = this->spglyph; +void SPGlyph::set(unsigned int key, const gchar *value) { + SPGlyph* object = this; SPGlyph *glyph = SP_GLYPH(object); @@ -224,8 +204,8 @@ void CGlyph::set(unsigned int key, const gchar *value) { /** * * Receives update notifications. * */ -void CGlyph::update(SPCtx *ctx, guint flags) { - SPGlyph* object = this->spglyph; +void SPGlyph::update(SPCtx *ctx, guint flags) { + SPGlyph* object = this; SPGlyph *glyph = SP_GLYPH(object); (void)glyph; @@ -249,8 +229,8 @@ void CGlyph::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPGlyph* object = this->spglyph; +Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPGlyph* object = this; // SPGlyph *glyph = SP_GLYPH(object); diff --git a/src/sp-glyph.h b/src/sp-glyph.h index affa7b6f0..5ac0b4707 100644 --- a/src/sp-glyph.h +++ b/src/sp-glyph.h @@ -18,9 +18,8 @@ #include "sp-object.h" -#define SP_TYPE_GLYPH (sp_glyph_get_type ()) #define SP_GLYPH(obj) ((SPGlyph*)obj) -#define SP_IS_GLYPH(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPGlyph))) +#define SP_IS_GLYPH(obj) (dynamic_cast<const SPGlyph*>((SPObject*)obj)) enum glyphArabicForm { GLYPH_ARABIC_FORM_INITIAL, @@ -35,12 +34,10 @@ enum glyphOrientation { GLYPH_ORIENTATION_BOTH }; -class CGlyph; - -class SPGlyph : public SPObject { +class SPGlyph : public SPObject, public CObject { public: SPGlyph(); - CGlyph* cglyph; + virtual ~SPGlyph(); Glib::ustring unicode; Glib::ustring glyph_name; @@ -52,12 +49,6 @@ public: double vert_origin_x; double vert_origin_y; double vert_adv_y; -}; - -class CGlyph : public CObject { -public: - CGlyph(SPGlyph* glyph); - virtual ~CGlyph(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -67,15 +58,6 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -private: - SPGlyph* spglyph; -}; - -struct SPGlyphClass { - SPObjectClass parent_class; }; -GType sp_glyph_get_type (void); - #endif //#ifndef __SP_GLYPH_H__ diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 3e3bc257b..970ba25ba 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -66,60 +66,45 @@ namespace { bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide); } -G_DEFINE_TYPE(SPGuide, sp_guide, G_TYPE_OBJECT); - -static void sp_guide_class_init(SPGuideClass *gc) -{ - GObjectClass *gobject_class = (GObjectClass *) gc; - - gobject_class->set_property = sp_guide_set_property; - gobject_class->get_property = sp_guide_get_property; - - g_object_class_install_property(gobject_class, - PROP_COLOR, - g_param_spec_uint("color", "Color", "Color", - 0, - 0xffffffff, - 0xff000000, - (GParamFlags) G_PARAM_READWRITE)); - - g_object_class_install_property(gobject_class, - PROP_HICOLOR, - g_param_spec_uint("hicolor", "HiColor", "HiColor", - 0, - 0xffffffff, - 0xff000000, - (GParamFlags) G_PARAM_READWRITE)); -} - -CGuide::CGuide(SPGuide* guide) : CObject(guide) { - this->spguide = guide; +//static void sp_guide_class_init(SPGuideClass *gc) +//{ +// GObjectClass *gobject_class = (GObjectClass *) gc; +// +// gobject_class->set_property = sp_guide_set_property; +// gobject_class->get_property = sp_guide_get_property; +// +// g_object_class_install_property(gobject_class, +// PROP_COLOR, +// g_param_spec_uint("color", "Color", "Color", +// 0, +// 0xffffffff, +// 0xff000000, +// (GParamFlags) G_PARAM_READWRITE)); +// +// g_object_class_install_property(gobject_class, +// PROP_HICOLOR, +// g_param_spec_uint("hicolor", "HiColor", "HiColor", +// 0, +// 0xffffffff, +// 0xff000000, +// (GParamFlags) G_PARAM_READWRITE)); +//} +// CPPIFY: properties! + +SPGuide::SPGuide() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; + + this->label = NULL; + this->views = NULL; + + this->normal_to_line = Geom::Point(0.,1.); + this->point_on_line = Geom::Point(0.,0.); + this->color = 0x0000ff7f; + this->hicolor = 0xff00007f; } -CGuide::~CGuide() { -} - -SPGuide::SPGuide() : SPObject() { - SPGuide* guide = this; - - guide->cguide = new CGuide(guide); - guide->typeHierarchy.insert(typeid(SPGuide)); - - delete guide->cobject; - guide->cobject = guide->cguide; - - guide->label = NULL; - guide->views = NULL; - - guide->normal_to_line = Geom::Point(0.,1.); - guide->point_on_line = Geom::Point(0.,0.); - guide->color = 0x0000ff7f; - guide->hicolor = 0xff00007f; -} - -static void sp_guide_init(SPGuide *guide) -{ - new (guide) SPGuide(); +SPGuide::~SPGuide() { } static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/) @@ -154,10 +139,10 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, } } -void CGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPGuide* object = this->spguide; + SPGuide* object = this; object->readAttr( "inkscape:label" ); object->readAttr( "orientation" ); @@ -167,8 +152,8 @@ void CGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { document->addResource("guide", object); } -void CGuide::release() { - SPGuide* object = this->spguide; +void SPGuide::release() { + SPGuide* object = this; SPGuide *guide = (SPGuide *) object; while (guide->views) { @@ -184,8 +169,8 @@ void CGuide::release() { CObject::release(); } -void CGuide::set(unsigned int key, const gchar *value) { - SPGuide* object = this->spguide; +void SPGuide::set(unsigned int key, const gchar *value) { + SPGuide* object = this; SPGuide *guide = SP_GUIDE(object); switch (key) { diff --git a/src/sp-guide.h b/src/sp-guide.h index 41837a872..30a9b8b75 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -23,19 +23,14 @@ struct SPCanvas; struct SPCanvasGroup; class SPDesktop; -G_BEGIN_DECLS - -#define SP_TYPE_GUIDE (sp_guide_get_type()) #define SP_GUIDE(obj) ((SPGuide*)obj) -#define SP_IS_GUIDE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPGuide))) - -class CGuide; +#define SP_IS_GUIDE(obj) (dynamic_cast<const SPGuide*>((SPObject*)obj)) /* Represents the constraint on p that dot(g.direction, p) == g.position. */ -class SPGuide : public SPObject { +class SPGuide : public SPObject, public CObject { public: SPGuide(); - CGuide* cguide; + virtual ~SPGuide(); char* label; Geom::Point normal_to_line; @@ -55,29 +50,12 @@ public: void sensitize(SPCanvas *canvas, gboolean sensitive); Geom::Point getPositionFrom(Geom::Point const &pt) const; double getDistanceFrom(Geom::Point const &pt) const; -}; - -class CGuide : public CObject { -public: - CGuide(SPGuide* guide); - virtual ~CGuide(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); virtual void set(unsigned int key, const gchar* value); - -private: - SPGuide* spguide; }; - -class SPGuideClass { -public: - SPObjectClass parent_class; -}; - -GType sp_guide_get_type(); - void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts); void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_delete_all_guides(SPDesktop *dt); @@ -90,8 +68,6 @@ void sp_guide_remove(SPGuide *guide); char *sp_guide_description(SPGuide const *guide, const bool verbose = true); -G_END_DECLS - #endif // SEEN_SP_GUIDE_H /* diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index 12973191f..22fbc320a 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -43,37 +43,15 @@ namespace { bool metadataRegistered = SPFactory::instance().registerObject("svg:metadata", createMetadata); } -G_DEFINE_TYPE(SPMetadata, sp_metadata, G_TYPE_OBJECT); +SPMetadata::SPMetadata() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -static void -sp_metadata_class_init (SPMetadataClass *klass) -{ -} - -CMetadata::CMetadata(SPMetadata* metadata) : CObject(metadata) { - this->spmetadata = metadata; -} - -CMetadata::~CMetadata() { -} - -SPMetadata::SPMetadata() : SPObject() { - SPMetadata* metadata = this; - - metadata->cmetadata = new CMetadata(metadata); - metadata->typeHierarchy.insert(typeid(SPMetadata)); - - delete metadata->cobject; - metadata->cobject = metadata->cmetadata; - - (void)metadata; - debug("0x%08x",(unsigned int)metadata); + (void)this; + debug("0x%08x",(unsigned int)this); } -static void -sp_metadata_init (SPMetadata *metadata) -{ - new (metadata) SPMetadata(); +SPMetadata::~SPMetadata() { } namespace { @@ -91,7 +69,7 @@ void strip_ids_recursively(Inkscape::XML::Node *node) { } -void CMetadata::build(SPDocument* doc, Inkscape::XML::Node* repr) { +void SPMetadata::build(SPDocument* doc, Inkscape::XML::Node* repr) { using Inkscape::XML::NodeSiblingIterator; debug("0x%08x",(unsigned int)object); @@ -107,7 +85,8 @@ void CMetadata::build(SPDocument* doc, Inkscape::XML::Node* repr) { CObject::build(doc, repr); } -void CMetadata::release() { + +void SPMetadata::release() { debug("0x%08x",(unsigned int)object); // handle ourself @@ -115,7 +94,7 @@ void CMetadata::release() { CObject::release(); } -void CMetadata::set(unsigned int key, const gchar* value) { +void SPMetadata::set(unsigned int key, const gchar* value) { debug("0x%08x %s(%u): '%s'",(unsigned int)object, sp_attribute_name(key),key,value); @@ -123,7 +102,7 @@ void CMetadata::set(unsigned int key, const gchar* value) { CObject::set(key, value); } -void CMetadata::update(SPCtx* ctx, unsigned int flags) { +void SPMetadata::update(SPCtx* ctx, unsigned int flags) { debug("0x%08x",(unsigned int)object); //SPMetadata *metadata = SP_METADATA(object); @@ -137,8 +116,8 @@ void CMetadata::update(SPCtx* ctx, unsigned int flags) { // CObject::onUpdate(ctx, flags); } -Inkscape::XML::Node* CMetadata::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { - SPMetadata* object = this->spmetadata; +Inkscape::XML::Node* SPMetadata::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { + SPMetadata* object = this; debug("0x%08x",(unsigned int)object); //SPMetadata *metadata = SP_METADATA(object); diff --git a/src/sp-metadata.h b/src/sp-metadata.h index c0ec753cb..8857e1645 100644 --- a/src/sp-metadata.h +++ b/src/sp-metadata.h @@ -17,27 +17,13 @@ /* Metadata base class */ -#define SP_TYPE_METADATA (sp_metadata_get_type ()) #define SP_METADATA(obj) ((SPMetadata*)obj) -#define SP_IS_METADATA(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPMetadata))) +#define SP_IS_METADATA(obj) (dynamic_cast<const SPMetadata*>((SPObject*)obj)) -class CMetadata; - -class SPMetadata : public SPObject { +class SPMetadata : public SPObject, public CObject { public: SPMetadata(); - CMetadata* cmetadata; -}; - -struct SPMetadataClass { - SPObjectClass parent_class; -}; - - -class CMetadata : public CObject { -public: - CMetadata(SPMetadata* metadata); - virtual ~CMetadata(); + virtual ~SPMetadata(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -45,14 +31,8 @@ public: virtual void set(unsigned int key, const gchar* value); virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -protected: - SPMetadata* spmetadata; }; - -GType sp_metadata_get_type (void); - SPMetadata * sp_document_metadata (SPDocument *document); #endif diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index 1a67a49ad..ef9843cea 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -29,43 +29,23 @@ namespace { bool missingGlyphRegistered = SPFactory::instance().registerObject("svg:missing-glyph", createMissingGlyph); } -G_DEFINE_TYPE(SPMissingGlyph, sp_missing_glyph, G_TYPE_OBJECT); - -static void sp_missing_glyph_class_init(SPMissingGlyphClass *gc) -{ -} - -CMissingGlyph::CMissingGlyph(SPMissingGlyph* mg) : CObject(mg) { - this->spmissingglyph = mg; -} - -CMissingGlyph::~CMissingGlyph() { -} - -SPMissingGlyph::SPMissingGlyph() : SPObject() { - SPMissingGlyph* glyph = this; - - glyph->cmissingglyph = new CMissingGlyph(glyph); - glyph->typeHierarchy.insert(typeid(SPMissingGlyph)); - - delete glyph->cobject; - glyph->cobject = glyph->cmissingglyph; +SPMissingGlyph::SPMissingGlyph() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; //TODO: correct these values: - glyph->d = NULL; - glyph->horiz_adv_x = 0; - glyph->vert_origin_x = 0; - glyph->vert_origin_y = 0; - glyph->vert_adv_y = 0; + this->d = NULL; + this->horiz_adv_x = 0; + this->vert_origin_x = 0; + this->vert_origin_y = 0; + this->vert_adv_y = 0; } -static void sp_missing_glyph_init(SPMissingGlyph *glyph) -{ - new (glyph) SPMissingGlyph(); +SPMissingGlyph::~SPMissingGlyph() { } -void CMissingGlyph::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPMissingGlyph* object = this->spmissingglyph; +void SPMissingGlyph::build(SPDocument* doc, Inkscape::XML::Node* repr) { + SPMissingGlyph* object = this; CObject::build(doc, repr); @@ -76,13 +56,13 @@ void CMissingGlyph::build(SPDocument* doc, Inkscape::XML::Node* repr) { object->readAttr( "vert-adv-y" ); } -void CMissingGlyph::release() { +void SPMissingGlyph::release() { CObject::release(); } -void CMissingGlyph::set(unsigned int key, const gchar* value) { - SPMissingGlyph* object = this->spmissingglyph; +void SPMissingGlyph::set(unsigned int key, const gchar* value) { + SPMissingGlyph* object = this; SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); @@ -142,8 +122,8 @@ void CMissingGlyph::set(unsigned int key, const gchar* value) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CMissingGlyph::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { - SPMissingGlyph* object = this->spmissingglyph; +Inkscape::XML::Node* SPMissingGlyph::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { + SPMissingGlyph* object = this; // SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); diff --git a/src/sp-missing-glyph.h b/src/sp-missing-glyph.h index 3a4bab9fe..513adf464 100644 --- a/src/sp-missing-glyph.h +++ b/src/sp-missing-glyph.h @@ -18,44 +18,24 @@ #include "sp-object.h" -#define SP_TYPE_MISSING_GLYPH (sp_missing_glyph_get_type ()) #define SP_MISSING_GLYPH(obj) ((SPMissingGlyph*)obj) -#define SP_IS_MISSING_GLYPH(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPMissingGlyph))) +#define SP_IS_MISSING_GLYPH(obj) (dynamic_cast<const SPMissingGlyph*>((SPObject*)obj)) -class CMissingGlyph; - -class SPMissingGlyph : public SPObject { +class SPMissingGlyph : public SPObject, public CObject { public: SPMissingGlyph(); - CMissingGlyph* cmissingglyph; + virtual ~SPMissingGlyph(); char* d; double horiz_adv_x; double vert_origin_x; double vert_origin_y; double vert_adv_y; -}; - -struct SPMissingGlyphClass { - SPObjectClass parent_class; -}; - -class CMissingGlyph : public CObject { -public: - CMissingGlyph(SPMissingGlyph* mg); - virtual ~CMissingGlyph(); - - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); virtual void set(unsigned int key, const gchar* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -protected: - SPMissingGlyph* spmissingglyph; }; - -GType sp_missing_glyph_get_type (void); - #endif //#ifndef __SP_MISSING_GLYPH_H__ diff --git a/src/sp-script.cpp b/src/sp-script.cpp index 5d706a17e..e0cae1ea5 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -26,38 +26,18 @@ namespace { bool scriptRegistered = SPFactory::instance().registerObject("svg:script", createScript); } -G_DEFINE_TYPE(SPScript, sp_script, G_TYPE_OBJECT); +SPScript::SPScript() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -static void sp_script_class_init(SPScriptClass *sc) -{ + this->xlinkhref = NULL; } -CScript::CScript(SPScript* script) : CObject(script) { - this->spscript = script; +SPScript::~SPScript() { } -CScript::~CScript() { -} - -SPScript::SPScript() : SPObject() { - SPScript* script = this; - - script->cscript = new CScript(script); - script->typeHierarchy.insert(typeid(SPScript)); - - delete script->cobject; - script->cobject = script->cscript; - - script->xlinkhref = NULL; -} - -static void sp_script_init(SPScript *script) -{ - new (script) SPScript(); -} - -void CScript::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPScript* object = this->spscript; +void SPScript::build(SPDocument* doc, Inkscape::XML::Node* repr) { + SPScript* object = this; CObject::build(doc, repr); @@ -73,8 +53,8 @@ void CScript::build(SPDocument* doc, Inkscape::XML::Node* repr) { * sp-object-repr.cpp's repr_name_entries array. */ -void CScript::release() { - SPScript* object = this->spscript; +void SPScript::release() { + SPScript* object = this; if (object->document) { // Unregister ourselves @@ -84,16 +64,16 @@ void CScript::release() { CObject::release(); } -void CScript::update(SPCtx* ctx, unsigned int flags) { +void SPScript::update(SPCtx* ctx, unsigned int flags) { } -void CScript::modified(unsigned int flags) { +void SPScript::modified(unsigned int flags) { } -void CScript::set(unsigned int key, const gchar* value) { - SPScript* object = this->spscript; +void SPScript::set(unsigned int key, const gchar* value) { + SPScript* object = this; SPScript *scr = SP_SCRIPT(object); @@ -109,7 +89,7 @@ void CScript::set(unsigned int key, const gchar* value) { } } -Inkscape::XML::Node* CScript::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { +Inkscape::XML::Node* SPScript::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { return repr; } diff --git a/src/sp-script.h b/src/sp-script.h index 5bb7bfbc6..8194cb48a 100644 --- a/src/sp-script.h +++ b/src/sp-script.h @@ -14,31 +14,16 @@ #include "sp-item.h" -#define SP_TYPE_SCRIPT (sp_script_get_type()) #define SP_SCRIPT(obj) ((SPScript*)obj) -#define SP_IS_SCRIPT(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPScript))) +#define SP_IS_SCRIPT(obj) (dynamic_cast<const SPScript*>((SPObject*)obj)) /* SPScript */ - -class CScript; - -class SPScript : public SPObject { +class SPScript : public SPObject, public CObject { public: SPScript(); - CScript* cscript; + virtual ~SPScript(); gchar *xlinkhref; -}; - -struct SPScriptClass { - SPObjectClass parent_class; -}; - - -class CScript : public CObject { -public: - CScript(SPScript* script); - virtual ~CScript(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -46,14 +31,8 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -protected: - SPScript* spscript; }; - -GType sp_script_get_type(); - #endif /* diff --git a/src/sp-string.cpp b/src/sp-string.cpp index 29679b93a..a5df0c726 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -46,47 +46,25 @@ namespace { # SPSTRING #####################################################*/ -G_DEFINE_TYPE(SPString, sp_string, G_TYPE_OBJECT); +SPString::SPString() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -static void -sp_string_class_init(SPStringClass *classname) -{ + new (&this->string) Glib::ustring(); } -CString::CString(SPString* str) : CObject(str) { - this->spstring = str; +SPString::~SPString() { } -CString::~CString() { -} - -SPString::SPString() : SPObject() { - SPString* string = this; - - string->cstring = new CString(string); - string->typeHierarchy.insert(typeid(SPString)); - - delete string->cobject; - string->cobject = string->cstring; - - new (&string->string) Glib::ustring(); -} - -static void -sp_string_init(SPString *string) -{ - new (string) SPString(); -} - -void CString::build(SPDocument *doc, Inkscape::XML::Node *repr) { - SPString* object = this->spstring; - object->cstring->read_content(); +void SPString::build(SPDocument *doc, Inkscape::XML::Node *repr) { + SPString* object = this; + object->read_content(); CObject::build(doc, repr); } -void CString::release() { - SPString* object = this->spstring; +void SPString::release() { + SPString* object = this; SPString *string = SP_STRING(object); string->string.~ustring(); @@ -95,8 +73,8 @@ void CString::release() { } -void CString::read_content() { - SPString* object = this->spstring; +void SPString::read_content() { + SPString* object = this; SPString *string = SP_STRING(object); @@ -138,7 +116,7 @@ void CString::read_content() { object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -void CString::update(SPCtx *ctx, unsigned flags) { +void SPString::update(SPCtx *ctx, unsigned flags) { // CObject::onUpdate(ctx, flags); if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG)) { diff --git a/src/sp-string.h b/src/sp-string.h index 64b19e950..2aa1d98cb 100644 --- a/src/sp-string.h +++ b/src/sp-string.h @@ -10,29 +10,15 @@ #include "sp-object.h" -#define SP_TYPE_STRING (sp_string_get_type ()) #define SP_STRING(obj) ((SPString*)obj) -#define SP_IS_STRING(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPString))) +#define SP_IS_STRING(obj) (dynamic_cast<const SPString*>((SPObject*)obj)) -class CString; - -class SPString : public SPObject { +class SPString : public SPObject, public CObject { public: SPString(); - CString* cstring; + virtual ~SPString(); Glib::ustring string; -}; - -struct SPStringClass { - SPObjectClass parent_class; -}; - - -class CString : public CObject { -public: - CString(SPString* str); - virtual ~CString(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -40,12 +26,6 @@ public: virtual void read_content(); virtual void update(SPCtx* ctx, unsigned int flags); - -protected: - SPString* spstring; }; - -GType sp_string_get_type (); - #endif diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index e130b677b..16974ebce 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -17,41 +17,19 @@ namespace { bool styleRegistered = SPFactory::instance().registerObject("svg:style", createStyle); } -G_DEFINE_TYPE(SPStyleElem, sp_style_elem, G_TYPE_OBJECT); +SPStyleElem::SPStyleElem() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; -static void -sp_style_elem_class_init(SPStyleElemClass *klass) -{ -} - -CStyleElem::CStyleElem(SPStyleElem* se) : CObject(se) { - this->spstyleelem = se; + media_set_all(this->media); + this->is_css = false; } -CStyleElem::~CStyleElem() { -} - -SPStyleElem::SPStyleElem() : SPObject() { - SPStyleElem* style_elem = this; - - style_elem->cstyleelem = new CStyleElem(style_elem); - style_elem->typeHierarchy.insert(typeid(SPStyleElem)); - - delete style_elem->cobject; - style_elem->cobject = style_elem->cstyleelem; - - media_set_all(style_elem->media); - style_elem->is_css = false; -} - -static void -sp_style_elem_init(SPStyleElem *style_elem) -{ - new (style_elem) SPStyleElem(); +SPStyleElem::~SPStyleElem() { } -void CStyleElem::set(unsigned int key, const gchar* value) { - SPStyleElem* object = this->spstyleelem; +void SPStyleElem::set(unsigned int key, const gchar* value) { + SPStyleElem* object = this; g_return_if_fail(object); SPStyleElem &style_elem = *SP_STYLE_ELEM(object); @@ -110,8 +88,8 @@ child_order_changed_cb(Inkscape::XML::Node *, Inkscape::XML::Node *, static_cast<SPObject *>(data)->cobject->read_content(); } -Inkscape::XML::Node* CStyleElem::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { - SPStyleElem* object = this->spstyleelem; +Inkscape::XML::Node* SPStyleElem::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { + SPStyleElem* object = this; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:style"); @@ -287,8 +265,8 @@ property_cb(CRDocHandler *const a_handler, g_return_if_fail(append_status == CR_OK); } -void CStyleElem::read_content() { - SPStyleElem* object = this->spstyleelem; +void SPStyleElem::read_content() { + SPStyleElem* object = this; SPStyleElem &style_elem = *SP_STYLE_ELEM(object); @@ -375,10 +353,10 @@ rec_add_listener(Inkscape::XML::Node &repr, } } -void CStyleElem::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPStyleElem* object = this->spstyleelem; +void SPStyleElem::build(SPDocument *document, Inkscape::XML::Node *repr) { + SPStyleElem* object = this; - object->cstyleelem->read_content(); + object->read_content(); object->readAttr( "type" ); object->readAttr( "media" ); diff --git a/src/sp-style-elem.h b/src/sp-style-elem.h index 2cc9dcb53..7b55818dd 100644 --- a/src/sp-style-elem.h +++ b/src/sp-style-elem.h @@ -4,43 +4,24 @@ #include "sp-object.h" #include "media.h" -#define SP_TYPE_STYLE_ELEM (sp_style_elem_get_type()) #define SP_STYLE_ELEM(obj) ((SPStyleElem*)obj) -#define SP_IS_STYLE_ELEM(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPStyleElem))) +#define SP_IS_STYLE_ELEM(obj) (dynamic_cast<const SPStyleElem*>((SPObject*)obj)) -class CStyleElem; - -class SPStyleElem : public SPObject { +class SPStyleElem : public SPObject, public CObject { public: SPStyleElem(); - CStyleElem* cstyleelem; + virtual ~SPStyleElem(); Media media; bool is_css; -}; - -class SPStyleElemClass : public SPObjectClass { -}; - - -class CStyleElem : public CObject { -public: - CStyleElem(SPStyleElem* se); - virtual ~CStyleElem(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void set(unsigned int key, gchar const* value); virtual void read_content(); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - -protected: - SPStyleElem* spstyleelem; }; -GType sp_style_elem_get_type(); - - #endif /* !INKSCAPE_SP_STYLE_ELEM_H */ /* diff --git a/src/sp-title.cpp b/src/sp-title.cpp index 614d5033e..57c61f590 100644 --- a/src/sp-title.cpp +++ b/src/sp-title.cpp @@ -26,38 +26,16 @@ namespace { bool titleRegistered = SPFactory::instance().registerObject("svg:title", createTitle); } -G_DEFINE_TYPE(SPTitle, sp_title, G_TYPE_OBJECT); - -static void -sp_title_class_init(SPTitleClass *klass) -{ -} - -CTitle::CTitle(SPTitle* title) : CObject(title) { - this->sptitle = title; -} - -CTitle::~CTitle() { -} - -SPTitle::SPTitle() : SPObject() { - SPTitle* desc = this; - - desc->ctitle = new CTitle(desc); - desc->typeHierarchy.insert(typeid(SPTitle)); - - delete desc->cobject; - desc->cobject = desc->ctitle; +SPTitle::SPTitle() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; } -static void -sp_title_init(SPTitle *desc) -{ - new (desc) SPTitle(); +SPTitle::~SPTitle() { } -Inkscape::XML::Node* CTitle::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPTitle* object = this->sptitle; +Inkscape::XML::Node* SPTitle::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPTitle* object = this; if (!repr) { repr = object->getRepr()->duplicate(xml_doc); diff --git a/src/sp-title.h b/src/sp-title.h index 427021026..3258d0a67 100644 --- a/src/sp-title.h +++ b/src/sp-title.h @@ -14,35 +14,15 @@ #include "sp-object.h" -#define SP_TYPE_TITLE (sp_title_get_type ()) #define SP_TITLE(obj) ((SPTitle*)obj) -#define SP_IS_TITLE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPTitle))) +#define SP_IS_TITLE(obj) (dynamic_cast<const SPTitle*>((SPObject*)obj)) -class CTitle; - -class SPTitle : public SPObject { +class SPTitle : public SPObject, public CObject { public: SPTitle(); - CTitle* ctitle; -}; - -struct SPTitleClass { - SPObjectClass parent_class; -}; - - -class CTitle : public CObject { -public: - CTitle(SPTitle* title); - virtual ~CTitle(); + virtual ~SPTitle(); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - -protected: - SPTitle* sptitle; }; - -GType sp_title_get_type (void); - #endif |
