# HG changeset patch # User David Bryant # Date 1290043802 -37800 # Node ID 345fb56d89fc6181b45558ed5dfc4ed937579ee6 # Parent d04c3fe1822cad574d6692e0c12e1e056c9f47a3 Blind checkpoint diff -r d04c3fe1822c -r 345fb56d89fc doodle/core/backtrace.d --- a/doodle/core/backtrace.d Thu Oct 28 18:29:50 2010 +1030 +++ b/doodle/core/backtrace.d Thu Nov 18 12:00:02 2010 +1030 @@ -1,28 +1,15 @@ module doodle.core.backtrace; // -// Provides support for a readable backtrace on a program crash. -// -// Everything is private - you build this into a library and -// link to the library, and bingo (via static this). -// -// It works by registering a stacktrace handler with the runtime, -// which, unlike the default one, provides demangled symbols -// rather than just a list of addresses. +// Register signal handlers and throw Error. +// Technically we shouldn't be throwing an exception from +// a signal handler, but it happens to work. // private { - import core.stdc.signal; - import core.stdc.stdlib : free; - import core.stdc.string : strlen; - import core.runtime; - import std.demangle; import std.string; - extern (C) int backtrace(void**, size_t); - extern (C) char** backtrace_symbols(void**, int); - // signal handler for otherwise-fatal thread-specific signals extern (C) void signalHandler(int sig) { string name() { @@ -45,60 +32,6 @@ signal(SIGFPE, &signalHandler); signal(SIGILL, &signalHandler); signal(SIGSEGV, &signalHandler); - signal(SIGINT, &signalHandler); - } - - static this() { - // register our trace handler for each thread - Runtime.traceHandler = &traceHandler; - } - - Throwable.TraceInfo traceHandler(void * ptr = null) { - return new TraceInfo; - } - - class TraceInfo : Throwable.TraceInfo { - this() { - immutable MAXFRAMES = 128; - void*[MAXFRAMES] callstack; - - numframes = backtrace(callstack.ptr, MAXFRAMES); - framelist = backtrace_symbols(callstack.ptr, numframes); - } - - ~this() { - free(framelist); - } - - override string toString() const { return null; } // Why does toString require overriding? - - override int opApply(scope int delegate(ref char[]) dg) { - // NOTE: The first 5 frames with the current implementation are - // inside core.runtime and the object code, so eliminate - // these for readability. - immutable FIRSTFRAME = 5; - int ret = 0; - - for(int i = FIRSTFRAME; i < numframes; ++i) { - char[] text = framelist[i][0 .. strlen(framelist[i])]; - - int a = text.lastIndexOf('('); - int b = text.lastIndexOf('+'); - - if (a != -1 && b != -1) { - ++a; - text = format("%s%s%s", text[0..a], demangle(text[a..b].idup), text[b..$]).dup; - } - - ret = dg(text); - if (ret) - break; - } - return ret; - } - - private: - int numframes; - char** framelist; + signal(SIGINT, &signalHandler); } } diff -r d04c3fe1822c -r 345fb56d89fc doodle/gtk/cairo_canvas.d --- a/doodle/gtk/cairo_canvas.d Thu Oct 28 18:29:50 2010 +1030 +++ b/doodle/gtk/cairo_canvas.d Thu Nov 18 12:00:02 2010 +1030 @@ -36,6 +36,15 @@ } final class CairoCanvas : Table, private IViewport { + static this() { + _cursors = [ + Cursor.DEFAULT : CursorType.ARROW, + Cursor.HAND : CursorType.HAND1, + Cursor.CROSSHAIR : CursorType.CROSSHAIR, + Cursor.PENCIL : CursorType.PENCIL + ]; + } + this(in Layer[] layers, IEventHandler eventHandler, IGrid grid, in double pixelsPerMillimetre) { super(3, 3, 0); @@ -129,13 +138,6 @@ AttachOptions.SHRINK, AttachOptions.FILL | AttachOptions.EXPAND, 0, 0); - - _cursors = [ - Cursor.DEFAULT : CursorType.ARROW, - Cursor.HAND : CursorType.HAND1, - Cursor.CROSSHAIR : CursorType.CROSSHAIR, - Cursor.PENCIL : CursorType.PENCIL - ]; } protected { // XXX the compiler complains about unimplemented methods if this is private @@ -434,6 +436,6 @@ Rectangle _damageScreen; ScreenModel _screenModel; - immutable CursorType[Cursor] _cursors; + static immutable CursorType[Cursor] _cursors; } } diff -r d04c3fe1822c -r 345fb56d89fc doodle/gtk/ruler.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doodle/gtk/ruler.d Thu Nov 18 12:00:02 2010 +1030 @@ -0,0 +1,35 @@ +module doodle.gtk.ruler; + +/+ +public { + import gtk.DrawingArea; +} + +private { +} + +// +// + +class Ruler : DrawingArea { + this() { + addOnConfigure(&onConfigure); + } + + void move(double base) { + } + + private { + bool onExpose(GdkEventExpose * event, Widget widget) { + } + + bool onConfigure(GdkEventConfigure * event, Widget widget) { + assert(widget is this); + } + + double _min, _max; // millimetres + bool _visible; + double _value; + } +} ++/