Code

5b9aa3c8005a5c75b97679326620be05f9d4e6e1
[inkscape.git] / src / gc-finalized.cpp
1 /*
2  * Inkscape::GC::Finalized - mixin for GC-managed objects with non-trivial
3  *                           destructors
4  *
5  * Copyright 2006 MenTaLguY <mental@rydia.net>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * See the file COPYING for details.
13  *
14  */
16 #include <typeinfo>
17 #include "debug/simple-event.h"
18 #include "debug/event-tracker.h"
19 #include "util/format.h"
20 #include "util/share.h"
21 #include "gc-finalized.h"
23 namespace Inkscape {
25 namespace GC {
27 namespace {
29 // workaround for g++ 4.0.2
30 typedef Debug::SimpleEvent<Debug::Event::FINALIZERS> BaseEvent;
32 class FinalizerEvent : public BaseEvent {
33 public:
34     FinalizerEvent(Finalized *object)
35     : BaseEvent(Util::share_static_string("gc-finalizer"))
36     {
37         _addProperty("base", Util::format("%p", Core::base(object)));
38         _addProperty("pointer", Util::format("%p", object));
39         _addProperty("class", Util::share_static_string(typeid(*object).name()));
40     }
41 };
43 }
45 void Finalized::_invoke_dtor(void *base, void *offset) {
46     Finalized *object=_unoffset(base, offset);
47     Debug::EventTracker<FinalizerEvent> tracker(object);
48     object->~Finalized();
49 }
51 }
53 }
55 /*
56   Local Variables:
57   mode:c++
58   c-file-style:"stroustrup"
59   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
60   indent-tabs-mode:nil
61   fill-column:99
62   End:
63 */
64 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :