summaryrefslogtreecommitdiffstats
path: root/src/libnr
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-08-28 19:18:21 +0000
committerKrzysztof Kosinski <tweenk.pl@gmail.com>2011-08-28 19:18:21 +0000
commitbe7df18d6aef42dd657426b6a9d30834e5f54ca6 (patch)
tree9bc96a469b9cf6595004d1733d1b7104eb764092 /src/libnr
parentRemove last forward declaration of NRPixBlock (diff)
downloadinkscape-be7df18d6aef42dd657426b6a9d30834e5f54ca6.tar.gz
inkscape-be7df18d6aef42dd657426b6a9d30834e5f54ca6.zip
Remove nr-object.h and nr-macros.h
(bzr r10582.1.10)
Diffstat (limited to 'src/libnr')
-rw-r--r--src/libnr/Makefile_insert3
-rw-r--r--src/libnr/nr-macros.h61
-rw-r--r--src/libnr/nr-object.cpp318
-rw-r--r--src/libnr/nr-object.h157
4 files changed, 0 insertions, 539 deletions
diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert
index c4b6daa12..487f34be1 100644
--- a/src/libnr/Makefile_insert
+++ b/src/libnr/Makefile_insert
@@ -1,8 +1,5 @@
## Makefile.am fragment sourced by src/Makefile.am.
ink_common_sources += \
- libnr/nr-macros.h \
- libnr/nr-object.cpp \
- libnr/nr-object.h \
libnr/nr-point-fns.cpp \
libnr/nr-point-fns.h
diff --git a/src/libnr/nr-macros.h b/src/libnr/nr-macros.h
deleted file mode 100644
index 37a3675e6..000000000
--- a/src/libnr/nr-macros.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef __NR_MACROS_H__
-#define __NR_MACROS_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <math.h>
-
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <assert.h>
-
-#ifndef TRUE
-#define TRUE (!0)
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef MAX
-#define MAX(a,b) (((a) < (b)) ? (b) : (a))
-#endif
-#ifndef MIN
-#define MIN(a,b) (((a) > (b)) ? (b) : (a))
-#endif
-
-/** Returns v bounded to within [a, b]. If v is NaN then returns a.
- *
- * \pre \a a \<= \a b.
- */
-#define NR_CLAMP(v,a,b) \
- (assert (a <= b), \
- ((v) >= (a)) \
- ? (((v) > (b)) \
- ? (b) \
- : (v)) \
- : (a))
-
-#undef CLAMP /* get rid of glib's version, which doesn't handle NaN correctly */
-#define CLAMP(v,a,b) NR_CLAMP(v,a,b)
-
-#define NR_DF_TEST_CLOSE(a,b,e) (fabs ((a) - (b)) <= (e))
-
-// Todo: move these into nr-matrix.h
-#define NR_RECT_DFLS_TEST_EMPTY(a) (((a)->x0 >= (a)->x1) || ((a)->y0 >= (a)->y1))
-#define NR_RECT_DFLS_TEST_EMPTY_REF(a) (((a).x0 >= (a).x1) || ((a).y0 >= (a).y1))
-#define NR_RECT_DFLS_TEST_INTERSECT(a,b) (((a)->x0 < (b)->x1) && ((a)->x1 > (b)->x0) && ((a)->y0 < (b)->y1) && ((a)->y1 > (b)->y0))
-#define NR_RECT_DFLS_TEST_INTERSECT_REF(a,b) (((a).x0 < (b).x1) && ((a).x1 > (b).x0) && ((a).y0 < (b).y1) && ((a).y1 > (b).y0))
-#define NR_RECT_DF_POINT_DF_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1))
-#define NR_RECT_LS_POINT_LS_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1))
-#define NR_RECT_LS_TEST_INSIDE(r,x,y) ((x >= (r)->x0) && (x < (r)->x1) && (y >= (r)->y0) && (y < (r)->y1))
-
-#define NR_MATRIX_D_FROM_DOUBLE(d) ((NR::Matrix *) &(d)[0])
-
-#endif
diff --git a/src/libnr/nr-object.cpp b/src/libnr/nr-object.cpp
deleted file mode 100644
index d92052d10..000000000
--- a/src/libnr/nr-object.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-#define __NR_OBJECT_C__
-
-/*
- * RGBA display list system for inkscape
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * MenTaLguY <mental@rydia.net>
- *
- * This code is in public domain
- */
-
-#include <string.h>
-#include <stdio.h>
-
-#include <typeinfo>
-
-#include <glib/gmem.h>
-#include <libnr/nr-macros.h>
-
-#include "nr-object.h"
-#include "debug/event-tracker.h"
-#include "debug/simple-event.h"
-#include "util/share.h"
-#include "util/format.h"
-
-unsigned int nr_emit_fail_warning(const gchar *file, unsigned int line, const gchar *method, const gchar *expr)
-{
- fprintf (stderr, "File %s line %d (%s): Assertion %s failed\n", file, line, method, expr);
- return 1;
-}
-
-/* NRObject */
-
-static NRObjectClass **classes = NULL;
-static unsigned int classes_len = 0;
-static unsigned int classes_size = 0;
-
-NRType nr_type_is_a(NRType type, NRType test)
-{
- nr_return_val_if_fail(type < classes_len, FALSE);
- nr_return_val_if_fail(test < classes_len, FALSE);
-
- NRObjectClass *c = classes[type];
-
- while (c) {
- if (c->type == test) {
- return TRUE;
- }
- c = c->parent;
- }
-
- return FALSE;
-}
-
-void const *nr_object_check_instance_cast(void const *ip, NRType tc)
-{
- nr_return_val_if_fail(ip != NULL, NULL);
- nr_return_val_if_fail(nr_type_is_a(((NRObject const *) ip)->klass->type, tc), ip);
- return ip;
-}
-
-unsigned int nr_object_check_instance_type(void const *ip, NRType tc)
-{
- if (ip == NULL) {
- return FALSE;
- }
-
- return nr_type_is_a(((NRObject const *) ip)->klass->type, tc);
-}
-
-NRType nr_object_register_type(NRType parent,
- gchar const *name,
- unsigned int csize,
- unsigned int isize,
- void (* cinit) (NRObjectClass *),
- void (* iinit) (NRObject *))
-{
- if (classes_len >= classes_size) {
- classes_size += 32;
- classes = g_renew (NRObjectClass *, classes, classes_size);
- if (classes_len == 0) {
- classes[0] = NULL;
- classes_len = 1;
- }
- }
-
- NRType const type = classes_len;
- classes_len += 1;
-
- classes[type] = (NRObjectClass*) new char[csize];
- NRObjectClass *c = classes[type];
-
- /* FIXME: is this necessary? */
- memset(c, 0, csize);
-
- if (classes[parent]) {
- memcpy(c, classes[parent], classes[parent]->csize);
- }
-
- c->type = type;
- c->parent = classes[parent];
- c->name = strdup(name);
- c->csize = csize;
- c->isize = isize;
- c->cinit = cinit;
- c->iinit = iinit;
-
- c->cinit(c);
-
- return type;
-}
-
-static void nr_object_class_init (NRObjectClass *klass);
-static void nr_object_init (NRObject *object);
-static void nr_object_finalize (NRObject *object);
-
-NRType nr_object_get_type()
-{
- static NRType type = 0;
-
- if (!type) {
- type = nr_object_register_type (0,
- "NRObject",
- sizeof (NRObjectClass),
- sizeof (NRObject),
- (void (*) (NRObjectClass *)) nr_object_class_init,
- (void (*) (NRObject *)) nr_object_init);
- }
-
- return type;
-}
-
-static void nr_object_class_init(NRObjectClass *c)
-{
- c->finalize = nr_object_finalize;
- c->cpp_ctor = NRObject::invoke_ctor<NRObject>;
-}
-
-static void nr_object_init (NRObject */*object*/)
-{
-}
-
-static void nr_object_finalize (NRObject */*object*/)
-{
-}
-
-/* Dynamic lifecycle */
-
-static void nr_class_tree_object_invoke_init(NRObjectClass *c, NRObject *object)
-{
- if (c->parent) {
- nr_class_tree_object_invoke_init(c->parent, object);
- }
- c->iinit (object);
-}
-
-namespace {
-
-namespace Debug = Inkscape::Debug;
-namespace Util = Inkscape::Util;
-
-typedef Debug::SimpleEvent<Debug::Event::FINALIZERS> BaseFinalizerEvent;
-
-class FinalizerEvent : public BaseFinalizerEvent {
-public:
- FinalizerEvent(NRObject *object)
- : BaseFinalizerEvent(Util::share_static_string("nr-object-finalizer"))
- {
- _addProperty("object", Util::format("%p", object));
- _addProperty("class", Util::share_static_string(typeid(*object).name()));
- }
-};
-
-void finalize_object(void *base, void *)
-{
- NRObject *object = reinterpret_cast<NRObject *>(base);
- Debug::EventTracker<FinalizerEvent> tracker(object);
- object->klass->finalize(object);
- object->~NRObject();
-}
-
-}
-
-NRObject *NRObject::alloc(NRType type)
-{
- nr_return_val_if_fail (type < classes_len, NULL);
-
- NRObjectClass *c = classes[type];
-
- if ( c->parent && c->cpp_ctor == c->parent->cpp_ctor ) {
- g_error("Cannot instantiate NRObject class %s which has not registered a C++ constructor\n", c->name);
- }
-
- NRObject *object = reinterpret_cast<NRObject *>(
- ::operator new(c->isize, Inkscape::GC::SCANNED, Inkscape::GC::AUTO,
- &finalize_object, NULL)
- );
- memset(object, 0xf0, c->isize);
-
- c->cpp_ctor(object);
- object->klass = c;
- nr_class_tree_object_invoke_init (c, object);
-
- return object;
-}
-
-/* NRActiveObject */
-
-static void nr_active_object_class_init(NRActiveObjectClass *c);
-static void nr_active_object_init(NRActiveObject *object);
-static void nr_active_object_finalize(NRObject *object);
-
-static NRObjectClass *parent_class;
-
-NRType nr_active_object_get_type()
-{
- static NRType type = 0;
- if (!type) {
- type = nr_object_register_type (NR_TYPE_OBJECT,
- "NRActiveObject",
- sizeof (NRActiveObjectClass),
- sizeof (NRActiveObject),
- (void (*) (NRObjectClass *)) nr_active_object_class_init,
- (void (*) (NRObject *)) nr_active_object_init);
- }
- return type;
-}
-
-static void nr_active_object_class_init(NRActiveObjectClass *c)
-{
- NRObjectClass *object_class = (NRObjectClass *) c;
-
- parent_class = object_class->parent;
-
- object_class->finalize = nr_active_object_finalize;
- object_class->cpp_ctor = NRObject::invoke_ctor<NRActiveObject>;
-}
-
-static void nr_active_object_init(NRActiveObject */*object*/)
-{
-}
-
-static void nr_active_object_finalize(NRObject *object)
-{
- NRActiveObject *aobject = (NRActiveObject *) object;
-
- if (aobject->callbacks) {
- for (unsigned int i = 0; i < aobject->callbacks->length; i++) {
- NRObjectListener *listener = aobject->callbacks->listeners + i;
- if ( listener->vector->dispose ) {
- listener->vector->dispose(object, listener->data);
- }
- }
- g_free (aobject->callbacks);
- }
-
- ((NRObjectClass *) (parent_class))->finalize(object);
-}
-
-void nr_active_object_add_listener(NRActiveObject *object,
- const NRObjectEventVector *vector,
- unsigned int size,
- void *data)
-{
- if (!object->callbacks) {
- object->callbacks = (NRObjectCallbackBlock*)g_malloc(sizeof(NRObjectCallbackBlock));
- object->callbacks->size = 1;
- object->callbacks->length = 0;
- }
-
- if (object->callbacks->length >= object->callbacks->size) {
- int newsize = object->callbacks->size << 1;
- object->callbacks = (NRObjectCallbackBlock *)
- g_realloc(object->callbacks, sizeof(NRObjectCallbackBlock) + (newsize - 1) * sizeof (NRObjectListener));
- object->callbacks->size = newsize;
- }
-
- NRObjectListener *listener = object->callbacks->listeners + object->callbacks->length;
- listener->vector = vector;
- listener->size = size;
- listener->data = data;
- object->callbacks->length += 1;
-}
-
-void nr_active_object_remove_listener_by_data(NRActiveObject *object, void *data)
-{
- if (object->callbacks == NULL) {
- return;
- }
-
- for (unsigned i = 0; i < object->callbacks->length; i++) {
- NRObjectListener *listener = object->callbacks->listeners + i;
- if ( listener->data == data ) {
- object->callbacks->length -= 1;
- if ( object->callbacks->length < 1 ) {
- g_free(object->callbacks);
- object->callbacks = NULL;
- } else if ( object->callbacks->length != i ) {
- *listener = object->callbacks->listeners[object->callbacks->length];
- }
- return;
- }
- }
-}
-
-
-
-/*
- 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/libnr/nr-object.h b/src/libnr/nr-object.h
deleted file mode 100644
index 269130284..000000000
--- a/src/libnr/nr-object.h
+++ /dev/null
@@ -1,157 +0,0 @@
-#ifndef __NR_OBJECT_H__
-#define __NR_OBJECT_H__
-
-/*
- * RGBA display list system for inkscape
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * MenTaLguY <mental@rydia.net>
- *
- * This code is in public domain
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib/gtypes.h>
-#include "gc-managed.h"
-#include "gc-finalized.h"
-#include "gc-anchored.h"
-
-typedef guint32 NRType;
-
-struct NRObject;
-struct NRObjectClass;
-
-#define NR_TYPE_OBJECT (nr_object_get_type ())
-#define NR_OBJECT(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_OBJECT, NRObject))
-#define NR_IS_OBJECT(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_OBJECT))
-
-#define NR_TYPE_ACTIVE_OBJECT (nr_active_object_get_type ())
-#define NR_ACTIVE_OBJECT(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ACTIVE_OBJECT, NRActiveObject))
-#define NR_IS_ACTIVE_OBJECT(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ACTIVE_OBJECT))
-
-#define nr_return_if_fail(expr) if (!(expr) && nr_emit_fail_warning (__FILE__, __LINE__, "?", #expr)) return
-#define nr_return_val_if_fail(expr,val) if (!(expr) && nr_emit_fail_warning (__FILE__, __LINE__, "?", #expr)) return (val)
-
-unsigned int nr_emit_fail_warning (const gchar *file, unsigned int line, const gchar *method, const gchar *expr);
-
-#ifndef NR_DISABLE_CAST_CHECKS
-#define NR_CHECK_INSTANCE_CAST(ip, tc, ct) ((ct *) nr_object_check_instance_cast (ip, tc))
-#else
-#define NR_CHECK_INSTANCE_CAST(ip, tc, ct) ((ct *) ip)
-#endif
-
-#define NR_CHECK_INSTANCE_TYPE(ip, tc) nr_object_check_instance_type (ip, tc)
-#define NR_OBJECT_GET_CLASS(ip) (((NRObject *) ip)->klass)
-
-NRType nr_type_is_a (NRType type, NRType test);
-
-void const *nr_object_check_instance_cast(void const *ip, NRType tc);
-unsigned int nr_object_check_instance_type(void const *ip, NRType tc);
-
-NRType nr_object_register_type (NRType parent,
- gchar const *name,
- unsigned int csize,
- unsigned int isize,
- void (* cinit) (NRObjectClass *),
- void (* iinit) (NRObject *));
-
-/* NRObject */
-
-class NRObject : public Inkscape::GC::Managed<>,
- public Inkscape::GC::Finalized,
- public Inkscape::GC::Anchored
-{
-public:
- NRObjectClass *klass;
-
- static NRObject *alloc(NRType type);
-
- template <typename T>
- static void invoke_ctor(NRObject *object) {
- new (object) T();
- }
-
- /* these can go away eventually */
- NRObject *reference() {
- return Inkscape::GC::anchor(this);
- }
- NRObject *unreference() {
- Inkscape::GC::release(this);
- return NULL;
- }
-
-protected:
- NRObject() {}
-
-private:
- NRObject(NRObject const &); // no copy
- void operator=(NRObject const &); // no assign
-
- void *operator new(size_t size, void *placement) { (void)size; return placement; }
-};
-
-struct NRObjectClass {
- NRType type;
- NRObjectClass *parent;
-
- gchar *name;
- unsigned int csize;
- unsigned int isize;
- void (* cinit) (NRObjectClass *);
- void (* iinit) (NRObject *);
- void (* finalize) (NRObject *object);
- void (*cpp_ctor)(NRObject *object);
-};
-
-NRType nr_object_get_type (void);
-
-/* Dynamic lifecycle */
-
-inline NRObject *nr_object_new (NRType type) {
- return NRObject::alloc(type);
-}
-
-inline NRObject *nr_object_ref (NRObject *object) {
- return object->reference();
-}
-inline NRObject *nr_object_unref (NRObject *object) {
- return object->unreference();
-}
-
-/* NRActiveObject */
-
-struct NRObjectEventVector {
- void (* dispose) (NRObject *object, void *data);
-};
-
-struct NRObjectListener {
- const NRObjectEventVector *vector;
- unsigned int size;
- void *data;
-};
-
-struct NRObjectCallbackBlock {
- unsigned int size;
- unsigned int length;
- NRObjectListener listeners[1];
-};
-
-struct NRActiveObject : public NRObject {
- NRActiveObject() : callbacks(NULL) {}
- NRObjectCallbackBlock *callbacks;
-};
-
-struct NRActiveObjectClass : public NRObjectClass {
-};
-
-NRType nr_active_object_get_type (void);
-
-void nr_active_object_add_listener (NRActiveObject *object, const NRObjectEventVector *vector, unsigned int size, void *data);
-void nr_active_object_remove_listener_by_data (NRActiveObject *object, void *data);
-
-#endif
-