summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-04-02 21:01:45 +0000
committerMarkus Engel <markus.engel@tum.de>2013-04-02 21:01:45 +0000
commit8443720ce6429b9beec839e60b8a808595f4ba72 (patch)
tree3e08d3c631c2590a19481613a6e31cf09f6bed42 /src
parentReplaced some forgotten old casting macros. (diff)
downloadinkscape-8443720ce6429b9beec839e60b8a808595f4ba72.tar.gz
inkscape-8443720ce6429b9beec839e60b8a808595f4ba72.zip
Cleaned up a bit. Uses some C++11 features.
(bzr r11608.1.72)
Diffstat (limited to 'src')
-rw-r--r--src/box3d-side.cpp14
-rw-r--r--src/box3d-side.h11
-rw-r--r--src/interface.cpp76
-rw-r--r--src/main.cpp4
-rw-r--r--src/selection-describer.cpp88
-rw-r--r--src/sp-ellipse.cpp50
-rw-r--r--src/sp-ellipse.h48
-rw-r--r--src/sp-factory.cpp54
-rw-r--r--src/sp-factory.h6
-rw-r--r--src/sp-line.cpp13
-rw-r--r--src/sp-line.h20
-rw-r--r--src/sp-object-repr.cpp324
-rw-r--r--src/sp-offset.cpp46
-rw-r--r--src/sp-offset.h13
-rw-r--r--src/sp-path.cpp36
-rw-r--r--src/sp-path.h12
-rw-r--r--src/sp-polygon.cpp13
-rw-r--r--src/sp-polygon.h11
-rw-r--r--src/sp-polyline.cpp12
-rw-r--r--src/sp-polyline.h20
-rw-r--r--src/sp-rect.cpp19
-rw-r--r--src/sp-rect.h14
-rw-r--r--src/sp-shape.cpp38
-rw-r--r--src/sp-shape.h19
-rw-r--r--src/sp-spiral.cpp19
-rw-r--r--src/sp-spiral.h14
-rw-r--r--src/sp-star.cpp12
-rw-r--r--src/sp-star.h10
-rw-r--r--src/sp-tref.cpp2
29 files changed, 325 insertions, 693 deletions
diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp
index 23bc269d5..c2940254f 100644
--- a/src/box3d-side.cpp
+++ b/src/box3d-side.cpp
@@ -24,8 +24,6 @@
#include "desktop-style.h"
#include "box3d.h"
-struct SPPathClass;
-
static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]);
#include "sp-factory.h"
@@ -38,12 +36,6 @@ namespace {
bool box3DSideRegistered = SPFactory::instance().registerObject("inkscape:box3dside", createBox3DSide);
}
-G_DEFINE_TYPE(Box3DSide, box3d_side, G_TYPE_OBJECT);
-
-static void box3d_side_class_init(Box3DSideClass *klass)
-{
-}
-
CBox3DSide::CBox3DSide(Box3DSide* box3dside) : CPolygon(box3dside) {
this->spbox3dside = box3dside;
}
@@ -69,12 +61,6 @@ Box3DSide::Box3DSide() : SPPolygon() {
side->front_or_rear = Box3D::FRONT;
}
-static void
-box3d_side_init (Box3DSide * side)
-{
- new (side) Box3DSide();
-}
-
void CBox3DSide::build(SPDocument * document, Inkscape::XML::Node * repr) {
Box3DSide* object = this->spbox3dside;
diff --git a/src/box3d-side.h b/src/box3d-side.h
index 641bfd78a..37528f405 100644
--- a/src/box3d-side.h
+++ b/src/box3d-side.h
@@ -16,9 +16,8 @@
#include "sp-polygon.h"
#include "axis-manip.h"
-#define SP_TYPE_BOX3D_SIDE (box3d_side_get_type ())
+
#define SP_BOX3D_SIDE(obj) ((Box3DSide*)obj)
-//#define SP_IS_BOX3D_SIDE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(Box3DSide)))
#define SP_IS_BOX3D_SIDE(obj) (dynamic_cast<const Box3DSide*>((SPObject*)obj))
class SPBox3D;
@@ -38,11 +37,6 @@ public:
static Box3DSide * createBox3DSide(SPBox3D *box);
};
-struct Box3DSideClass {
- SPPolygonClass parent_class;
-};
-
-
class CBox3DSide : public CPolygon {
public:
CBox3DSide(Box3DSide* box3dside);
@@ -59,9 +53,6 @@ protected:
Box3DSide* spbox3dside;
};
-
-GType box3d_side_get_type (void);
-
void box3d_side_position_set (Box3DSide *side); // FIXME: Replace this by box3d_side_set_shape??
gchar *box3d_side_axes_string(Box3DSide *side);
diff --git a/src/interface.cpp b/src/interface.cpp
index 986d3107f..ab1e550a3 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -1701,32 +1701,56 @@ void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//
void ContextMenu::MakeObjectMenu(void)
{
- GObjectClass *klass = G_OBJECT_GET_CLASS(_object); //to deduce the object's type from its class
-
- if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ITEM))
- {
- MakeItemMenu ();
- }
- if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_GROUP))
- {
- MakeGroupMenu();
- }
- if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ANCHOR))
- {
- MakeAnchorMenu();
- }
- if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_IMAGE))
- {
- MakeImageMenu();
- }
- if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_SHAPE))
- {
- MakeShapeMenu();
- }
- if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_TEXT))
- {
- MakeTextMenu();
- }
+// GObjectClass *klass = G_OBJECT_GET_CLASS(_object); //to deduce the object's type from its class
+//
+// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ITEM))
+// {
+// MakeItemMenu ();
+// }
+// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_GROUP))
+// {
+// MakeGroupMenu();
+// }
+// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ANCHOR))
+// {
+// MakeAnchorMenu();
+// }
+// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_IMAGE))
+// {
+// MakeImageMenu();
+// }
+// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_SHAPE))
+// {
+// MakeShapeMenu();
+// }
+// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_TEXT))
+// {
+// MakeTextMenu();
+// }
+
+ if (SP_IS_ITEM(_object)) {
+ MakeItemMenu();
+ }
+
+ if (SP_IS_GROUP(_object)) {
+ MakeGroupMenu();
+ }
+
+ if (SP_IS_ANCHOR(_object)) {
+ MakeAnchorMenu();
+ }
+
+ if (SP_IS_IMAGE(_object)) {
+ MakeImageMenu();
+ }
+
+ if (SP_IS_SHAPE(_object)) {
+ MakeShapeMenu();
+ }
+
+ if (SP_IS_TEXT(_object)) {
+ MakeTextMenu();
+ }
}
void ContextMenu::MakeItemMenu (void)
diff --git a/src/main.cpp b/src/main.cpp
index 58ab19616..83f82fa84 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -795,8 +795,8 @@ static GSList *fixupFilenameEncoding( GSList* fl )
static int sp_common_main( int argc, char const **argv, GSList **flDest )
{
/// \todo fixme: Move these to some centralized location (Lauris)
- sp_object_type_register("sodipodi:namedview", SP_TYPE_NAMEDVIEW);
- sp_object_type_register("sodipodi:guide", SP_TYPE_GUIDE);
+ //sp_object_type_register("sodipodi:namedview", SP_TYPE_NAMEDVIEW);
+ //sp_object_type_register("sodipodi:guide", SP_TYPE_GUIDE);
// temporarily switch gettext encoding to locale, so that help messages can be output properly
diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp
index 391db8950..1639a2b95 100644
--- a/src/selection-describer.cpp
+++ b/src/selection-describer.cpp
@@ -37,46 +37,89 @@
#include "sp-polyline.h"
#include "sp-spiral.h"
-static const gchar *
-type2term(GType type)
-{
- if (type == SP_TYPE_ANCHOR)
+//static const gchar *
+//type2term(GType type)
+//{
+// if (type == SP_TYPE_ANCHOR)
+// //TRANSLATORS: "Link" means internet link (anchor)
+// { return C_("Web", "Link"); }
+// if (type == SP_TYPE_CIRCLE)
+// { return _("Circle"); }
+// if (type == SP_TYPE_ELLIPSE)
+// { return _("Ellipse"); }
+// if (type == SP_TYPE_FLOWTEXT)
+// { return _("Flowed text"); }
+// if (type == SP_TYPE_GROUP)
+// { return _("Group"); }
+// if (type == SP_TYPE_IMAGE)
+// { return _("Image"); }
+// if (type == SP_TYPE_LINE)
+// { return _("Line"); }
+// if (type == SP_TYPE_PATH)
+// { return _("Path"); }
+// if (type == SP_TYPE_POLYGON)
+// { return _("Polygon"); }
+// if (type == SP_TYPE_POLYLINE)
+// { return _("Polyline"); }
+// if (type == SP_TYPE_RECT)
+// { return _("Rectangle"); }
+// if (type == SP_TYPE_BOX3D)
+// { return _("3D Box"); }
+// if (type == SP_TYPE_TEXT)
+// { return C_("Object", "Text"); }
+// if (type == SP_TYPE_USE)
+// // TRANSLATORS: "Clone" is a noun, type of object
+// { return C_("Object", "Clone"); }
+// if (type == SP_TYPE_ARC)
+// { return _("Ellipse"); }
+// if (type == SP_TYPE_OFFSET)
+// { return _("Offset path"); }
+// if (type == SP_TYPE_SPIRAL)
+// { return _("Spiral"); }
+// if (type == SP_TYPE_STAR)
+// { return _("Star"); }
+// return NULL;
+//}
+
+// CPPIFY: this is ugly.
+static const char* object2term(SPObject* object) {
+ if (SP_IS_ANCHOR(object))
//TRANSLATORS: "Link" means internet link (anchor)
{ return C_("Web", "Link"); }
- if (type == SP_TYPE_CIRCLE)
+ if (SP_IS_CIRCLE(object))
{ return _("Circle"); }
- if (type == SP_TYPE_ELLIPSE)
+ if (SP_IS_ELLIPSE(object))
{ return _("Ellipse"); }
- if (type == SP_TYPE_FLOWTEXT)
+ if (SP_IS_FLOWTEXT(object))
{ return _("Flowed text"); }
- if (type == SP_TYPE_GROUP)
+ if (SP_IS_GROUP(object))
{ return _("Group"); }
- if (type == SP_TYPE_IMAGE)
+ if (SP_IS_IMAGE(object))
{ return _("Image"); }
- if (type == SP_TYPE_LINE)
+ if (SP_IS_LINE(object))
{ return _("Line"); }
- if (type == SP_TYPE_PATH)
+ if (SP_IS_PATH(object))
{ return _("Path"); }
- if (type == SP_TYPE_POLYGON)
+ if (SP_IS_POLYGON(object))
{ return _("Polygon"); }
- if (type == SP_TYPE_POLYLINE)
+ if (SP_IS_POLYLINE(object))
{ return _("Polyline"); }
- if (type == SP_TYPE_RECT)
+ if (SP_IS_RECT(object))
{ return _("Rectangle"); }
- if (type == SP_TYPE_BOX3D)
+ if (SP_IS_BOX3D(object))
{ return _("3D Box"); }
- if (type == SP_TYPE_TEXT)
+ if (SP_IS_TEXT(object))
{ return C_("Object", "Text"); }
- if (type == SP_TYPE_USE)
+ if (SP_IS_USE(object))
// TRANSLATORS: "Clone" is a noun, type of object
{ return C_("Object", "Clone"); }
- if (type == SP_TYPE_ARC)
+ if (SP_IS_ARC(object))
{ return _("Ellipse"); }
- if (type == SP_TYPE_OFFSET)
+ if (SP_IS_OFFSET(object))
{ return _("Offset path"); }
- if (type == SP_TYPE_SPIRAL)
+ if (SP_IS_SPIRAL(object))
{ return _("Spiral"); }
- if (type == SP_TYPE_STAR)
+ if (SP_IS_STAR(object))
{ return _("Star"); }
return NULL;
}
@@ -85,7 +128,8 @@ static GSList *collect_terms (GSList *items)
{
GSList *r = NULL;
for (GSList *i = items; i != NULL; i = i->next) {
- const gchar *term = type2term (G_OBJECT_TYPE(i->data));
+ //const gchar *term = type2term (G_OBJECT_TYPE(i->data));
+ const char* term = object2term(SP_OBJECT(i->data));
if (term != NULL && g_slist_find (r, term) == NULL)
r = g_slist_prepend (r, (void *) term);
}
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index 66c7a81a8..0e84a0360 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -88,11 +88,6 @@ static double sp_round(double x, double y)
static gboolean sp_arc_set_elliptical_path_attribute(SPArc *arc, Inkscape::XML::Node *repr);
-G_DEFINE_TYPE(SPGenericEllipse, sp_genericellipse, G_TYPE_OBJECT);
-
-static void sp_genericellipse_class_init(SPGenericEllipseClass *klass)
-{
-}
CGenericEllipse::CGenericEllipse(SPGenericEllipse* genericEllipse) : CShape(genericEllipse) {
this->spgenericEllipse = genericEllipse;
@@ -123,12 +118,6 @@ SPGenericEllipse::SPGenericEllipse() : SPShape() {
ellipse->closed = TRUE;
}
-static void
-sp_genericellipse_init(SPGenericEllipse *ellipse)
-{
- new (ellipse) SPGenericEllipse();
-}
-
void CGenericEllipse::update(SPCtx *ctx, guint flags) {
SPGenericEllipse* object = this->spgenericEllipse;
@@ -372,12 +361,6 @@ Inkscape::XML::Node* CGenericEllipse::write(Inkscape::XML::Document *xml_doc, In
/* SVG <ellipse> element */
-G_DEFINE_TYPE(SPEllipse, sp_ellipse, G_TYPE_OBJECT);
-
-static void sp_ellipse_class_init(SPEllipseClass *klass)
-{
-}
-
CEllipse::CEllipse(SPEllipse* ellipse) : CGenericEllipse(ellipse) {
this->spellipse = ellipse;
}
@@ -399,12 +382,6 @@ SPEllipse::SPEllipse() : SPGenericEllipse() {
ellipse->cobject = ellipse->cellipse;
}
-static void
-sp_ellipse_init(SPEllipse *ellipse)
-{
- new (ellipse) SPEllipse();
-}
-
void CEllipse::build(SPDocument *document, Inkscape::XML::Node *repr) {
CGenericEllipse::build(document, repr);
@@ -490,13 +467,6 @@ sp_ellipse_position_set(SPEllipse *ellipse, gdouble x, gdouble y, gdouble rx, gd
/* SVG <circle> element */
-G_DEFINE_TYPE(SPCircle, sp_circle, G_TYPE_OBJECT);
-
-static void
-sp_circle_class_init(SPCircleClass *klass)
-{
-}
-
CCircle::CCircle(SPCircle* circle) : CGenericEllipse(circle) {
this->spcircle = circle;
}
@@ -518,12 +488,6 @@ SPCircle::SPCircle() : SPGenericEllipse() {
circle->cobject = circle->ccircle;
}
-static void
-sp_circle_init(SPCircle *circle)
-{
- new (circle) SPCircle();
-}
-
void CCircle::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPCircle* object = this->spcircle;
@@ -551,7 +515,6 @@ Inkscape::XML::Node* CCircle::write(Inkscape::XML::Document *xml_doc, Inkscape::
return repr;
}
-
void CCircle::set(unsigned int key, gchar const* value) {
SPGenericEllipse *ge = this->spcircle;
SPCircle* object = (SPCircle*)ge;
@@ -584,13 +547,6 @@ gchar* CCircle::description() {
/* <path sodipodi:type="arc"> element */
-G_DEFINE_TYPE(SPArc, sp_arc, G_TYPE_OBJECT);
-
-static void
-sp_arc_class_init(SPArcClass *klass)
-{
-}
-
CArc::CArc(SPArc* arc) : CGenericEllipse(arc) {
this->sparc = arc;
}
@@ -612,12 +568,6 @@ SPArc::SPArc() : SPGenericEllipse() {
arc->cobject = arc->carc;
}
-static void
-sp_arc_init(SPArc *arc)
-{
- new (arc) SPArc();
-}
-
void CArc::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPArc* object = this->sparc;
diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h
index 3b0c0f4c3..01f1a4a52 100644
--- a/src/sp-ellipse.h
+++ b/src/sp-ellipse.h
@@ -17,14 +17,8 @@
#include "svg/svg-length.h"
#include "sp-shape.h"
-G_BEGIN_DECLS
-
/* Common parent class */
-
-#define SP_TYPE_GENERICELLIPSE (sp_genericellipse_get_type ())
#define SP_GENERICELLIPSE(obj) ((SPGenericEllipse*)obj)
-//#define SP_IS_GENERICELLIPSE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPGenericEllipse)))
-
#define SP_IS_GENERICELLIPSE(obj) (dynamic_cast<const SPGenericEllipse*>((SPObject*)obj))
class CGenericEllipse;
@@ -43,11 +37,6 @@ public:
double start, end;
};
-struct SPGenericEllipseClass {
- SPShapeClass parent_class;
-};
-
-
class CGenericEllipse : public CShape {
public:
CGenericEllipse(SPGenericEllipse* genericEllipse);
@@ -65,17 +54,11 @@ protected:
SPGenericEllipse* spgenericEllipse;
};
-
-GType sp_genericellipse_get_type (void);
-
/* This is technically priate by we need this in object edit (Lauris) */
void sp_genericellipse_normalize (SPGenericEllipse *ellipse);
/* SVG <ellipse> element */
-
-#define SP_TYPE_ELLIPSE (sp_ellipse_get_type ())
#define SP_ELLIPSE(obj) ((SPEllipse*)obj)
-//#define SP_IS_ELLIPSE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPEllipse)))
#define SP_IS_ELLIPSE(obj) (dynamic_cast<const SPEllipse*>((SPObject*)obj))
class CEllipse;
@@ -86,11 +69,6 @@ public:
CEllipse* cellipse;
};
-struct SPEllipseClass {
- SPGenericEllipseClass parent_class;
-};
-
-
class CEllipse : public CGenericEllipse {
public:
CEllipse(SPEllipse* ellipse);
@@ -105,16 +83,10 @@ protected:
SPEllipse* spellipse;
};
-
-GType sp_ellipse_get_type (void);
-
void sp_ellipse_position_set (SPEllipse * ellipse, gdouble x, gdouble y, gdouble rx, gdouble ry);
/* SVG <circle> element */
-
-#define SP_TYPE_CIRCLE (sp_circle_get_type ())
#define SP_CIRCLE(obj) ((SPCircle*)obj)
-//#define SP_IS_CIRCLE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPCircle)))
#define SP_IS_CIRCLE(obj) (dynamic_cast<const SPCircle*>((SPObject*)obj))
class CCircle;
@@ -125,11 +97,6 @@ public:
CCircle* ccircle;
};
-struct SPCircleClass {
- SPGenericEllipseClass parent_class;
-};
-
-
class CCircle : public CGenericEllipse {
public:
CCircle(SPCircle* circle);
@@ -144,14 +111,8 @@ protected:
SPCircle* spcircle;
};
-
-GType sp_circle_get_type (void);
-
/* <path sodipodi:type="arc"> element */
-
-#define SP_TYPE_ARC (sp_arc_get_type ())
#define SP_ARC(obj) ((SPArc*)obj)
-//#define SP_IS_ARC(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPArc)))
#define SP_IS_ARC(obj) (dynamic_cast<const SPArc*>((SPObject*)obj))
class CArc;
@@ -162,11 +123,6 @@ public:
CArc* carc;
};
-struct SPArcClass {
- SPGenericEllipseClass parent_class;
-};
-
-
class CArc : public CGenericEllipse {
public:
CArc(SPArc* arc);
@@ -182,11 +138,7 @@ protected:
SPArc* sparc;
};
-
-GType sp_arc_get_type (void);
void sp_arc_position_set (SPArc * arc, gdouble x, gdouble y, gdouble rx, gdouble ry);
Geom::Point sp_arc_get_xy (SPArc *ge, gdouble arg);
-G_END_DECLS
-
#endif
diff --git a/src/sp-factory.cpp b/src/sp-factory.cpp
index a8d9d9f5f..29b308111 100644
--- a/src/sp-factory.cpp
+++ b/src/sp-factory.cpp
@@ -10,25 +10,31 @@ SPFactory& SPFactory::instance() {
return factory;
}
-bool SPFactory::registerObject(std::string id, CreateObjectMethod* createFunction) {
+bool SPFactory::registerObject(std::string id, std::function<SPObject*()> createFunction) {
return this->objectMap.insert(std::make_pair(id, createFunction)).second;
}
SPObject* SPFactory::createObject(const Inkscape::XML::Node& id) const {
- std::map<std::string, CreateObjectMethod*>::const_iterator entry;
+ std::map<std::string, std::function<SPObject*()>>::const_iterator entry;
- if (id.type() == Inkscape::XML::TEXT_NODE) {
- entry = this->objectMap.find("string");
- } else if (id.type() == Inkscape::XML::ELEMENT_NODE) {
- gchar const* const type_name = id.attribute("sodipodi:type");
+ switch (id.type()) {
+ case Inkscape::XML::TEXT_NODE:
+ entry = this->objectMap.find("string");
+ break;
- if (type_name) {
- entry = this->objectMap.find(type_name);
- } else {
- entry = this->objectMap.find(id.name());
+ case Inkscape::XML::ELEMENT_NODE: {
+ gchar const* const type_name = id.attribute("sodipodi:type");
+
+ if (type_name) {
+ entry = this->objectMap.find(type_name);
+ } else {
+ entry = this->objectMap.find(id.name());
+ }
+
+ break;
}
- } else {
- entry = this->objectMap.end();
+ default:
+ entry = this->objectMap.end();
}
if (entry == this->objectMap.end()) {
@@ -38,28 +44,4 @@ SPObject* SPFactory::createObject(const Inkscape::XML::Node& id) const {
}
return (entry->second)();
-
-// std::map<std::string, CreateObjectMethod*>::const_iterator entry = this->objectMap.find(id);
-//
-// if (entry == objectMap.end()) {
-// g_warning("Factory: Type \"%s\" not registered!", id.c_str());
-//
-// SPObject* o = new SPObject();
-// return o;
-// }
-//
-// return (entry->second)();
}
-
-/*
- * if ( repr->type() == Inkscape::XML::TEXT_NODE ) {
- return SP_TYPE_STRING;
- } else if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) {
- gchar const * const type_name = repr->attribute("sodipodi:type");
- return ( type_name
- ? name_to_gtype(SODIPODI_TYPE, type_name)
- : name_to_gtype(REPR_NAME, repr->name()) );
- } else {
- return 0;
- }
- */
diff --git a/src/sp-factory.h b/src/sp-factory.h
index 24e3c412a..c541781df 100644
--- a/src/sp-factory.h
+++ b/src/sp-factory.h
@@ -1,5 +1,6 @@
#pragma once
+#include <functional>
#include <map>
#include <string>
@@ -18,11 +19,10 @@ class SPFactory {
public:
static SPFactory& instance();
- typedef SPObject* CreateObjectMethod();
- bool registerObject(std::string id, CreateObjectMethod* createFunction);
+ bool registerObject(std::string id, std::function<SPObject*()> createFunction);
SPObject* createObject(const Inkscape::XML::Node& id) const;
private:
- std::map<std::string, CreateObjectMethod*> objectMap;
+ std::map<std::string, std::function<SPObject*()>> objectMap;
};
diff --git a/src/sp-line.cpp b/src/sp-line.cpp
index d7ffa8307..4a14b883c 100644
--- a/src/sp-line.cpp
+++ b/src/sp-line.cpp
@@ -34,13 +34,6 @@ namespace {
bool lineRegistered = SPFactory::instance().registerObject("svg:line", createLine);
}
-G_DEFINE_TYPE(SPLine, sp_line, G_TYPE_OBJECT);
-
-static void
-sp_line_class_init(SPLineClass *klass)
-{
-}
-
CLine::CLine(SPLine* line) : CShape(line) {
this->spline = line;
}
@@ -66,12 +59,6 @@ SPLine::SPLine() : SPShape() {
line->y2.unset();
}
-static void
-sp_line_init(SPLine * line)
-{
- new (line) SPLine();
-}
-
void CLine::build(SPDocument * document, Inkscape::XML::Node * repr) {
SPLine* object = this->spline;
diff --git a/src/sp-line.h b/src/sp-line.h
index 305f67cd5..9b8bf149d 100644
--- a/src/sp-line.h
+++ b/src/sp-line.h
@@ -17,19 +17,12 @@
#include "svg/svg-length.h"
#include "sp-shape.h"
-
-
-#define SP_TYPE_LINE (sp_line_get_type())
#define SP_LINE(obj) ((SPLine*)obj)
-//#define SP_IS_LINE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPLine)))
#define SP_IS_LINE(obj) (dynamic_cast<const SPLine*>((SPObject*)obj))
class SPLine;
-class SPLineClass;
class CLine;
-GType sp_line_get_type(void) G_GNUC_CONST;
-
class SPLine : public SPShape {
public:
SPLine();
@@ -39,20 +32,8 @@ public:
SVGLength y1;
SVGLength x2;
SVGLength y2;
-
-private:
- friend class SPLineClass;
-};
-
-class SPLineClass {
-public:
- SPShapeClass parent_class;
-
-private:
- friend class SPLine;
};
-
class CLine : public CShape {
public:
CLine(SPLine* line);
@@ -73,7 +54,6 @@ protected:
SPLine* spline;
};
-
#endif // SEEN_SP_LINE_H
/*
Local Variables:
diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp
index 1b6eb87a6..1d85903c5 100644
--- a/src/sp-object-repr.cpp
+++ b/src/sp-object-repr.cpp
@@ -10,86 +10,86 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "sp-defs.h"
-#include "sp-symbol.h"
-#include "marker.h"
-#include "sp-use.h"
+//#include "sp-defs.h"
+//#include "sp-symbol.h"
+//#include "marker.h"
+//#include "sp-use.h"
#include "sp-root.h"
-#include "sp-image.h"
-#include "sp-linear-gradient-fns.h"
-#include "sp-mesh-gradient-fns.h"
-#include "sp-mesh-row-fns.h"
-#include "sp-mesh-patch-fns.h"
-#include "sp-object-repr.h"
-#include "sp-path.h"
-#include "sp-radial-gradient-fns.h"
-#include "sp-rect.h"
-#include "box3d.h"
-#include "box3d-side.h"
-#include "persp3d.h"
-#include "sp-ellipse.h"
-#include "sp-star.h"
-#include "sp-stop.h"
-#include "sp-spiral.h"
-#include "sp-offset.h"
-#include "sp-line.h"
-#include "sp-metadata.h"
-#include "sp-polyline.h"
-#include "sp-textpath.h"
-#include "sp-tref.h"
-#include "sp-tspan.h"
-#include "sp-pattern.h"
-#include "sp-clippath.h"
-#include "sp-mask.h"
-#include "sp-anchor.h"
-#include "sp-flowdiv.h"
-#include "sp-flowregion.h"
-#include "sp-flowtext.h"
-#include "sp-script.h"
+//#include "sp-image.h"
+//#include "sp-linear-gradient-fns.h"
+//#include "sp-mesh-gradient-fns.h"
+//#include "sp-mesh-row-fns.h"
+//#include "sp-mesh-patch-fns.h"
+//#include "sp-object-repr.h"
+//#include "sp-path.h"
+//#include "sp-radial-gradient-fns.h"
+//#include "sp-rect.h"
+//#include "box3d.h"
+//#include "box3d-side.h"
+//#include "persp3d.h"
+//#include "sp-ellipse.h"
+//#include "sp-star.h"
+//#include "sp-stop.h"
+//#include "sp-spiral.h"
+//#include "sp-offset.h"
+//#include "sp-line.h"
+//#include "sp-metadata.h"
+//#include "sp-polyline.h"
+//#include "sp-textpath.h"
+//#include "sp-tref.h"
+//#include "sp-tspan.h"
+//#include "sp-pattern.h"
+//#include "sp-clippath.h"
+//#include "sp-mask.h"
+//#include "sp-anchor.h"
+//#include "sp-flowdiv.h"
+//#include "sp-flowregion.h"
+//#include "sp-flowtext.h"
+//#include "sp-script.h"
#include "config.h"
-#include "sp-font.h"
-#include "sp-font-face.h"
-#include "sp-glyph.h"
-#include "sp-missing-glyph.h"
-#include "sp-glyph-kerning.h"
-
-#include "sp-style-elem.h"
-#include "sp-switch.h"
-#include "color-profile.h"
+//#include "sp-font.h"
+//#include "sp-font-face.h"
+//#include "sp-glyph.h"
+//#include "sp-missing-glyph.h"
+//#include "sp-glyph-kerning.h"
+//
+//#include "sp-style-elem.h"
+//#include "sp-switch.h"
+//#include "color-profile.h"
#include "xml/repr.h"
-#include "sp-filter.h"
-#include "filters/blend.h"
-#include "filters/colormatrix.h"
-#include "filters/componenttransfer.h"
-#include "filters/componenttransfer-funcnode.h"
-#include "filters/composite.h"
-#include "filters/convolvematrix.h"
-#include "filters/diffuselighting.h"
-#include "filters/distantlight.h"
-#include "filters/displacementmap.h"
-#include "filters/flood.h"
-#include "filters/gaussian-blur.h"
-#include "filters/image.h"
-#include "filters/merge.h"
-#include "filters/morphology.h"
-#include "filters/offset.h"
-#include "filters/pointlight.h"
-#include "filters/specularlighting.h"
-#include "filters/spotlight.h"
-#include "filters/tile.h"
-#include "filters/turbulence.h"
-#include "filters/mergenode.h"
-#include "live_effects/lpeobject.h"
-#include "sp-title.h"
-#include "sp-desc.h"
+//#include "sp-filter.h"
+//#include "filters/blend.h"
+//#include "filters/colormatrix.h"
+//#include "filters/componenttransfer.h"
+//#include "filters/componenttransfer-funcnode.h"
+//#include "filters/composite.h"
+//#include "filters/convolvematrix.h"
+//#include "filters/diffuselighting.h"
+//#include "filters/distantlight.h"
+//#include "filters/displacementmap.h"
+//#include "filters/flood.h"
+//#include "filters/gaussian-blur.h"
+//#include "filters/image.h"
+//#include "filters/merge.h"
+//#include "filters/morphology.h"
+//#include "filters/offset.h"
+//#include "filters/pointlight.h"
+//#include "filters/specularlighting.h"
+//#include "filters/spotlight.h"
+//#include "filters/tile.h"
+//#include "filters/turbulence.h"
+//#include "filters/mergenode.h"
+//#include "live_effects/lpeobject.h"
+//#include "sp-title.h"
+//#include "sp-desc.h"
#include "sp-factory.h"
-enum NameType { REPR_NAME, SODIPODI_TYPE };
-static unsigned const N_NAME_TYPES = SODIPODI_TYPE + 1;
-
-static GType name_to_gtype(NameType name_type, gchar const *name);
+//enum NameType { REPR_NAME, SODIPODI_TYPE };
+//static unsigned const N_NAME_TYPES = SODIPODI_TYPE + 1;
+//
+//static GType name_to_gtype(NameType name_type, gchar const *name);
SPRoot *sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr)
{
@@ -113,28 +113,28 @@ SPRoot *sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *rep
return SP_ROOT(object);
}
-GType
-sp_repr_type_lookup(Inkscape::XML::Node *repr)
-{
- if ( repr->type() == Inkscape::XML::TEXT_NODE ) {
- return SP_TYPE_STRING;
- } else if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) {
- gchar const * const type_name = repr->attribute("sodipodi:type");
- return ( type_name
- ? name_to_gtype(SODIPODI_TYPE, type_name)
- : name_to_gtype(REPR_NAME, repr->name()) );
- } else {
- return 0;
- }
-}
-
-static GHashTable *t2dtable[N_NAME_TYPES] = {NULL};
-
-static void
-populate_dtables()
-{
- struct NameTypeEntry { char const *const name; GType const type_id; };
- NameTypeEntry const repr_name_entries[] = {
+//GType
+//sp_repr_type_lookup(Inkscape::XML::Node *repr)
+//{
+// if ( repr->type() == Inkscape::XML::TEXT_NODE ) {
+// return SP_TYPE_STRING;
+// } else if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) {
+// gchar const * const type_name = repr->attribute("sodipodi:type");
+// return ( type_name
+// ? name_to_gtype(SODIPODI_TYPE, type_name)
+// : name_to_gtype(REPR_NAME, repr->name()) );
+// } else {
+// return 0;
+// }
+//}
+//
+//static GHashTable *t2dtable[N_NAME_TYPES] = {NULL};
+//
+//static void
+//populate_dtables()
+//{
+// struct NameTypeEntry { char const *const name; GType const type_id; };
+// NameTypeEntry const repr_name_entries[] = {
// { "svg:a", SP_TYPE_ANCHOR },
// //{ "svg:animate", SP_TYPE_ANIMATE },
// { "svg:circle", SP_TYPE_CIRCLE },
@@ -213,75 +213,75 @@ populate_dtables()
// { "svg:tspan", SP_TYPE_TSPAN },
// { "svg:use", SP_TYPE_USE },
// { "inkscape:path-effect", TYPE_LIVEPATHEFFECT }
- };
- NameTypeEntry const sodipodi_name_entries[] = {
- { "arc", SP_TYPE_ARC },
- { "inkscape:offset", SP_TYPE_OFFSET },
- { "spiral", SP_TYPE_SPIRAL },
- { "star", SP_TYPE_STAR },
- { "inkscape:box3d", SP_TYPE_BOX3D },
- { "inkscape:box3dside", SP_TYPE_BOX3D_SIDE },
- { "inkscape:persp3d", SP_TYPE_PERSP3D }
- };
-
- NameTypeEntry const *const t2entries[] = {
- repr_name_entries,
- sodipodi_name_entries
- };
- unsigned const t2n_entries[] = {
- G_N_ELEMENTS(repr_name_entries),
- G_N_ELEMENTS(sodipodi_name_entries)
- };
+// };
+// NameTypeEntry const sodipodi_name_entries[] = {
+// { "arc", SP_TYPE_ARC },
+// { "inkscape:offset", SP_TYPE_OFFSET },
+// { "spiral", SP_TYPE_SPIRAL },
+// { "star", SP_TYPE_STAR },
+// { "inkscape:box3d", SP_TYPE_BOX3D },
+// { "inkscape:box3dside", SP_TYPE_BOX3D_SIDE },
+// { "inkscape:persp3d", SP_TYPE_PERSP3D }
+// };
+//
+// NameTypeEntry const *const t2entries[] = {
+// repr_name_entries,
+// sodipodi_name_entries
+// };
+// unsigned const t2n_entries[] = {
+// G_N_ELEMENTS(repr_name_entries),
+// G_N_ELEMENTS(sodipodi_name_entries)
+// };
+//
+// for (unsigned nt = 0; nt < N_NAME_TYPES; ++nt) {
+// NameTypeEntry const *const entries = t2entries[nt];
+// unsigned const n_entries = t2n_entries[nt];
+// GHashTable *&dtable = t2dtable[nt];
+//
+// dtable = g_hash_table_new(g_str_hash, g_str_equal);
+// for (unsigned i = 0; i < n_entries; ++i) {
+// g_hash_table_insert(dtable,
+// (void *)entries[i].name,
+// (gpointer) entries[i].type_id);
+// }
+// }
+//}
- for (unsigned nt = 0; nt < N_NAME_TYPES; ++nt) {
- NameTypeEntry const *const entries = t2entries[nt];
- unsigned const n_entries = t2n_entries[nt];
- GHashTable *&dtable = t2dtable[nt];
-
- dtable = g_hash_table_new(g_str_hash, g_str_equal);
- for (unsigned i = 0; i < n_entries; ++i) {
- g_hash_table_insert(dtable,
- (void *)entries[i].name,
- (gpointer) entries[i].type_id);
- }
- }
-}
+//static inline void
+//ensure_dtables_populated()
+//{
+// if (!*t2dtable) {
+// populate_dtables();
+// }
+//}
-static inline void
-ensure_dtables_populated()
-{
- if (!*t2dtable) {
- populate_dtables();
- }
-}
-
-static GType
-name_to_gtype(NameType const name_type, gchar const *name)
-{
- ensure_dtables_populated();
-
- gpointer const data = g_hash_table_lookup(t2dtable[name_type], name);
- return ( ( data == NULL )
- ? SP_TYPE_OBJECT
- : (GType) data );
-}
-
-void
-sp_object_type_register(gchar const *name, GType const gtype)
-{
- GType const current = name_to_gtype(REPR_NAME, name);
- if (current == SP_TYPE_OBJECT) {
- g_hash_table_insert(t2dtable[REPR_NAME],
- const_cast<gchar *>(name),
- (gpointer) gtype);
- } else {
- /* Already registered. */
- if (current != gtype) {
- g_warning("repr type `%s' already registered as type #%lu, ignoring attempt to re-register as #%lu.",
- name, current, gtype);
- }
- }
-}
+//static GType
+//name_to_gtype(NameType const name_type, gchar const *name)
+//{
+// ensure_dtables_populated();
+//
+// gpointer const data = g_hash_table_lookup(t2dtable[name_type], name);
+// return ( ( data == NULL )
+// ? SP_TYPE_OBJECT
+// : (GType) data );
+//}
+//
+//void
+//sp_object_type_register(gchar const *name, GType const gtype)
+//{
+// GType const current = name_to_gtype(REPR_NAME, name);
+// if (current == SP_TYPE_OBJECT) {
+// g_hash_table_insert(t2dtable[REPR_NAME],
+// const_cast<gchar *>(name),
+// (gpointer) gtype);
+// } else {
+// /* Already registered. */
+// if (current != gtype) {
+// g_warning("repr type `%s' already registered as type #%lu, ignoring attempt to re-register as #%lu.",
+// name, current, gtype);
+// }
+// }
+//}
/*
Local Variables:
diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp
index 5a9b3933c..f812ad931 100644
--- a/src/sp-offset.cpp
+++ b/src/sp-offset.cpp
@@ -78,8 +78,6 @@ namespace {
* radius (look in object-edit).
*/
-static void sp_offset_finalize(GObject *obj);
-
static void refresh_offset_source(SPOffset* offset);
static void sp_offset_start_listening(SPOffset *offset,SPObject* to);
@@ -97,18 +95,6 @@ static void sp_offset_source_modified (SPObject *iSource, guint flags, SPItem *i
// reappearing in offset when the radius becomes too large
static bool use_slow_but_correct_offset_method=false;
-G_DEFINE_TYPE(SPOffset, sp_offset, G_TYPE_OBJECT);
-
-/**
- * SPOffset vtable initialization.
- */
-static void
-sp_offset_class_init(SPOffsetClass *klass)
-{
- GObjectClass *gobject_class = (GObjectClass *) klass;
- gobject_class->finalize = sp_offset_finalize;
-}
-
COffset::COffset(SPOffset* offset) : CShape(offset) {
this->spoffset = offset;
}
@@ -147,33 +133,13 @@ SPOffset::SPOffset() : SPShape() {
offset->_changed_connection = offset->sourceRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_offset_href_changed), offset));
}
-/**
- * Callback for SPOffset object initialization.
- */
-static void
-sp_offset_init(SPOffset *offset)
-{
- new (offset) SPOffset();
-}
-
-/**
- * Callback for SPOffset finalization.
- */
-static void
-sp_offset_finalize(GObject *obj)
-{
- SPOffset *offset = (SPOffset *) obj;
+SPOffset::~SPOffset() {
+ delete this->sourceRef;
- delete offset->sourceRef;
-
- offset->_modified_connection.disconnect();
- offset->_modified_connection.~connection();
- offset->_delete_connection.disconnect();
- offset->_delete_connection.~connection();
- offset->_changed_connection.disconnect();
- offset->_changed_connection.~connection();
- offset->_transformed_connection.disconnect();
- offset->_transformed_connection.~connection();
+ this->_modified_connection.disconnect();
+ this->_delete_connection.disconnect();
+ this->_changed_connection.disconnect();
+ this->_transformed_connection.disconnect();
}
void COffset::build(SPDocument *document, Inkscape::XML::Node *repr) {
diff --git a/src/sp-offset.h b/src/sp-offset.h
index 75d42e443..20f5164b4 100644
--- a/src/sp-offset.h
+++ b/src/sp-offset.h
@@ -55,6 +55,8 @@ class SPUseReference;
class SPOffset : public SPShape {
public:
SPOffset();
+ virtual ~SPOffset();
+
COffset* coffset;
void *originalPath; ///< will be a livarot Path, just don't declare it here to please the gcc linker
@@ -79,13 +81,6 @@ public:
sigc::connection _transformed_connection;
};
-/// The SPOffset vtable.
-struct SPOffsetClass
-{
- SPShapeClass parent_class;
-};
-
-
class COffset : public CShape {
public:
COffset(SPOffset* offset);
@@ -106,10 +101,6 @@ protected:
SPOffset* spoffset;
};
-
-/* Standard Gtk function */
-GType sp_offset_get_type (void);
-
double sp_offset_distance_to_original (SPOffset * offset, Geom::Point px);
void sp_offset_top_point (SPOffset const *offset, Geom::Point *px);
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index bc6a2cb21..394b815fb 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -61,24 +61,6 @@ namespace {
bool pathRegistered = SPFactory::instance().registerObject("svg:path", createPath);
}
-
-static void sp_path_finalize(GObject *obj);
-
-G_DEFINE_TYPE(SPPath, sp_path, G_TYPE_OBJECT);
-
-/**
- * Does the object-oriented work of initializing the class structure
- * including parent class, and registers function pointers for
- * the functions build, set, write, and set_transform.
- */
-static void
-sp_path_class_init(SPPathClass * klass)
-{
- GObjectClass *gobject_class = (GObjectClass *) klass;
- gobject_class->finalize = sp_path_finalize;
-}
-
-
gint SPPath::nodesInPath() const
{
return _curve ? _curve->nodes_in_path() : 0;
@@ -156,25 +138,9 @@ SPPath::SPPath() : SPShape(), connEndPair(this) {
path->clpeitem = path->cpath;
path->citem = path->cpath;
path->cobject = path->cpath;
-
- //new (&path->connEndPair) SPConnEndPair(path);
-}
-
-/**
- * Initializes an SPPath.
- */
-static void
-sp_path_init(SPPath *path)
-{
- new (path) SPPath();
}
-static void
-sp_path_finalize(GObject *obj)
-{
- SPPath *path = (SPPath *) obj;
-
- path->connEndPair.~SPConnEndPair();
+SPPath::~SPPath() {
}
void CPath::build(SPDocument *document, Inkscape::XML::Node *repr) {
diff --git a/src/sp-path.h b/src/sp-path.h
index a442c49dd..a9b9e7f68 100644
--- a/src/sp-path.h
+++ b/src/sp-path.h
@@ -22,9 +22,7 @@
class SPCurve;
class CPath;
-#define SP_TYPE_PATH (sp_path_get_type ())
#define SP_PATH(obj) ((SPPath*)obj)
-//#define SP_IS_PATH(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPPath)))
#define SP_IS_PATH(obj) (dynamic_cast<const SPPath*>((SPObject*)obj))
/**
@@ -33,6 +31,8 @@ class CPath;
class SPPath : public SPShape {
public:
SPPath();
+ virtual ~SPPath();
+
CPath* cpath;
gint nodesInPath() const;
@@ -51,11 +51,6 @@ public:
SPConnEndPair connEndPair;
};
-struct SPPathClass {
- SPShapeClass shape_class;
-};
-
-
class CPath : public CShape {
public:
CPath(SPPath* path);
@@ -78,9 +73,6 @@ protected:
SPPath* sppath;
};
-
-GType sp_path_get_type (void);
-
#endif // SEEN_SP_PATH_H
/*
diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp
index 5b84c0bec..8155c0767 100644
--- a/src/sp-polygon.cpp
+++ b/src/sp-polygon.cpp
@@ -35,12 +35,6 @@ namespace {
bool polygonRegistered = SPFactory::instance().registerObject("svg:polygon", createPolygon);
}
-G_DEFINE_TYPE(SPPolygon, sp_polygon, G_TYPE_OBJECT);
-
-static void sp_polygon_class_init(SPPolygonClass *pc)
-{
-}
-
CPolygon::CPolygon(SPPolygon* polygon) : CShape(polygon) {
this->sppolygon = polygon;
}
@@ -61,11 +55,6 @@ SPPolygon::SPPolygon() : SPShape() {
polygon->cobject = polygon->cpolygon;
}
-static void sp_polygon_init(SPPolygon *polygon)
-{
- new (polygon) SPPolygon();
-}
-
void CPolygon::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPPolygon* object = this->sppolygon;
@@ -74,8 +63,6 @@ void CPolygon::build(SPDocument *document, Inkscape::XML::Node *repr) {
object->readAttr( "points" );
}
-
-
/*
* sp_svg_write_polygon: Write points attribute for polygon tag.
* pathv may only contain paths with only straight line segments
diff --git a/src/sp-polygon.h b/src/sp-polygon.h
index 1489f78ae..7a95f5364 100644
--- a/src/sp-polygon.h
+++ b/src/sp-polygon.h
@@ -15,9 +15,8 @@
#include "sp-shape.h"
-#define SP_TYPE_POLYGON (sp_polygon_get_type ())
+
#define SP_POLYGON(obj) ((SPPolygon*)obj)
-//#define SP_IS_POLYGON(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPPolygon)))
#define SP_IS_POLYGON(obj) (dynamic_cast<const SPPolygon*>((SPObject*)obj))
class CPolygon;
@@ -28,11 +27,6 @@ public:
CPolygon* cpolygon;
};
-struct SPPolygonClass {
- SPShapeClass parent_class;
-};
-
-
class CPolygon : public CShape {
public:
CPolygon(SPPolygon* polygon);
@@ -47,9 +41,6 @@ protected:
SPPolygon* sppolygon;
};
-
-GType sp_polygon_get_type (void);
-
// made 'public' so that SPCurve can set it as friend:
void sp_polygon_set(SPObject *object, unsigned int key, const gchar *value);
diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp
index efa2bf874..310fd9db8 100644
--- a/src/sp-polyline.cpp
+++ b/src/sp-polyline.cpp
@@ -30,13 +30,6 @@ namespace {
bool polyLineRegistered = SPFactory::instance().registerObject("svg:polyline", createPolyLine);
}
-G_DEFINE_TYPE(SPPolyLine, sp_polyline, G_TYPE_OBJECT);
-
-static void
-sp_polyline_class_init(SPPolyLineClass *klass)
-{
-}
-
CPolyLine::CPolyLine(SPPolyLine* polyline) : CShape(polyline) {
this->sppolyline = polyline;
}
@@ -57,11 +50,6 @@ SPPolyLine::SPPolyLine() : SPShape() {
polyline->cobject = polyline->cpolyline;
}
-void sp_polyline_init(SPPolyLine * polyline)
-{
- new (polyline) SPPolyLine();
-}
-
void CPolyLine::build(SPDocument * document, Inkscape::XML::Node * repr) {
SPPolyLine* object = this->sppolyline;
diff --git a/src/sp-polyline.h b/src/sp-polyline.h
index c6f9340f8..994ee18b1 100644
--- a/src/sp-polyline.h
+++ b/src/sp-polyline.h
@@ -3,38 +3,19 @@
#include "sp-shape.h"
-
-
-#define SP_TYPE_POLYLINE (sp_polyline_get_type ())
#define SP_POLYLINE(obj) ((SPPolyLine*)obj)
-//#define SP_IS_POLYLINE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPPolyLine)))
#define SP_IS_POLYLINE(obj) (dynamic_cast<const SPPolyLine*>((SPObject*)obj))
class SPPolyLine;
-class SPPolyLineClass;
class CPolyLine;
-GType sp_polyline_get_type (void) G_GNUC_CONST;
-
class SPPolyLine : public SPShape {
public:
SPPolyLine();
CPolyLine* cpolyline;
-
-private:
- friend class SPPolyLineClass;
-};
-
-class SPPolyLineClass {
-public:
- SPShapeClass parent_class;
-
-private:
- friend class SPPolyLine;
};
-
class CPolyLine : public CShape {
public:
CPolyLine(SPPolyLine* polyline);
@@ -50,7 +31,6 @@ protected:
SPPolyLine* sppolyline;
};
-
#endif // SEEN_SP_POLYLINE_H
/*
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index 833e87020..9ba444ca6 100644
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
@@ -34,21 +34,10 @@
#include "sp-factory.h"
namespace {
- SPObject* createRect() {
- return new SPRect();
- }
-
- bool rectRegistered = SPFactory::instance().registerObject("svg:rect", createRect);
+ bool rectRegistered = SPFactory::instance().registerObject("svg:rect", []() { return new SPRect(); });
}
-G_DEFINE_TYPE(SPRect, sp_rect, G_TYPE_OBJECT);
-
-static void
-sp_rect_class_init(SPRectClass *klass)
-{
-}
-
CRect::CRect(SPRect* rect) : CShape(rect) {
this->sprect = rect;
}
@@ -77,12 +66,6 @@ SPRect::SPRect() : SPShape() {
/* sp_svg_length_unset(&rect->ry, SP_SVG_UNIT_NONE, 0.0, 0.0); */
}
-static void
-sp_rect_init(SPRect *rect)
-{
- new (rect) SPRect();
-}
-
void CRect::build(SPDocument* doc, Inkscape::XML::Node* repr) {
SPRect* object = this->sprect;
diff --git a/src/sp-rect.h b/src/sp-rect.h
index aaf090388..57d38d21b 100644
--- a/src/sp-rect.h
+++ b/src/sp-rect.h
@@ -18,11 +18,8 @@
#include "sp-shape.h"
#include <2geom/forward.h>
-G_BEGIN_DECLS
-#define SP_TYPE_RECT (sp_rect_get_type ())
#define SP_RECT(obj) ((SPRect*)obj)
-//#define SP_IS_RECT(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPRect)))
#define SP_IS_RECT(obj) (dynamic_cast<const SPRect*>((SPObject*)obj))
class CRect;
@@ -63,11 +60,6 @@ private:
static gdouble vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform);
};
-struct SPRectClass {
- SPShapeClass parent_class;
-};
-
-
class CRect : public CShape {
public:
CRect(SPRect* sprect);
@@ -91,12 +83,6 @@ protected:
SPRect* sprect;
};
-
-/* Standard GType function */
-GType sp_rect_get_type (void) G_GNUC_CONST;
-
-G_END_DECLS
-
#endif // SEEN_SP_RECT_H
/*
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index babb4f029..fc80defb3 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -56,18 +56,6 @@
static void sp_shape_finalize (GObject *object);
static void sp_shape_update_marker_view (SPShape *shape, Inkscape::DrawingItem *ai);
-G_DEFINE_TYPE(SPShape, sp_shape, G_TYPE_OBJECT);
-
-/**
- * Initializes a SPShapeClass object. Establishes the function pointers to the class'
- * member routines in the class vtable, and sets pointers to parent classes.
- */
-static void
-sp_shape_class_init(SPShapeClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
- gobject_class->finalize = sp_shape_finalize;
-}
CShape::CShape(SPShape* shape) : CLPEItem(shape) {
this->spshape = shape;
@@ -76,7 +64,6 @@ CShape::CShape(SPShape* shape) : CLPEItem(shape) {
CShape::~CShape() {
}
-
SPShape::SPShape() : SPLPEItem() {
SPShape* shape = this;
@@ -97,29 +84,10 @@ SPShape::SPShape() : SPLPEItem() {
shape->_curve_before_lpe = NULL;
}
-/**
- * Initializes an SPShape object.
- */
-static void
-sp_shape_init(SPShape *shape)
-{
- new (shape) SPShape();
-}
-
-static void
-sp_shape_finalize(GObject *object)
-{
- SPShape *shape=(SPShape *)object;
-
+SPShape::~SPShape() {
for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) {
- shape->_release_connect[i].disconnect();
- shape->_release_connect[i].~connection();
- shape->_modified_connect[i].disconnect();
- shape->_modified_connect[i].~connection();
- }
-
- if (((GObjectClass *) (sp_shape_parent_class))->finalize) {
- (* ((GObjectClass *) (sp_shape_parent_class))->finalize)(object);
+ this->_release_connect[i].disconnect();
+ this->_modified_connect[i].disconnect();
}
}
diff --git a/src/sp-shape.h b/src/sp-shape.h
index 5a9d49622..c11ce87f3 100644
--- a/src/sp-shape.h
+++ b/src/sp-shape.h
@@ -22,16 +22,15 @@
#include <stddef.h>
#include <sigc++/connection.h>
-#define SP_TYPE_SHAPE (sp_shape_get_type ())
#define SP_SHAPE(obj) ((SPShape*)obj)
-//#define SP_IS_SHAPE(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPShape)))
#define SP_IS_SHAPE(obj) (dynamic_cast<const SPShape*>((SPObject*)obj))
#define SP_SHAPE_WRITE_PATH (1 << 2)
class SPDesktop;
namespace Inkscape { class DrawingItem; }
-GType sp_shape_get_type (void) G_GNUC_CONST;
+
+
class CShape;
/**
@@ -40,6 +39,8 @@ class CShape;
class SPShape : public SPLPEItem {
public:
SPShape();
+ virtual ~SPShape();
+
CShape* cshape;
void setShape ();
@@ -59,20 +60,8 @@ public:
SPObject *_marker[SP_MARKER_LOC_QTY];
sigc::connection _release_connect [SP_MARKER_LOC_QTY];
sigc::connection _modified_connect [SP_MARKER_LOC_QTY];
-
-private:
- friend class SPShapeClass;
};
-class SPShapeClass {
-public:
- SPLPEItemClass item_class;
-
-private:
- friend class SPShape;
-};
-
-
class CShape : public CLPEItem {
public:
CShape(SPShape* shape);
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index dabd9cdd0..4c87da1b5 100644
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
@@ -40,15 +40,6 @@ namespace {
}
-G_DEFINE_TYPE(SPSpiral, sp_spiral, G_TYPE_OBJECT);
-
-/**
- * SPSpiral vtable initialization.
- */
-static void sp_spiral_class_init(SPSpiralClass *klass)
-{
-}
-
CSpiral::CSpiral(SPSpiral* spiral) : CShape(spiral) {
this->spspiral = spiral;
}
@@ -77,15 +68,6 @@ SPSpiral::SPSpiral() : SPShape() {
spiral->t0 = 0.0;
}
-/**
- * Callback for SPSpiral object initialization.
- */
-static void
-sp_spiral_init (SPSpiral * spiral)
-{
- new (spiral) SPSpiral();
-}
-
void CSpiral::build(SPDocument * document, Inkscape::XML::Node * repr) {
SPSpiral* object = this->spspiral;
@@ -235,7 +217,6 @@ void CSpiral::update(SPCtx *ctx, guint flags) {
CShape::update(ctx, flags);
}
-
void CSpiral::update_patheffect(bool write) {
SPSpiral* shape = this->spspiral;
diff --git a/src/sp-spiral.h b/src/sp-spiral.h
index aaca363c2..9220e74fe 100644
--- a/src/sp-spiral.h
+++ b/src/sp-spiral.h
@@ -23,10 +23,8 @@
#define SAMPLE_STEP (1.0/4.0) ///< step per 2PI
#define SAMPLE_SIZE 8 ///< sample size per one bezier
-#define SP_TYPE_SPIRAL (sp_spiral_get_type ())
-#define SP_SPIRAL(obj) ((SPSpiral*)obj)
-//#define SP_IS_SPIRAL(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPSpiral)))
+#define SP_SPIRAL(obj) ((SPSpiral*)obj)
#define SP_IS_SPIRAL(obj) (dynamic_cast<const SPSpiral*>((SPObject*)obj))
class CSpiral;
@@ -69,12 +67,6 @@ public:
void fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom::Point const& hat1, Geom::Point& hat2, double* t) const;
};
-/// The SPSpiral vtable.
-struct SPSpiralClass {
- SPShapeClass parent_class;
-};
-
-
class CSpiral : public CShape {
public:
CSpiral(SPSpiral* spiral);
@@ -95,8 +87,4 @@ protected:
SPSpiral* spspiral;
};
-
-/* Standard Gtk function */
-GType sp_spiral_get_type (void);
-
#endif // SEEN_SP_SPIRAL_H
diff --git a/src/sp-star.cpp b/src/sp-star.cpp
index 741591479..b6a6132a4 100644
--- a/src/sp-star.cpp
+++ b/src/sp-star.cpp
@@ -42,12 +42,6 @@ namespace {
bool starRegistered = SPFactory::instance().registerObject("star", createStar);
}
-G_DEFINE_TYPE(SPStar, sp_star, G_TYPE_OBJECT);
-
-static void sp_star_class_init(SPStarClass *klass)
-{
-}
-
CStar::CStar(SPStar* star) : CPolygon(star) {
this->spstar = star;
}
@@ -78,12 +72,6 @@ SPStar::SPStar() : SPPolygon() {
star->randomized = 0.0;
}
-static void
-sp_star_init (SPStar * star)
-{
- new (star) SPStar();
-}
-
void CStar::build(SPDocument * document, Inkscape::XML::Node * repr) {
SPStar* object = this->spstar;
diff --git a/src/sp-star.h b/src/sp-star.h
index 19b586dc0..3e787beb3 100644
--- a/src/sp-star.h
+++ b/src/sp-star.h
@@ -16,9 +16,8 @@
#include "sp-polygon.h"
-#define SP_TYPE_STAR (sp_star_get_type ())
+
#define SP_STAR(obj) ((SPStar*)obj)
-//#define SP_IS_STAR(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPStar)))
#define SP_IS_STAR(obj) (dynamic_cast<const SPStar*>((SPObject*)obj))
class CStar;
@@ -43,10 +42,6 @@ public:
double randomized;
};
-struct SPStarClass {
- SPPolygonClass parent_class;
-};
-
// CPPIFY: This derivation is a bit weird.
// parent_class = reinterpret_cast<SPShapeClass *>(g_type_class_ref(SP_TYPE_SHAPE));
// So shouldn't star be derived from shape instead of polygon?
@@ -71,9 +66,6 @@ protected:
SPStar* spstar;
};
-
-GType sp_star_get_type (void);
-
void sp_star_position_set (SPStar *star, gint sides, Geom::Point center, gdouble r1, gdouble r2, gdouble arg1, gdouble arg2, bool isflat, double rounded, double randomized);
Geom::Point sp_star_get_xy (SPStar const *star, SPStarPoint point, gint index, bool randomized = false);
diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp
index 22ebb5c17..e52879a03 100644
--- a/src/sp-tref.cpp
+++ b/src/sp-tref.cpp
@@ -469,7 +469,7 @@ void sp_tref_update_text(SPTRef *tref)
Inkscape::XML::Document *xml_doc = tref->document->getReprDoc();
Inkscape::XML::Node *newStringRepr = xml_doc->createTextNode(charData.c_str());
- tref->stringChild = SP_OBJECT(g_object_new(sp_repr_type_lookup(newStringRepr), NULL));
+ tref->stringChild = SPFactory::instance().createObject(*newStringRepr); //SP_OBJECT(g_object_new(sp_repr_type_lookup(newStringRepr), NULL));
// Add this SPString as a child of the tref
tref->attach(tref->stringChild, tref->lastChild());