From: ellson Date: Fri, 29 Jul 2005 22:08:24 +0000 (+0000) Subject: add jumptable for gvplugin_device callbacks X-Git-Tag: LAST_LIBGRAPH~32^2~7350 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c4720492653a1327eb4e8215f5766c666230d18;p=graphviz add jumptable for gvplugin_device callbacks - needed so that (non-builtin) plugins can be loaded into static binaries --- diff --git a/lib/gvc/gvcint.h b/lib/gvc/gvcint.h index 284456126..3cd0a523d 100644 --- a/lib/gvc/gvcint.h +++ b/lib/gvc/gvcint.h @@ -129,6 +129,14 @@ extern "C" { int alloc; } gv_argvlist_t; + typedef struct gvdevice_callbacks_s { + void (*refresh) (GVJ_t * job); + void (*button_press) (GVJ_t * job, int button, pointf pointer); + void (*button_release) (GVJ_t * job, int button, pointf pointer); + void (*motion) (GVJ_t * job, pointf pointer); + void (*modify) (GVJ_t * job, char *name, char *value); + } gvdevice_callbacks_t; + struct GVJ_s { GVJ_t *next; /* linked list of jobs */ GVJ_t *next_active; /* linked list of active jobs (e.g. multiple windows) */ @@ -137,8 +145,9 @@ extern "C" { FILE *output_file; int output_lang; - gvplugin_active_device_t device; gvplugin_active_render_t render; + gvplugin_active_device_t device; + gvdevice_callbacks_t *callbacks; #ifndef DISABLE_CODEGENS codegen_t *codegen; /* current codegen */ diff --git a/lib/gvc/gvdevice.c b/lib/gvc/gvdevice.c index 4f1dfb0fc..e898ac447 100644 --- a/lib/gvc/gvdevice.c +++ b/lib/gvc/gvdevice.c @@ -77,14 +77,18 @@ int gvdevice_features(GVJ_t * job) return features; } +extern gvdevice_callbacks_t gvdevice_callbacks; + void gvdevice_finalize(GVC_t * gvc) { GVJ_t *job = gvc->active_jobs; gvdevice_engine_t *gvde = job->device.engine; if (gvde) { - if (gvde->finalize) + if (gvde->finalize) { + job->callbacks = &gvdevice_callbacks; gvde->finalize(gvc); + } } #ifndef DISABLE_CODEGENS else { diff --git a/lib/gvc/gvevent.c b/lib/gvc/gvevent.c index 1481d90f2..72f718d31 100644 --- a/lib/gvc/gvevent.c +++ b/lib/gvc/gvevent.c @@ -23,7 +23,7 @@ #define ZOOMFACTOR 1.1 #define EPSILON .0001 -void gvevent_refresh(GVJ_t * job) +static void gvevent_refresh(GVJ_t * job) { emit_graph(job, job->g); } @@ -283,7 +283,7 @@ static void gvevent_select_current_obj(GVJ_t * job) } } -#if 0 +#if 1 for (i = 0; i < job->selected_obj_type_name.argc; i++) fprintf(stderr,"%s%s", job->selected_obj_type_name.argv[i], (i==(job->selected_obj_type_name.argc - 1))?"\n":" "); @@ -293,7 +293,7 @@ fprintf(stderr,"\n"); #endif } -void gvevent_button_press(GVJ_t * job, int button, pointf pointer) +static void gvevent_button_press(GVJ_t * job, int button, pointf pointer) { switch (button) { case 1: /* select / create in edit mode */ @@ -337,7 +337,13 @@ void gvevent_button_press(GVJ_t * job, int button, pointf pointer) job->oldpointer = pointer; } -void gvevent_motion(GVJ_t * job, pointf pointer) +static void gvevent_button_release(GVJ_t *job, int button, pointf pointer) +{ + job->click = 0; + job->active = 0; +} + +static void gvevent_motion(GVJ_t * job, pointf pointer) { double dx = pointer.x - job->oldpointer.x; double dy = pointer.y - job->oldpointer.y; @@ -363,12 +369,6 @@ void gvevent_motion(GVJ_t * job, pointf pointer) job->oldpointer = pointer; } -void gvevent_button_release(GVJ_t *job, int button, pointf pointer) -{ - job->click = 0; - job->active = 0; -} - static int quit_cb(GVJ_t * job) { return 1; @@ -457,3 +457,11 @@ gvevent_key_binding_t gvevent_key_binding[] = { }; int gvevent_key_binding_size = ARRAY_SIZE(gvevent_key_binding); + +gvdevice_callbacks_t gvdevice_callbacks = { + gvevent_refresh, + gvevent_button_press, + gvevent_button_release, + gvevent_motion, + NULL, +}; diff --git a/lib/gvc/gvplugin_device.h b/lib/gvc/gvplugin_device.h index c56af4d1e..67f3b9036 100644 --- a/lib/gvc/gvplugin_device.h +++ b/lib/gvc/gvplugin_device.h @@ -28,13 +28,6 @@ extern "C" { void (*finalize) (GVC_t * gvc); }; -/* callbacks */ - extern void gvevent_refresh(GVJ_t * job); - extern void gvevent_button_press(GVJ_t * job, int button, pointf pointer); - extern void gvevent_button_release(GVJ_t * job, int button, pointf pointer); - extern void gvevent_motion(GVJ_t * job, pointf pointer); - - #ifdef __cplusplus } #endif