From df7828a7a8ba0b7e6c2dd892ca5f0a62ef718bf0 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 24 Feb 2015 19:22:08 -0500 Subject: create SPObject factory (bzr r13939.1.1) --- src/Makefile_insert | 2 +- src/box3d-side.cpp | 10 - src/box3d.cpp | 10 - src/color-profile.cpp | 11 - src/document.cpp | 2 +- src/factory.h | 28 --- src/filters/blend.cpp | 14 -- src/filters/colormatrix.cpp | 14 -- src/filters/componenttransfer-funcnode.cpp | 30 --- src/filters/componenttransfer.cpp | 14 -- src/filters/composite.cpp | 14 -- src/filters/convolvematrix.cpp | 14 -- src/filters/diffuselighting.cpp | 14 -- src/filters/displacementmap.cpp | 14 -- src/filters/distantlight.cpp | 15 -- src/filters/flood.cpp | 14 -- src/filters/gaussian-blur.cpp | 13 -- src/filters/image.cpp | 14 -- src/filters/merge.cpp | 14 -- src/filters/mergenode.cpp | 14 -- src/filters/morphology.cpp | 14 -- src/filters/offset.cpp | 14 -- src/filters/pointlight.cpp | 14 -- src/filters/specularlighting.cpp | 14 -- src/filters/spotlight.cpp | 14 -- src/filters/tile.cpp | 14 -- src/filters/turbulence.cpp | 14 -- src/live_effects/lpeobject.cpp | 10 - src/persp3d.cpp | 10 - src/sp-anchor.cpp | 14 -- src/sp-clippath.cpp | 10 - src/sp-defs.cpp | 10 - src/sp-desc.cpp | 14 -- src/sp-ellipse.cpp | 29 --- src/sp-factory.cpp | 337 +++++++++++++++++++++++++++++ src/sp-factory.h | 20 +- src/sp-filter.cpp | 9 - src/sp-flowdiv.cpp | 34 --- src/sp-flowregion.cpp | 14 -- src/sp-flowtext.cpp | 10 - src/sp-font-face.cpp | 10 - src/sp-font.cpp | 9 - src/sp-glyph.cpp | 9 - src/sp-guide.cpp | 10 - src/sp-hatch-path.cpp | 17 -- src/sp-hatch.cpp | 16 -- src/sp-image.cpp | 9 - src/sp-item-group.cpp | 10 - src/sp-line.cpp | 13 -- src/sp-linear-gradient.cpp | 11 - src/sp-marker.cpp | 10 - src/sp-mask.cpp | 10 - src/sp-mesh-gradient.cpp | 11 - src/sp-mesh-patch.cpp | 10 - src/sp-mesh-row.cpp | 10 - src/sp-metadata.cpp | 10 - src/sp-missing-glyph.cpp | 10 - src/sp-namedview.cpp | 10 - src/sp-object.cpp | 12 +- src/sp-offset.cpp | 10 - src/sp-path.cpp | 10 - src/sp-pattern.cpp | 10 - src/sp-polygon.cpp | 12 - src/sp-polyline.cpp | 10 - src/sp-radial-gradient.cpp | 12 +- src/sp-rect.cpp | 10 - src/sp-root.cpp | 15 -- src/sp-script.cpp | 10 - src/sp-solid-color.cpp | 9 - src/sp-spiral.cpp | 10 - src/sp-star.cpp | 10 - src/sp-stop.cpp | 10 - src/sp-string.cpp | 17 -- src/sp-style-elem.cpp | 10 - src/sp-switch.cpp | 14 -- src/sp-symbol.cpp | 10 - src/sp-tag-use-reference.cpp | 10 - src/sp-tag-use.cpp | 13 +- src/sp-tag.cpp | 12 - src/sp-text.cpp | 14 -- src/sp-title.cpp | 14 -- src/sp-tref.cpp | 14 +- src/sp-tspan.cpp | 15 -- src/sp-use.cpp | 14 +- 84 files changed, 361 insertions(+), 1035 deletions(-) create mode 100644 src/sp-factory.cpp (limited to 'src') diff --git a/src/Makefile_insert b/src/Makefile_insert index b07541109..ea4755bb5 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -124,7 +124,7 @@ ink_common_sources += \ sp-defs.cpp sp-defs.h \ sp-desc.cpp sp-desc.h \ sp-ellipse.cpp sp-ellipse.h \ - sp-factory.h \ + sp-factory.h sp-factory.cpp \ sp-filter.cpp sp-filter.h number-opt-number.h \ sp-filter-primitive.cpp sp-filter-primitive.h \ sp-filter-reference.cpp sp-filter-reference.h \ diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 3058eab2d..93d55232e 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -28,16 +28,6 @@ static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); -#include "sp-factory.h" - -namespace { - SPObject* createBox3DSide() { - return new Box3DSide(); - } - - bool box3DSideRegistered = SPFactory::instance().registerObject("inkscape:box3dside", createBox3DSide); -} - Box3DSide::Box3DSide() : SPPolygon() { this->dir1 = Box3D::NONE; this->dir2 = Box3D::NONE; diff --git a/src/box3d.cpp b/src/box3d.cpp index 86f99049b..dc04a2eb6 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -44,16 +44,6 @@ static void box3d_ref_changed(SPObject *old_ref, SPObject *ref, SPBox3D *box); static gint counter = 0; -#include "sp-factory.h" - -namespace { - SPObject* createBox3D() { - return new SPBox3D(); - } - - bool box3DRegistered = SPFactory::instance().registerObject("inkscape:box3d", createBox3D); -} - SPBox3D::SPBox3D() : SPGroup() { this->my_counter = 0; this->swapped = Box3D::NONE; diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 28550b75d..85a6fa876 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -185,17 +185,6 @@ cmsHPROFILE ColorProfileImpl::getNULLProfile() { #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - -#include "sp-factory.h" - -namespace { - SPObject* createColorProfile() { - return new Inkscape::ColorProfile(); - } - - bool rectRegistered = SPFactory::instance().registerObject("svg:color-profile", createColorProfile); -} - ColorProfile::ColorProfile() : SPObject() { this->impl = new ColorProfileImpl(); diff --git a/src/document.cpp b/src/document.cpp index 11971e63d..2a50d00bd 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -368,7 +368,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, // Create SPRoot element const std::string typeString = NodeTraits::get_type_string(*rroot); - SPObject* rootObj = SPFactory::instance().createObject(typeString); + SPObject* rootObj = SPFactory::createObject(typeString); document->root = dynamic_cast(rootObj); if (document->root == 0) { diff --git a/src/factory.h b/src/factory.h index c1288b460..6b448064e 100644 --- a/src/factory.h +++ b/src/factory.h @@ -81,34 +81,6 @@ private: }; -struct NodeTraits { - static std::string get_type_string(Inkscape::XML::Node const &node) { - std::string name; - - switch (node.type()) { - case Inkscape::XML::TEXT_NODE: - name = "string"; - break; - - case Inkscape::XML::ELEMENT_NODE: { - char const *const sptype = node.attribute("sodipodi:type"); - - if (sptype) { - name = sptype; - } else { - name = node.name(); - } - break; - } - default: - name = ""; - break; - } - - return name; - } -}; - #endif /* diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index ca1d5bf96..6e92ef50f 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "sp-filter.h" @@ -30,16 +26,6 @@ #include "display/nr-filter-blend.h" #include "display/nr-filter-types.h" -#include "sp-factory.h" - -namespace { - SPObject* createBlend() { - return new SPFeBlend(); - } - - bool blendRegistered = SPFactory::instance().registerObject("svg:feBlend", createBlend); -} - SPFeBlend::SPFeBlend() : SPFilterPrimitive(), blend_mode(Inkscape::Filters::BLEND_NORMAL), in2(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp index 58f601a65..a7f0296c2 100644 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "attributes.h" @@ -29,16 +25,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-colormatrix.h" -#include "sp-factory.h" - -namespace { - SPObject* createColorMatrix() { - return new SPFeColorMatrix(); - } - - bool colorMatrixRegistered = SPFactory::instance().registerObject("svg:feColorMatrix", createColorMatrix); -} - SPFeColorMatrix::SPFeColorMatrix() : SPFilterPrimitive(), type(Inkscape::Filters::COLORMATRIX_MATRIX), value(0) { diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index d8c5b0d49..76e99a648 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "attributes.h" @@ -31,32 +27,6 @@ #include "macros.h" -#include "sp-factory.h" - -namespace { - SPObject* createFuncR() { - return new SPFeFuncNode(SPFeFuncNode::R); - } - - SPObject* createFuncG() { - return new SPFeFuncNode(SPFeFuncNode::G); - } - - SPObject* createFuncB() { - return new SPFeFuncNode(SPFeFuncNode::B); - } - - SPObject* createFuncA() { - return new SPFeFuncNode(SPFeFuncNode::A); - } - - bool funcRRegistered = SPFactory::instance().registerObject("svg:feFuncR", createFuncR); - bool funcGRegistered = SPFactory::instance().registerObject("svg:feFuncG", createFuncG); - bool funcBRegistered = SPFactory::instance().registerObject("svg:feFuncB", createFuncB); - bool funcARegistered = SPFactory::instance().registerObject("svg:feFuncA", createFuncA); -} - - /* FeFuncNode class */ SPFeFuncNode::SPFeFuncNode(SPFeFuncNode::Channel channel) : SPObject(), type(Inkscape::Filters::COMPONENTTRANSFER_TYPE_IDENTITY), diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index 610b3dd02..3d0264390 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "document.h" @@ -27,16 +23,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-component-transfer.h" -#include "sp-factory.h" - -namespace { - SPObject* createComponentTransfer() { - return new SPFeComponentTransfer(); - } - - bool componentTransferRegistered = SPFactory::instance().registerObject("svg:feComponentTransfer", createComponentTransfer); -} - SPFeComponentTransfer::SPFeComponentTransfer() : SPFilterPrimitive(), renderer(NULL) { diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index e600b6d20..3e651a778 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "filters/composite.h" @@ -25,16 +21,6 @@ #include "display/nr-filter-composite.h" #include "sp-filter.h" -#include "sp-factory.h" - -namespace { - SPObject* createComposite() { - return new SPFeComposite(); - } - - bool compositeRegistered = SPFactory::instance().registerObject("svg:feComposite", createComposite); -} - SPFeComposite::SPFeComposite() : SPFilterPrimitive(), composite_operator(COMPOSITE_DEFAULT), k1(0), k2(0), k3(0), k4(0), in2(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp index bd710b116..3a443bebc 100644 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include #include @@ -28,16 +24,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-convolve-matrix.h" -#include "sp-factory.h" - -namespace { - SPObject* createConvolveMatrix() { - return new SPFeConvolveMatrix(); - } - - bool convolveMatrixRegistered = SPFactory::instance().registerObject("svg:feConvolveMatrix", createConvolveMatrix); -} - SPFeConvolveMatrix::SPFeConvolveMatrix() : SPFilterPrimitive() { this->bias = 0; this->divisorIsSet = 0; diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index 09179a69d..120c058d2 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "strneq.h" #include "attributes.h" @@ -36,16 +32,6 @@ /* FeDiffuseLighting base class */ static void sp_feDiffuseLighting_children_modified(SPFeDiffuseLighting *sp_diffuselighting); -#include "sp-factory.h" - -namespace { - SPObject* createDiffuseLighting() { - return new SPFeDiffuseLighting(); - } - - bool diffuseLightingRegistered = SPFactory::instance().registerObject("svg:feDiffuseLighting", createDiffuseLighting); -} - SPFeDiffuseLighting::SPFeDiffuseLighting() : SPFilterPrimitive() { this->surfaceScale = 1; this->diffuseConstant = 1; diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index 7dedfc031..1dbea67ff 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "filters/displacementmap.h" @@ -25,16 +21,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-displacement-map.h" -#include "sp-factory.h" - -namespace { - SPObject* createDisplacementMap() { - return new SPFeDisplacementMap(); - } - - bool displacementMapRegistered = SPFactory::instance().registerObject("svg:feDisplacementMap", createDisplacementMap); -} - SPFeDisplacementMap::SPFeDisplacementMap() : SPFilterPrimitive() { this->scale=0; this->xChannelSelector = DISPLACEMENTMAP_CHANNEL_ALPHA; diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index bd8bd2797..fb7380174 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "attributes.h" @@ -30,17 +26,6 @@ #include "macros.h" -#include "sp-factory.h" - -namespace { - SPObject* createDistantLight() { - return new SPFeDistantLight(); - } - - bool distantLightRegistered = SPFactory::instance().registerObject("svg:feDistantLight", createDistantLight); -} - - SPFeDistantLight::SPFeDistantLight() : SPObject(), azimuth(0), azimuth_set(FALSE), elevation(0), elevation_set(FALSE) { } diff --git a/src/filters/flood.cpp b/src/filters/flood.cpp index 134492d34..94ca61b98 100644 --- a/src/filters/flood.cpp +++ b/src/filters/flood.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "strneq.h" #include "attributes.h" @@ -27,16 +23,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-flood.h" -#include "sp-factory.h" - -namespace { - SPObject* createFlood() { - return new SPFeFlood(); - } - - bool floodRegistered = SPFactory::instance().registerObject("svg:feFlood", createFlood); -} - SPFeFlood::SPFeFlood() : SPFilterPrimitive() { this->color = 0; diff --git a/src/filters/gaussian-blur.cpp b/src/filters/gaussian-blur.cpp index fc1e65925..43a1f6dfb 100644 --- a/src/filters/gaussian-blur.cpp +++ b/src/filters/gaussian-blur.cpp @@ -27,19 +27,6 @@ #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" -//#define SP_MACROS_SILENT -//#include "macros.h" - -#include "sp-factory.h" - -namespace { - SPObject* createGaussianBlur() { - return new SPGaussianBlur(); - } - - bool gaussianBlurRegistered = SPFactory::instance().registerObject("svg:feGaussianBlur", createGaussianBlur); -} - SPGaussianBlur::SPGaussianBlur() : SPFilterPrimitive() { } diff --git a/src/filters/image.cpp b/src/filters/image.cpp index 116939e0f..62e8b76b9 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "display/nr-filter-image.h" #include "uri.h" @@ -31,16 +27,6 @@ #include "display/nr-filter.h" -#include "sp-factory.h" - -namespace { - SPObject* createImage() { - return new SPFeImage(); - } - - bool imageRegistered = SPFactory::instance().registerObject("svg:feImage", createImage); -} - SPFeImage::SPFeImage() : SPFilterPrimitive() { this->href = NULL; this->from_element = 0; diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index 882ab36dd..68f671b11 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -11,10 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "xml/repr.h" @@ -24,16 +20,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-merge.h" -#include "sp-factory.h" - -namespace { - SPObject* createMerge() { - return new SPFeMerge(); - } - - bool mergeRegistered = SPFactory::instance().registerObject("svg:feMerge", createMerge); -} - SPFeMerge::SPFeMerge() : SPFilterPrimitive() { } diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index ba237c776..691184eb5 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -13,26 +13,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "xml/repr.h" #include "filters/mergenode.h" #include "filters/merge.h" #include "display/nr-filter-types.h" -#include "sp-factory.h" - -namespace { - SPObject* createMergeNode() { - return new SPFeMergeNode(); - } - - bool mergeNodeRegistered = SPFactory::instance().registerObject("svg:feMergeNode", createMergeNode); -} - SPFeMergeNode::SPFeMergeNode() : SPObject(), input(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) { } diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp index d3611b081..326c9b7a6 100644 --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "attributes.h" @@ -26,16 +22,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-morphology.h" -#include "sp-factory.h" - -namespace { - SPObject* createMorphology() { - return new SPFeMorphology(); - } - - bool morphologyRegistered = SPFactory::instance().registerObject("svg:feMorphology", createMorphology); -} - SPFeMorphology::SPFeMorphology() : SPFilterPrimitive() { this->Operator = Inkscape::Filters::MORPHOLOGY_OPERATOR_ERODE; diff --git a/src/filters/offset.cpp b/src/filters/offset.cpp index 234a1a964..c35649dcc 100644 --- a/src/filters/offset.cpp +++ b/src/filters/offset.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "filters/offset.h" @@ -25,16 +21,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-offset.h" -#include "sp-factory.h" - -namespace { - SPObject* createOffset() { - return new SPFeOffset(); - } - - bool offsetRegistered = SPFactory::instance().registerObject("svg:feOffset", createOffset); -} - SPFeOffset::SPFeOffset() : SPFilterPrimitive() { this->dx = 0; this->dy = 0; diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index 1c7532b4e..dd3a78f4c 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "attributes.h" @@ -29,16 +25,6 @@ #define SP_MACROS_SILENT #include "macros.h" -#include "sp-factory.h" - -namespace { - SPObject* createPointLight() { - return new SPFePointLight(); - } - - bool pointLightRegistered = SPFactory::instance().registerObject("svg:fePointLight", createPointLight); -} - SPFePointLight::SPFePointLight() : SPObject(), x(0), x_set(FALSE), y(0), y_set(FALSE), z(0), z_set(FALSE) { } diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index 6cdd5d9ba..bda1a0f30 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "strneq.h" #include "attributes.h" @@ -36,16 +32,6 @@ /* FeSpecularLighting base class */ static void sp_feSpecularLighting_children_modified(SPFeSpecularLighting *sp_specularlighting); -#include "sp-factory.h" - -namespace { - SPObject* createSpecularLighting() { - return new SPFeSpecularLighting(); - } - - bool specularLightingRegistered = SPFactory::instance().registerObject("svg:feSpecularLighting", createSpecularLighting); -} - SPFeSpecularLighting::SPFeSpecularLighting() : SPFilterPrimitive() { this->surfaceScale = 1; this->specularConstant = 1; diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index c0344067c..2e55d39d0 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "attributes.h" @@ -29,16 +25,6 @@ #define SP_MACROS_SILENT #include "macros.h" -#include "sp-factory.h" - -namespace { - SPObject* createSpotLight() { - return new SPFeSpotLight(); - } - - bool spotLightRegistered = SPFactory::instance().registerObject("svg:feSpotLight", createSpotLight); -} - SPFeSpotLight::SPFeSpotLight() : SPObject(), x(0), x_set(FALSE), y(0), y_set(FALSE), z(0), z_set(FALSE), pointsAtX(0), pointsAtX_set(FALSE), pointsAtY(0), pointsAtY_set(FALSE), pointsAtZ(0), pointsAtZ_set(FALSE), diff --git a/src/filters/tile.cpp b/src/filters/tile.cpp index 19e96f47d..623f3ab37 100644 --- a/src/filters/tile.cpp +++ b/src/filters/tile.cpp @@ -11,10 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "filters/tile.h" @@ -22,16 +18,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-tile.h" -#include "sp-factory.h" - -namespace { - SPObject* createTile() { - return new SPFeTile(); - } - - bool tileRegistered = SPFactory::instance().registerObject("svg:feTile", createTile); -} - SPFeTile::SPFeTile() : SPFilterPrimitive() { } diff --git a/src/filters/turbulence.cpp b/src/filters/turbulence.cpp index d33667a8c..7541175ed 100644 --- a/src/filters/turbulence.cpp +++ b/src/filters/turbulence.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "turbulence.h" @@ -28,16 +24,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-turbulence.h" -#include "sp-factory.h" - -namespace { - SPObject* createTurbulence() { - return new SPFeTurbulence(); - } - - bool turbulenceRegistered = SPFactory::instance().registerObject("svg:feTurbulence", createTurbulence); -} - SPFeTurbulence::SPFeTurbulence() : SPFilterPrimitive() { this->stitchTiles = 0; this->seed = 0; diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index d92c94d01..8e5ae568f 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -20,16 +20,6 @@ //#define LIVEPATHEFFECT_VERBOSE -#include "sp-factory.h" - -namespace { - SPObject* createLivepatheffect() { - return new LivePathEffectObject(); - } - - bool livepatheffectRegistered = SPFactory::instance().registerObject("inkscape:path-effect", createLivepatheffect); -} - 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 Inkscape::XML::NodeEventVector const livepatheffect_repr_events = { diff --git a/src/persp3d.cpp b/src/persp3d.cpp index c761947ad..dc0975d12 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -34,16 +34,6 @@ static void persp3d_on_repr_attr_changed (Inkscape::XML::Node * repr, const gcha static int global_counter = 0; -#include "sp-factory.h" - -namespace { - SPObject* createPersp3D() { - return new Persp3D(); - } - - bool persp3DRegistered = SPFactory::instance().registerObject("inkscape:persp3d", createPersp3D); -} - /* Constructor/destructor for the internal class */ Persp3DImpl::Persp3DImpl() { diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index 7b558bf08..78ba10c13 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -13,10 +13,6 @@ #define noSP_ANCHOR_VERBOSE -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "xml/quote.h" #include "xml/repr.h" @@ -25,16 +21,6 @@ #include "ui/view/view.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createAnchor() { - return new SPAnchor(); - } - - bool anchorRegistered = SPFactory::instance().registerObject("svg:a", createAnchor); -} - SPAnchor::SPAnchor() : SPGroup() { this->href = NULL; } diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 5065f25c3..3c6167438 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -40,16 +40,6 @@ struct SPClipPathView { static SPClipPathView* sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); static SPClipPathView* sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view); -#include "sp-factory.h" - -namespace { - SPObject* createClipPath() { - return new SPClipPath(); - } - - bool clipPathRegistered = SPFactory::instance().registerObject("svg:clipPath", createClipPath); -} - SPClipPath::SPClipPath() : SPObjectGroup() { this->clipPathUnits_set = FALSE; this->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE; diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index 334570076..8dd695867 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -20,16 +20,6 @@ #include "xml/repr.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createDefs() { - return new SPDefs(); - } - - bool defsRegistered = SPFactory::instance().registerObject("svg:defs", createDefs); -} - SPDefs::SPDefs() : SPObject() { } diff --git a/src/sp-desc.cpp b/src/sp-desc.cpp index 199ae0176..3c75d087a 100644 --- a/src/sp-desc.cpp +++ b/src/sp-desc.cpp @@ -9,23 +9,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "sp-desc.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createDesc() { - return new SPDesc(); - } - - bool descRegistered = SPFactory::instance().registerObject("svg:desc", createDesc); -} - SPDesc::SPDesc() : SPObject() { } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index a74d4687d..885fedafa 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -34,35 +34,6 @@ #include "svg/path-string.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { -SPObject *create_ellipse() -{ - SPGenericEllipse *ellipse = new SPGenericEllipse(); - ellipse->type = SP_GENERIC_ELLIPSE_ELLIPSE; - return ellipse; -} - -SPObject *create_circle() -{ - SPGenericEllipse *circle = new SPGenericEllipse(); - circle->type = SP_GENERIC_ELLIPSE_CIRCLE; - return circle; -} - -SPObject *create_arc() -{ - SPGenericEllipse *arc = new SPGenericEllipse(); - arc->type = SP_GENERIC_ELLIPSE_ARC; - return arc; -} - -bool ellipse_registered = SPFactory::instance().registerObject("svg:ellipse", create_ellipse); -bool circle_registered = SPFactory::instance().registerObject("svg:circle", create_circle); -bool arc_registered = SPFactory::instance().registerObject("arc", create_arc); -} - #ifndef M_PI #define M_PI 3.14159265358979323846 diff --git a/src/sp-factory.cpp b/src/sp-factory.cpp new file mode 100644 index 000000000..9911222e5 --- /dev/null +++ b/src/sp-factory.cpp @@ -0,0 +1,337 @@ +/* + * Factory for SPObject tree + * + * Authors: + * Markus Engel + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-factory.h" + +// primary +#include "box3d.h" +#include "box3d-side.h" +#include "color-profile.h" +#include "persp3d.h" +#include "sp-anchor.h" +#include "sp-clippath.h" +#include "sp-defs.h" +#include "sp-desc.h" +#include "sp-ellipse.h" +#include "sp-filter.h" +#include "sp-flowdiv.h" +#include "sp-flowregion.h" +#include "sp-flowtext.h" +#include "sp-font.h" +#include "sp-font-face.h" +#include "sp-glyph.h" +#include "sp-guide.h" +#include "sp-hatch.h" +#include "sp-hatch-path.h" +#include "sp-image.h" +#include "sp-item-group.h" +#include "sp-line.h" +#include "sp-linear-gradient.h" +#include "sp-marker.h" +#include "sp-mask.h" +#include "sp-mesh-gradient.h" +#include "sp-mesh-patch.h" +#include "sp-mesh-row.h" +#include "sp-metadata.h" +#include "sp-missing-glyph.h" +#include "sp-namedview.h" +#include "sp-object.h" +#include "sp-offset.h" +#include "sp-path.h" +#include "sp-pattern.h" +#include "sp-polygon.h" +#include "sp-polyline.h" +#include "sp-radial-gradient.h" +#include "sp-rect.h" +#include "sp-root.h" +#include "sp-script.h" +#include "sp-solid-color.h" +#include "sp-spiral.h" +#include "sp-star.h" +#include "sp-stop.h" +#include "sp-string.h" +#include "sp-style-elem.h" +#include "sp-switch.h" +#include "sp-symbol.h" +#include "sp-tag.h" +#include "sp-tag-use.h" +#include "sp-text.h" +#include "sp-textpath.h" +#include "sp-title.h" +#include "sp-tref.h" +#include "sp-tspan.h" +#include "sp-use.h" +#include "live_effects/lpeobject.h" + +// filters +#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/displacementmap.h" +#include "filters/distantlight.h" +#include "filters/flood.h" +#include "filters/gaussian-blur.h" +#include "filters/image.h" +#include "filters/merge.h" +#include "filters/mergenode.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" + +SPObject *SPFactory::createObject(std::string const& id) +{ + SPObject *ret = NULL; + + if (id == "inkscape:box3d") + ret = new SPBox3D; + else if (id == "inkscape:box3dside") + ret = new Box3DSide; + else if (id == "svg:color-profile") + ret = new Inkscape::ColorProfile; + else if (id == "inkscape:persp3d") + ret = new Persp3D; + else if (id == "svg:a") + ret = new SPAnchor; + else if (id == "svg:clipPath") + ret = new SPClipPath; + else if (id == "svg:defs") + ret = new SPDefs; + else if (id == "svg:desc") + ret = new SPDesc; + else if (id == "svg:ellipse") { + SPGenericEllipse *e = new SPGenericEllipse; + e->type = SP_GENERIC_ELLIPSE_ELLIPSE; + ret = e; + } else if (id == "svg:circle") { + SPGenericEllipse *c = new SPGenericEllipse; + c->type = SP_GENERIC_ELLIPSE_CIRCLE; + ret = c; + } else if (id == "arc") { + SPGenericEllipse *a = new SPGenericEllipse; + a->type = SP_GENERIC_ELLIPSE_ARC; + ret = a; + } + else if (id == "svg:filter") + ret = new SPFilter; + else if (id == "svg:flowDiv") + ret = new SPFlowdiv; + else if (id == "svg:flowSpan") + ret = new SPFlowtspan; + else if (id == "svg:flowPara") + ret = new SPFlowpara; + else if (id == "svg:flowLine") + ret = new SPFlowline; + else if (id == "svg:flowRegionBreak") + ret = new SPFlowregionbreak; + else if (id == "svg:flowRegion") + ret = new SPFlowregion; + else if (id == "svg:flowRegionExclude") + ret = new SPFlowregionExclude; + else if (id == "svg:flowRoot") + ret = new SPFlowtext; + else if (id == "svg:font") + ret = new SPFont; + else if (id == "svg:font-face") + ret = new SPFontFace; + else if (id == "svg:glyph") + ret = new SPGlyph; + else if (id == "sodipodi:guide") + ret = new SPGuide; + else if (id == "svg:hatch") + ret = new SPHatch; + else if (id == "svg:hatchPath") + ret = new SPHatchPath; + else if (id == "svg:image") + ret = new SPImage; + else if (id == "svg:g") + ret = new SPGroup; + else if (id == "svg:line") + ret = new SPLine; + else if (id == "svg:linearGradient") + ret = new SPLinearGradient; + else if (id == "svg:marker") + ret = new SPMarker; + else if (id == "svg:mask") + ret = new SPMask; + else if (id == "svg:meshGradient") + ret = new SPMeshGradient; + else if (id == "svg:meshPatch") + ret = new SPMeshPatch; + else if (id == "svg:meshRow") + ret = new SPMeshRow; + else if (id == "svg:metadata") + ret = new SPMetadata; + else if (id == "svg:missing-glyph") + ret = new SPMissingGlyph; + else if (id == "sodipodi:namedview") + ret = new SPNamedView; + else if (id == "inkscape:offset") + ret = new SPOffset; + else if (id == "svg:path") + ret = new SPPath; + else if (id == "svg:pattern") + ret = new SPPattern; + else if (id == "svg:polygon") + ret = new SPPolygon; + else if (id == "svg:polyline") + ret = new SPPolyLine; + else if (id == "svg:radialGradient") + ret = new SPRadialGradient; + else if (id == "svg:rect") + ret = new SPRect; + else if (id == "svg:svg") + ret = new SPRoot; + else if (id == "svg:script") + ret = new SPScript; + else if (id == "svg:solidColor") + ret = new SPSolidColor; + else if (id == "spiral") + ret = new SPSpiral; + else if (id == "star") + ret = new SPStar; + else if (id == "svg:stop") + ret = new SPStop; + else if (id == "string") + ret = new SPString; + else if (id == "svg:style") + ret = new SPStyleElem; + else if (id == "svg:switch") + ret = new SPSwitch; + else if (id == "svg:symbol") + ret = new SPSymbol; + else if (id == "inkscape:tag") + ret = new SPTag; + else if (id == "inkscape:tagref") + ret = new SPTagUse; + else if (id == "svg:text") + ret = new SPText; + else if (id == "svg:title") + ret = new SPTitle; + else if (id == "svg:tref") + ret = new SPTRef; + else if (id == "svg:tspan") + ret = new SPTSpan; + else if (id == "svg:textPath") + ret = new SPTextPath; + else if (id == "svg:use") + ret = new SPUse; + else if (id == "inkscape:path-effect") + ret = new LivePathEffectObject; + + + // filters + else if (id == "svg:feBlend") + ret = new SPFeBlend; + else if (id == "svg:feColorMatrix") + ret = new SPFeColorMatrix; + else if (id == "svg:feComponentTransfer") + ret = new SPFeComponentTransfer; + else if (id == "svg:feFuncR") + ret = new SPFeFuncNode(SPFeFuncNode::R); + else if (id == "svg:feFuncG") + ret = new SPFeFuncNode(SPFeFuncNode::G); + else if (id == "svg:feFuncB") + ret = new SPFeFuncNode(SPFeFuncNode::B); + else if (id == "svg:feFuncA") + ret = new SPFeFuncNode(SPFeFuncNode::A); + else if (id == "svg:feComposite") + ret = new SPFeComposite; + else if (id == "svg:feConvolveMatrix") + ret = new SPFeConvolveMatrix; + else if (id == "svg:feDiffuseLighting") + ret = new SPFeDiffuseLighting; + else if (id == "svg:feDisplacementMap") + ret = new SPFeDisplacementMap; + else if (id == "svg:feDistantLight") + ret = new SPFeDistantLight; + else if (id == "svg:feFlood") + ret = new SPFeFlood; + else if (id == "svg:feGaussianBlur") + ret = new SPGaussianBlur; + else if (id == "svg:feImage") + ret = new SPFeImage; + else if (id == "svg:feMerge") + ret = new SPFeMerge; + else if (id == "svg:feMergeNode") + ret = new SPFeMergeNode; + else if (id == "svg:feMorphology") + ret = new SPFeMorphology; + else if (id == "svg:feOffset") + ret = new SPFeOffset; + else if (id == "svg:fePointLight") + ret = new SPFePointLight; + else if (id == "svg:feSpecularLighting") + ret = new SPFeSpecularLighting; + else if (id == "svg:feSpotLight") + ret = new SPFeSpotLight; + else if (id == "svg:feTile") + ret = new SPFeTile; + else if (id == "svg:feTurbulence") + ret = new SPFeTurbulence; + else if (id == "inkscape:grid") + ret = new SPObject; // TODO wtf + else if (id == "rdf:RDF") // no SP node yet + {} + else if (id == "inkscape:clipboard") // SP node not necessary + {} + else if (id.empty()) // comments + {} + else { + fprintf(stderr, "WARNING: unknown type: %s", id.c_str()); + } + + return ret; +} + +std::string NodeTraits::get_type_string(Inkscape::XML::Node const &node) +{ + std::string name; + + switch (node.type()) { + case Inkscape::XML::TEXT_NODE: + name = "string"; + break; + + case Inkscape::XML::ELEMENT_NODE: { + char const *const sptype = node.attribute("sodipodi:type"); + + if (sptype) { + name = sptype; + } else { + name = node.name(); + } + break; + } + default: + name = ""; + break; + } + + return name; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/sp-factory.h b/src/sp-factory.h index 0621f77ba..040fd14ae 100644 --- a/src/sp-factory.h +++ b/src/sp-factory.h @@ -1,6 +1,6 @@ -/** @file +/* * Factory for SPObject tree - *//* + * * Authors: * Markus Engel * @@ -11,11 +11,23 @@ #ifndef SP_FACTORY_SEEN #define SP_FACTORY_SEEN -#include "factory.h" +#include class SPObject; -typedef Singleton< Factory > SPFactory; +namespace Inkscape { +namespace XML { +class Node; +} +} + +struct SPFactory { + static SPObject *createObject(std::string const& id); +}; + +struct NodeTraits { + static std::string get_type_string(Inkscape::XML::Node const &node); +}; #endif diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 9cb33a6f3..a70fbd5bb 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -41,15 +41,6 @@ using std::pair; static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); static void filter_ref_modified(SPObject *href, guint flags, SPFilter *filter); -#include "sp-factory.h" - -namespace { - SPObject* createFilter() { - return new SPFilter(); - } - - bool filterRegistered = SPFactory::instance().registerObject("svg:filter", createFilter); -} SPFilter::SPFilter() : SPObject(), filterUnits(SP_FILTER_UNITS_OBJECTBOUNDINGBOX), filterUnits_set(FALSE), diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index 00ba48b06..8d9c51ab8 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -1,45 +1,11 @@ /* */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "xml/repr.h" #include "sp-flowdiv.h" #include "sp-string.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createFlowdiv() { - return new SPFlowdiv(); - } - - SPObject* createFlowtspan() { - return new SPFlowtspan(); - } - - SPObject* createFlowpara() { - return new SPFlowpara(); - } - - SPObject* createFlowline() { - return new SPFlowline(); - } - - SPObject* createFlowregionbreak() { - return new SPFlowregionbreak(); - } - - bool flowdivRegistered = SPFactory::instance().registerObject("svg:flowDiv", createFlowdiv); - bool flowtspanRegistered = SPFactory::instance().registerObject("svg:flowSpan", createFlowtspan); - bool flowparaRegistered = SPFactory::instance().registerObject("svg:flowPara", createFlowpara); - bool flowlineRegistered = SPFactory::instance().registerObject("svg:flowLine", createFlowline); - bool flowregionbreakRegistered = SPFactory::instance().registerObject("svg:flowRegionBreak", createFlowregionbreak); -} - SPFlowdiv::SPFlowdiv() : SPItem() { } diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 580945d74..5715e5eb1 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -23,20 +23,6 @@ #include "livarot/Path.h" #include "livarot/Shape.h" -#include "sp-factory.h" - -namespace { - SPObject* createFlowregion() { - return new SPFlowregion(); - } - - SPObject* createFlowregionExclude() { - return new SPFlowregionExclude(); - } - - bool flowregionRegistered = SPFactory::instance().registerObject("svg:flowRegion", createFlowregion); - bool flowregionExcludeRegistered = SPFactory::instance().registerObject("svg:flowRegionExclude", createFlowregionExclude); -} static void GetDest(SPObject* child,Shape **computed); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 6d2385aff..cac3cc61d 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -34,16 +34,6 @@ #include "display/drawing-text.h" -#include "sp-factory.h" - -namespace { - SPObject* createFlowtext() { - return new SPFlowtext(); - } - - bool flowtextRegistered = SPFactory::instance().registerObject("svg:flowRoot", createFlowtext); -} - SPFlowtext::SPFlowtext() : SPItem() { this->par_indent = 0; } diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 9782f0c83..afd2a9dee 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -259,16 +259,6 @@ static std::vector sp_read_fontFaceStretchType(gchar const return v; } -#include "sp-factory.h" - -namespace { - SPObject* createFontFace() { - return new SPFontFace(); - } - - bool fontFaceRegistered = SPFactory::instance().registerObject("svg:font-face", createFontFace); -} - SPFontFace::SPFontFace() : SPObject() { std::vector style; style.push_back(SP_FONTFACE_STYLE_ALL); diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 62cf521d3..341a6159f 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -23,15 +23,6 @@ #include "display/nr-svgfonts.h" -#include "sp-factory.h" - -namespace { - SPObject* createFont() { - return new SPFont(); - } - - bool fontRegistered = SPFactory::instance().registerObject("svg:font", createFont); -} //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 diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index eaa69d486..4829aae51 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -20,15 +20,6 @@ #include "document.h" #include -#include "sp-factory.h" - -namespace { - SPObject* createGlyph() { - return new SPGlyph(); - } - bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); -} - SPGlyph::SPGlyph() : SPObject() //TODO: correct these values: diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 08b055508..4e1c5913d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -47,16 +47,6 @@ using Inkscape::DocumentUndo; using std::vector; -#include "sp-factory.h" - -namespace { - SPObject* createGuide() { - return new SPGuide(); - } - - bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide); -} - SPGuide::SPGuide() : SPObject() , label(NULL) diff --git a/src/sp-hatch-path.cpp b/src/sp-hatch-path.cpp index bc95c246e..32a514dcb 100644 --- a/src/sp-hatch-path.cpp +++ b/src/sp-hatch-path.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include #include <2geom/path.h> @@ -37,19 +33,6 @@ #include "svg/css-ostringstream.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - -SPObject* createHatchPath() -{ - return new SPHatchPath(); -} - -bool hatchRegistered = SPFactory::instance().registerObject("svg:hatchPath", createHatchPath); - -} // namespace - SPHatchPath::SPHatchPath() : offset(), _display(), diff --git a/src/sp-hatch.cpp b/src/sp-hatch.cpp index dfecb2250..ea4c5865a 100644 --- a/src/sp-hatch.cpp +++ b/src/sp-hatch.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include #include <2geom/transforms.h> @@ -35,18 +31,6 @@ #include "sp-hatch-path.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - -SPObject* createHatch() { - return new SPHatch(); -} - -bool hatchRegistered = SPFactory::instance().registerObject("svg:hatch", createHatch); - -} // namespace - SPHatch::SPHatch() : SPPaintServer(), href(), diff --git a/src/sp-image.cpp b/src/sp-image.cpp index b6177fae6..bf5b9ebcd 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -42,7 +42,6 @@ #include "snap-candidate.h" #include "preferences.h" #include "io/sys.h" -#include "sp-factory.h" #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #include "cms-system.h" @@ -112,14 +111,6 @@ extern guint update_in_progress; #define DEBUG_MESSAGE_SCISLAC(key, ...) #endif // DEBUG_LCMS -namespace { -SPObject* createImage() { - return new SPImage(); -} - -bool imageRegistered = SPFactory::instance().registerObject("svg:image", createImage); -} - SPImage::SPImage() : SPItem(), SPViewBox() { this->x.unset(); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 0f76051bc..0c65bbaed 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -58,16 +58,6 @@ using Inkscape::DocumentUndo; static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write); -#include "sp-factory.h" - -namespace { - SPObject* createGroup() { - return new SPGroup(); - } - - bool groupRegistered = SPFactory::instance().registerObject("svg:g", createGroup); -} - SPGroup::SPGroup() : SPLPEItem() { this->_layer_mode = SPGroup::GROUP; } diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 8af95b4ce..cf21be912 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -11,9 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif #include "attributes.h" #include "style.h" #include "sp-line.h" @@ -24,16 +21,6 @@ #include "document.h" #include "inkscape.h" -#include "sp-factory.h" - -namespace { - SPObject* createLine() { - return new SPLine(); - } - - bool lineRegistered = SPFactory::instance().registerObject("svg:line", createLine); -} - SPLine::SPLine() : SPShape() { this->x1.unset(); this->y1.unset(); diff --git a/src/sp-linear-gradient.cpp b/src/sp-linear-gradient.cpp index 6e9f5e6dd..29579b617 100644 --- a/src/sp-linear-gradient.cpp +++ b/src/sp-linear-gradient.cpp @@ -5,17 +5,6 @@ #include "attributes.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createLinearGradient() { - return new SPLinearGradient(); - } - - bool linearGradientRegistered = SPFactory::instance().registerObject("svg:linearGradient", createLinearGradient); -} - - /* * Linear Gradient */ diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 371a6c35c..d3cf50fa7 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -43,16 +43,6 @@ public: std::vector items; }; -#include "sp-factory.h" - -namespace { - SPObject* createMarker() { - return new SPMarker(); - } - - bool markerRegistered = SPFactory::instance().registerObject("svg:marker", createMarker); -} - SPMarker::SPMarker() : SPGroup(), SPViewBox() { this->markerUnits = 0; diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 9707c9d8e..d60473e1d 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -37,16 +37,6 @@ struct SPMaskView { SPMaskView *sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); SPMaskView *sp_mask_view_list_remove (SPMaskView *list, SPMaskView *view); -#include "sp-factory.h" - -namespace { - SPObject* createMask() { - return new SPMask(); - } - - bool maskRegistered = SPFactory::instance().registerObject("svg:mask", createMask); -} - SPMask::SPMask() : SPObjectGroup() { this->maskUnits_set = FALSE; this->maskUnits = SP_CONTENT_UNITS_OBJECTBOUNDINGBOX; diff --git a/src/sp-mesh-gradient.cpp b/src/sp-mesh-gradient.cpp index 5c6a2f9da..3301d257c 100644 --- a/src/sp-mesh-gradient.cpp +++ b/src/sp-mesh-gradient.cpp @@ -6,17 +6,6 @@ #include "sp-mesh-gradient.h" -#include "sp-factory.h" - -namespace { - SPObject* createMeshGradient() { - return new SPMeshGradient(); - } - - bool meshGradientRegistered = SPFactory::instance().registerObject("svg:meshGradient", createMeshGradient); -} - - /* * Mesh Gradient */ diff --git a/src/sp-mesh-patch.cpp b/src/sp-mesh-patch.cpp index 216de8270..e7c7c837d 100644 --- a/src/sp-mesh-patch.cpp +++ b/src/sp-mesh-patch.cpp @@ -20,16 +20,6 @@ #include "attributes.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createMeshPatch() { - return new SPMeshPatch(); - } - - bool meshPatchRegistered = SPFactory::instance().registerObject("svg:meshPatch", createMeshPatch); -} - SPMeshPatch* SPMeshPatch::getNextMeshPatch() { SPMeshPatch *result = 0; diff --git a/src/sp-mesh-row.cpp b/src/sp-mesh-row.cpp index 07747f7f5..f95909b63 100644 --- a/src/sp-mesh-row.cpp +++ b/src/sp-mesh-row.cpp @@ -19,16 +19,6 @@ #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createMeshRow() { - return new SPMeshRow(); - } - - bool meshRowRegistered = SPFactory::instance().registerObject("svg:meshRow", createMeshRow); -} - SPMeshRow* SPMeshRow::getNextMeshRow() { SPMeshRow *result = 0; diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index bf4ce27a1..6bdc2f0b9 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -33,16 +33,6 @@ /* Metadata base class */ -#include "sp-factory.h" - -namespace { - SPObject* createMetadata() { - return new SPMetadata(); - } - - bool metadataRegistered = SPFactory::instance().registerObject("svg:metadata", createMetadata); -} - SPMetadata::SPMetadata() : SPObject() { } diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index 06b741165..75de55693 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -19,16 +19,6 @@ #include "sp-missing-glyph.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createMissingGlyph() { - return new SPMissingGlyph(); - } - - bool missingGlyphRegistered = SPFactory::instance().registerObject("svg:missing-glyph", createMissingGlyph); -} - SPMissingGlyph::SPMissingGlyph() : SPObject() { //TODO: correct these values: this->d = NULL; diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index dc36e68b9..c26eff39f 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -56,16 +56,6 @@ static void sp_namedview_show_single_guide(SPGuide* guide, bool show); static gboolean sp_str_to_bool(const gchar *str); static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color); -#include "sp-factory.h" - -namespace { - SPObject* createNamedView() { - return new SPNamedView(); - } - - bool namedViewRegistered = SPFactory::instance().registerObject("sodipodi:namedview", createNamedView); -} - SPNamedView::SPNamedView() : SPObjectGroup(), snap_manager(this) { this->zoom = 0; this->guidecolor = 0; diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 1094b88a7..343db435e 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -61,14 +61,6 @@ using std::strstr; # define debug(f, a...) /* */ #endif -namespace { - SPObject* createObject() { - return new SPObject(); - } - - bool gridRegistered = SPFactory::instance().registerObject("inkscape:grid", createObject); -} - guint update_in_progress = 0; // guard against update-during-update Inkscape::XML::NodeEventVector object_event_vector = { @@ -629,7 +621,7 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) const std::string type_string = NodeTraits::get_type_string(*child); - SPObject* ochild = SPFactory::instance().createObject(type_string); + SPObject* ochild = SPFactory::createObject(type_string); if (ochild == NULL) { // Currenty, there are many node types that do not have // corresponding classes in the SPObject tree. @@ -688,7 +680,7 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { for (Inkscape::XML::Node *rchild = repr->firstChild() ; rchild != NULL; rchild = rchild->next()) { const std::string typeString = NodeTraits::get_type_string(*rchild); - SPObject* child = SPFactory::instance().createObject(typeString); + SPObject* child = SPFactory::createObject(typeString); if (child == NULL) { // Currenty, there are many node types that do not have // corresponding classes in the SPObject tree. diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 3aa1e4eb6..15d3821c7 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -43,16 +43,6 @@ class SPDocument; -#include "sp-factory.h" - -namespace { - SPObject* createOffset() { - return new SPOffset(); - } - - bool offsetRegistered = SPFactory::instance().registerObject("inkscape:offset", createOffset); -} - #define noOFFSET_VERBOSE /** \note diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 0fef57698..51cc8d6dc 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -51,16 +51,6 @@ #define noPATH_VERBOSE -#include "sp-factory.h" - -namespace { - SPObject* createPath() { - return new SPPath(); - } - - bool pathRegistered = SPFactory::instance().registerObject("svg:path", createPath); -} - gint SPPath::nodesInPath() const { return _curve ? _curve->nodes_in_path() : 0; diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 961ab0f84..987a86fe4 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -45,16 +45,6 @@ static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat); static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern); -#include "sp-factory.h" - -namespace { - SPObject* createPattern() { - return new SPPattern(); - } - - bool patternRegistered = SPFactory::instance().registerObject("svg:pattern", createPattern); -} - SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { this->href = NULL; diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index 302905a62..af71280d5 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -11,8 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include "attributes.h" #include "sp-polygon.h" #include "display/curve.h" @@ -25,16 +23,6 @@ #include "xml/repr.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createPolygon() { - return new SPPolygon(); - } - - bool polygonRegistered = SPFactory::instance().registerObject("svg:polygon", createPolygon); -} - SPPolygon::SPPolygon() : SPShape() { } diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index c80190097..a12f927b5 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -20,16 +20,6 @@ #include "xml/repr.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createPolyLine() { - return new SPPolyLine(); - } - - bool polyLineRegistered = SPFactory::instance().registerObject("svg:polyline", createPolyLine); -} - SPPolyLine::SPPolyLine() : SPShape() { } diff --git a/src/sp-radial-gradient.cpp b/src/sp-radial-gradient.cpp index 2c2b17b7d..8fb230ba7 100644 --- a/src/sp-radial-gradient.cpp +++ b/src/sp-radial-gradient.cpp @@ -5,17 +5,7 @@ #include "attributes.h" #include "xml/repr.h" -#include "2geom/transforms.h" - -#include "sp-factory.h" - -namespace { - SPObject* createRadialGradient() { - return new SPRadialGradient(); - } - - bool radialGradientRegistered = SPFactory::instance().registerObject("svg:radialGradient", createRadialGradient); -} +#include <2geom/transforms.h> /* * Radial Gradient diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index af3e2bfb4..361d3c8c0 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -31,16 +31,6 @@ #define noRECT_VERBOSE -#include "sp-factory.h" - -namespace { - SPObject* createRect() { - return new SPRect(); - } - - bool rectRegistered = SPFactory::instance().registerObject("svg:rect", createRect); -} - SPRect::SPRect() : SPShape() { } diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 3a39a51c1..8bedec0a5 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include <2geom/transforms.h> @@ -32,17 +28,6 @@ #include "xml/repr.h" #include "util/units.h" -#include "sp-factory.h" - -namespace { -SPObject *createRoot() -{ - return new SPRoot(); -} - -bool rootRegistered = SPFactory::instance().registerObject("svg:svg", createRoot); -} - SPRoot::SPRoot() : SPGroup(), SPViewBox() { this->onload = NULL; diff --git a/src/sp-script.cpp b/src/sp-script.cpp index 260b3dcfd..f1ea9c9bd 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -16,16 +16,6 @@ #include #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createScript() { - return new SPScript(); - } - - bool scriptRegistered = SPFactory::instance().registerObject("svg:script", createScript); -} - SPScript::SPScript() : SPObject() { this->xlinkhref = NULL; } diff --git a/src/sp-solid-color.cpp b/src/sp-solid-color.cpp index 72569d8c0..f319410b0 100644 --- a/src/sp-solid-color.cpp +++ b/src/sp-solid-color.cpp @@ -16,18 +16,9 @@ #include "style.h" #include "xml/repr.h" -#include "sp-factory.h" #include "sp-item.h" #include "style-internal.h" -namespace { - SPObject* createSolidColor() { - return new SPSolidColor(); - } - - bool solidColorRegistered = SPFactory::instance().registerObject("svg:solidColor", createSolidColor); -} - /* * Solid Color diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 9ef73d56d..5dbd7dfa0 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -28,16 +28,6 @@ #include "sp-spiral.h" -#include "sp-factory.h" - -namespace { - SPObject* createSpiral() { - return new SPSpiral(); - } - - bool spiralRegistered = SPFactory::instance().registerObject("spiral", createSpiral); -} - SPSpiral::SPSpiral() : SPShape() , cx(0) diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 97a690520..51d5e6254 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -32,16 +32,6 @@ #include "sp-star.h" -#include "sp-factory.h" - -namespace { - SPObject* createStar() { - return new SPStar(); - } - - bool starRegistered = SPFactory::instance().registerObject("star", createStar); -} - SPStar::SPStar() : SPPolygon() { this->sides = 5; this->center = Geom::Point(0, 0); diff --git a/src/sp-stop.cpp b/src/sp-stop.cpp index 3ee467322..5e8fed86c 100644 --- a/src/sp-stop.cpp +++ b/src/sp-stop.cpp @@ -24,16 +24,6 @@ #include "svg/css-ostringstream.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createStop() { - return new SPStop(); - } - - bool stopRegistered = SPFactory::instance().registerObject("svg:stop", createStop); -} - SPStop::SPStop() : SPObject() { this->path_string = NULL; diff --git a/src/sp-string.cpp b/src/sp-string.cpp index b561187d0..26bb44006 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -22,30 +22,13 @@ * */ - - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - - #include "sp-string.h" #include "style.h" #include "xml/repr.h" -#include "sp-factory.h" - #include -namespace { - SPObject* createString() { - return new SPString(); - } - - bool stringRegistered = SPFactory::instance().registerObject("string", createString); -} - /*##################################################### # SPSTRING #####################################################*/ diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index 668780272..80e45677c 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -7,16 +7,6 @@ #include "style.h" using Inkscape::XML::TEXT_NODE; -#include "sp-factory.h" - -namespace { - SPObject* createStyle() { - return new SPStyleElem(); - } - - bool styleRegistered = SPFactory::instance().registerObject("svg:style", createStyle); -} - SPStyleElem::SPStyleElem() : SPObject() { media_set_all(this->media); this->is_css = false; diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index db6db9909..66cec3637 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "sp-switch.h" @@ -25,16 +21,6 @@ #include #include -#include "sp-factory.h" - -namespace { - SPObject* createSwitch() { - return new SPSwitch(); - } - - bool switchRegistered = SPFactory::instance().registerObject("svg:switch", createSwitch); -} - SPSwitch::SPSwitch() : SPGroup() { this->_cached_item = 0; } diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 3156680b3..62fb232a3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -26,16 +26,6 @@ #include "sp-symbol.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createSymbol() { - return new SPSymbol(); - } - - bool symbolRegistered = SPFactory::instance().registerObject("svg:symbol", createSymbol); -} - SPSymbol::SPSymbol() : SPGroup(), SPViewBox() { } diff --git a/src/sp-tag-use-reference.cpp b/src/sp-tag-use-reference.cpp index 50c011812..220cd16d1 100644 --- a/src/sp-tag-use-reference.cpp +++ b/src/sp-tag-use-reference.cpp @@ -20,16 +20,6 @@ #include "sp-text.h" #include "uri.h" -#if 0 -namespace { - SPObject* createTagUseReference() { - return new SPTag(); - } - bool tagUseReferencesRegistered = SPFactory::instance().registerObject("inkscape:tag", createTag); -} -// this SPObject doesn't need to be registered -#endif - bool SPTagUseReference::_acceptObject(SPObject * const obj) const { diff --git a/src/sp-tag-use.cpp b/src/sp-tag-use.cpp index 5851598f2..935f7429e 100644 --- a/src/sp-tag-use.cpp +++ b/src/sp-tag-use.cpp @@ -10,10 +10,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include @@ -30,13 +26,6 @@ #include "sp-tag-use.h" #include "sp-tag-use-reference.h" -namespace { - SPObject* createTagUse() { - return new SPTagUse(); - } - bool tagUseRegistered = SPFactory::instance().registerObject("inkscape:tagref", createTagUse); -} - SPTagUse::SPTagUse() { href = NULL; @@ -173,7 +162,7 @@ SPTagUse::href_changed(SPObject */*old_ref*/, SPObject */*ref*/) Inkscape::XML::Node *childrepr = refobj->getRepr(); const std::string typeString = NodeTraits::get_type_string(*childrepr); - SPObject* child_ = SPFactory::instance().createObject(typeString); + SPObject* child_ = SPFactory::createObject(typeString); if (child_) { child = child_; attach(child_, lastChild()); diff --git a/src/sp-tag.cpp b/src/sp-tag.cpp index c4b40417f..d331e6b18 100644 --- a/src/sp-tag.cpp +++ b/src/sp-tag.cpp @@ -10,23 +10,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" -#include "sp-factory.h" #include "sp-tag.h" #include "xml/repr.h" #include -namespace { - SPObject* createTag() { - return new SPTag(); - } - bool tagsRegistered = SPFactory::instance().registerObject("inkscape:tag", createTag); -} - /* * Move this SPItem into or after another SPItem in the doc * \param target - the SPItem to move into or after diff --git a/src/sp-text.cpp b/src/sp-text.cpp index e40661824..0dca42bb4 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -23,10 +23,6 @@ * */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <2geom/affine.h> #include #include @@ -55,22 +51,12 @@ #include "text-editing.h" -#include "sp-factory.h" - // For SVG 2 text flow #include "livarot/Path.h" #include "livarot/Shape.h" #include "sp-shape.h" #include "display/curve.h" -namespace { - SPObject* createText() { - return new SPText(); - } - - bool textRegistered = SPFactory::instance().registerObject("svg:text", createText); -} - /*##################################################### # SPTEXT #####################################################*/ diff --git a/src/sp-title.cpp b/src/sp-title.cpp index 4ecfcfa8e..ba5ae754a 100644 --- a/src/sp-title.cpp +++ b/src/sp-title.cpp @@ -9,23 +9,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "sp-title.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createTitle() { - return new SPTitle(); - } - - bool titleRegistered = SPFactory::instance().registerObject("svg:title", createTitle); -} - SPTitle::SPTitle() : SPObject() { } diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 6a229e170..aef18462a 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -16,10 +16,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "attributes.h" @@ -35,14 +31,6 @@ #include "xml/node.h" #include "xml/repr.h" -namespace { - SPObject* createTRef() { - return new SPTRef(); - } - - bool trefRegistered = SPFactory::instance().registerObject("svg:tref", createTRef); -} - //#define DEBUG_TREF #ifdef DEBUG_TREF # define debug(f, a...) { g_message("%s(%d) %s:", \ @@ -413,7 +401,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 = SPFactory::instance().createObject(NodeTraits::get_type_string(*newStringRepr)); + tref->stringChild = SPFactory::createObject(NodeTraits::get_type_string(*newStringRepr)); // Add this SPString as a child of the tref tref->attach(tref->stringChild, tref->lastChild()); diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 147efff33..7582cb9e6 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -44,21 +44,6 @@ #include "document.h" #include "2geom/transforms.h" -#include "sp-factory.h" - -namespace { - SPObject* createTSpan() { - return new SPTSpan(); - } - - SPObject* createTextPath() { - return new SPTextPath(); - } - - bool tspanRegistered = SPFactory::instance().registerObject("svg:tspan", createTSpan); - bool textPathRegistered = SPFactory::instance().registerObject("svg:textPath", createTextPath); -} - /*##################################################### # SPTSPAN #####################################################*/ diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 7e02de3c1..239f487a4 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include @@ -42,14 +38,6 @@ #include "sp-text.h" #include "sp-flowtext.h" -namespace { - SPObject* createUse() { - return new SPUse(); - } - - bool useRegistered = SPFactory::instance().registerObject("svg:use", createUse); -} - SPUse::SPUse() : SPItem(), child(NULL), @@ -482,7 +470,7 @@ void SPUse::href_changed() { if (refobj) { Inkscape::XML::Node *childrepr = refobj->getRepr(); - SPObject* obj = SPFactory::instance().createObject(NodeTraits::get_type_string(*childrepr)); + SPObject* obj = SPFactory::createObject(NodeTraits::get_type_string(*childrepr)); SPItem *item = dynamic_cast(obj); if (item) { -- cgit v1.2.3 From 73f83ba325e7d28693363d8d6e6b9482e4e12081 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 24 Feb 2015 20:04:28 -0500 Subject: Strip ToolFactory (bzr r13939.1.2) --- src/CMakeLists.txt | 1 + src/desktop.cpp | 2 +- src/ui/CMakeLists.txt | 1 + src/ui/Makefile_insert | 1 + src/ui/tool-factory.cpp | 102 +++++++++++++++++++++++++++++++++++++ src/ui/tool-factory.h | 10 ++-- src/ui/tools/arc-tool.cpp | 10 ---- src/ui/tools/box3d-tool.cpp | 10 ---- src/ui/tools/calligraphic-tool.cpp | 10 ---- src/ui/tools/connector-tool.cpp | 10 ---- src/ui/tools/dropper-tool.cpp | 10 ---- src/ui/tools/eraser-tool.cpp | 10 ---- src/ui/tools/flood-tool.cpp | 10 ---- src/ui/tools/gradient-tool.cpp | 10 ---- src/ui/tools/lpe-tool.cpp | 11 ---- src/ui/tools/measure-tool.cpp | 10 ---- src/ui/tools/mesh-tool.cpp | 10 ---- src/ui/tools/node-tool.cpp | 10 ---- src/ui/tools/pen-tool.cpp | 9 ---- src/ui/tools/pencil-tool.cpp | 9 ---- src/ui/tools/rect-tool.cpp | 10 ---- src/ui/tools/select-tool.cpp | 9 ---- src/ui/tools/spiral-tool.cpp | 10 ---- src/ui/tools/spray-tool.cpp | 10 ---- src/ui/tools/star-tool.cpp | 10 ---- src/ui/tools/text-tool.cpp | 9 ---- src/ui/tools/tweak-tool.cpp | 10 ---- src/ui/tools/zoom-tool.cpp | 9 ---- 28 files changed, 112 insertions(+), 221 deletions(-) create mode 100644 src/ui/tool-factory.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 617e9dce1..ddb715f55 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,7 @@ set(sp_SRC sp-defs.cpp sp-desc.cpp sp-ellipse.cpp + sp-factory.cpp sp-filter-primitive.cpp sp-filter-reference.cpp sp-filter.cpp diff --git a/src/desktop.cpp b/src/desktop.cpp index cdf8f276c..1152184c9 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -687,7 +687,7 @@ void SPDesktop::set_event_context2(const std::string& toolName) } } - Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::instance().createObject(toolName); + Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::createObject(toolName); new_tool->desktop = this; new_tool->message_context = new Inkscape::MessageContext(this->messageStack()); event_context = new_tool; diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 98a5a224c..674254686 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -8,6 +8,7 @@ set(ui_SRC object-edit.cpp previewholder.cpp shape-editor.cpp + tool-factory.cpp tools-switch.cpp uxmanager.cpp diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert index 7aeb4a83d..f94cba4e9 100644 --- a/src/ui/Makefile_insert +++ b/src/ui/Makefile_insert @@ -21,6 +21,7 @@ ink_common_sources += \ ui/previewholder.h \ ui/shape-editor.cpp \ ui/shape-editor.h \ + ui/tool-factory.cpp \ ui/tool-factory.h \ ui/tools-switch.cpp \ ui/tools-switch.h \ diff --git a/src/ui/tool-factory.cpp b/src/ui/tool-factory.cpp new file mode 100644 index 000000000..700bd40ce --- /dev/null +++ b/src/ui/tool-factory.cpp @@ -0,0 +1,102 @@ +/* + * Factory for ToolBase tree + * + * Authors: + * Markus Engel + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "tool-factory.h" + +#include "ui/tools/arc-tool.h" +#include "ui/tools/box3d-tool.h" +#include "ui/tools/calligraphic-tool.h" +#include "ui/tools/connector-tool.h" +#include "ui/tools/dropper-tool.h" +#include "ui/tools/eraser-tool.h" +#include "ui/tools/flood-tool.h" +#include "ui/tools/gradient-tool.h" +#include "ui/tools/lpe-tool.h" +#include "ui/tools/measure-tool.h" +#include "ui/tools/mesh-tool.h" +#include "ui/tools/node-tool.h" +#include "ui/tools/pencil-tool.h" +#include "ui/tools/pen-tool.h" +#include "ui/tools/rect-tool.h" +#include "ui/tools/select-tool.h" +#include "ui/tools/spiral-tool.h" +#include "ui/tools/spray-tool.h" +#include "ui/tools/star-tool.h" +#include "ui/tools/text-tool.h" +#include "ui/tools/tool-base.h" +#include "ui/tools/tweak-tool.h" +#include "ui/tools/zoom-tool.h" + +using namespace Inkscape::UI::Tools; + +ToolBase *ToolFactory::createObject(std::string const& id) +{ + ToolBase *tool = NULL; + + if (id == "/tools/shapes/arc") + tool = new ArcTool; + else if (id == "/tools/shapes/3dbox") + tool = new Box3dTool; + else if (id == "/tools/calligraphic") + tool = new CalligraphicTool; + else if (id == "/tools/connector") + tool = new ConnectorTool; + else if (id == "/tools/dropper") + tool = new DropperTool; + else if (id == "/tools/eraser") + tool = new EraserTool; + else if (id == "/tools/paintbucket") + tool = new FloodTool; + else if (id == "/tools/gradient") + tool = new GradientTool; + else if (id == "/tools/lpetool") + tool = new LpeTool; + else if (id == "/tools/measure") + tool = new MeasureTool; + else if (id == "/tools/mesh") + tool = new MeshTool; + else if (id == "/tools/nodes") + tool = new NodeTool; + else if (id == "/tools/freehand/pencil") + tool = new PencilTool; + else if (id == "/tools/freehand/pen") + tool = new PenTool; + else if (id == "/tools/shapes/rect") + tool = new RectTool; + else if (id == "/tools/select") + tool = new SelectTool; + else if (id == "/tools/shapes/spiral") + tool = new SpiralTool; + else if (id == "/tools/spray") + tool = new SprayTool; + else if (id == "/tools/shapes/star") + tool = new StarTool; + else if (id == "/tools/text") + tool = new TextTool; + else if (id == "/tools/tweak") + tool = new TweakTool; + else if (id == "/tools/zoom") + tool = new ZoomTool; + else + fprintf(stderr, "WARNING: unknown tool: %s", id.c_str()); + + return tool; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/tool-factory.h b/src/ui/tool-factory.h index 726706732..3b041fec5 100644 --- a/src/ui/tool-factory.h +++ b/src/ui/tool-factory.h @@ -1,6 +1,6 @@ -/** @file +/* * Factory for ToolBase tree - *//* + * * Authors: * Markus Engel * @@ -11,7 +11,7 @@ #ifndef TOOL_FACTORY_SEEN #define TOOL_FACTORY_SEEN -#include "factory.h" +#include namespace Inkscape { namespace UI { @@ -23,7 +23,9 @@ class ToolBase; } } -typedef Singleton< Factory > ToolFactory; +struct ToolFactory { + static Inkscape::UI::Tools::ToolBase *createObject(std::string const& id); +}; #endif diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index b9206407a..c6a9bb23a 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -48,20 +48,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createArcContext() { - return new ArcTool(); - } - - bool arcContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/arc", createArcContext); -} - const std::string& ArcTool::getPrefsPath() { return ArcTool::prefsPath; } diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index f8ae685c4..538e0c7e2 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -52,20 +52,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createBox3dTool() { - return new Box3dTool(); - } - - bool Box3dToolRegistered = ToolFactory::instance().registerObject("/tools/shapes/3dbox", createBox3dTool); -} - const std::string& Box3dTool::getPrefsPath() { return Box3dTool::prefsPath; } diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 151ab5f89..15e6527a3 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -82,22 +82,12 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { static void add_cap(SPCurve *curve, Geom::Point const &from, Geom::Point const &to, double rounding); -namespace { - ToolBase* createCalligraphicContext() { - return new CalligraphicTool(); - } - - bool calligraphicContextRegistered = ToolFactory::instance().registerObject("/tools/calligraphic", createCalligraphicContext); -} - const std::string& CalligraphicTool::getPrefsPath() { return CalligraphicTool::prefsPath; } diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 26a4eadd5..d76b0d142 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -109,8 +109,6 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { @@ -147,14 +145,6 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { NULL /* order_changed */ }; -namespace { - ToolBase* createConnectorContext() { - return new ConnectorTool(); - } - - bool connectorContextRegistered = ToolFactory::instance().registerObject("/tools/connector", createConnectorContext); -} - const std::string& ConnectorTool::getPrefsPath() { return ConnectorTool::prefsPath; } diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 9038628ee..bda9d8e8a 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -52,20 +52,10 @@ using Inkscape::DocumentUndo; static GdkCursor *cursor_dropper_fill = NULL; static GdkCursor *cursor_dropper_stroke = NULL; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createDropperContext() { - return new DropperTool(); - } - - bool dropperContextRegistered = ToolFactory::instance().registerObject("/tools/dropper", createDropperContext); -} - const std::string& DropperTool::getPrefsPath() { return DropperTool::prefsPath; } diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 1b4dcfe25..af0cbcb78 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -84,20 +84,10 @@ using Inkscape::DocumentUndo; #define DRAG_DEFAULT 1.0 #define DRAG_MAX 1.0 -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createEraserContext() { - return new EraserTool(); - } - - bool eraserContextRegistered = ToolFactory::instance().registerObject("/tools/eraser", createEraserContext); -} - const std::string& EraserTool::getPrefsPath() { return EraserTool::prefsPath; } diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index f9b64e4fd..bb8782dfa 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -74,20 +74,10 @@ using Inkscape::Display::ExtractARGB32; using Inkscape::Display::ExtractRGB32; using Inkscape::Display::AssembleARGB32; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createPaintbucketContext() { - return new FloodTool(); - } - - bool paintbucketContextRegistered = ToolFactory::instance().registerObject("/tools/paintbucket", createPaintbucketContext); -} - const std::string& FloodTool::getPrefsPath() { return FloodTool::prefsPath; } diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 5da30da7b..5be84eb76 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -51,22 +51,12 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint state, guint32 etime); -namespace { - ToolBase* createGradientContext() { - return new GradientTool(); - } - - bool gradientContextRegistered = ToolFactory::instance().registerObject("/tools/gradient", createGradientContext); -} - const std::string& GradientTool::getPrefsPath() { return GradientTool::prefsPath; } diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index c9b656397..c0517578d 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -58,23 +58,12 @@ SubtoolEntry lpesubtools[] = { {Inkscape::LivePathEffect::MIRROR_SYMMETRY, "draw-geometry-mirror"} }; - -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data); -namespace { - ToolBase* createLPEToolContext() { - return new LpeTool(); - } - - bool lpetoolContextRegistered = ToolFactory::instance().registerObject("/tools/lpetool", createLPEToolContext); -} - const std::string& LpeTool::getPrefsPath() { return LpeTool::prefsPath; } diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index b7e54b9c8..0875c29e0 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -49,22 +49,12 @@ using Inkscape::ControlManager; using Inkscape::CTLINE_SECONDARY; using Inkscape::Util::unit_table; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { std::vector measure_tmp_items; -namespace { - ToolBase* createMeasureContext() { - return new MeasureTool(); - } - - bool measureContextRegistered = ToolFactory::instance().registerObject("/tools/measure", createMeasureContext); -} - const std::string& MeasureTool::getPrefsPath() { return MeasureTool::prefsPath; } diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index d333b932e..9527b7de8 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -53,22 +53,12 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { static void sp_mesh_drag(MeshTool &rc, Geom::Point const pt, guint state, guint32 etime); -namespace { - ToolBase* createMeshContext() { - return new MeshTool(); - } - - bool meshContextRegistered = ToolFactory::instance().registerObject("/tools/mesh", createMeshContext); -} - const std::string& MeshTool::getPrefsPath() { return MeshTool::prefsPath; } diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index caec901a6..f8045a029 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -107,20 +107,10 @@ using Inkscape::ControlManager; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createNodesContext() { - return new NodeTool(); - } - - bool nodesContextRegistered = ToolFactory::instance().registerObject("/tools/nodes", createNodesContext); -} - const std::string& NodeTool::getPrefsPath() { return NodeTool::prefsPath; } diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 5174775c9..d28b7c27a 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -73,8 +73,6 @@ #include "live_effects/lpe-bspline.h" #include <2geom/nearest-point.h> -#include "ui/tool-factory.h" - #include "live_effects/effect.h" @@ -88,13 +86,6 @@ static Geom::Point pen_drag_origin_w(0, 0); static bool pen_within_tolerance = false; static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical const double handleCubicGap = 0.01; -namespace { - ToolBase* createPenContext() { - return new PenTool(); - } - - bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext); -} const std::string& PenTool::getPrefsPath() { return PenTool::prefsPath; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 28fed3a8f..db24c7432 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -43,7 +43,6 @@ #include "display/sp-canvas.h" #include "display/curve.h" #include "livarot/Path.h" -#include "ui/tool-factory.h" #include "ui/tool/event-utils.h" namespace Inkscape { @@ -55,14 +54,6 @@ static bool pencil_within_tolerance = false; static bool in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; } -namespace { - ToolBase* createPencilContext() { - return new PencilTool(); - } - - bool pencilContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pencil", createPencilContext); -} - const std::string& PencilTool::getPrefsPath() { return PencilTool::prefsPath; } diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 9476ff624..62a9006ea 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -46,20 +46,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createRectContext() { - return new RectTool(); - } - - bool rectContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/rect", createRectContext); -} - const std::string& RectTool::getPrefsPath() { return RectTool::prefsPath; } diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 939b1a0b3..40b994968 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -49,7 +49,6 @@ #include "display/sp-canvas.h" #include "display/sp-canvas-item.h" #include "display/drawing-item.h" -#include "ui/tool-factory.h" using Inkscape::DocumentUndo; @@ -65,14 +64,6 @@ static GdkCursor *CursorSelectDragging = NULL; static gint rb_escaped = 0; // if non-zero, rubberband was canceled by esc, so the next button release should not deselect static gint drag_escaped = 0; // if non-zero, drag was canceled by esc -namespace { - ToolBase* createSelectContext() { - return new SelectTool(); - } - - bool selectContextRegistered = ToolFactory::instance().registerObject("/tools/select", createSelectContext); -} - const std::string& SelectTool::getPrefsPath() { return SelectTool::prefsPath; } diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index f208e1c43..833fef18d 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -45,20 +45,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createSpiralContext() { - return new SpiralTool(); - } - - bool spiralContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/spiral", createSpiralContext); -} - const std::string& SpiralTool::getPrefsPath() { return SpiralTool::prefsPath; } diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index a01c5c55b..790270d91 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -84,20 +84,10 @@ using namespace std; // Please enable again when working on 1.0 #define ENABLE_SPRAY_MODE_SINGLE_PATH -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createSprayContext() { - return new SprayTool(); - } - - bool sprayContextRegistered = ToolFactory::instance().registerObject("/tools/spray", createSprayContext); -} - const std::string& SprayTool::getPrefsPath() { return SprayTool::prefsPath; } diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index df311f2d8..9190ae57b 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -49,20 +49,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createStarContext() { - return new StarTool(); - } - - bool starContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/star", createStarContext); -} - const std::string& StarTool::getPrefsPath() { return StarTool::prefsPath; } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index df0583d67..a2c0c81ae 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -52,7 +52,6 @@ #include "xml/node-event-vector.h" #include "xml/repr.h" #include -#include "ui/tool-factory.h" using Inkscape::ControlManager; using Inkscape::DocumentUndo; @@ -71,14 +70,6 @@ static gint sptc_focus_in(GtkWidget *widget, GdkEventFocus *event, TextTool *tc) static gint sptc_focus_out(GtkWidget *widget, GdkEventFocus *event, TextTool *tc); static void sptc_commit(GtkIMContext *imc, gchar *string, TextTool *tc); -namespace { - ToolBase* createTextContext() { - return new TextTool(); - } - - bool textContextRegistered = ToolFactory::instance().registerObject("/tools/text", createTextContext); -} - const std::string& TextTool::getPrefsPath() { return TextTool::prefsPath; } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 5e53fdb93..80b52fba6 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -91,20 +91,10 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createTweakContext() { - return new TweakTool(); - } - - bool tweakContextRegistered = ToolFactory::instance().registerObject("/tools/tweak", createTweakContext); -} - const std::string& TweakTool::getPrefsPath() { return TweakTool::prefsPath; } diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index b3fb78c8f..6a4d4dbbd 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -25,20 +25,11 @@ #include "selection-chemistry.h" #include "ui/tools/zoom-tool.h" -#include "ui/tool-factory.h" namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createZoomContext() { - return new ZoomTool(); - } - - bool zoomContextRegistered = ToolFactory::instance().registerObject("/tools/zoom", createZoomContext); -} - const std::string& ZoomTool::getPrefsPath() { return ZoomTool::prefsPath; } -- cgit v1.2.3 From 982ffe6c01c8856c62c157ebafb3f59fad09efa5 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 24 Feb 2015 20:05:17 -0500 Subject: Kill factory.h (bzr r13939.1.3) --- src/factory.h | 95 ----------------------------------------------------------- 1 file changed, 95 deletions(-) delete mode 100644 src/factory.h (limited to 'src') diff --git a/src/factory.h b/src/factory.h deleted file mode 100644 index 6b448064e..000000000 --- a/src/factory.h +++ /dev/null @@ -1,95 +0,0 @@ -/** @file - * Generic Factory - *//* - * Authors: - * Markus Engel - * - * Copyright (C) 2013 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef FACTORY_H_SEEN -#define FACTORY_H_SEEN - -#include -#include -#include -#include "xml/node.h" - -/** - * A simple singleton implementation. - */ -template -struct Singleton { - static T &instance() { - static T inst; - return inst; - } -}; - -namespace FactoryExceptions { -class TypeNotRegistered : public std::exception { -public: - TypeNotRegistered(std::string const &type) - : std::exception() - , _type_string(type) { - } - - virtual ~TypeNotRegistered() throw() { - } - - char const *what() const throw() { - return _type_string.c_str(); - } - -private: - std::string const _type_string; -}; -} // namespace FactoryExceptions - -/** - * A Factory for creating objects which can be identified by strings. - */ -template -class Factory { -public: - typedef BaseObject *CreateFunction(); - - bool registerObject(std::string const &id, CreateFunction *creator) { - return this->_object_map.insert(std::make_pair(id, creator)).second; - } - - BaseObject *createObject(std::string const &id) const { - typename std::map::const_iterator it = this->_object_map.find(id); - - if (it == this->_object_map.end()) { - //throw FactoryExceptions::TypeNotRegistered(id); - if (!(id.empty() // comments, usually - || id == "rdf:RDF" // no SP node yet - || id == "inkscape:clipboard" // SP node not necessary - || id == "inkscape:_templateinfo")) { - g_warning("unknown type: %s", id.c_str()); - } - return NULL; - } - - return it->second(); - } - -private: - std::map _object_map; -}; - - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 9b389b95fffb2a5827d5dd216152f3f9c3c91176 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 24 Feb 2015 20:14:01 -0500 Subject: Restore libinkscape.a (bzr r13939.1.4) --- src/Makefile.am | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 8fb7e23ef..1945c6f12 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,6 +23,7 @@ endif noinst_LIBRARIES = \ + libinkscape.a \ libcroco/libcroco.a \ libavoid/libavoid.a \ $(internal_GDL) \ @@ -194,13 +195,13 @@ DISTCLEANFILES = \ # ################################################ # this should speed up the build -#libinkscape_a_SOURCES = $(ink_common_sources) +libinkscape_a_SOURCES = $(ink_common_sources) -inkscape_SOURCES += main.cpp $(ink_common_sources) $(win32_sources) +inkscape_SOURCES += main.cpp $(win32_sources) inkscape_LDADD = $(all_libs) inkscape_LDFLAGS = $(kdeldflags) $(mwindows) -inkview_SOURCES += inkview.cpp $(ink_common_sources) $(win32_sources) +inkview_SOURCES += inkview.cpp $(win32_sources) inkview_LDADD = $(all_libs) inkview_LDFLAGS = $(mwindows) -- cgit v1.2.3 From c41f1ca2878908fecd97c171ecac3ffa8641ec53 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 24 Feb 2015 21:19:56 -0500 Subject: Backport commit 2086344 from GIMP master: try to fix rulers (bug #1351597) This might not do what it's supposed to, but I doubt keeping it in will do any harm if it doesn't fix the bug (bzr r13941) --- src/widgets/ruler.cpp | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index 8e818843d..ab486eeeb 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -144,7 +144,8 @@ static gboolean sp_ruler_expose (GtkWidget *widget, GdkEventExpose *event); #endif static void sp_ruler_draw_ticks (SPRuler *ruler); -static void sp_ruler_draw_pos (SPRuler *ruler); +static void sp_ruler_draw_pos (SPRuler *ruler, + cairo_t *cr); static void sp_ruler_make_pixmap (SPRuler *ruler); static PangoLayout * sp_ruler_get_layout (GtkWidget *widget, @@ -710,7 +711,7 @@ sp_ruler_draw (GtkWidget *widget, cairo_set_source_surface(cr, priv->backing_store, 0, 0); cairo_paint(cr); - sp_ruler_draw_pos (ruler); + sp_ruler_draw_pos (ruler, cr); return FALSE; } @@ -735,7 +736,8 @@ sp_ruler_make_pixmap (SPRuler *ruler) } static void -sp_ruler_draw_pos (SPRuler *ruler) +sp_ruler_draw_pos (SPRuler *ruler, + cairo_t *cr) { GtkWidget *widget = GTK_WIDGET (ruler); @@ -797,25 +799,31 @@ sp_ruler_draw_pos (SPRuler *ruler) if ((bs_width > 0) && (bs_height > 0)) { - cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); gdouble lower; gdouble upper; gdouble position; gdouble increment; - cairo_rectangle (cr, - allocation.x, allocation.y, - allocation.width, allocation.height); - cairo_clip (cr); - - cairo_translate (cr, allocation.x, allocation.y); - - /* If a backing store exists, restore the ruler */ - if (priv->backing_store) + if (! cr) + { + cr = gdk_cairo_create (gtk_widget_get_window (widget)); + cairo_translate (cr, allocation.x, allocation.y); + cairo_rectangle (cr, allocation.x, allocation.y, allocation.width, allocation.height); + cairo_clip (cr); + + cairo_translate (cr, allocation.x, allocation.y); + + /* If a backing store exists, restore the ruler */ + if (priv->backing_store) + { + cairo_set_source_surface (cr, priv->backing_store, 0, 0); + cairo_rectangle (cr, priv->xsrc, priv->ysrc, bs_width, bs_height); + cairo_fill (cr); + } + } + else { - cairo_set_source_surface (cr, priv->backing_store, 0, 0); - cairo_rectangle (cr, priv->xsrc, priv->ysrc, bs_width, bs_height); - cairo_fill (cr); + cairo_reference (cr); } position = sp_ruler_get_position (ruler); @@ -1126,7 +1134,7 @@ sp_ruler_set_position (SPRuler *ruler, priv->position = position; g_object_notify (G_OBJECT (ruler), "position"); - sp_ruler_draw_pos (ruler); + sp_ruler_draw_pos (ruler, NULL); } } -- cgit v1.2.3 From fee3e231cbf555b6e6eebef9ca6c10ad0d4f69d2 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Wed, 25 Feb 2015 10:04:02 -0500 Subject: Removed reference to factory.h in the src/makefile_insert file that was breaking make dist. factory.h was removed in revision 13940. (bzr r13942) --- src/Makefile_insert | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/Makefile_insert b/src/Makefile_insert index ea4755bb5..68ec982b3 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -40,7 +40,6 @@ ink_common_sources += \ enums.h \ event-log.cpp event-log.h event.h \ extract-uri.cpp extract-uri.h \ - factory.h \ file.cpp file.h \ fill-or-stroke.h \ filter-chemistry.cpp filter-chemistry.h \ -- cgit v1.2.3 From 5088f2350311258798aeaf6fd7219518198ef93b Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 25 Feb 2015 12:11:02 -0500 Subject: load rectangle parameters as px. (Bug 1424798) Fixed bugs: - https://launchpad.net/bugs/1424798 (bzr r13943) --- src/widgets/rect-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 016aa4987..c2134b10c 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -307,7 +307,7 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); //tracker->addUnit( SP_UNIT_PERCENT, 0 ); // fixme: add % meaning per cent of the width/height - tracker->setActiveUnit( desktop->getNamedView()->display_units ); + tracker->setActiveUnit(unit_table.getUnit("px")); g_object_set_data( holder, "tracker", tracker ); /* W */ -- cgit v1.2.3 From 8967965913d42a4ddf5617553d772405fb277bd8 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Feb 2015 14:22:23 -0500 Subject: Don't compile doxygen-main.cpp (bzr r13944) --- src/CMakeLists.txt | 1 - src/Makefile_insert | 1 - src/doxygen-main.cpp | 363 --------------------------------------------------- src/doxygen-main.dox | 363 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 363 insertions(+), 365 deletions(-) delete mode 100644 src/doxygen-main.cpp create mode 100644 src/doxygen-main.dox (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ddb715f55..67b2d4918 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,7 +195,6 @@ set(inkscape_SRC document-subset.cpp document-undo.cpp document.cpp - doxygen-main.cpp ege-color-prof-tracker.cpp event-log.cpp extract-uri.cpp diff --git a/src/Makefile_insert b/src/Makefile_insert index 68ec982b3..477180895 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -35,7 +35,6 @@ ink_common_sources += \ document.cpp document.h document-private.h \ document-subset.cpp document-subset.h \ document-undo.cpp document-undo.h \ - doxygen-main.cpp \ ege-color-prof-tracker.cpp ege-color-prof-tracker.h \ enums.h \ event-log.cpp event-log.h event.h \ diff --git a/src/doxygen-main.cpp b/src/doxygen-main.cpp deleted file mode 100644 index 6a5723bfd..000000000 --- a/src/doxygen-main.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/** - * @file - * Doxygen documentation - main page and namespace documentation. - */ -/* Authors: - * Ralf Stephan - * Krzysztof Kosiński - * - * Copyright (C) 2005-2008 authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -// Note: % before a word prevents that word from being linkified - -/** - * Main %Inkscape namespace. - * - * This namespace contains all code internal to %Inkscape. - */ -namespace Inkscape { - -/** - * Some STL-style algorithms. - * - * This namespace contains a few generic algorithms used with the %XML tree. - */ -namespace Algorithms {} - - -/** - * Debugging utilities. - * - * This namespace contains various debugging code which can help developers - * to pinpoint problems with their (or others') code. - */ -namespace Debug {} - -/** - * Rendering-related code. - * - * This namespace contains code related to the renderer. - */ -namespace Display {} - -/** - * Extension support. - * - * This namespace contains the extension subsystem and implementations - * of the internal extensions. This includes input and output filters, bitmap - * extensions, and printing. - */ -namespace Extension {} - -/** - * Boehm-GC based garbage collector. - * - * This namespace contains code related to the garbage collector and base - * classes for %GC-managed objects. - */ -namespace GC {} - -/** - * Low-level IO code. - * - * This namespace contains low level IO-related code, including a homegrown - * streams implementation, routines for formatting SVG output, and some - * file handling utility functions. - */ -namespace IO {} - -/** - * Live Path Effects code. - * - * This namespace contains classes and functions related to the implementation - * of Live Path Effects, which apply arbitrary transformation to a path and - * update whenever the original path is modified. - */ -namespace LivePathEffect {} - -/** - * Tracing backend. - * - * This namespace contains the integrated potrace-based tracing backend, used - * in the Trace Bitmap and Paint Bucket features. - */ -namespace Trace {} - -/** - * User interface code. - * - * This namespace contains everything related to the user interface of Inkscape. - */ -namespace UI { - -/** - * Dialog code. - * - * This namespace contains all code related to dialogs. - */ -namespace Dialog {} - -/** - * Custom widgets. - * - * This namespace contains custom user interface widgets used thorough - * Inkscape. - */ -namespace Widget {} - -} // namespace UI - -/** - * Miscellaneous supporting code. - * - * This namespace contains miscellaneous low-level code: an implementation of - * garbage-collected lists, tuples, generic pointer iterators and length unit - * handling. - */ -namespace Util {} - -/** - * @Inkscape %XML tree. - * - * This namespace contains classes and functions that comprise the XML tree - * of Inkscape documents. - * - * SVG documents in Inkscape are represented as two parallel hierarchies - * of nodes: the object tree, which contains all information about - * the document's state when loaded, and the %XML tree, which contains all - * information about the document's %XML representation. For this reason - * this tree is also called the "repr tree", and %XML nodes are called "reprs". - * - * The central class is XML::Node, which provides all operations. It should be - * noted that nodes are currently typeless and operations not valid for their - * type simply do nothing (like trying to iterate over children of a text node). - * In addition to standard DOM operations, the %XML tree supports observers - - * objects derived from Xml::NodeObserver which receive notifications about - * changes in the document tree. - */ -namespace XML {} - -} // namespace Inkscape - -/** \mainpage Inkscape Source Code Documentation - * While the standard doxygen documentation can be accessed through the links - * in the header, the following documents are additionally available to the - * interested reader. - * - * \section groups Main directory documentation - * Inkscape's classes and files in the main directory can be grouped into - * the following categories: - * - * - \subpage ObjectTree - inkscape's SVG canvas - * - \subpage Tools - the tools UI - * - \subpage UI - inkscape's user interface - * - \subpage XmlTree - XML backbone of the document - * - \subpage Rendering - rendering and buffering - * - \subpage OtherServices - what doesn't fit in the above - * - * See also the other directories until doxygen - * allows setting links to those doc files. - * - * \section extlinks Links to external documentation - * - * \subsection liblinks External documentation on libraries used in inkscape - * - * C++: - * gtkmm - * atkmm - * gdkmm - * glibmm - * pangomm - * libsigc++ - * C: - * GTK+ - * gdk-pixbuf - * GObject - * atk - * pango - * ORBit - * bonobo - * bonobo-activation - * libxslt - * libxml2 - * Legacy: - * GnomeVFS - * - * \subsection stdlinks External standards documentation - * - * SVG1.1 - * SVG1.2 - * SVGMobile - * SVGTest - * PNG - * XSLT - * PostScript - * Gnome-HIG - */ - -/** \page ObjectTree Object Tree Classes and Files - * Inkscape::ObjectHierarchy [\ref object-hierarchy.cpp, \ref object-hierarchy.h] - * - SPObject [\ref sp-object.cpp, \ref sp-object.h, \ref object-edit.cpp, \ref sp-object-repr.cpp] - * - SPDefs [\ref sp-defs.cpp, \ref sp-defs.h] - * - SPFlowline [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] - * - SPFlowregionbreak [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] - * - SPGuide [\ref sp-guide.cpp, \ref sp-guide.h] - * - SPItem [\ref sp-item.cpp, \ref sp-item.h, \ref sp-item-notify-moveto.cpp, \ref sp-item-rm-unsatisfied-cns.cpp, \ref sp-item-transform.cpp, \ref sp-item-update-cns.cpp, ] - * - SPFlowdiv [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] - * - SPFlowpara [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] - * - SPFlowregion [\ref sp-flowregion.cpp, \ref sp-flowregion.h] - * - SPFlowregionExclude [\ref sp-flowregion.cpp, \ref sp-flowregion.h] - * - SPFlowtext [\ref sp-flowtext.cpp, \ref sp-flowtext.h] - * - SPFlowtspan [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] - * - SPGroup [\ref sp-item-group.cpp, \ref sp-item-group.h] - * - SPAnchor [\ref sp-anchor.cpp, \ref sp-anchor.h] - * - SPMarker [\ref marker.cpp, \ref marker.h] - * - SPRoot [\ref sp-root.cpp, \ref sp-root.h] - * - SPSymbol [\ref sp-symbol.cpp, \ref sp-symbol.h] - * - SPImage [\ref sp-image.cpp, \ref sp-image.h] - * - SPShape [\ref sp-shape.cpp, \ref sp-shape.h] - * - SPGenericEllipse [\ref sp-ellipse.cpp, \ref sp-ellipse.h] - * - SPArc - * - SPCircle - * - SPEllipse - * - SPLine [\ref sp-line.cpp, \ref sp-line.h] - * - SPOffset [\ref sp-offset.cpp, \ref sp-offset.h] - * - SPPath [\ref sp-path.cpp, \ref sp-path.h, \ref path-chemistry.cpp, \ref splivarot.cpp] - * - SPPolygon [\ref sp-polygon.cpp, \ref sp-polygon.h] - * - SPStar [\ref sp-star.cpp, \ref sp-star.h] - * - SPPolyLine [\ref sp-polyline.cpp, \ref sp-polyline.h] - * - SPRect [\ref sp-rect.cpp, \ref sp-rect.h] - * - SPSpiral [\ref sp-spiral.cpp, \ref sp-spiral.h] - * - SPText [\ref sp-text.cpp, \ref sp-text.h, \ref text-chemistry.cpp, \ref text-editing.cpp] - * - SPTextPath [\ref sp-tspan.cpp, \ref sp-tspan.h] - * - SPTSpan [\ref sp-tspan.cpp, \ref sp-tspan.h] - * - SPUse [\ref sp-use.cpp, \ref sp-use.h] - * - SPMetadata [\ref sp-metadata.cpp, \ref sp-metadata.h] - * - SPObjectGroup [\ref sp-object-group.cpp, \ref sp-object-group.h] - * - SPClipPath [\ref sp-clippath.cpp, \ref sp-clippath.h] - * - SPMask [\ref sp-mask.cpp, \ref sp-mask.h] - * - SPNamedView [\ref sp-namedview.cpp, \ref sp-namedview.h] - * - SPPaintServer [\ref sp-paint-server.cpp, \ref sp-paint-server.h] - * - SPGradient [\ref sp-gradient.cpp, \ref sp-gradient.h, \ref gradient-chemistry.cpp, \ref sp-gradient-reference.h, \ref sp-gradient-spread.h, \ref sp-gradient-units.h, \ref sp-gradient-vector.h] - * - SPLinearGradient - * - SPRadialGradient - * - SPPattern [\ref sp-pattern.cpp, \ref sp-pattern.h] - * - SPStop [\ref sp-stop.h] - * - SPString [\ref sp-string.cpp, \ref sp-string.h] - * - SPStyleElem [\ref sp-style-elem.cpp, \ref sp-style-elem.h] - * - */ -/** \page Tools Tools Related Classes and Files - * - * SelCue [\ref selcue.cpp, \ref selcue.h, \ref rubberband.cpp] - * Inkscape::Selection [\ref selection.cpp, \ref selection.h, \ref selection-chemistry.cpp] - * SPSelTrans [\ref seltrans.cpp, \ref seltrans.h] - * - * \section Event Context Class Hierarchy - * - *- ToolBase[\ref event-context.cpp, \ref event-context.h] - * - ArcTool [\ref arc-context.cpp, \ref arc-context.h] - * - SPDrawContext [\ref draw-context.cpp, \ref draw-context.h] - * - PenTool [\ref pen-context.cpp, \ref pen-context.h] - * - PencilTool [\ref pencil-context.cpp, \ref pencil-context.h] - * - ConnectorTool [\ref connector-context.cpp, \ref connector-context.h, \ref sp-conn-end.cpp, \ref sp-conn-end-pair.cpp] - * - GradientTool [\ref gradient-context.cpp, \ref gradient-context.h, \ref gradient-drag.cpp, \ref gradient-toolbar.cpp] - * - RectTool [\ref rect-context.cpp, \ref rect-context.h] - * - SelectTool [\ref select-context.cpp, \ref select-context.h] - * - SpiralTool [\ref spiral-context.cpp, \ref spiral-context.h] - * - StarTool [\ref star-context.cpp, \ref star-context.h] - * - FloodContext [\ref flood-context.cpp, \ref flood-context.h] - * - Box3dTool [\ref box3d-context.cpp, \ref box3d-context.h] - * - * SPNodeContext [\ref node-context.cpp, \ref node-context.h] - * - * ZoomTool [\ref zoom-context.cpp, \ref zoom-context.h] - * - * CalligraphicTool [\ref dyna-draw-context.cpp, \ref dyna-draw-context.h] - * - * DropperTool [\ref dropper-context.cpp, \ref dropper-context.h] - */ -/** \page UI User Interface Classes and Files - * - * - Inkscape::UI::View::View [\ref ui/view/view.cpp, \ref ui/view/view.h] - * - SPDesktop [\ref desktop.cpp, \ref desktop-events.cpp, \ref desktop-handles.cpp, \ref desktop-style.cpp, \ref desktop.h, \ref desktop-events.h, \ref desktop-handles.h, \ref desktop-style.h] - * - SPSVGView [\ref svg-view.cpp, \ref svg-view.h] - * - * SPDesktopWidget [\ref desktop-widget.h] SPSVGSPViewWidget [\ref svg-view.cpp] - * SPDocument [\ref document.cpp, \ref document.h] - * - * SPDrawAnchor [\ref draw-anchor.cpp, \ref draw-anchor.h] - * SPKnot [\ref knot.cpp, \ref knot.h, \ref knot-enums.h] - * SPKnotHolder [\ref knotholder.cpp, \ref knotholder.h, \ref knot-holder-entity.h] - * - * [\ref layer-fns.cpp, \ref selection-describer.h] - * Inkscape::MessageContext [\ref message-context.h] - * Inkscape::MessageStack [\ref message-stack.h, \ref message.h] - * - * Snapper, GridSnapper, GuideSnapper [\ref snap.cpp, \ref snap.h] - * - * SPGuide [\ref sp-guide.cpp, \ref sp-guide.h, \ref satisfied-guide-cns.cpp, \ref sp-guide-attachment.h, \ref sp-guide-constraint.h] - * - * [\ref help.cpp] [\ref inkscape.cpp] [\ref inkscape-stock.cpp] - * [\ref interface.cpp] [\ref main.cpp, \ref winmain.cpp] - * [\ref menus-skeleton.h, \ref preferences-skeleton.h] - * [\ref select-toolbar.cpp] [\ref shortcuts.cpp] - * [\ref sp-cursor.cpp] [\ref text-edit.cpp] [\ref toolbox.cpp] - * Inkscape::Verb [\ref verbs.h] - * - */ -/** \page XmlTree CSS/XML Tree Classes and Files - * - * SPStyle [\ref style.cpp, \ref style.h] - * Media [\ref media.cpp, \ref media.h] - * [\ref attributes.cpp, \ref attributes.h] - * - * - Inkscape::URIReference [\ref uri-references.cpp, \ref uri-references.h] - * - SPClipPathReference [\ref sp-clippath.h] - * - SPGradientReference [\ref sp-gradient-reference.h] - * - SPMarkerReference [\ref marker.h] - * - SPMaskReference [\ref sp-mask.h] - * - SPUseReference [\ref sp-use-reference.h] - * - SPUsePath - */ -/** \page Rendering Rendering Related Classes and Files - * - * SPColor [\ref color.cpp, \ref color.h, \ref color-rgba.h] - * [\ref geom.cpp] [\ref mod360.cpp] - */ -/** \page OtherServices Classes and Files From Other Services - * [\ref inkview.cpp, \ref slideshow.cpp] - * - * Inkscape::GC - * - * [\ref prefs-utils.cpp] [\ref print.cpp] - * - * - Inkscape::GZipBuffer [\ref streams-gzip.h] - * - Inkscape::JarBuffer [\ref streams-jar.h] - * - Inkscape::ZlibBuffer [\ref streams-zlib.h] - * - Inkscape::URIHandle [\ref streams-handles.h] - * - Inkscape::FileHandle - * [\ref dir-util.cpp] [\ref file.cpp] - * Inkscape::URI [\ref uri.h, \ref extract-uri.cpp, \ref uri-references.cpp] - * Inkscape::BadURIException [\ref bad-uri-exception.h] - * - * Inkscape::Whiteboard::UndoStackObserver [\ref undo-stack-observer.cpp, \ref composite-undo-stack-observer.cpp] - * [\ref document-undo.cpp] - * - * {\ref dialogs/} [\ref decimal-round.h] [\ref enums.h] - */ - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/doxygen-main.dox b/src/doxygen-main.dox new file mode 100644 index 000000000..6a5723bfd --- /dev/null +++ b/src/doxygen-main.dox @@ -0,0 +1,363 @@ +/** + * @file + * Doxygen documentation - main page and namespace documentation. + */ +/* Authors: + * Ralf Stephan + * Krzysztof Kosiński + * + * Copyright (C) 2005-2008 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +// Note: % before a word prevents that word from being linkified + +/** + * Main %Inkscape namespace. + * + * This namespace contains all code internal to %Inkscape. + */ +namespace Inkscape { + +/** + * Some STL-style algorithms. + * + * This namespace contains a few generic algorithms used with the %XML tree. + */ +namespace Algorithms {} + + +/** + * Debugging utilities. + * + * This namespace contains various debugging code which can help developers + * to pinpoint problems with their (or others') code. + */ +namespace Debug {} + +/** + * Rendering-related code. + * + * This namespace contains code related to the renderer. + */ +namespace Display {} + +/** + * Extension support. + * + * This namespace contains the extension subsystem and implementations + * of the internal extensions. This includes input and output filters, bitmap + * extensions, and printing. + */ +namespace Extension {} + +/** + * Boehm-GC based garbage collector. + * + * This namespace contains code related to the garbage collector and base + * classes for %GC-managed objects. + */ +namespace GC {} + +/** + * Low-level IO code. + * + * This namespace contains low level IO-related code, including a homegrown + * streams implementation, routines for formatting SVG output, and some + * file handling utility functions. + */ +namespace IO {} + +/** + * Live Path Effects code. + * + * This namespace contains classes and functions related to the implementation + * of Live Path Effects, which apply arbitrary transformation to a path and + * update whenever the original path is modified. + */ +namespace LivePathEffect {} + +/** + * Tracing backend. + * + * This namespace contains the integrated potrace-based tracing backend, used + * in the Trace Bitmap and Paint Bucket features. + */ +namespace Trace {} + +/** + * User interface code. + * + * This namespace contains everything related to the user interface of Inkscape. + */ +namespace UI { + +/** + * Dialog code. + * + * This namespace contains all code related to dialogs. + */ +namespace Dialog {} + +/** + * Custom widgets. + * + * This namespace contains custom user interface widgets used thorough + * Inkscape. + */ +namespace Widget {} + +} // namespace UI + +/** + * Miscellaneous supporting code. + * + * This namespace contains miscellaneous low-level code: an implementation of + * garbage-collected lists, tuples, generic pointer iterators and length unit + * handling. + */ +namespace Util {} + +/** + * @Inkscape %XML tree. + * + * This namespace contains classes and functions that comprise the XML tree + * of Inkscape documents. + * + * SVG documents in Inkscape are represented as two parallel hierarchies + * of nodes: the object tree, which contains all information about + * the document's state when loaded, and the %XML tree, which contains all + * information about the document's %XML representation. For this reason + * this tree is also called the "repr tree", and %XML nodes are called "reprs". + * + * The central class is XML::Node, which provides all operations. It should be + * noted that nodes are currently typeless and operations not valid for their + * type simply do nothing (like trying to iterate over children of a text node). + * In addition to standard DOM operations, the %XML tree supports observers - + * objects derived from Xml::NodeObserver which receive notifications about + * changes in the document tree. + */ +namespace XML {} + +} // namespace Inkscape + +/** \mainpage Inkscape Source Code Documentation + * While the standard doxygen documentation can be accessed through the links + * in the header, the following documents are additionally available to the + * interested reader. + * + * \section groups Main directory documentation + * Inkscape's classes and files in the main directory can be grouped into + * the following categories: + * + * - \subpage ObjectTree - inkscape's SVG canvas + * - \subpage Tools - the tools UI + * - \subpage UI - inkscape's user interface + * - \subpage XmlTree - XML backbone of the document + * - \subpage Rendering - rendering and buffering + * - \subpage OtherServices - what doesn't fit in the above + * + * See also the other directories until doxygen + * allows setting links to those doc files. + * + * \section extlinks Links to external documentation + * + * \subsection liblinks External documentation on libraries used in inkscape + * + * C++: + * gtkmm + * atkmm + * gdkmm + * glibmm + * pangomm + * libsigc++ + * C: + * GTK+ + * gdk-pixbuf + * GObject + * atk + * pango + * ORBit + * bonobo + * bonobo-activation + * libxslt + * libxml2 + * Legacy: + * GnomeVFS + * + * \subsection stdlinks External standards documentation + * + * SVG1.1 + * SVG1.2 + * SVGMobile + * SVGTest + * PNG + * XSLT + * PostScript + * Gnome-HIG + */ + +/** \page ObjectTree Object Tree Classes and Files + * Inkscape::ObjectHierarchy [\ref object-hierarchy.cpp, \ref object-hierarchy.h] + * - SPObject [\ref sp-object.cpp, \ref sp-object.h, \ref object-edit.cpp, \ref sp-object-repr.cpp] + * - SPDefs [\ref sp-defs.cpp, \ref sp-defs.h] + * - SPFlowline [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] + * - SPFlowregionbreak [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] + * - SPGuide [\ref sp-guide.cpp, \ref sp-guide.h] + * - SPItem [\ref sp-item.cpp, \ref sp-item.h, \ref sp-item-notify-moveto.cpp, \ref sp-item-rm-unsatisfied-cns.cpp, \ref sp-item-transform.cpp, \ref sp-item-update-cns.cpp, ] + * - SPFlowdiv [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] + * - SPFlowpara [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] + * - SPFlowregion [\ref sp-flowregion.cpp, \ref sp-flowregion.h] + * - SPFlowregionExclude [\ref sp-flowregion.cpp, \ref sp-flowregion.h] + * - SPFlowtext [\ref sp-flowtext.cpp, \ref sp-flowtext.h] + * - SPFlowtspan [\ref sp-flowdiv.cpp, \ref sp-flowdiv.h] + * - SPGroup [\ref sp-item-group.cpp, \ref sp-item-group.h] + * - SPAnchor [\ref sp-anchor.cpp, \ref sp-anchor.h] + * - SPMarker [\ref marker.cpp, \ref marker.h] + * - SPRoot [\ref sp-root.cpp, \ref sp-root.h] + * - SPSymbol [\ref sp-symbol.cpp, \ref sp-symbol.h] + * - SPImage [\ref sp-image.cpp, \ref sp-image.h] + * - SPShape [\ref sp-shape.cpp, \ref sp-shape.h] + * - SPGenericEllipse [\ref sp-ellipse.cpp, \ref sp-ellipse.h] + * - SPArc + * - SPCircle + * - SPEllipse + * - SPLine [\ref sp-line.cpp, \ref sp-line.h] + * - SPOffset [\ref sp-offset.cpp, \ref sp-offset.h] + * - SPPath [\ref sp-path.cpp, \ref sp-path.h, \ref path-chemistry.cpp, \ref splivarot.cpp] + * - SPPolygon [\ref sp-polygon.cpp, \ref sp-polygon.h] + * - SPStar [\ref sp-star.cpp, \ref sp-star.h] + * - SPPolyLine [\ref sp-polyline.cpp, \ref sp-polyline.h] + * - SPRect [\ref sp-rect.cpp, \ref sp-rect.h] + * - SPSpiral [\ref sp-spiral.cpp, \ref sp-spiral.h] + * - SPText [\ref sp-text.cpp, \ref sp-text.h, \ref text-chemistry.cpp, \ref text-editing.cpp] + * - SPTextPath [\ref sp-tspan.cpp, \ref sp-tspan.h] + * - SPTSpan [\ref sp-tspan.cpp, \ref sp-tspan.h] + * - SPUse [\ref sp-use.cpp, \ref sp-use.h] + * - SPMetadata [\ref sp-metadata.cpp, \ref sp-metadata.h] + * - SPObjectGroup [\ref sp-object-group.cpp, \ref sp-object-group.h] + * - SPClipPath [\ref sp-clippath.cpp, \ref sp-clippath.h] + * - SPMask [\ref sp-mask.cpp, \ref sp-mask.h] + * - SPNamedView [\ref sp-namedview.cpp, \ref sp-namedview.h] + * - SPPaintServer [\ref sp-paint-server.cpp, \ref sp-paint-server.h] + * - SPGradient [\ref sp-gradient.cpp, \ref sp-gradient.h, \ref gradient-chemistry.cpp, \ref sp-gradient-reference.h, \ref sp-gradient-spread.h, \ref sp-gradient-units.h, \ref sp-gradient-vector.h] + * - SPLinearGradient + * - SPRadialGradient + * - SPPattern [\ref sp-pattern.cpp, \ref sp-pattern.h] + * - SPStop [\ref sp-stop.h] + * - SPString [\ref sp-string.cpp, \ref sp-string.h] + * - SPStyleElem [\ref sp-style-elem.cpp, \ref sp-style-elem.h] + * + */ +/** \page Tools Tools Related Classes and Files + * + * SelCue [\ref selcue.cpp, \ref selcue.h, \ref rubberband.cpp] + * Inkscape::Selection [\ref selection.cpp, \ref selection.h, \ref selection-chemistry.cpp] + * SPSelTrans [\ref seltrans.cpp, \ref seltrans.h] + * + * \section Event Context Class Hierarchy + * + *- ToolBase[\ref event-context.cpp, \ref event-context.h] + * - ArcTool [\ref arc-context.cpp, \ref arc-context.h] + * - SPDrawContext [\ref draw-context.cpp, \ref draw-context.h] + * - PenTool [\ref pen-context.cpp, \ref pen-context.h] + * - PencilTool [\ref pencil-context.cpp, \ref pencil-context.h] + * - ConnectorTool [\ref connector-context.cpp, \ref connector-context.h, \ref sp-conn-end.cpp, \ref sp-conn-end-pair.cpp] + * - GradientTool [\ref gradient-context.cpp, \ref gradient-context.h, \ref gradient-drag.cpp, \ref gradient-toolbar.cpp] + * - RectTool [\ref rect-context.cpp, \ref rect-context.h] + * - SelectTool [\ref select-context.cpp, \ref select-context.h] + * - SpiralTool [\ref spiral-context.cpp, \ref spiral-context.h] + * - StarTool [\ref star-context.cpp, \ref star-context.h] + * - FloodContext [\ref flood-context.cpp, \ref flood-context.h] + * - Box3dTool [\ref box3d-context.cpp, \ref box3d-context.h] + * + * SPNodeContext [\ref node-context.cpp, \ref node-context.h] + * + * ZoomTool [\ref zoom-context.cpp, \ref zoom-context.h] + * + * CalligraphicTool [\ref dyna-draw-context.cpp, \ref dyna-draw-context.h] + * + * DropperTool [\ref dropper-context.cpp, \ref dropper-context.h] + */ +/** \page UI User Interface Classes and Files + * + * - Inkscape::UI::View::View [\ref ui/view/view.cpp, \ref ui/view/view.h] + * - SPDesktop [\ref desktop.cpp, \ref desktop-events.cpp, \ref desktop-handles.cpp, \ref desktop-style.cpp, \ref desktop.h, \ref desktop-events.h, \ref desktop-handles.h, \ref desktop-style.h] + * - SPSVGView [\ref svg-view.cpp, \ref svg-view.h] + * + * SPDesktopWidget [\ref desktop-widget.h] SPSVGSPViewWidget [\ref svg-view.cpp] + * SPDocument [\ref document.cpp, \ref document.h] + * + * SPDrawAnchor [\ref draw-anchor.cpp, \ref draw-anchor.h] + * SPKnot [\ref knot.cpp, \ref knot.h, \ref knot-enums.h] + * SPKnotHolder [\ref knotholder.cpp, \ref knotholder.h, \ref knot-holder-entity.h] + * + * [\ref layer-fns.cpp, \ref selection-describer.h] + * Inkscape::MessageContext [\ref message-context.h] + * Inkscape::MessageStack [\ref message-stack.h, \ref message.h] + * + * Snapper, GridSnapper, GuideSnapper [\ref snap.cpp, \ref snap.h] + * + * SPGuide [\ref sp-guide.cpp, \ref sp-guide.h, \ref satisfied-guide-cns.cpp, \ref sp-guide-attachment.h, \ref sp-guide-constraint.h] + * + * [\ref help.cpp] [\ref inkscape.cpp] [\ref inkscape-stock.cpp] + * [\ref interface.cpp] [\ref main.cpp, \ref winmain.cpp] + * [\ref menus-skeleton.h, \ref preferences-skeleton.h] + * [\ref select-toolbar.cpp] [\ref shortcuts.cpp] + * [\ref sp-cursor.cpp] [\ref text-edit.cpp] [\ref toolbox.cpp] + * Inkscape::Verb [\ref verbs.h] + * + */ +/** \page XmlTree CSS/XML Tree Classes and Files + * + * SPStyle [\ref style.cpp, \ref style.h] + * Media [\ref media.cpp, \ref media.h] + * [\ref attributes.cpp, \ref attributes.h] + * + * - Inkscape::URIReference [\ref uri-references.cpp, \ref uri-references.h] + * - SPClipPathReference [\ref sp-clippath.h] + * - SPGradientReference [\ref sp-gradient-reference.h] + * - SPMarkerReference [\ref marker.h] + * - SPMaskReference [\ref sp-mask.h] + * - SPUseReference [\ref sp-use-reference.h] + * - SPUsePath + */ +/** \page Rendering Rendering Related Classes and Files + * + * SPColor [\ref color.cpp, \ref color.h, \ref color-rgba.h] + * [\ref geom.cpp] [\ref mod360.cpp] + */ +/** \page OtherServices Classes and Files From Other Services + * [\ref inkview.cpp, \ref slideshow.cpp] + * + * Inkscape::GC + * + * [\ref prefs-utils.cpp] [\ref print.cpp] + * + * - Inkscape::GZipBuffer [\ref streams-gzip.h] + * - Inkscape::JarBuffer [\ref streams-jar.h] + * - Inkscape::ZlibBuffer [\ref streams-zlib.h] + * - Inkscape::URIHandle [\ref streams-handles.h] + * - Inkscape::FileHandle + * [\ref dir-util.cpp] [\ref file.cpp] + * Inkscape::URI [\ref uri.h, \ref extract-uri.cpp, \ref uri-references.cpp] + * Inkscape::BadURIException [\ref bad-uri-exception.h] + * + * Inkscape::Whiteboard::UndoStackObserver [\ref undo-stack-observer.cpp, \ref composite-undo-stack-observer.cpp] + * [\ref document-undo.cpp] + * + * {\ref dialogs/} [\ref decimal-round.h] [\ref enums.h] + */ + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From a609c4ecbcadb7b87e9a5956f8c95b4edefd829b Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Feb 2015 14:27:51 -0500 Subject: Remove useless file (bzr r13945) --- src/display/CMakeLists.txt | 1 - src/display/Makefile_insert | 1 - src/display/nr-filter-utils.cpp | 21 --------------------- 3 files changed, 23 deletions(-) delete mode 100644 src/display/nr-filter-utils.cpp (limited to 'src') diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 800c4d0d4..d4f8c16ff 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -42,7 +42,6 @@ set(display_SRC nr-filter-tile.cpp nr-filter-turbulence.cpp nr-filter-units.cpp - nr-filter-utils.cpp nr-filter.cpp nr-light.cpp nr-style.cpp diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 2355c3653..20e498981 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -90,7 +90,6 @@ ink_common_sources += \ display/nr-filter-types.h \ display/nr-filter-units.cpp \ display/nr-filter-units.h \ - display/nr-filter-utils.cpp \ display/nr-filter-utils.h \ display/nr-light.cpp \ display/nr-light.h \ diff --git a/src/display/nr-filter-utils.cpp b/src/display/nr-filter-utils.cpp deleted file mode 100644 index 1ba341791..000000000 --- a/src/display/nr-filter-utils.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "nr-filter-utils.h" - -namespace Inkscape { -namespace Filters { - -/* Everything moved to .h, because they were short functions that should - * get inlined */ - -} /* namespace Filters */ -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 5865f0044d4d75a2d988a8bf2ea3bc65ed6f4c18 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Feb 2015 17:24:47 -0500 Subject: Isolate components of libgc (bzr r13946) --- src/CMakeLists.txt | 1 + src/Makefile.am | 2 + src/Makefile_insert | 9 +- src/composite-undo-stack-observer.h | 2 +- src/debug/demangle.cpp | 2 +- src/debug/gc-heap.h | 2 +- src/debug/heap.cpp | 2 +- src/debug/logger.cpp | 2 +- src/debug/simple-event.h | 2 +- src/display/nr-filter.h | 2 +- src/document-subset.h | 2 +- src/document.h | 2 +- src/gc-alloc.h | 90 ---------- src/gc-allocator.h | 0 src/gc-anchored.h | 2 +- src/gc-core.h | 213 ------------------------ src/gc-finalized.h | 2 +- src/gc-managed.h | 63 ------- src/gc-soft-ptr.h | 70 -------- src/gc.cpp | 312 ----------------------------------- src/inkview.cpp | 2 +- src/layer-manager.cpp | 2 +- src/layer-manager.h | 2 +- src/libgc/CMakeLists.txt | 15 ++ src/libgc/Makefile_insert | 13 ++ src/libgc/gc-alloc.h | 90 ++++++++++ src/libgc/gc-core.h | 213 ++++++++++++++++++++++++ src/libgc/gc-managed.h | 63 +++++++ src/libgc/gc-soft-ptr.h | 70 ++++++++ src/libgc/gc.cpp | 312 +++++++++++++++++++++++++++++++++++ src/main.cpp | 2 +- src/message-stack.h | 2 +- src/selection.h | 4 +- src/ui/clipboard.cpp | 2 +- src/ui/dialog/filedialog.cpp | 2 +- src/ui/dialog/filedialogimpl-win32.h | 2 +- src/ui/dialog/memory.cpp | 2 +- src/ui/dialog/ocaldialogs.cpp | 2 +- src/ui/view/view.h | 2 +- src/undo-stack-observer.h | 2 +- src/util/list.h | 2 +- src/util/share.h | 2 +- src/xml/attribute-record.h | 2 +- src/xml/composite-node-observer.h | 2 +- src/xml/event.h | 2 +- src/xml/log-builder.h | 2 +- src/xml/subtree.h | 2 +- 47 files changed, 813 insertions(+), 787 deletions(-) delete mode 100644 src/gc-alloc.h delete mode 100644 src/gc-allocator.h delete mode 100644 src/gc-core.h delete mode 100644 src/gc-managed.h delete mode 100644 src/gc-soft-ptr.h delete mode 100644 src/gc.cpp create mode 100644 src/libgc/CMakeLists.txt create mode 100644 src/libgc/Makefile_insert create mode 100644 src/libgc/gc-alloc.h create mode 100644 src/libgc/gc-core.h create mode 100644 src/libgc/gc-managed.h create mode 100644 src/libgc/gc-soft-ptr.h create mode 100644 src/libgc/gc.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 67b2d4918..208f31716 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -491,6 +491,7 @@ add_subdirectory(2geom) add_subdirectory(libavoid) add_subdirectory(libcola) add_subdirectory(libcroco) +add_subdirectory(libgc) add_subdirectory(libgdl) add_subdirectory(libuemf) add_subdirectory(libvpsc) diff --git a/src/Makefile.am b/src/Makefile.am index 1945c6f12..db70b3956 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,6 +29,7 @@ noinst_LIBRARIES = \ $(internal_GDL) \ libuemf/libuemf.a \ libcola/libcola.a \ + libgc/libgc.a \ libvpsc/libvpsc.a \ livarot/libvarot.a \ 2geom/lib2geom.a \ @@ -115,6 +116,7 @@ include filters/Makefile_insert include helper/Makefile_insert include io/Makefile_insert include libcroco/Makefile_insert +include libgc/Makefile_insert include libgdl/Makefile_insert include libnrtype/Makefile_insert include libavoid/Makefile_insert diff --git a/src/Makefile_insert b/src/Makefile_insert index 477180895..2bd457529 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -43,13 +43,8 @@ ink_common_sources += \ fill-or-stroke.h \ filter-chemistry.cpp filter-chemistry.h \ filter-enums.cpp filter-enums.h \ - gc-alloc.h \ - gc-anchored.h gc-anchored.cpp \ - gc-core.h \ - gc.cpp \ - gc-finalized.h gc-finalized.cpp \ - gc-managed.h \ - gc-soft-ptr.h \ + gc-anchored.cpp gc-anchored.h \ + gc-finalized.cpp gc-finalized.h \ gradient-chemistry.cpp gradient-chemistry.h \ gradient-drag.cpp gradient-drag.h \ graphlayout.cpp graphlayout.h \ diff --git a/src/composite-undo-stack-observer.h b/src/composite-undo-stack-observer.h index c93a2338b..00b1ab728 100644 --- a/src/composite-undo-stack-observer.h +++ b/src/composite-undo-stack-observer.h @@ -10,7 +10,7 @@ #ifndef SEEN_COMPOSITE_UNDO_COMMIT_OBSERVER_H #define SEEN_COMPOSITE_UNDO_COMMIT_OBSERVER_H -#include "gc-alloc.h" +#include "libgc/gc-alloc.h" #include "undo-stack-observer.h" #include diff --git a/src/debug/demangle.cpp b/src/debug/demangle.cpp index 2b00fb8e9..a6386ebd2 100644 --- a/src/debug/demangle.cpp +++ b/src/debug/demangle.cpp @@ -14,7 +14,7 @@ #include #include "debug/demangle.h" #include "util/format.h" -#include "gc-alloc.h" +#include "libgc/gc-alloc.h" namespace Inkscape { diff --git a/src/debug/gc-heap.h b/src/debug/gc-heap.h index 957f2067a..ec35a6d2f 100644 --- a/src/debug/gc-heap.h +++ b/src/debug/gc-heap.h @@ -12,7 +12,7 @@ #ifndef SEEN_INKSCAPE_DEBUG_GC_HEAP_H #define SEEN_INKSCAPE_DEBUG_GC_HEAP_H -#include "gc-core.h" +#include "libgc/gc-core.h" #include "debug/heap.h" namespace Inkscape { diff --git a/src/debug/heap.cpp b/src/debug/heap.cpp index 8e7a920ba..f522b737c 100644 --- a/src/debug/heap.cpp +++ b/src/debug/heap.cpp @@ -13,7 +13,7 @@ # include "config.h" #endif -#include "gc-alloc.h" +#include "libgc/gc-alloc.h" #include "debug/gc-heap.h" #include "debug/sysv-heap.h" #include diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index 485dbc365..5e977c764 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -15,7 +15,7 @@ #include "inkscape-version.h" #include "debug/logger.h" #include "debug/simple-event.h" -#include "gc-alloc.h" +#include "libgc/gc-alloc.h" namespace Inkscape { diff --git a/src/debug/simple-event.h b/src/debug/simple-event.h index 506ee1b03..7786a58d2 100644 --- a/src/debug/simple-event.h +++ b/src/debug/simple-event.h @@ -16,7 +16,7 @@ #include #include // g_assert() -#include "gc-alloc.h" +#include "libgc/gc-alloc.h" #include "debug/event.h" namespace Inkscape { diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 9a30efabd..4c42b6f28 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -18,7 +18,7 @@ #include "display/nr-filter-types.h" #include "svg/svg-length.h" #include "sp-filter-units.h" -#include "gc-managed.h" +#include "libgc/gc-managed.h" namespace Inkscape { class DrawingContext; diff --git a/src/document-subset.h b/src/document-subset.h index 298b7872d..940124f83 100644 --- a/src/document-subset.h +++ b/src/document-subset.h @@ -14,7 +14,7 @@ #include #include -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "gc-anchored.h" class SPObject; diff --git a/src/document.h b/src/document.h index 22c341eae..42768b1be 100644 --- a/src/document.h +++ b/src/document.h @@ -21,7 +21,7 @@ #include #include "libcroco/cr-cascade.h" #include <2geom/forward.h> -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" #include diff --git a/src/gc-alloc.h b/src/gc-alloc.h deleted file mode 100644 index ba672ae2c..000000000 --- a/src/gc-alloc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Inkscape::GC::Alloc - GC-aware STL allocator - * - * Copyright 2004 MenTaLguY - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * See the file COPYING for details. - * - */ - -#ifndef SEEN_INKSCAPE_GC_ALLOC_H -#define SEEN_INKSCAPE_GC_ALLOC_H - -#include -#include -#include "gc-core.h" - -namespace Inkscape { - -namespace GC { - -template -class Alloc { -public: - typedef T value_type; - typedef T *pointer; - typedef T const *const_pointer; - typedef T &reference; - typedef T const &const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - template - struct rebind { typedef Alloc other; }; - - Alloc() {} - template Alloc(Alloc const &) {} - - pointer address(reference r) { return &r; } - const_pointer address(const_reference r) { return &r; } - - size_type max_size() const { - return std::numeric_limits::max() / sizeof(T); - } - - pointer allocate(size_type count, void const * =NULL) { - return static_cast(::operator new(count * sizeof(T), SCANNED, collect)); - } - - void construct(pointer p, const_reference value) { - new (static_cast(p)) T(value); - } - void destroy(pointer p) { p->~T(); } - - void deallocate(pointer p, size_type) { ::operator delete(p, GC); } -}; - -// allocators with the same collection policy are interchangable - -template -bool operator==(Alloc const &, Alloc const &) { - return collect1 == collect2; -} - -template -bool operator!=(Alloc const &, Alloc const &) { - return collect1 != collect2; -} - -} - -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/gc-allocator.h b/src/gc-allocator.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/gc-anchored.h b/src/gc-anchored.h index 99b78c784..a65c4f248 100644 --- a/src/gc-anchored.h +++ b/src/gc-anchored.h @@ -9,7 +9,7 @@ #ifndef SEEN_INKSCAPE_GC_ANCHORED_H #define SEEN_INKSCAPE_GC_ANCHORED_H -#include "gc-managed.h" +#include "libgc/gc-managed.h" namespace Inkscape { diff --git a/src/gc-core.h b/src/gc-core.h deleted file mode 100644 index d9d0bf4ff..000000000 --- a/src/gc-core.h +++ /dev/null @@ -1,213 +0,0 @@ -/** @file - * @brief Wrapper for Boehm GC - */ -/* Authors: - * MenTaLguY - * - * Copyright (C) 2004 MenTaLguY - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef SEEN_INKSCAPE_GC_CORE_H -#define SEEN_INKSCAPE_GC_CORE_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#ifdef HAVE_GC_GC_H -# include -#else -# include -#endif - -namespace Inkscape { -namespace GC { - -enum ScanPolicy { - SCANNED, - ATOMIC -}; - -enum CollectionPolicy { - AUTO, - MANUAL -}; - -enum Delete { - GC -}; - -typedef void (*CleanupFunc)(void *mem, void *data); - -struct Ops { - void (*do_init)(); - void *(*malloc)(std::size_t size); - void *(*malloc_atomic)(std::size_t size); - void *(*malloc_uncollectable)(std::size_t size); - void *(*malloc_atomic_uncollectable)(std::size_t size); - void *(*base)(void *ptr); - void (*register_finalizer_ignore_self)(void *base, - CleanupFunc func, void *data, - CleanupFunc *old_func, - void **old_data); - int (*general_register_disappearing_link)(void **p_ptr, - void const *base); - int (*unregister_disappearing_link)(void **p_ptr); - std::size_t (*get_heap_size)(); - std::size_t (*get_free_bytes)(); - void (*gcollect)(); - void (*enable)(); - void (*disable)(); - void (*free)(void *ptr); -}; - -struct Core { -public: - static void init(); - static inline void *malloc(std::size_t size) { - return _ops.malloc(size); - } - static inline void *malloc_atomic(std::size_t size) { - return _ops.malloc_atomic(size); - } - static inline void *malloc_uncollectable(std::size_t size) { - return _ops.malloc_uncollectable(size); - } - static inline void *malloc_atomic_uncollectable(std::size_t size) { - return _ops.malloc_atomic_uncollectable(size); - } - static inline void *base(void *ptr) { - return _ops.base(ptr); - } - static inline void register_finalizer_ignore_self(void *base, - CleanupFunc func, - void *data, - CleanupFunc *old_func, - void **old_data) - { - return _ops.register_finalizer_ignore_self(base, func, data, - old_func, old_data); - } - static inline int general_register_disappearing_link(void **p_ptr, - void *base) - { - return _ops.general_register_disappearing_link(p_ptr, base); - } - static inline int unregister_disappearing_link(void **p_ptr) { - return _ops.unregister_disappearing_link(p_ptr); - } - static inline std::size_t get_heap_size() { - return _ops.get_heap_size(); - } - static inline std::size_t get_free_bytes() { - return _ops.get_free_bytes(); - } - static inline void gcollect() { - _ops.gcollect(); - } - static inline void enable() { - _ops.enable(); - } - static inline void disable() { - _ops.disable(); - } - static inline void free(void *ptr) { - return _ops.free(ptr); - } -private: - static Ops _ops; -}; - -inline void init() { - Core::init(); -} - -void request_early_collection(); - -} -} - -inline void *operator new(std::size_t size, - Inkscape::GC::ScanPolicy scan, - Inkscape::GC::CollectionPolicy collect, - Inkscape::GC::CleanupFunc cleanup=NULL, - void *data=NULL) -throw(std::bad_alloc) -{ - using namespace Inkscape::GC; - - void *mem; - if ( collect == AUTO ) { - if ( scan == SCANNED ) { - mem = Core::malloc(size); - } else { - mem = Core::malloc_atomic(size); - } - } else { - if ( scan == SCANNED ) { - mem = Core::malloc_uncollectable(size); - } else { - mem = Core::malloc_atomic_uncollectable(size); - } - } - if (!mem) { - throw std::bad_alloc(); - } - if (cleanup) { - Core::register_finalizer_ignore_self(mem, cleanup, data, NULL, NULL); - } - return mem; -} - -inline void *operator new(std::size_t size, - Inkscape::GC::ScanPolicy scan, - Inkscape::GC::CleanupFunc cleanup=NULL, - void *data=NULL) -throw(std::bad_alloc) -{ - return operator new(size, scan, Inkscape::GC::AUTO, cleanup, data); -} - -inline void *operator new[](std::size_t size, - Inkscape::GC::ScanPolicy scan, - Inkscape::GC::CollectionPolicy collect, - Inkscape::GC::CleanupFunc cleanup=NULL, - void *data=NULL) -throw(std::bad_alloc) -{ - return operator new(size, scan, collect, cleanup, data); -} - -inline void *operator new[](std::size_t size, - Inkscape::GC::ScanPolicy scan, - Inkscape::GC::CleanupFunc cleanup=NULL, - void *data=NULL) -throw(std::bad_alloc) -{ - return operator new[](size, scan, Inkscape::GC::AUTO, cleanup, data); -} - -inline void operator delete(void *mem, Inkscape::GC::Delete) { - Inkscape::GC::Core::free(mem); -} - -inline void operator delete[](void *mem, Inkscape::GC::Delete) { - operator delete(mem, Inkscape::GC::GC); -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/gc-finalized.h b/src/gc-finalized.h index 814a2af18..2df479833 100644 --- a/src/gc-finalized.h +++ b/src/gc-finalized.h @@ -18,7 +18,7 @@ #include #include -#include "gc-core.h" +#include "libgc/gc-core.h" namespace Inkscape { diff --git a/src/gc-managed.h b/src/gc-managed.h deleted file mode 100644 index 74d224c9b..000000000 --- a/src/gc-managed.h +++ /dev/null @@ -1,63 +0,0 @@ -/** @file - * @brief Base class for GC-managed objects - */ -/* Copyright 2004 MenTaLguY - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * See the file COPYING for details. - */ - -#ifndef SEEN_INKSCAPE_GC_MANAGED_H -#define SEEN_INKSCAPE_GC_MANAGED_H - -#include "gc-core.h" - -namespace Inkscape { - -namespace GC { - -/** @brief A base class for objects for whom the normal new and delete - * operators should use the garbage-collected allocator - */ -template -class Managed { -public: - void *operator new(std::size_t size, - ScanPolicy scan=default_scan, - CollectionPolicy collect=default_collect) - throw (std::bad_alloc) - { - return ::operator new(size, scan, collect); - } - - void *operator new[](std::size_t size, - ScanPolicy scan=default_scan, - CollectionPolicy collect=default_collect) - throw (std::bad_alloc) - { - return ::operator new[](size, scan, collect); - } - - void operator delete(void *p) { return ::operator delete(p, GC); } -}; - -} - -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/gc-soft-ptr.h b/src/gc-soft-ptr.h deleted file mode 100644 index 9e7304939..000000000 --- a/src/gc-soft-ptr.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2006 MenTaLguY - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * See the file COPYING for details. - * - */ - -#ifndef SEEN_INKSCAPE_GC_SOFT_PTR_H -#define SEEN_INKSCAPE_GC_SOFT_PTR_H - -#include "gc-core.h" - -namespace Inkscape { - -namespace GC { - -/** - * A class for pointers which can be automatically cleared to break - * finalization cycles. - */ -template -class soft_ptr { -public: - soft_ptr(T *pointer=NULL) : _pointer(pointer) { - _register(); - } - - operator T *() const { return static_cast(_pointer); } - T &operator*() const { return *static_cast(_pointer); } - T *operator->() const { return static_cast(_pointer); } - T &operator[](int i) const { return static_cast(_pointer)[i]; } - - soft_ptr &operator=(T *pointer) { - _pointer = pointer; - return *this; - } - - // default copy - -private: - void _register() { - void *base=Core::base(this); - if (base) { - Core::general_register_disappearing_link(&_pointer, base); - } - } - - void *_pointer; -}; - -} - -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/gc.cpp b/src/gc.cpp deleted file mode 100644 index 280a8b1dc..000000000 --- a/src/gc.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/** @file - * Wrapper for Boehm GC. - */ -/* Authors: - * MenTaLguY - * - * Copyright (C) 2004 MenTaLguY - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "gc-core.h" -#include -#include -#include -#include -#include -#include -#include - -namespace Inkscape { -namespace GC { - -namespace { - -void display_warning(char *msg, GC_word arg) { - g_warning(msg, arg); -} - -void do_init() { - GC_no_dls = 1; - GC_all_interior_pointers = 1; - GC_finalize_on_demand = 0; - - GC_INIT(); - - GC_set_warn_proc(&display_warning); -} - -void *debug_malloc(std::size_t size) { - return GC_debug_malloc(size, GC_EXTRAS); -} - -void *debug_malloc_atomic(std::size_t size) { - return GC_debug_malloc_atomic(size, GC_EXTRAS); -} - -void *debug_malloc_uncollectable(std::size_t size) { - return GC_debug_malloc_uncollectable(size, GC_EXTRAS); -} - -void *debug_malloc_atomic_uncollectable(std::size_t size) { - return GC_debug_malloc_uncollectable(size, GC_EXTRAS); -} - -std::ptrdiff_t compute_debug_base_fixup() { - char *base=reinterpret_cast(GC_debug_malloc(1, GC_EXTRAS)); - char *real_base=reinterpret_cast(GC_base(base)); - GC_debug_free(base); - return base - real_base; -} - -inline std::ptrdiff_t const &debug_base_fixup() { - static std::ptrdiff_t fixup=compute_debug_base_fixup(); - return fixup; -} - -void *debug_base(void *ptr) { - char *base=reinterpret_cast(GC_base(ptr)); - return base + debug_base_fixup(); -} - -int debug_general_register_disappearing_link(void **p_ptr, void const *base) { - char const *real_base = reinterpret_cast(base) - debug_base_fixup(); -#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) - return GC_general_register_disappearing_link(p_ptr, real_base); -#else // compatibility with older Boehm GC versions - return GC_general_register_disappearing_link(p_ptr, const_cast(real_base)); -#endif -} - -void dummy_do_init() {} - -void *dummy_base(void *) { return NULL; } - -void dummy_register_finalizer(void *, CleanupFunc, void *, - CleanupFunc *old_func, void **old_data) -{ - if (old_func) { - *old_func = NULL; - } - if (old_data) { - *old_data = NULL; - } -} - -int dummy_general_register_disappearing_link(void **, void const *) { return false; } - -int dummy_unregister_disappearing_link(void **/*link*/) { return false; } - -std::size_t dummy_get_heap_size() { return 0; } - -std::size_t dummy_get_free_bytes() { return 0; } - -void dummy_gcollect() {} - -void dummy_enable() {} - -void dummy_disable() {} - -Ops enabled_ops = { - &do_init, - &GC_malloc, - &GC_malloc_atomic, - &GC_malloc_uncollectable, - &GC_malloc_atomic_uncollectable, - &GC_base, - &GC_register_finalizer_ignore_self, -#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) - &GC_general_register_disappearing_link, -#else // compatibility with older Boehm GC versions - (int (*)(void**, const void*))(&GC_general_register_disappearing_link), -#endif - &GC_unregister_disappearing_link, - &GC_get_heap_size, - &GC_get_free_bytes, - &GC_gcollect, - &GC_enable, - &GC_disable, - &GC_free -}; - -Ops debug_ops = { - &do_init, - &debug_malloc, - &debug_malloc_atomic, - &debug_malloc_uncollectable, - &debug_malloc_atomic_uncollectable, - &debug_base, - &GC_debug_register_finalizer_ignore_self, - &debug_general_register_disappearing_link, - &GC_unregister_disappearing_link, - &GC_get_heap_size, - &GC_get_free_bytes, - &GC_gcollect, - &GC_enable, - &GC_disable, - &GC_debug_free -}; - -Ops disabled_ops = { - &dummy_do_init, - &std::malloc, - &std::malloc, - &std::malloc, - &std::malloc, - &dummy_base, - &dummy_register_finalizer, - &dummy_general_register_disappearing_link, - &dummy_unregister_disappearing_link, - &dummy_get_heap_size, - &dummy_get_free_bytes, - &dummy_gcollect, - &dummy_enable, - &dummy_disable, - &std::free -}; - -class InvalidGCModeError : public std::runtime_error { -public: - InvalidGCModeError(const char *mode) - : runtime_error(std::string("Unknown GC mode \"") + mode + "\"") - {} -}; - -Ops const &get_ops() throw (InvalidGCModeError) { - char *mode_string=std::getenv("_INKSCAPE_GC"); - if (mode_string) { - if (!std::strcmp(mode_string, "enable")) { - return enabled_ops; - } else if (!std::strcmp(mode_string, "debug")) { - return debug_ops; - } else if (!std::strcmp(mode_string, "disable")) { - return disabled_ops; - } else { - throw InvalidGCModeError(mode_string); - } - } else { - return enabled_ops; - } -} - -void die_because_not_initialized() { - g_error("Attempt to use GC allocator before call to Inkscape::GC::init()"); -} - -void *stub_malloc(std::size_t) { - die_because_not_initialized(); - return NULL; -} - -void *stub_base(void *) { - die_because_not_initialized(); - return NULL; -} - -void stub_register_finalizer_ignore_self(void *, CleanupFunc, void *, - CleanupFunc *, void **) -{ - die_because_not_initialized(); -} - -int stub_general_register_disappearing_link(void **, void const *) { - die_because_not_initialized(); - return 0; -} - -int stub_unregister_disappearing_link(void **) { - die_because_not_initialized(); - return 0; -} - -std::size_t stub_get_heap_size() { - die_because_not_initialized(); - return 0; -} - -std::size_t stub_get_free_bytes() { - die_because_not_initialized(); - return 0; -} - -void stub_gcollect() { - die_because_not_initialized(); -} - -void stub_enable() { - die_because_not_initialized(); -} - -void stub_disable() { - die_because_not_initialized(); -} - -void stub_free(void *) { - die_because_not_initialized(); -} - -} - -Ops Core::_ops = { - NULL, - &stub_malloc, - &stub_malloc, - &stub_malloc, - &stub_malloc, - &stub_base, - &stub_register_finalizer_ignore_self, - &stub_general_register_disappearing_link, - &stub_unregister_disappearing_link, - &stub_get_heap_size, - &stub_get_free_bytes, - &stub_gcollect, - &stub_enable, - &stub_disable, - &stub_free -}; - -void Core::init() { - try { - _ops = get_ops(); - } catch (InvalidGCModeError &e) { - g_warning("%s; enabling normal collection", e.what()); - _ops = enabled_ops; - } - - _ops.do_init(); -} - - -namespace { - -bool collection_requested=false; -bool collection_task() { - Core::gcollect(); - Core::gcollect(); - collection_requested=false; - return false; -} - -} - -void request_early_collection() { - if (!collection_requested) { - collection_requested=true; - Glib::signal_idle().connect(sigc::ptr_fun(&collection_task)); - } -} - -} -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/inkview.cpp b/src/inkview.cpp index 0b7b4d35c..5e96b56c5 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -47,7 +47,7 @@ #include #include -#include "gc-core.h" +#include "libgc/gc-core.h" #include "preferences.h" #include diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index b1e365fe2..ca8ab3475 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -11,7 +11,7 @@ #include #include #include -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "gc-finalized.h" #include "document.h" #include "desktop.h" diff --git a/src/layer-manager.h b/src/layer-manager.h index 9eea68004..8e108635d 100644 --- a/src/layer-manager.h +++ b/src/layer-manager.h @@ -15,7 +15,7 @@ #include "document-subset.h" #include "gc-finalized.h" -#include "gc-soft-ptr.h" +#include "libgc/gc-soft-ptr.h" class SPDesktop; class SPDocument; diff --git a/src/libgc/CMakeLists.txt b/src/libgc/CMakeLists.txt new file mode 100644 index 000000000..22dd464e1 --- /dev/null +++ b/src/libgc/CMakeLists.txt @@ -0,0 +1,15 @@ + +set(libgc_SRC + gc.cpp + + # ------- + # Headers + gc-alloc.h + gc-anchored.h + gc-core.h + gc-managed.h + gc-soft-ptr.h +) + +add_inkscape_lib(gc_LIB "${libgc_SRC}") +# add_inkscape_source("${libgc_SRC}") diff --git a/src/libgc/Makefile_insert b/src/libgc/Makefile_insert new file mode 100644 index 000000000..e899a5b4a --- /dev/null +++ b/src/libgc/Makefile_insert @@ -0,0 +1,13 @@ +## Makefile.am fragment sourced by src/Makefile.am. + +libgc/all: libgc/libgc.a + +libgc/clean: + rm -f libgc/libgc.a $(libgc_libgc_a_OBJECTS) + +libgc_libgc_a_SOURCES = \ + libgc/gc.cpp \ + libgc/gc-alloc.h \ + libgc/gc-core.h \ + libgc/gc-managed.h \ + libgc/gc-soft-ptr.h diff --git a/src/libgc/gc-alloc.h b/src/libgc/gc-alloc.h new file mode 100644 index 000000000..765b28b19 --- /dev/null +++ b/src/libgc/gc-alloc.h @@ -0,0 +1,90 @@ +/* + * Inkscape::GC::Alloc - GC-aware STL allocator + * + * Copyright 2004 MenTaLguY + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See the file COPYING for details. + * + */ + +#ifndef SEEN_INKSCAPE_GC_ALLOC_H +#define SEEN_INKSCAPE_GC_ALLOC_H + +#include +#include +#include "libgc/gc-core.h" + +namespace Inkscape { + +namespace GC { + +template +class Alloc { +public: + typedef T value_type; + typedef T *pointer; + typedef T const *const_pointer; + typedef T &reference; + typedef T const &const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + template + struct rebind { typedef Alloc other; }; + + Alloc() {} + template Alloc(Alloc const &) {} + + pointer address(reference r) { return &r; } + const_pointer address(const_reference r) { return &r; } + + size_type max_size() const { + return std::numeric_limits::max() / sizeof(T); + } + + pointer allocate(size_type count, void const * =NULL) { + return static_cast(::operator new(count * sizeof(T), SCANNED, collect)); + } + + void construct(pointer p, const_reference value) { + new (static_cast(p)) T(value); + } + void destroy(pointer p) { p->~T(); } + + void deallocate(pointer p, size_type) { ::operator delete(p, GC); } +}; + +// allocators with the same collection policy are interchangable + +template +bool operator==(Alloc const &, Alloc const &) { + return collect1 == collect2; +} + +template +bool operator!=(Alloc const &, Alloc const &) { + return collect1 != collect2; +} + +} + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libgc/gc-core.h b/src/libgc/gc-core.h new file mode 100644 index 000000000..d9d0bf4ff --- /dev/null +++ b/src/libgc/gc-core.h @@ -0,0 +1,213 @@ +/** @file + * @brief Wrapper for Boehm GC + */ +/* Authors: + * MenTaLguY + * + * Copyright (C) 2004 MenTaLguY + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_GC_CORE_H +#define SEEN_INKSCAPE_GC_CORE_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#ifdef HAVE_GC_GC_H +# include +#else +# include +#endif + +namespace Inkscape { +namespace GC { + +enum ScanPolicy { + SCANNED, + ATOMIC +}; + +enum CollectionPolicy { + AUTO, + MANUAL +}; + +enum Delete { + GC +}; + +typedef void (*CleanupFunc)(void *mem, void *data); + +struct Ops { + void (*do_init)(); + void *(*malloc)(std::size_t size); + void *(*malloc_atomic)(std::size_t size); + void *(*malloc_uncollectable)(std::size_t size); + void *(*malloc_atomic_uncollectable)(std::size_t size); + void *(*base)(void *ptr); + void (*register_finalizer_ignore_self)(void *base, + CleanupFunc func, void *data, + CleanupFunc *old_func, + void **old_data); + int (*general_register_disappearing_link)(void **p_ptr, + void const *base); + int (*unregister_disappearing_link)(void **p_ptr); + std::size_t (*get_heap_size)(); + std::size_t (*get_free_bytes)(); + void (*gcollect)(); + void (*enable)(); + void (*disable)(); + void (*free)(void *ptr); +}; + +struct Core { +public: + static void init(); + static inline void *malloc(std::size_t size) { + return _ops.malloc(size); + } + static inline void *malloc_atomic(std::size_t size) { + return _ops.malloc_atomic(size); + } + static inline void *malloc_uncollectable(std::size_t size) { + return _ops.malloc_uncollectable(size); + } + static inline void *malloc_atomic_uncollectable(std::size_t size) { + return _ops.malloc_atomic_uncollectable(size); + } + static inline void *base(void *ptr) { + return _ops.base(ptr); + } + static inline void register_finalizer_ignore_self(void *base, + CleanupFunc func, + void *data, + CleanupFunc *old_func, + void **old_data) + { + return _ops.register_finalizer_ignore_self(base, func, data, + old_func, old_data); + } + static inline int general_register_disappearing_link(void **p_ptr, + void *base) + { + return _ops.general_register_disappearing_link(p_ptr, base); + } + static inline int unregister_disappearing_link(void **p_ptr) { + return _ops.unregister_disappearing_link(p_ptr); + } + static inline std::size_t get_heap_size() { + return _ops.get_heap_size(); + } + static inline std::size_t get_free_bytes() { + return _ops.get_free_bytes(); + } + static inline void gcollect() { + _ops.gcollect(); + } + static inline void enable() { + _ops.enable(); + } + static inline void disable() { + _ops.disable(); + } + static inline void free(void *ptr) { + return _ops.free(ptr); + } +private: + static Ops _ops; +}; + +inline void init() { + Core::init(); +} + +void request_early_collection(); + +} +} + +inline void *operator new(std::size_t size, + Inkscape::GC::ScanPolicy scan, + Inkscape::GC::CollectionPolicy collect, + Inkscape::GC::CleanupFunc cleanup=NULL, + void *data=NULL) +throw(std::bad_alloc) +{ + using namespace Inkscape::GC; + + void *mem; + if ( collect == AUTO ) { + if ( scan == SCANNED ) { + mem = Core::malloc(size); + } else { + mem = Core::malloc_atomic(size); + } + } else { + if ( scan == SCANNED ) { + mem = Core::malloc_uncollectable(size); + } else { + mem = Core::malloc_atomic_uncollectable(size); + } + } + if (!mem) { + throw std::bad_alloc(); + } + if (cleanup) { + Core::register_finalizer_ignore_self(mem, cleanup, data, NULL, NULL); + } + return mem; +} + +inline void *operator new(std::size_t size, + Inkscape::GC::ScanPolicy scan, + Inkscape::GC::CleanupFunc cleanup=NULL, + void *data=NULL) +throw(std::bad_alloc) +{ + return operator new(size, scan, Inkscape::GC::AUTO, cleanup, data); +} + +inline void *operator new[](std::size_t size, + Inkscape::GC::ScanPolicy scan, + Inkscape::GC::CollectionPolicy collect, + Inkscape::GC::CleanupFunc cleanup=NULL, + void *data=NULL) +throw(std::bad_alloc) +{ + return operator new(size, scan, collect, cleanup, data); +} + +inline void *operator new[](std::size_t size, + Inkscape::GC::ScanPolicy scan, + Inkscape::GC::CleanupFunc cleanup=NULL, + void *data=NULL) +throw(std::bad_alloc) +{ + return operator new[](size, scan, Inkscape::GC::AUTO, cleanup, data); +} + +inline void operator delete(void *mem, Inkscape::GC::Delete) { + Inkscape::GC::Core::free(mem); +} + +inline void operator delete[](void *mem, Inkscape::GC::Delete) { + operator delete(mem, Inkscape::GC::GC); +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libgc/gc-managed.h b/src/libgc/gc-managed.h new file mode 100644 index 000000000..9f6d9c2f6 --- /dev/null +++ b/src/libgc/gc-managed.h @@ -0,0 +1,63 @@ +/** @file + * @brief Base class for GC-managed objects + */ +/* Copyright 2004 MenTaLguY + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See the file COPYING for details. + */ + +#ifndef SEEN_INKSCAPE_GC_MANAGED_H +#define SEEN_INKSCAPE_GC_MANAGED_H + +#include "libgc/gc-core.h" + +namespace Inkscape { + +namespace GC { + +/** @brief A base class for objects for whom the normal new and delete + * operators should use the garbage-collected allocator + */ +template +class Managed { +public: + void *operator new(std::size_t size, + ScanPolicy scan=default_scan, + CollectionPolicy collect=default_collect) + throw (std::bad_alloc) + { + return ::operator new(size, scan, collect); + } + + void *operator new[](std::size_t size, + ScanPolicy scan=default_scan, + CollectionPolicy collect=default_collect) + throw (std::bad_alloc) + { + return ::operator new[](size, scan, collect); + } + + void operator delete(void *p) { return ::operator delete(p, GC); } +}; + +} + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libgc/gc-soft-ptr.h b/src/libgc/gc-soft-ptr.h new file mode 100644 index 000000000..bb26ebb04 --- /dev/null +++ b/src/libgc/gc-soft-ptr.h @@ -0,0 +1,70 @@ +/* + * Copyright 2006 MenTaLguY + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See the file COPYING for details. + * + */ + +#ifndef SEEN_INKSCAPE_GC_SOFT_PTR_H +#define SEEN_INKSCAPE_GC_SOFT_PTR_H + +#include "libgc/gc-core.h" + +namespace Inkscape { + +namespace GC { + +/** + * A class for pointers which can be automatically cleared to break + * finalization cycles. + */ +template +class soft_ptr { +public: + soft_ptr(T *pointer=NULL) : _pointer(pointer) { + _register(); + } + + operator T *() const { return static_cast(_pointer); } + T &operator*() const { return *static_cast(_pointer); } + T *operator->() const { return static_cast(_pointer); } + T &operator[](int i) const { return static_cast(_pointer)[i]; } + + soft_ptr &operator=(T *pointer) { + _pointer = pointer; + return *this; + } + + // default copy + +private: + void _register() { + void *base=Core::base(this); + if (base) { + Core::general_register_disappearing_link(&_pointer, base); + } + } + + void *_pointer; +}; + +} + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libgc/gc.cpp b/src/libgc/gc.cpp new file mode 100644 index 000000000..044fc6065 --- /dev/null +++ b/src/libgc/gc.cpp @@ -0,0 +1,312 @@ +/** @file + * Wrapper for Boehm GC. + */ +/* Authors: + * MenTaLguY + * + * Copyright (C) 2004 MenTaLguY + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "libgc/gc-core.h" +#include +#include +#include +#include +#include +#include +#include + +namespace Inkscape { +namespace GC { + +namespace { + +void display_warning(char *msg, GC_word arg) { + g_warning(msg, arg); +} + +void do_init() { + GC_no_dls = 1; + GC_all_interior_pointers = 1; + GC_finalize_on_demand = 0; + + GC_INIT(); + + GC_set_warn_proc(&display_warning); +} + +void *debug_malloc(std::size_t size) { + return GC_debug_malloc(size, GC_EXTRAS); +} + +void *debug_malloc_atomic(std::size_t size) { + return GC_debug_malloc_atomic(size, GC_EXTRAS); +} + +void *debug_malloc_uncollectable(std::size_t size) { + return GC_debug_malloc_uncollectable(size, GC_EXTRAS); +} + +void *debug_malloc_atomic_uncollectable(std::size_t size) { + return GC_debug_malloc_uncollectable(size, GC_EXTRAS); +} + +std::ptrdiff_t compute_debug_base_fixup() { + char *base=reinterpret_cast(GC_debug_malloc(1, GC_EXTRAS)); + char *real_base=reinterpret_cast(GC_base(base)); + GC_debug_free(base); + return base - real_base; +} + +inline std::ptrdiff_t const &debug_base_fixup() { + static std::ptrdiff_t fixup=compute_debug_base_fixup(); + return fixup; +} + +void *debug_base(void *ptr) { + char *base=reinterpret_cast(GC_base(ptr)); + return base + debug_base_fixup(); +} + +int debug_general_register_disappearing_link(void **p_ptr, void const *base) { + char const *real_base = reinterpret_cast(base) - debug_base_fixup(); +#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) + return GC_general_register_disappearing_link(p_ptr, real_base); +#else // compatibility with older Boehm GC versions + return GC_general_register_disappearing_link(p_ptr, const_cast(real_base)); +#endif +} + +void dummy_do_init() {} + +void *dummy_base(void *) { return NULL; } + +void dummy_register_finalizer(void *, CleanupFunc, void *, + CleanupFunc *old_func, void **old_data) +{ + if (old_func) { + *old_func = NULL; + } + if (old_data) { + *old_data = NULL; + } +} + +int dummy_general_register_disappearing_link(void **, void const *) { return false; } + +int dummy_unregister_disappearing_link(void **/*link*/) { return false; } + +std::size_t dummy_get_heap_size() { return 0; } + +std::size_t dummy_get_free_bytes() { return 0; } + +void dummy_gcollect() {} + +void dummy_enable() {} + +void dummy_disable() {} + +Ops enabled_ops = { + &do_init, + &GC_malloc, + &GC_malloc_atomic, + &GC_malloc_uncollectable, + &GC_malloc_atomic_uncollectable, + &GC_base, + &GC_register_finalizer_ignore_self, +#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) + &GC_general_register_disappearing_link, +#else // compatibility with older Boehm GC versions + (int (*)(void**, const void*))(&GC_general_register_disappearing_link), +#endif + &GC_unregister_disappearing_link, + &GC_get_heap_size, + &GC_get_free_bytes, + &GC_gcollect, + &GC_enable, + &GC_disable, + &GC_free +}; + +Ops debug_ops = { + &do_init, + &debug_malloc, + &debug_malloc_atomic, + &debug_malloc_uncollectable, + &debug_malloc_atomic_uncollectable, + &debug_base, + &GC_debug_register_finalizer_ignore_self, + &debug_general_register_disappearing_link, + &GC_unregister_disappearing_link, + &GC_get_heap_size, + &GC_get_free_bytes, + &GC_gcollect, + &GC_enable, + &GC_disable, + &GC_debug_free +}; + +Ops disabled_ops = { + &dummy_do_init, + &std::malloc, + &std::malloc, + &std::malloc, + &std::malloc, + &dummy_base, + &dummy_register_finalizer, + &dummy_general_register_disappearing_link, + &dummy_unregister_disappearing_link, + &dummy_get_heap_size, + &dummy_get_free_bytes, + &dummy_gcollect, + &dummy_enable, + &dummy_disable, + &std::free +}; + +class InvalidGCModeError : public std::runtime_error { +public: + InvalidGCModeError(const char *mode) + : runtime_error(std::string("Unknown GC mode \"") + mode + "\"") + {} +}; + +Ops const &get_ops() throw (InvalidGCModeError) { + char *mode_string=std::getenv("_INKSCAPE_GC"); + if (mode_string) { + if (!std::strcmp(mode_string, "enable")) { + return enabled_ops; + } else if (!std::strcmp(mode_string, "debug")) { + return debug_ops; + } else if (!std::strcmp(mode_string, "disable")) { + return disabled_ops; + } else { + throw InvalidGCModeError(mode_string); + } + } else { + return enabled_ops; + } +} + +void die_because_not_initialized() { + g_error("Attempt to use GC allocator before call to Inkscape::GC::init()"); +} + +void *stub_malloc(std::size_t) { + die_because_not_initialized(); + return NULL; +} + +void *stub_base(void *) { + die_because_not_initialized(); + return NULL; +} + +void stub_register_finalizer_ignore_self(void *, CleanupFunc, void *, + CleanupFunc *, void **) +{ + die_because_not_initialized(); +} + +int stub_general_register_disappearing_link(void **, void const *) { + die_because_not_initialized(); + return 0; +} + +int stub_unregister_disappearing_link(void **) { + die_because_not_initialized(); + return 0; +} + +std::size_t stub_get_heap_size() { + die_because_not_initialized(); + return 0; +} + +std::size_t stub_get_free_bytes() { + die_because_not_initialized(); + return 0; +} + +void stub_gcollect() { + die_because_not_initialized(); +} + +void stub_enable() { + die_because_not_initialized(); +} + +void stub_disable() { + die_because_not_initialized(); +} + +void stub_free(void *) { + die_because_not_initialized(); +} + +} + +Ops Core::_ops = { + NULL, + &stub_malloc, + &stub_malloc, + &stub_malloc, + &stub_malloc, + &stub_base, + &stub_register_finalizer_ignore_self, + &stub_general_register_disappearing_link, + &stub_unregister_disappearing_link, + &stub_get_heap_size, + &stub_get_free_bytes, + &stub_gcollect, + &stub_enable, + &stub_disable, + &stub_free +}; + +void Core::init() { + try { + _ops = get_ops(); + } catch (InvalidGCModeError &e) { + g_warning("%s; enabling normal collection", e.what()); + _ops = enabled_ops; + } + + _ops.do_init(); +} + + +namespace { + +bool collection_requested=false; +bool collection_task() { + Core::gcollect(); + Core::gcollect(); + collection_requested=false; + return false; +} + +} + +void request_early_collection() { + if (!collection_requested) { + collection_requested=true; + Glib::signal_idle().connect(sigc::ptr_fun(&collection_task)); + } +} + +} +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/main.cpp b/src/main.cpp index 15576109d..5dd8b7cff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,7 +52,7 @@ #include #include -#include "gc-core.h" +#include "libgc/gc-core.h" #ifdef AND #undef AND diff --git a/src/message-stack.h b/src/message-stack.h index 42bf4e8a7..e8d2aa202 100644 --- a/src/message-stack.h +++ b/src/message-stack.h @@ -22,7 +22,7 @@ #include #include -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" #include "message.h" diff --git a/src/selection.h b/src/selection.h index 5964b20e8..e8c85241e 100644 --- a/src/selection.h +++ b/src/selection.h @@ -19,10 +19,10 @@ #include #include -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" -#include "gc-soft-ptr.h" +#include "libgc/gc-soft-ptr.h" #include "sp-item.h" diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 5802a1be3..f1c19d18e 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -32,7 +32,7 @@ #include #include #include // for g_file_set_contents etc., used in _onGet and paste -#include "gc-core.h" +#include "libgc/gc-core.h" #include "xml/repr.h" #include "inkscape.h" #include "io/stringstream.h" diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index 00ed09551..ca46403a0 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -19,7 +19,7 @@ #include "filedialogimpl-gtkmm.h" #include "filedialog.h" -#include "gc-core.h" +#include "libgc/gc-core.h" #include "ui/dialog-events.h" #include "extension/output.h" #include "preferences.h" diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h index f77249abd..1d3640646 100644 --- a/src/ui/dialog/filedialogimpl-win32.h +++ b/src/ui/dialog/filedialogimpl-win32.h @@ -24,7 +24,7 @@ #include "filedialogimpl-gtkmm.h" -#include "gc-core.h" +#include "libgc/gc-core.h" // define WINVER high enough so we get the correct OPENFILENAMEW size #ifndef WINVER #define WINVER 0x0500 diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp index 0008eb284..e5fb6b563 100644 --- a/src/ui/dialog/memory.cpp +++ b/src/ui/dialog/memory.cpp @@ -20,7 +20,7 @@ #include #include -#include "gc-core.h" +#include "libgc/gc-core.h" #include "debug/heap.h" #include "verbs.h" diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index c4dd9df98..e8778d14c 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -26,7 +26,7 @@ #include "path-prefix.h" #include "filedialogimpl-gtkmm.h" #include "ui/interface.h" -#include "gc-core.h" +#include "libgc/gc-core.h" #include "ui/dialog-events.h" #include "io/sys.h" #include "preferences.h" diff --git a/src/ui/view/view.h b/src/ui/view/view.h index 48f4d2549..8edff8709 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -15,7 +15,7 @@ #include #include #include "message.h" -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" #include <2geom/forward.h> diff --git a/src/undo-stack-observer.h b/src/undo-stack-observer.h index 1057ace8f..a2bcb3a23 100644 --- a/src/undo-stack-observer.h +++ b/src/undo-stack-observer.h @@ -10,7 +10,7 @@ #ifndef SEEN_UNDO_COMMIT_OBSERVER_H #define SEEN_UNDO_COMMIT_OBSERVER_H -#include "gc-managed.h" +#include "libgc/gc-managed.h" namespace Inkscape { diff --git a/src/util/list.h b/src/util/list.h index de5a458e9..05a35320d 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -12,7 +12,7 @@ #include #include -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "util/reference.h" namespace Inkscape { diff --git a/src/util/share.h b/src/util/share.h index 6b5e6a4ef..46685c593 100644 --- a/src/util/share.h +++ b/src/util/share.h @@ -12,7 +12,7 @@ #ifndef SEEN_INKSCAPE_UTIL_SHARE_H #define SEEN_INKSCAPE_UTIL_SHARE_H -#include "gc-core.h" +#include "libgc/gc-core.h" #include #include diff --git a/src/xml/attribute-record.h b/src/xml/attribute-record.h index a61329b83..70691005e 100644 --- a/src/xml/attribute-record.h +++ b/src/xml/attribute-record.h @@ -6,7 +6,7 @@ #define SEEN_XML_SP_REPR_ATTR_H #include -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "util/share.h" #define SP_REPR_ATTRIBUTE_KEY(a) g_quark_to_string((a)->key) diff --git a/src/xml/composite-node-observer.h b/src/xml/composite-node-observer.h index 3e4b1673a..968fe20dd 100644 --- a/src/xml/composite-node-observer.h +++ b/src/xml/composite-node-observer.h @@ -15,7 +15,7 @@ #ifndef SEEN_INKSCAPE_XML_COMPOSITE_NODE_OBSERVER_H #define SEEN_INKSCAPE_XML_COMPOSITE_NODE_OBSERVER_H -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "xml/node-observer.h" #include "util/list-container.h" diff --git a/src/xml/event.h b/src/xml/event.h index d25ea0e07..bc63ca504 100644 --- a/src/xml/event.h +++ b/src/xml/event.h @@ -24,7 +24,7 @@ typedef unsigned int GQuark; #include #include "util/share.h" #include "util/forward-pointer-iterator.h" -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "xml/node.h" namespace Inkscape { diff --git a/src/xml/log-builder.h b/src/xml/log-builder.h index aa8f2c1c6..e27a5e5ac 100644 --- a/src/xml/log-builder.h +++ b/src/xml/log-builder.h @@ -14,7 +14,7 @@ #ifndef SEEN_INKSCAPE_XML_LOG_BUILDER_H #define SEEN_INKSCAPE_XML_LOG_BUILDER_H -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "xml/node-observer.h" namespace Inkscape { diff --git a/src/xml/subtree.h b/src/xml/subtree.h index 11bf515f1..7b154bd65 100644 --- a/src/xml/subtree.h +++ b/src/xml/subtree.h @@ -15,7 +15,7 @@ #ifndef SEEN_INKSCAPE_XML_SUBTREE_H #define SEEN_INKSCAPE_XML_SUBTREE_H -#include "gc-managed.h" +#include "libgc/gc-managed.h" #include "xml/composite-node-observer.h" namespace Inkscape { -- cgit v1.2.3 From 52f3d8937eac1d8b7115af5a4a9c8b0e6c70eb78 Mon Sep 17 00:00:00 2001 From: mathog <> Date: Wed, 25 Feb 2015 15:02:56 -0800 Subject: fix for bug 1425317 (bzr r13947) --- src/extension/internal/emf-inout.cpp | 4 ++-- src/extension/internal/emf-print.cpp | 4 ++++ src/extension/internal/text_reassemble.c | 20 +++++++++++++++++--- src/extension/internal/wmf-inout.cpp | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 71b6b82f7..31e69706f 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -188,7 +188,7 @@ double Emf::current_scale(PEMF_CALLBACK_DATA d){ "matrix(a,b,c,d,e,f)" (WITH the double quotes) */ std::string Emf::current_matrix(PEMF_CALLBACK_DATA d, double x, double y, int useoffset){ - std::stringstream cxform; + SVGOStringStream cxform; double scale = current_scale(d); cxform << "\"matrix("; cxform << d->dc[d->level].worldTransform.eM11/scale; cxform << ","; @@ -1058,7 +1058,7 @@ Emf::snap_to_faraway_pair(double *x, double *y) Since exclude clip can go through here, it calls snap_to_faraway_pair for numerical stability. */ std::string Emf::pix_to_xy(PEMF_CALLBACK_DATA d, double x, double y){ - std::stringstream cxform; + SVGOStringStream cxform; double tx = pix_to_x_point(d,x,y); double ty = pix_to_y_point(d,x,y); snap_to_faraway_pair(&tx,&ty); diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index b22dbc0e3..67a9242bc 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -251,7 +251,11 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) g_error("Fatal programming error in PrintEmf::begin at textcomment_set 1"); } + char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); snprintf(buff, sizeof(buff) - 1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, Inkscape::Util::Quantity::convert(dwInchesX, "in", "mm"), Inkscape::Util::Quantity::convert(dwInchesY, "in", "mm")); + setlocale(LC_NUMERIC, oldlocale); + g_free(oldlocale); rec = textcomment_set(buff); if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { g_error("Fatal programming error in PrintEmf::begin at textcomment_set 1"); diff --git a/src/extension/internal/text_reassemble.c b/src/extension/internal/text_reassemble.c index 4dfc49420..d3aafef12 100644 --- a/src/extension/internal/text_reassemble.c +++ b/src/extension/internal/text_reassemble.c @@ -67,11 +67,11 @@ Optional compiler switches for development: File: text_reassemble.c -Version: 0.0.15 -Date: 24-JUL-2014 +Version: 0.0.16 +Date: 25-FEB-2015 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2014 David Mathog and California Institute of Technology (Caltech) +Copyright: 2015 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -80,6 +80,7 @@ extern "C" { #include "text_reassemble.h" #include /* For a couple of text functions. Exact copy from libUEMF. */ +#include #include /* Code generated by make_ucd_mn_table.c using: @@ -1936,6 +1937,15 @@ void TR_layout_2_svg(TR_INFO *tri){ double newx,newy,tmpx; uint32_t utmp; + /* copy the current numeric locale, make a copy because setlocale may stomp on + the memory it points to. Then change it because SVG needs decimal points, + not commas, in floats. Restore on exit from this routine. + */ + char *prev_locale = setlocale(LC_NUMERIC,NULL); + char *hold_locale = malloc(sizeof(char) * (strlen(prev_locale) + 1)); + strcpy(hold_locale,prev_locale); + (void) setlocale(LC_NUMERIC,"POSIX"); + /* #define DBG_TR_PARA 0 #define DBG_TR_INPUT 1 @@ -2232,6 +2242,10 @@ void TR_layout_2_svg(TR_INFO *tri){ } /* end of j loop */ TRPRINT(tri,"\n"); } /* end of i loop */ + + /* restore locale and free memory. */ + (void) setlocale(LC_NUMERIC,hold_locale); + free(hold_locale); } /** diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 8eb03131c..503a93418 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -176,7 +176,7 @@ double Wmf::current_scale(PWMF_CALLBACK_DATA /*d*/){ /* WMF has no worldTransform, so this always returns an Identity rotation matrix, but the offsets may have values.*/ std::string Wmf::current_matrix(PWMF_CALLBACK_DATA d, double x, double y, int useoffset){ - std::stringstream cxform; + SVGOStringStream cxform; double scale = current_scale(d); cxform << "\"matrix("; cxform << 1.0/scale; cxform << ","; @@ -948,7 +948,7 @@ Wmf::pix_to_abs_size(PWMF_CALLBACK_DATA d, double px) /* returns "x,y" (without the quotes) in inkscape coordinates for a pair of WMF x,y coordinates */ std::string Wmf::pix_to_xy(PWMF_CALLBACK_DATA d, double x, double y){ - std::stringstream cxform; + SVGOStringStream cxform; cxform << pix_to_x_point(d,x,y); cxform << ","; cxform << pix_to_y_point(d,x,y); -- cgit v1.2.3 From caefef71482531ff82c444d552f406cbfbd360b8 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Feb 2015 18:08:51 -0500 Subject: Collect util/ into a static library (bzr r13948) --- src/Makefile.am | 1 + src/display/canvas-axonomgrid.cpp | 2 +- src/display/canvas-grid.cpp | 4 +- src/helper/Makefile_insert | 1 + src/helper/mathfns.h | 82 ++++++++++++++++++++++++++++++++++++++ src/snap.cpp | 2 +- src/sp-shape.cpp | 2 +- src/util/CMakeLists.txt | 5 +-- src/util/Makefile_insert | 12 ++++-- src/util/mathfns.h | 83 --------------------------------------- 10 files changed, 99 insertions(+), 95 deletions(-) create mode 100644 src/helper/mathfns.h delete mode 100644 src/util/mathfns.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index db70b3956..a8f69fbfc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,6 +34,7 @@ noinst_LIBRARIES = \ livarot/libvarot.a \ 2geom/lib2geom.a \ libdepixelize/libdepixelize.a \ + util/libutil.a \ libinkversion.a all_libs = \ diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 88c23bf62..a2df86823 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -50,7 +50,7 @@ #include "svg/svg-color.h" #include "2geom/line.h" #include "2geom/angle.h" -#include "util/mathfns.h" +#include "helper/mathfns.h" #include "round.h" #include "util/units.h" diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 0f58096ce..9b9f64529 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -35,7 +35,7 @@ #include "ui/widget/registered-widget.h" #include "desktop.h" #include "sp-canvas-util.h" -#include "util/mathfns.h" +#include "helper/mathfns.h" #include "display/cairo-utils.h" #include "display/canvas-axonomgrid.h" @@ -50,7 +50,7 @@ #include "sp-root.h" #include "svg/svg-color.h" #include "svg/stringstream.h" -#include "util/mathfns.h" +#include "helper/mathfns.h" #include "xml/node-event-vector.h" #include "verbs.h" #include "display/sp-canvas.h" diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert index 4c6437f13..5cb4cea8d 100644 --- a/src/helper/Makefile_insert +++ b/src/helper/Makefile_insert @@ -14,6 +14,7 @@ ink_common_sources += \ helper/geom-nodetype.h \ helper/gnome-utils.cpp \ helper/gnome-utils.h \ + helper/mathfns.h \ helper/png-write.cpp \ helper/png-write.h \ helper/sp-marshal.cpp \ diff --git a/src/helper/mathfns.h b/src/helper/mathfns.h new file mode 100644 index 000000000..8fb88dc26 --- /dev/null +++ b/src/helper/mathfns.h @@ -0,0 +1,82 @@ +/* + * ... some mathmatical functions + * + * Authors: + * Johan Engelen + * + * Copyright (C) 2007 Johan Engelen + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_UTIL_MATHFNS_H +#define SEEN_INKSCAPE_UTIL_MATHFNS_H + +#include <2geom/point.h> + +namespace Inkscape { + +namespace Util { + +/** + * Returns area in triangle given by points; may be negative. + */ +inline double +triangle_area (Geom::Point p1, Geom::Point p2, Geom::Point p3) +{ + using Geom::X; + using Geom::Y; + return (p1[X]*p2[Y] + p1[Y]*p3[X] + p2[X]*p3[Y] - p2[Y]*p3[X] - p1[Y]*p2[X] - p1[X]*p3[Y]); +} + +/** + * \return x rounded to the nearest multiple of c1 plus c0. + * + * \note + * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero + * mean "ignore the grid in this dimension". + */ +inline double round_to_nearest_multiple_plus(double x, double const c1, double const c0) +{ + return floor((x - c0) / c1 + .5) * c1 + c0; +} + +/** + * \return x rounded to the lower multiple of c1 plus c0. + * + * \note + * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero + * mean "ignore the grid in this dimension". + */ +inline double round_to_lower_multiple_plus(double x, double const c1, double const c0 = 0) +{ + return floor((x - c0) / c1) * c1 + c0; +} + +/** + * \return x rounded to the upper multiple of c1 plus c0. + * + * \note + * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero + * mean "ignore the grid in this dimension". + */ +inline double round_to_upper_multiple_plus(double x, double const c1, double const c0 = 0) +{ + return ceil((x - c0) / c1) * c1 + c0; +} + +} + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/snap.cpp b/src/snap.cpp index 8138e4546..96b5ab53c 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -33,7 +33,7 @@ #include "sp-guide.h" #include "preferences.h" #include "ui/tools/tool-base.h" -#include "util/mathfns.h" +#include "helper/mathfns.h" using std::vector; using Inkscape::Util::round_to_upper_multiple_plus; using Inkscape::Util::round_to_lower_multiple_plus; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 16f9ec13b..78135d459 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -47,7 +47,7 @@ #include "bad-uri-exception.h" #include "xml/repr.h" -#include "util/mathfns.h" // for triangle_area() +#include "helper/mathfns.h" // for triangle_area() #include "splivarot.h" // for bounding box calculation diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 732e01b0c..8fd8c8c66 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -31,7 +31,6 @@ set(util_SRC list.h longest-common-suffix.h map-list.h - mathfns.h reference.h reverse-list.h share.h @@ -43,5 +42,5 @@ set(util_SRC ziptool.h ) -# add_inkscape_lib(util_LIB "${util_SRC}") -add_inkscape_source("${util_SRC}") +add_inkscape_lib(util_LIB "${util_SRC}") +# add_inkscape_source("${util_SRC}") diff --git a/src/util/Makefile_insert b/src/util/Makefile_insert index 6d2e63278..c23dffbca 100644 --- a/src/util/Makefile_insert +++ b/src/util/Makefile_insert @@ -1,8 +1,13 @@ ## Makefile.am fragment sourced by src/Makefile.am. -ink_common_sources += \ - util/ziptool.h \ - util/ziptool.cpp \ +util/all: util/libutil.a + +util/clean: + rm -f util/libutil.a $(util_libutil_a_OBJECTS) + +util_libutil_a_SOURCES = \ + util/ziptool.h \ + util/ziptool.cpp \ util/accumulators.h \ util/compose.hpp \ util/copy.h \ @@ -26,7 +31,6 @@ ink_common_sources += \ util/list-copy.h \ util/longest-common-suffix.h \ util/map-list.h \ - util/mathfns.h \ util/reference.h \ util/reverse-list.h \ util/share.h \ diff --git a/src/util/mathfns.h b/src/util/mathfns.h deleted file mode 100644 index 830e159da..000000000 --- a/src/util/mathfns.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Inkscape::Util::... some mathmatical functions - * - * Authors: - * Johan Engelen - * - * Copyright (C) 2007 Johan Engelen - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef SEEN_INKSCAPE_UTIL_MATHFNS_H -#define SEEN_INKSCAPE_UTIL_MATHFNS_H - -#include <2geom/point.h> - -namespace Inkscape { - -namespace Util { - -/** - * Returns area in triangle given by points; may be negative. - */ -inline double -triangle_area (Geom::Point p1, Geom::Point p2, Geom::Point p3) -{ - using Geom::X; - using Geom::Y; - return (p1[X]*p2[Y] + p1[Y]*p3[X] + p2[X]*p3[Y] - p2[Y]*p3[X] - p1[Y]*p2[X] - p1[X]*p3[Y]); -} - -/** - * \return x rounded to the nearest multiple of c1 plus c0. - * - * \note - * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero - * mean "ignore the grid in this dimension". - */ -inline double round_to_nearest_multiple_plus(double x, double const c1, double const c0) -{ - return floor((x - c0) / c1 + .5) * c1 + c0; -} - -/** - * \return x rounded to the lower multiple of c1 plus c0. - * - * \note - * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero - * mean "ignore the grid in this dimension". - */ -inline double round_to_lower_multiple_plus(double x, double const c1, double const c0 = 0) -{ - return floor((x - c0) / c1) * c1 + c0; -} - -/** - * \return x rounded to the upper multiple of c1 plus c0. - * - * \note - * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero - * mean "ignore the grid in this dimension". - */ -inline double round_to_upper_multiple_plus(double x, double const c1, double const c0 = 0) -{ - return ceil((x - c0) / c1) * c1 + c0; -} - - -} - -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 4ec3ceb519cc30950b70c0bb5fabc3e5a629c37b Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Feb 2015 18:10:21 -0500 Subject: whoops (bzr r13949) --- src/helper/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index b0e473ddd..74ce2c85d 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -32,6 +32,7 @@ set(helper_SRC geom-nodetype.h geom.h gnome-utils.h + mathfns.h pixbuf-ops.h png-write.h stock-items.h -- cgit v1.2.3 From 3b0e6ebad7223a61510fad03e241ceadfae961f0 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Feb 2015 21:49:35 -0500 Subject: Rename libgc/ => inkgc/ to reflect difference from Boehm GC (bzr r13950) --- src/CMakeLists.txt | 2 +- src/Makefile.am | 4 +- src/composite-undo-stack-observer.h | 2 +- src/debug/demangle.cpp | 2 +- src/debug/gc-heap.h | 2 +- src/debug/heap.cpp | 2 +- src/debug/logger.cpp | 2 +- src/debug/simple-event.h | 2 +- src/display/nr-filter.h | 2 +- src/document-subset.h | 2 +- src/document.h | 2 +- src/gc-anchored.h | 2 +- src/gc-finalized.h | 2 +- src/inkgc/CMakeLists.txt | 15 ++ src/inkgc/Makefile_insert | 13 ++ src/inkgc/gc-alloc.h | 90 ++++++++++ src/inkgc/gc-core.h | 213 ++++++++++++++++++++++++ src/inkgc/gc-managed.h | 63 +++++++ src/inkgc/gc-soft-ptr.h | 70 ++++++++ src/inkgc/gc.cpp | 312 +++++++++++++++++++++++++++++++++++ src/inkview.cpp | 2 +- src/layer-manager.cpp | 2 +- src/layer-manager.h | 2 +- src/libgc/CMakeLists.txt | 15 -- src/libgc/Makefile_insert | 13 -- src/libgc/gc-alloc.h | 90 ---------- src/libgc/gc-core.h | 213 ------------------------ src/libgc/gc-managed.h | 63 ------- src/libgc/gc-soft-ptr.h | 70 -------- src/libgc/gc.cpp | 312 ----------------------------------- src/main.cpp | 2 +- src/message-stack.h | 2 +- src/selection.h | 4 +- src/ui/clipboard.cpp | 2 +- src/ui/dialog/filedialog.cpp | 2 +- src/ui/dialog/filedialogimpl-win32.h | 2 +- src/ui/dialog/memory.cpp | 2 +- src/ui/dialog/ocaldialogs.cpp | 2 +- src/ui/view/view.h | 2 +- src/undo-stack-observer.h | 2 +- src/util/list.h | 2 +- src/util/share.h | 2 +- src/xml/attribute-record.h | 2 +- src/xml/composite-node-observer.h | 2 +- src/xml/event.h | 2 +- src/xml/log-builder.h | 2 +- src/xml/subtree.h | 2 +- 47 files changed, 811 insertions(+), 811 deletions(-) create mode 100644 src/inkgc/CMakeLists.txt create mode 100644 src/inkgc/Makefile_insert create mode 100644 src/inkgc/gc-alloc.h create mode 100644 src/inkgc/gc-core.h create mode 100644 src/inkgc/gc-managed.h create mode 100644 src/inkgc/gc-soft-ptr.h create mode 100644 src/inkgc/gc.cpp delete mode 100644 src/libgc/CMakeLists.txt delete mode 100644 src/libgc/Makefile_insert delete mode 100644 src/libgc/gc-alloc.h delete mode 100644 src/libgc/gc-core.h delete mode 100644 src/libgc/gc-managed.h delete mode 100644 src/libgc/gc-soft-ptr.h delete mode 100644 src/libgc/gc.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 208f31716..0b1e3931b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -491,7 +491,7 @@ add_subdirectory(2geom) add_subdirectory(libavoid) add_subdirectory(libcola) add_subdirectory(libcroco) -add_subdirectory(libgc) +add_subdirectory(inkgc) add_subdirectory(libgdl) add_subdirectory(libuemf) add_subdirectory(libvpsc) diff --git a/src/Makefile.am b/src/Makefile.am index a8f69fbfc..cfbbd4015 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,7 +29,7 @@ noinst_LIBRARIES = \ $(internal_GDL) \ libuemf/libuemf.a \ libcola/libcola.a \ - libgc/libgc.a \ + inkgc/libinkgc.a \ libvpsc/libvpsc.a \ livarot/libvarot.a \ 2geom/lib2geom.a \ @@ -117,7 +117,7 @@ include filters/Makefile_insert include helper/Makefile_insert include io/Makefile_insert include libcroco/Makefile_insert -include libgc/Makefile_insert +include inkgc/Makefile_insert include libgdl/Makefile_insert include libnrtype/Makefile_insert include libavoid/Makefile_insert diff --git a/src/composite-undo-stack-observer.h b/src/composite-undo-stack-observer.h index 00b1ab728..33afda48d 100644 --- a/src/composite-undo-stack-observer.h +++ b/src/composite-undo-stack-observer.h @@ -10,7 +10,7 @@ #ifndef SEEN_COMPOSITE_UNDO_COMMIT_OBSERVER_H #define SEEN_COMPOSITE_UNDO_COMMIT_OBSERVER_H -#include "libgc/gc-alloc.h" +#include "inkgc/gc-alloc.h" #include "undo-stack-observer.h" #include diff --git a/src/debug/demangle.cpp b/src/debug/demangle.cpp index a6386ebd2..1d94f0eb9 100644 --- a/src/debug/demangle.cpp +++ b/src/debug/demangle.cpp @@ -14,7 +14,7 @@ #include #include "debug/demangle.h" #include "util/format.h" -#include "libgc/gc-alloc.h" +#include "inkgc/gc-alloc.h" namespace Inkscape { diff --git a/src/debug/gc-heap.h b/src/debug/gc-heap.h index ec35a6d2f..d120ddba9 100644 --- a/src/debug/gc-heap.h +++ b/src/debug/gc-heap.h @@ -12,7 +12,7 @@ #ifndef SEEN_INKSCAPE_DEBUG_GC_HEAP_H #define SEEN_INKSCAPE_DEBUG_GC_HEAP_H -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" #include "debug/heap.h" namespace Inkscape { diff --git a/src/debug/heap.cpp b/src/debug/heap.cpp index f522b737c..0135a9ceb 100644 --- a/src/debug/heap.cpp +++ b/src/debug/heap.cpp @@ -13,7 +13,7 @@ # include "config.h" #endif -#include "libgc/gc-alloc.h" +#include "inkgc/gc-alloc.h" #include "debug/gc-heap.h" #include "debug/sysv-heap.h" #include diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index 5e977c764..2eb81a0ba 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -15,7 +15,7 @@ #include "inkscape-version.h" #include "debug/logger.h" #include "debug/simple-event.h" -#include "libgc/gc-alloc.h" +#include "inkgc/gc-alloc.h" namespace Inkscape { diff --git a/src/debug/simple-event.h b/src/debug/simple-event.h index 7786a58d2..03ce5d326 100644 --- a/src/debug/simple-event.h +++ b/src/debug/simple-event.h @@ -16,7 +16,7 @@ #include #include // g_assert() -#include "libgc/gc-alloc.h" +#include "inkgc/gc-alloc.h" #include "debug/event.h" namespace Inkscape { diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 4c42b6f28..211d8ddd9 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -18,7 +18,7 @@ #include "display/nr-filter-types.h" #include "svg/svg-length.h" #include "sp-filter-units.h" -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" namespace Inkscape { class DrawingContext; diff --git a/src/document-subset.h b/src/document-subset.h index 940124f83..2799ff173 100644 --- a/src/document-subset.h +++ b/src/document-subset.h @@ -14,7 +14,7 @@ #include #include -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "gc-anchored.h" class SPObject; diff --git a/src/document.h b/src/document.h index 42768b1be..a33b476cc 100644 --- a/src/document.h +++ b/src/document.h @@ -21,7 +21,7 @@ #include #include "libcroco/cr-cascade.h" #include <2geom/forward.h> -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" #include diff --git a/src/gc-anchored.h b/src/gc-anchored.h index a65c4f248..33305df5c 100644 --- a/src/gc-anchored.h +++ b/src/gc-anchored.h @@ -9,7 +9,7 @@ #ifndef SEEN_INKSCAPE_GC_ANCHORED_H #define SEEN_INKSCAPE_GC_ANCHORED_H -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" namespace Inkscape { diff --git a/src/gc-finalized.h b/src/gc-finalized.h index 2df479833..d39338643 100644 --- a/src/gc-finalized.h +++ b/src/gc-finalized.h @@ -18,7 +18,7 @@ #include #include -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" namespace Inkscape { diff --git a/src/inkgc/CMakeLists.txt b/src/inkgc/CMakeLists.txt new file mode 100644 index 000000000..22dd464e1 --- /dev/null +++ b/src/inkgc/CMakeLists.txt @@ -0,0 +1,15 @@ + +set(libgc_SRC + gc.cpp + + # ------- + # Headers + gc-alloc.h + gc-anchored.h + gc-core.h + gc-managed.h + gc-soft-ptr.h +) + +add_inkscape_lib(gc_LIB "${libgc_SRC}") +# add_inkscape_source("${libgc_SRC}") diff --git a/src/inkgc/Makefile_insert b/src/inkgc/Makefile_insert new file mode 100644 index 000000000..58aa39bb9 --- /dev/null +++ b/src/inkgc/Makefile_insert @@ -0,0 +1,13 @@ +## Makefile.am fragment sourced by src/Makefile.am. + +inkgc/all: inkgc/libinkgc.a + +inkgc/clean: + rm -f inkgc/libinkgc.a $(inkgc_libinkgc_a_OBJECTS) + +inkgc_libinkgc_a_SOURCES = \ + inkgc/gc.cpp \ + inkgc/gc-alloc.h \ + inkgc/gc-core.h \ + inkgc/gc-managed.h \ + inkgc/gc-soft-ptr.h diff --git a/src/inkgc/gc-alloc.h b/src/inkgc/gc-alloc.h new file mode 100644 index 000000000..917ee972d --- /dev/null +++ b/src/inkgc/gc-alloc.h @@ -0,0 +1,90 @@ +/* + * Inkscape::GC::Alloc - GC-aware STL allocator + * + * Copyright 2004 MenTaLguY + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See the file COPYING for details. + * + */ + +#ifndef SEEN_INKSCAPE_GC_ALLOC_H +#define SEEN_INKSCAPE_GC_ALLOC_H + +#include +#include +#include "inkgc/gc-core.h" + +namespace Inkscape { + +namespace GC { + +template +class Alloc { +public: + typedef T value_type; + typedef T *pointer; + typedef T const *const_pointer; + typedef T &reference; + typedef T const &const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + template + struct rebind { typedef Alloc other; }; + + Alloc() {} + template Alloc(Alloc const &) {} + + pointer address(reference r) { return &r; } + const_pointer address(const_reference r) { return &r; } + + size_type max_size() const { + return std::numeric_limits::max() / sizeof(T); + } + + pointer allocate(size_type count, void const * =NULL) { + return static_cast(::operator new(count * sizeof(T), SCANNED, collect)); + } + + void construct(pointer p, const_reference value) { + new (static_cast(p)) T(value); + } + void destroy(pointer p) { p->~T(); } + + void deallocate(pointer p, size_type) { ::operator delete(p, GC); } +}; + +// allocators with the same collection policy are interchangable + +template +bool operator==(Alloc const &, Alloc const &) { + return collect1 == collect2; +} + +template +bool operator!=(Alloc const &, Alloc const &) { + return collect1 != collect2; +} + +} + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/inkgc/gc-core.h b/src/inkgc/gc-core.h new file mode 100644 index 000000000..d9d0bf4ff --- /dev/null +++ b/src/inkgc/gc-core.h @@ -0,0 +1,213 @@ +/** @file + * @brief Wrapper for Boehm GC + */ +/* Authors: + * MenTaLguY + * + * Copyright (C) 2004 MenTaLguY + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_GC_CORE_H +#define SEEN_INKSCAPE_GC_CORE_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#ifdef HAVE_GC_GC_H +# include +#else +# include +#endif + +namespace Inkscape { +namespace GC { + +enum ScanPolicy { + SCANNED, + ATOMIC +}; + +enum CollectionPolicy { + AUTO, + MANUAL +}; + +enum Delete { + GC +}; + +typedef void (*CleanupFunc)(void *mem, void *data); + +struct Ops { + void (*do_init)(); + void *(*malloc)(std::size_t size); + void *(*malloc_atomic)(std::size_t size); + void *(*malloc_uncollectable)(std::size_t size); + void *(*malloc_atomic_uncollectable)(std::size_t size); + void *(*base)(void *ptr); + void (*register_finalizer_ignore_self)(void *base, + CleanupFunc func, void *data, + CleanupFunc *old_func, + void **old_data); + int (*general_register_disappearing_link)(void **p_ptr, + void const *base); + int (*unregister_disappearing_link)(void **p_ptr); + std::size_t (*get_heap_size)(); + std::size_t (*get_free_bytes)(); + void (*gcollect)(); + void (*enable)(); + void (*disable)(); + void (*free)(void *ptr); +}; + +struct Core { +public: + static void init(); + static inline void *malloc(std::size_t size) { + return _ops.malloc(size); + } + static inline void *malloc_atomic(std::size_t size) { + return _ops.malloc_atomic(size); + } + static inline void *malloc_uncollectable(std::size_t size) { + return _ops.malloc_uncollectable(size); + } + static inline void *malloc_atomic_uncollectable(std::size_t size) { + return _ops.malloc_atomic_uncollectable(size); + } + static inline void *base(void *ptr) { + return _ops.base(ptr); + } + static inline void register_finalizer_ignore_self(void *base, + CleanupFunc func, + void *data, + CleanupFunc *old_func, + void **old_data) + { + return _ops.register_finalizer_ignore_self(base, func, data, + old_func, old_data); + } + static inline int general_register_disappearing_link(void **p_ptr, + void *base) + { + return _ops.general_register_disappearing_link(p_ptr, base); + } + static inline int unregister_disappearing_link(void **p_ptr) { + return _ops.unregister_disappearing_link(p_ptr); + } + static inline std::size_t get_heap_size() { + return _ops.get_heap_size(); + } + static inline std::size_t get_free_bytes() { + return _ops.get_free_bytes(); + } + static inline void gcollect() { + _ops.gcollect(); + } + static inline void enable() { + _ops.enable(); + } + static inline void disable() { + _ops.disable(); + } + static inline void free(void *ptr) { + return _ops.free(ptr); + } +private: + static Ops _ops; +}; + +inline void init() { + Core::init(); +} + +void request_early_collection(); + +} +} + +inline void *operator new(std::size_t size, + Inkscape::GC::ScanPolicy scan, + Inkscape::GC::CollectionPolicy collect, + Inkscape::GC::CleanupFunc cleanup=NULL, + void *data=NULL) +throw(std::bad_alloc) +{ + using namespace Inkscape::GC; + + void *mem; + if ( collect == AUTO ) { + if ( scan == SCANNED ) { + mem = Core::malloc(size); + } else { + mem = Core::malloc_atomic(size); + } + } else { + if ( scan == SCANNED ) { + mem = Core::malloc_uncollectable(size); + } else { + mem = Core::malloc_atomic_uncollectable(size); + } + } + if (!mem) { + throw std::bad_alloc(); + } + if (cleanup) { + Core::register_finalizer_ignore_self(mem, cleanup, data, NULL, NULL); + } + return mem; +} + +inline void *operator new(std::size_t size, + Inkscape::GC::ScanPolicy scan, + Inkscape::GC::CleanupFunc cleanup=NULL, + void *data=NULL) +throw(std::bad_alloc) +{ + return operator new(size, scan, Inkscape::GC::AUTO, cleanup, data); +} + +inline void *operator new[](std::size_t size, + Inkscape::GC::ScanPolicy scan, + Inkscape::GC::CollectionPolicy collect, + Inkscape::GC::CleanupFunc cleanup=NULL, + void *data=NULL) +throw(std::bad_alloc) +{ + return operator new(size, scan, collect, cleanup, data); +} + +inline void *operator new[](std::size_t size, + Inkscape::GC::ScanPolicy scan, + Inkscape::GC::CleanupFunc cleanup=NULL, + void *data=NULL) +throw(std::bad_alloc) +{ + return operator new[](size, scan, Inkscape::GC::AUTO, cleanup, data); +} + +inline void operator delete(void *mem, Inkscape::GC::Delete) { + Inkscape::GC::Core::free(mem); +} + +inline void operator delete[](void *mem, Inkscape::GC::Delete) { + operator delete(mem, Inkscape::GC::GC); +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/inkgc/gc-managed.h b/src/inkgc/gc-managed.h new file mode 100644 index 000000000..f435d7802 --- /dev/null +++ b/src/inkgc/gc-managed.h @@ -0,0 +1,63 @@ +/** @file + * @brief Base class for GC-managed objects + */ +/* Copyright 2004 MenTaLguY + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See the file COPYING for details. + */ + +#ifndef SEEN_INKSCAPE_GC_MANAGED_H +#define SEEN_INKSCAPE_GC_MANAGED_H + +#include "inkgc/gc-core.h" + +namespace Inkscape { + +namespace GC { + +/** @brief A base class for objects for whom the normal new and delete + * operators should use the garbage-collected allocator + */ +template +class Managed { +public: + void *operator new(std::size_t size, + ScanPolicy scan=default_scan, + CollectionPolicy collect=default_collect) + throw (std::bad_alloc) + { + return ::operator new(size, scan, collect); + } + + void *operator new[](std::size_t size, + ScanPolicy scan=default_scan, + CollectionPolicy collect=default_collect) + throw (std::bad_alloc) + { + return ::operator new[](size, scan, collect); + } + + void operator delete(void *p) { return ::operator delete(p, GC); } +}; + +} + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/inkgc/gc-soft-ptr.h b/src/inkgc/gc-soft-ptr.h new file mode 100644 index 000000000..45a3ddcf7 --- /dev/null +++ b/src/inkgc/gc-soft-ptr.h @@ -0,0 +1,70 @@ +/* + * Copyright 2006 MenTaLguY + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See the file COPYING for details. + * + */ + +#ifndef SEEN_INKSCAPE_GC_SOFT_PTR_H +#define SEEN_INKSCAPE_GC_SOFT_PTR_H + +#include "inkgc/gc-core.h" + +namespace Inkscape { + +namespace GC { + +/** + * A class for pointers which can be automatically cleared to break + * finalization cycles. + */ +template +class soft_ptr { +public: + soft_ptr(T *pointer=NULL) : _pointer(pointer) { + _register(); + } + + operator T *() const { return static_cast(_pointer); } + T &operator*() const { return *static_cast(_pointer); } + T *operator->() const { return static_cast(_pointer); } + T &operator[](int i) const { return static_cast(_pointer)[i]; } + + soft_ptr &operator=(T *pointer) { + _pointer = pointer; + return *this; + } + + // default copy + +private: + void _register() { + void *base=Core::base(this); + if (base) { + Core::general_register_disappearing_link(&_pointer, base); + } + } + + void *_pointer; +}; + +} + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/inkgc/gc.cpp b/src/inkgc/gc.cpp new file mode 100644 index 000000000..90c02d9c8 --- /dev/null +++ b/src/inkgc/gc.cpp @@ -0,0 +1,312 @@ +/** @file + * Wrapper for Boehm GC. + */ +/* Authors: + * MenTaLguY + * + * Copyright (C) 2004 MenTaLguY + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "inkgc/gc-core.h" +#include +#include +#include +#include +#include +#include +#include + +namespace Inkscape { +namespace GC { + +namespace { + +void display_warning(char *msg, GC_word arg) { + g_warning(msg, arg); +} + +void do_init() { + GC_no_dls = 1; + GC_all_interior_pointers = 1; + GC_finalize_on_demand = 0; + + GC_INIT(); + + GC_set_warn_proc(&display_warning); +} + +void *debug_malloc(std::size_t size) { + return GC_debug_malloc(size, GC_EXTRAS); +} + +void *debug_malloc_atomic(std::size_t size) { + return GC_debug_malloc_atomic(size, GC_EXTRAS); +} + +void *debug_malloc_uncollectable(std::size_t size) { + return GC_debug_malloc_uncollectable(size, GC_EXTRAS); +} + +void *debug_malloc_atomic_uncollectable(std::size_t size) { + return GC_debug_malloc_uncollectable(size, GC_EXTRAS); +} + +std::ptrdiff_t compute_debug_base_fixup() { + char *base=reinterpret_cast(GC_debug_malloc(1, GC_EXTRAS)); + char *real_base=reinterpret_cast(GC_base(base)); + GC_debug_free(base); + return base - real_base; +} + +inline std::ptrdiff_t const &debug_base_fixup() { + static std::ptrdiff_t fixup=compute_debug_base_fixup(); + return fixup; +} + +void *debug_base(void *ptr) { + char *base=reinterpret_cast(GC_base(ptr)); + return base + debug_base_fixup(); +} + +int debug_general_register_disappearing_link(void **p_ptr, void const *base) { + char const *real_base = reinterpret_cast(base) - debug_base_fixup(); +#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) + return GC_general_register_disappearing_link(p_ptr, real_base); +#else // compatibility with older Boehm GC versions + return GC_general_register_disappearing_link(p_ptr, const_cast(real_base)); +#endif +} + +void dummy_do_init() {} + +void *dummy_base(void *) { return NULL; } + +void dummy_register_finalizer(void *, CleanupFunc, void *, + CleanupFunc *old_func, void **old_data) +{ + if (old_func) { + *old_func = NULL; + } + if (old_data) { + *old_data = NULL; + } +} + +int dummy_general_register_disappearing_link(void **, void const *) { return false; } + +int dummy_unregister_disappearing_link(void **/*link*/) { return false; } + +std::size_t dummy_get_heap_size() { return 0; } + +std::size_t dummy_get_free_bytes() { return 0; } + +void dummy_gcollect() {} + +void dummy_enable() {} + +void dummy_disable() {} + +Ops enabled_ops = { + &do_init, + &GC_malloc, + &GC_malloc_atomic, + &GC_malloc_uncollectable, + &GC_malloc_atomic_uncollectable, + &GC_base, + &GC_register_finalizer_ignore_self, +#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) + &GC_general_register_disappearing_link, +#else // compatibility with older Boehm GC versions + (int (*)(void**, const void*))(&GC_general_register_disappearing_link), +#endif + &GC_unregister_disappearing_link, + &GC_get_heap_size, + &GC_get_free_bytes, + &GC_gcollect, + &GC_enable, + &GC_disable, + &GC_free +}; + +Ops debug_ops = { + &do_init, + &debug_malloc, + &debug_malloc_atomic, + &debug_malloc_uncollectable, + &debug_malloc_atomic_uncollectable, + &debug_base, + &GC_debug_register_finalizer_ignore_self, + &debug_general_register_disappearing_link, + &GC_unregister_disappearing_link, + &GC_get_heap_size, + &GC_get_free_bytes, + &GC_gcollect, + &GC_enable, + &GC_disable, + &GC_debug_free +}; + +Ops disabled_ops = { + &dummy_do_init, + &std::malloc, + &std::malloc, + &std::malloc, + &std::malloc, + &dummy_base, + &dummy_register_finalizer, + &dummy_general_register_disappearing_link, + &dummy_unregister_disappearing_link, + &dummy_get_heap_size, + &dummy_get_free_bytes, + &dummy_gcollect, + &dummy_enable, + &dummy_disable, + &std::free +}; + +class InvalidGCModeError : public std::runtime_error { +public: + InvalidGCModeError(const char *mode) + : runtime_error(std::string("Unknown GC mode \"") + mode + "\"") + {} +}; + +Ops const &get_ops() throw (InvalidGCModeError) { + char *mode_string=std::getenv("_INKSCAPE_GC"); + if (mode_string) { + if (!std::strcmp(mode_string, "enable")) { + return enabled_ops; + } else if (!std::strcmp(mode_string, "debug")) { + return debug_ops; + } else if (!std::strcmp(mode_string, "disable")) { + return disabled_ops; + } else { + throw InvalidGCModeError(mode_string); + } + } else { + return enabled_ops; + } +} + +void die_because_not_initialized() { + g_error("Attempt to use GC allocator before call to Inkscape::GC::init()"); +} + +void *stub_malloc(std::size_t) { + die_because_not_initialized(); + return NULL; +} + +void *stub_base(void *) { + die_because_not_initialized(); + return NULL; +} + +void stub_register_finalizer_ignore_self(void *, CleanupFunc, void *, + CleanupFunc *, void **) +{ + die_because_not_initialized(); +} + +int stub_general_register_disappearing_link(void **, void const *) { + die_because_not_initialized(); + return 0; +} + +int stub_unregister_disappearing_link(void **) { + die_because_not_initialized(); + return 0; +} + +std::size_t stub_get_heap_size() { + die_because_not_initialized(); + return 0; +} + +std::size_t stub_get_free_bytes() { + die_because_not_initialized(); + return 0; +} + +void stub_gcollect() { + die_because_not_initialized(); +} + +void stub_enable() { + die_because_not_initialized(); +} + +void stub_disable() { + die_because_not_initialized(); +} + +void stub_free(void *) { + die_because_not_initialized(); +} + +} + +Ops Core::_ops = { + NULL, + &stub_malloc, + &stub_malloc, + &stub_malloc, + &stub_malloc, + &stub_base, + &stub_register_finalizer_ignore_self, + &stub_general_register_disappearing_link, + &stub_unregister_disappearing_link, + &stub_get_heap_size, + &stub_get_free_bytes, + &stub_gcollect, + &stub_enable, + &stub_disable, + &stub_free +}; + +void Core::init() { + try { + _ops = get_ops(); + } catch (InvalidGCModeError &e) { + g_warning("%s; enabling normal collection", e.what()); + _ops = enabled_ops; + } + + _ops.do_init(); +} + + +namespace { + +bool collection_requested=false; +bool collection_task() { + Core::gcollect(); + Core::gcollect(); + collection_requested=false; + return false; +} + +} + +void request_early_collection() { + if (!collection_requested) { + collection_requested=true; + Glib::signal_idle().connect(sigc::ptr_fun(&collection_task)); + } +} + +} +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/inkview.cpp b/src/inkview.cpp index 5e96b56c5..2c667237e 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -47,7 +47,7 @@ #include #include -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" #include "preferences.h" #include diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index ca8ab3475..3bbc831d5 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -11,7 +11,7 @@ #include #include #include -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "gc-finalized.h" #include "document.h" #include "desktop.h" diff --git a/src/layer-manager.h b/src/layer-manager.h index 8e108635d..a304929c6 100644 --- a/src/layer-manager.h +++ b/src/layer-manager.h @@ -15,7 +15,7 @@ #include "document-subset.h" #include "gc-finalized.h" -#include "libgc/gc-soft-ptr.h" +#include "inkgc/gc-soft-ptr.h" class SPDesktop; class SPDocument; diff --git a/src/libgc/CMakeLists.txt b/src/libgc/CMakeLists.txt deleted file mode 100644 index 22dd464e1..000000000 --- a/src/libgc/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ - -set(libgc_SRC - gc.cpp - - # ------- - # Headers - gc-alloc.h - gc-anchored.h - gc-core.h - gc-managed.h - gc-soft-ptr.h -) - -add_inkscape_lib(gc_LIB "${libgc_SRC}") -# add_inkscape_source("${libgc_SRC}") diff --git a/src/libgc/Makefile_insert b/src/libgc/Makefile_insert deleted file mode 100644 index e899a5b4a..000000000 --- a/src/libgc/Makefile_insert +++ /dev/null @@ -1,13 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -libgc/all: libgc/libgc.a - -libgc/clean: - rm -f libgc/libgc.a $(libgc_libgc_a_OBJECTS) - -libgc_libgc_a_SOURCES = \ - libgc/gc.cpp \ - libgc/gc-alloc.h \ - libgc/gc-core.h \ - libgc/gc-managed.h \ - libgc/gc-soft-ptr.h diff --git a/src/libgc/gc-alloc.h b/src/libgc/gc-alloc.h deleted file mode 100644 index 765b28b19..000000000 --- a/src/libgc/gc-alloc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Inkscape::GC::Alloc - GC-aware STL allocator - * - * Copyright 2004 MenTaLguY - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * See the file COPYING for details. - * - */ - -#ifndef SEEN_INKSCAPE_GC_ALLOC_H -#define SEEN_INKSCAPE_GC_ALLOC_H - -#include -#include -#include "libgc/gc-core.h" - -namespace Inkscape { - -namespace GC { - -template -class Alloc { -public: - typedef T value_type; - typedef T *pointer; - typedef T const *const_pointer; - typedef T &reference; - typedef T const &const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - template - struct rebind { typedef Alloc other; }; - - Alloc() {} - template Alloc(Alloc const &) {} - - pointer address(reference r) { return &r; } - const_pointer address(const_reference r) { return &r; } - - size_type max_size() const { - return std::numeric_limits::max() / sizeof(T); - } - - pointer allocate(size_type count, void const * =NULL) { - return static_cast(::operator new(count * sizeof(T), SCANNED, collect)); - } - - void construct(pointer p, const_reference value) { - new (static_cast(p)) T(value); - } - void destroy(pointer p) { p->~T(); } - - void deallocate(pointer p, size_type) { ::operator delete(p, GC); } -}; - -// allocators with the same collection policy are interchangable - -template -bool operator==(Alloc const &, Alloc const &) { - return collect1 == collect2; -} - -template -bool operator!=(Alloc const &, Alloc const &) { - return collect1 != collect2; -} - -} - -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libgc/gc-core.h b/src/libgc/gc-core.h deleted file mode 100644 index d9d0bf4ff..000000000 --- a/src/libgc/gc-core.h +++ /dev/null @@ -1,213 +0,0 @@ -/** @file - * @brief Wrapper for Boehm GC - */ -/* Authors: - * MenTaLguY - * - * Copyright (C) 2004 MenTaLguY - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef SEEN_INKSCAPE_GC_CORE_H -#define SEEN_INKSCAPE_GC_CORE_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#ifdef HAVE_GC_GC_H -# include -#else -# include -#endif - -namespace Inkscape { -namespace GC { - -enum ScanPolicy { - SCANNED, - ATOMIC -}; - -enum CollectionPolicy { - AUTO, - MANUAL -}; - -enum Delete { - GC -}; - -typedef void (*CleanupFunc)(void *mem, void *data); - -struct Ops { - void (*do_init)(); - void *(*malloc)(std::size_t size); - void *(*malloc_atomic)(std::size_t size); - void *(*malloc_uncollectable)(std::size_t size); - void *(*malloc_atomic_uncollectable)(std::size_t size); - void *(*base)(void *ptr); - void (*register_finalizer_ignore_self)(void *base, - CleanupFunc func, void *data, - CleanupFunc *old_func, - void **old_data); - int (*general_register_disappearing_link)(void **p_ptr, - void const *base); - int (*unregister_disappearing_link)(void **p_ptr); - std::size_t (*get_heap_size)(); - std::size_t (*get_free_bytes)(); - void (*gcollect)(); - void (*enable)(); - void (*disable)(); - void (*free)(void *ptr); -}; - -struct Core { -public: - static void init(); - static inline void *malloc(std::size_t size) { - return _ops.malloc(size); - } - static inline void *malloc_atomic(std::size_t size) { - return _ops.malloc_atomic(size); - } - static inline void *malloc_uncollectable(std::size_t size) { - return _ops.malloc_uncollectable(size); - } - static inline void *malloc_atomic_uncollectable(std::size_t size) { - return _ops.malloc_atomic_uncollectable(size); - } - static inline void *base(void *ptr) { - return _ops.base(ptr); - } - static inline void register_finalizer_ignore_self(void *base, - CleanupFunc func, - void *data, - CleanupFunc *old_func, - void **old_data) - { - return _ops.register_finalizer_ignore_self(base, func, data, - old_func, old_data); - } - static inline int general_register_disappearing_link(void **p_ptr, - void *base) - { - return _ops.general_register_disappearing_link(p_ptr, base); - } - static inline int unregister_disappearing_link(void **p_ptr) { - return _ops.unregister_disappearing_link(p_ptr); - } - static inline std::size_t get_heap_size() { - return _ops.get_heap_size(); - } - static inline std::size_t get_free_bytes() { - return _ops.get_free_bytes(); - } - static inline void gcollect() { - _ops.gcollect(); - } - static inline void enable() { - _ops.enable(); - } - static inline void disable() { - _ops.disable(); - } - static inline void free(void *ptr) { - return _ops.free(ptr); - } -private: - static Ops _ops; -}; - -inline void init() { - Core::init(); -} - -void request_early_collection(); - -} -} - -inline void *operator new(std::size_t size, - Inkscape::GC::ScanPolicy scan, - Inkscape::GC::CollectionPolicy collect, - Inkscape::GC::CleanupFunc cleanup=NULL, - void *data=NULL) -throw(std::bad_alloc) -{ - using namespace Inkscape::GC; - - void *mem; - if ( collect == AUTO ) { - if ( scan == SCANNED ) { - mem = Core::malloc(size); - } else { - mem = Core::malloc_atomic(size); - } - } else { - if ( scan == SCANNED ) { - mem = Core::malloc_uncollectable(size); - } else { - mem = Core::malloc_atomic_uncollectable(size); - } - } - if (!mem) { - throw std::bad_alloc(); - } - if (cleanup) { - Core::register_finalizer_ignore_self(mem, cleanup, data, NULL, NULL); - } - return mem; -} - -inline void *operator new(std::size_t size, - Inkscape::GC::ScanPolicy scan, - Inkscape::GC::CleanupFunc cleanup=NULL, - void *data=NULL) -throw(std::bad_alloc) -{ - return operator new(size, scan, Inkscape::GC::AUTO, cleanup, data); -} - -inline void *operator new[](std::size_t size, - Inkscape::GC::ScanPolicy scan, - Inkscape::GC::CollectionPolicy collect, - Inkscape::GC::CleanupFunc cleanup=NULL, - void *data=NULL) -throw(std::bad_alloc) -{ - return operator new(size, scan, collect, cleanup, data); -} - -inline void *operator new[](std::size_t size, - Inkscape::GC::ScanPolicy scan, - Inkscape::GC::CleanupFunc cleanup=NULL, - void *data=NULL) -throw(std::bad_alloc) -{ - return operator new[](size, scan, Inkscape::GC::AUTO, cleanup, data); -} - -inline void operator delete(void *mem, Inkscape::GC::Delete) { - Inkscape::GC::Core::free(mem); -} - -inline void operator delete[](void *mem, Inkscape::GC::Delete) { - operator delete(mem, Inkscape::GC::GC); -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libgc/gc-managed.h b/src/libgc/gc-managed.h deleted file mode 100644 index 9f6d9c2f6..000000000 --- a/src/libgc/gc-managed.h +++ /dev/null @@ -1,63 +0,0 @@ -/** @file - * @brief Base class for GC-managed objects - */ -/* Copyright 2004 MenTaLguY - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * See the file COPYING for details. - */ - -#ifndef SEEN_INKSCAPE_GC_MANAGED_H -#define SEEN_INKSCAPE_GC_MANAGED_H - -#include "libgc/gc-core.h" - -namespace Inkscape { - -namespace GC { - -/** @brief A base class for objects for whom the normal new and delete - * operators should use the garbage-collected allocator - */ -template -class Managed { -public: - void *operator new(std::size_t size, - ScanPolicy scan=default_scan, - CollectionPolicy collect=default_collect) - throw (std::bad_alloc) - { - return ::operator new(size, scan, collect); - } - - void *operator new[](std::size_t size, - ScanPolicy scan=default_scan, - CollectionPolicy collect=default_collect) - throw (std::bad_alloc) - { - return ::operator new[](size, scan, collect); - } - - void operator delete(void *p) { return ::operator delete(p, GC); } -}; - -} - -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libgc/gc-soft-ptr.h b/src/libgc/gc-soft-ptr.h deleted file mode 100644 index bb26ebb04..000000000 --- a/src/libgc/gc-soft-ptr.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2006 MenTaLguY - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * See the file COPYING for details. - * - */ - -#ifndef SEEN_INKSCAPE_GC_SOFT_PTR_H -#define SEEN_INKSCAPE_GC_SOFT_PTR_H - -#include "libgc/gc-core.h" - -namespace Inkscape { - -namespace GC { - -/** - * A class for pointers which can be automatically cleared to break - * finalization cycles. - */ -template -class soft_ptr { -public: - soft_ptr(T *pointer=NULL) : _pointer(pointer) { - _register(); - } - - operator T *() const { return static_cast(_pointer); } - T &operator*() const { return *static_cast(_pointer); } - T *operator->() const { return static_cast(_pointer); } - T &operator[](int i) const { return static_cast(_pointer)[i]; } - - soft_ptr &operator=(T *pointer) { - _pointer = pointer; - return *this; - } - - // default copy - -private: - void _register() { - void *base=Core::base(this); - if (base) { - Core::general_register_disappearing_link(&_pointer, base); - } - } - - void *_pointer; -}; - -} - -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libgc/gc.cpp b/src/libgc/gc.cpp deleted file mode 100644 index 044fc6065..000000000 --- a/src/libgc/gc.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/** @file - * Wrapper for Boehm GC. - */ -/* Authors: - * MenTaLguY - * - * Copyright (C) 2004 MenTaLguY - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "libgc/gc-core.h" -#include -#include -#include -#include -#include -#include -#include - -namespace Inkscape { -namespace GC { - -namespace { - -void display_warning(char *msg, GC_word arg) { - g_warning(msg, arg); -} - -void do_init() { - GC_no_dls = 1; - GC_all_interior_pointers = 1; - GC_finalize_on_demand = 0; - - GC_INIT(); - - GC_set_warn_proc(&display_warning); -} - -void *debug_malloc(std::size_t size) { - return GC_debug_malloc(size, GC_EXTRAS); -} - -void *debug_malloc_atomic(std::size_t size) { - return GC_debug_malloc_atomic(size, GC_EXTRAS); -} - -void *debug_malloc_uncollectable(std::size_t size) { - return GC_debug_malloc_uncollectable(size, GC_EXTRAS); -} - -void *debug_malloc_atomic_uncollectable(std::size_t size) { - return GC_debug_malloc_uncollectable(size, GC_EXTRAS); -} - -std::ptrdiff_t compute_debug_base_fixup() { - char *base=reinterpret_cast(GC_debug_malloc(1, GC_EXTRAS)); - char *real_base=reinterpret_cast(GC_base(base)); - GC_debug_free(base); - return base - real_base; -} - -inline std::ptrdiff_t const &debug_base_fixup() { - static std::ptrdiff_t fixup=compute_debug_base_fixup(); - return fixup; -} - -void *debug_base(void *ptr) { - char *base=reinterpret_cast(GC_base(ptr)); - return base + debug_base_fixup(); -} - -int debug_general_register_disappearing_link(void **p_ptr, void const *base) { - char const *real_base = reinterpret_cast(base) - debug_base_fixup(); -#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) - return GC_general_register_disappearing_link(p_ptr, real_base); -#else // compatibility with older Boehm GC versions - return GC_general_register_disappearing_link(p_ptr, const_cast(real_base)); -#endif -} - -void dummy_do_init() {} - -void *dummy_base(void *) { return NULL; } - -void dummy_register_finalizer(void *, CleanupFunc, void *, - CleanupFunc *old_func, void **old_data) -{ - if (old_func) { - *old_func = NULL; - } - if (old_data) { - *old_data = NULL; - } -} - -int dummy_general_register_disappearing_link(void **, void const *) { return false; } - -int dummy_unregister_disappearing_link(void **/*link*/) { return false; } - -std::size_t dummy_get_heap_size() { return 0; } - -std::size_t dummy_get_free_bytes() { return 0; } - -void dummy_gcollect() {} - -void dummy_enable() {} - -void dummy_disable() {} - -Ops enabled_ops = { - &do_init, - &GC_malloc, - &GC_malloc_atomic, - &GC_malloc_uncollectable, - &GC_malloc_atomic_uncollectable, - &GC_base, - &GC_register_finalizer_ignore_self, -#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) - &GC_general_register_disappearing_link, -#else // compatibility with older Boehm GC versions - (int (*)(void**, const void*))(&GC_general_register_disappearing_link), -#endif - &GC_unregister_disappearing_link, - &GC_get_heap_size, - &GC_get_free_bytes, - &GC_gcollect, - &GC_enable, - &GC_disable, - &GC_free -}; - -Ops debug_ops = { - &do_init, - &debug_malloc, - &debug_malloc_atomic, - &debug_malloc_uncollectable, - &debug_malloc_atomic_uncollectable, - &debug_base, - &GC_debug_register_finalizer_ignore_self, - &debug_general_register_disappearing_link, - &GC_unregister_disappearing_link, - &GC_get_heap_size, - &GC_get_free_bytes, - &GC_gcollect, - &GC_enable, - &GC_disable, - &GC_debug_free -}; - -Ops disabled_ops = { - &dummy_do_init, - &std::malloc, - &std::malloc, - &std::malloc, - &std::malloc, - &dummy_base, - &dummy_register_finalizer, - &dummy_general_register_disappearing_link, - &dummy_unregister_disappearing_link, - &dummy_get_heap_size, - &dummy_get_free_bytes, - &dummy_gcollect, - &dummy_enable, - &dummy_disable, - &std::free -}; - -class InvalidGCModeError : public std::runtime_error { -public: - InvalidGCModeError(const char *mode) - : runtime_error(std::string("Unknown GC mode \"") + mode + "\"") - {} -}; - -Ops const &get_ops() throw (InvalidGCModeError) { - char *mode_string=std::getenv("_INKSCAPE_GC"); - if (mode_string) { - if (!std::strcmp(mode_string, "enable")) { - return enabled_ops; - } else if (!std::strcmp(mode_string, "debug")) { - return debug_ops; - } else if (!std::strcmp(mode_string, "disable")) { - return disabled_ops; - } else { - throw InvalidGCModeError(mode_string); - } - } else { - return enabled_ops; - } -} - -void die_because_not_initialized() { - g_error("Attempt to use GC allocator before call to Inkscape::GC::init()"); -} - -void *stub_malloc(std::size_t) { - die_because_not_initialized(); - return NULL; -} - -void *stub_base(void *) { - die_because_not_initialized(); - return NULL; -} - -void stub_register_finalizer_ignore_self(void *, CleanupFunc, void *, - CleanupFunc *, void **) -{ - die_because_not_initialized(); -} - -int stub_general_register_disappearing_link(void **, void const *) { - die_because_not_initialized(); - return 0; -} - -int stub_unregister_disappearing_link(void **) { - die_because_not_initialized(); - return 0; -} - -std::size_t stub_get_heap_size() { - die_because_not_initialized(); - return 0; -} - -std::size_t stub_get_free_bytes() { - die_because_not_initialized(); - return 0; -} - -void stub_gcollect() { - die_because_not_initialized(); -} - -void stub_enable() { - die_because_not_initialized(); -} - -void stub_disable() { - die_because_not_initialized(); -} - -void stub_free(void *) { - die_because_not_initialized(); -} - -} - -Ops Core::_ops = { - NULL, - &stub_malloc, - &stub_malloc, - &stub_malloc, - &stub_malloc, - &stub_base, - &stub_register_finalizer_ignore_self, - &stub_general_register_disappearing_link, - &stub_unregister_disappearing_link, - &stub_get_heap_size, - &stub_get_free_bytes, - &stub_gcollect, - &stub_enable, - &stub_disable, - &stub_free -}; - -void Core::init() { - try { - _ops = get_ops(); - } catch (InvalidGCModeError &e) { - g_warning("%s; enabling normal collection", e.what()); - _ops = enabled_ops; - } - - _ops.do_init(); -} - - -namespace { - -bool collection_requested=false; -bool collection_task() { - Core::gcollect(); - Core::gcollect(); - collection_requested=false; - return false; -} - -} - -void request_early_collection() { - if (!collection_requested) { - collection_requested=true; - Glib::signal_idle().connect(sigc::ptr_fun(&collection_task)); - } -} - -} -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/main.cpp b/src/main.cpp index 5dd8b7cff..415118407 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,7 +52,7 @@ #include #include -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" #ifdef AND #undef AND diff --git a/src/message-stack.h b/src/message-stack.h index e8d2aa202..ed0315cf5 100644 --- a/src/message-stack.h +++ b/src/message-stack.h @@ -22,7 +22,7 @@ #include #include -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" #include "message.h" diff --git a/src/selection.h b/src/selection.h index e8c85241e..19e2ae1fd 100644 --- a/src/selection.h +++ b/src/selection.h @@ -19,10 +19,10 @@ #include #include -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" -#include "libgc/gc-soft-ptr.h" +#include "inkgc/gc-soft-ptr.h" #include "sp-item.h" diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index f1c19d18e..f1d0ff576 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -32,7 +32,7 @@ #include #include #include // for g_file_set_contents etc., used in _onGet and paste -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" #include "xml/repr.h" #include "inkscape.h" #include "io/stringstream.h" diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index ca46403a0..4e4b0278a 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -19,7 +19,7 @@ #include "filedialogimpl-gtkmm.h" #include "filedialog.h" -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" #include "ui/dialog-events.h" #include "extension/output.h" #include "preferences.h" diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h index 1d3640646..8c3b6bad6 100644 --- a/src/ui/dialog/filedialogimpl-win32.h +++ b/src/ui/dialog/filedialogimpl-win32.h @@ -24,7 +24,7 @@ #include "filedialogimpl-gtkmm.h" -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" // define WINVER high enough so we get the correct OPENFILENAMEW size #ifndef WINVER #define WINVER 0x0500 diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp index e5fb6b563..c0bc884fa 100644 --- a/src/ui/dialog/memory.cpp +++ b/src/ui/dialog/memory.cpp @@ -20,7 +20,7 @@ #include #include -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" #include "debug/heap.h" #include "verbs.h" diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index e8778d14c..a1c7d41bd 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -26,7 +26,7 @@ #include "path-prefix.h" #include "filedialogimpl-gtkmm.h" #include "ui/interface.h" -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" #include "ui/dialog-events.h" #include "io/sys.h" #include "preferences.h" diff --git a/src/ui/view/view.h b/src/ui/view/view.h index 8edff8709..21a5d0dfc 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -15,7 +15,7 @@ #include #include #include "message.h" -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" #include <2geom/forward.h> diff --git a/src/undo-stack-observer.h b/src/undo-stack-observer.h index a2bcb3a23..dadb4764e 100644 --- a/src/undo-stack-observer.h +++ b/src/undo-stack-observer.h @@ -10,7 +10,7 @@ #ifndef SEEN_UNDO_COMMIT_OBSERVER_H #define SEEN_UNDO_COMMIT_OBSERVER_H -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" namespace Inkscape { diff --git a/src/util/list.h b/src/util/list.h index 05a35320d..563b6091c 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -12,7 +12,7 @@ #include #include -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "util/reference.h" namespace Inkscape { diff --git a/src/util/share.h b/src/util/share.h index 46685c593..8f1e7045a 100644 --- a/src/util/share.h +++ b/src/util/share.h @@ -12,7 +12,7 @@ #ifndef SEEN_INKSCAPE_UTIL_SHARE_H #define SEEN_INKSCAPE_UTIL_SHARE_H -#include "libgc/gc-core.h" +#include "inkgc/gc-core.h" #include #include diff --git a/src/xml/attribute-record.h b/src/xml/attribute-record.h index 70691005e..7caeab6b6 100644 --- a/src/xml/attribute-record.h +++ b/src/xml/attribute-record.h @@ -6,7 +6,7 @@ #define SEEN_XML_SP_REPR_ATTR_H #include -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "util/share.h" #define SP_REPR_ATTRIBUTE_KEY(a) g_quark_to_string((a)->key) diff --git a/src/xml/composite-node-observer.h b/src/xml/composite-node-observer.h index 968fe20dd..6e93a57da 100644 --- a/src/xml/composite-node-observer.h +++ b/src/xml/composite-node-observer.h @@ -15,7 +15,7 @@ #ifndef SEEN_INKSCAPE_XML_COMPOSITE_NODE_OBSERVER_H #define SEEN_INKSCAPE_XML_COMPOSITE_NODE_OBSERVER_H -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "xml/node-observer.h" #include "util/list-container.h" diff --git a/src/xml/event.h b/src/xml/event.h index bc63ca504..73e68daeb 100644 --- a/src/xml/event.h +++ b/src/xml/event.h @@ -24,7 +24,7 @@ typedef unsigned int GQuark; #include #include "util/share.h" #include "util/forward-pointer-iterator.h" -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "xml/node.h" namespace Inkscape { diff --git a/src/xml/log-builder.h b/src/xml/log-builder.h index e27a5e5ac..e94dd1daa 100644 --- a/src/xml/log-builder.h +++ b/src/xml/log-builder.h @@ -14,7 +14,7 @@ #ifndef SEEN_INKSCAPE_XML_LOG_BUILDER_H #define SEEN_INKSCAPE_XML_LOG_BUILDER_H -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "xml/node-observer.h" namespace Inkscape { diff --git a/src/xml/subtree.h b/src/xml/subtree.h index 7b154bd65..bc6ae913a 100644 --- a/src/xml/subtree.h +++ b/src/xml/subtree.h @@ -15,7 +15,7 @@ #ifndef SEEN_INKSCAPE_XML_SUBTREE_H #define SEEN_INKSCAPE_XML_SUBTREE_H -#include "libgc/gc-managed.h" +#include "inkgc/gc-managed.h" #include "xml/composite-node-observer.h" namespace Inkscape { -- cgit v1.2.3