denemo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Denemo-devel] Transpose


From: Jeremiah Benham
Subject: Re: [Denemo-devel] Transpose
Date: Mon, 11 Aug 2008 23:15:52 -0500

On Mon, 2008-08-11 at 22:52 -0500, Jeremiah Benham wrote:
> On Mon, 2008-08-11 at 19:24 +0100, Richard Shann wrote:
> > On Mon, 2008-08-11 at 09:23 -0500, Jeremiah Benham wrote:
> > > No. I am going to have to read through the docs first. I will get
> > > started on that now. 
> > > 
> > > > As I mentioned I
> > > > could generate an interface to all the menu Actions callback
> > > functions
> > > > in a matter of minutes, given an example of the format required.
> > > 
> > > ok. I will get on that. 
> > I've written a very simple example of generating an interface array
> > the result looks like this:
> > 
> > 
> > /* Interface (dummy) for a scripting engine */
> > typedef struct  arraytype {
> > char *command_name;
> >  void* callback;
> > }
> > arraytype;
> > arraytype interface_array[] = {
> > {"Denemo_InsertBflatmaj",(void*) 0x816ac40},
> > {"Denemo_StaffUp",(void*) 0x815ec98},
> > {"Denemo_SetInitialDflatmaj",(void*) 0x816d920},
> > {"Denemo_ToggleStartCrescendo",(void*) 0x8170ed0},
> > {"Denemo_ToggleTenuto",(void*) 0x81710d8},
> 
> ok. I am a bit confused. I want to make sure I understand you. Is the
> above char *command_name to be names of the functions exported that the
> script writer will use? You are going to define this somewhere so that
> it creates an alias to pointers pointing to the actual function? There
> will need to be a header file containing something like
> denemointerface.h:
> 
> void Denemo_InsertBflatmaj();
> void Denemo_StaffUp();
> etc .....
> 
> Then the denemointerface.i file would look like this:
> %module denemointerface
> %{
> #include<denemointerface.h>
> %}
> external void Denemo_InsertBflatmaj();
> external void Denemo_StaffUp();
> etc .....

According to http://www.swig.org/tutorial.html
most of the time if all the functions are defined in 
denemointerface.h we would not need to redefine them in
denemointerface.i. denemointerface.i may be as simple as this:

%module denemointerface
%{
#include<denemointerface.h>
%}

%include<denemointerface.h>


Jeremiah


> 
> Am, I understanding this correctly? If so I can use the code you gave me
> to auto-generate the above very easily. 
> 
> > and so on.
> > The void* are the GtkAction pointers, so the call to
> > ToggleStartCrescendo would call a function that would do
> >  
> > gtk_action_activate(0x8170ed0);
> 
> Would 0x8170ed0 always be the same each time denemo is launched or does
> that dynamically change each time?
> 
> > For parameters, notice that there is a whole machinery GValue for
> > passing parameters whose types can be determined.
> > Here is a little snippet of code showing GValue in use:
> 
> So in this instance the alias would point to a GValue containing what?
> the function name and its arguments?
> 
> > GValue *value = g_malloc0(sizeof(GValue));
> >     g_value_init(value, G_TYPE_BOOLEAN);
> >     g_value_set_boolean(value,Denemo.gui->textview &&
> > GTK_WIDGET_VISIBLE(Denemo.gui->textwindow));
> >     g_object_set_property (G_OBJECT (widget), "active", value);
> > 
> > though you wouldn't normally generate them on the heap.
> 
> Do you want this variable GENERATE_INTERFACE_TO_SCRIPTING_LANGUAGE to be
> set by Autotools as a ./configure --enable-python --enable-ruby or what
> is your plan. Is this something that would be turned off by default on
> the next release? 
> 
> > I'm mentioning all this as I am scheduled to be in hospital Thursday
> > this week, and hope to come back to find everything finished!
> 
> I hope you are going to be ok.  
> 
> Jeremiah
> 
> > Richard
> > p.s. the code generating the above is this (at the end of view.c)
> > 
> > ...
> >    GtkActionGroup *action_group;
> >    GList *groups = gtk_ui_manager_get_action_groups (Denemo.ui_manager);
> >    action_group = GTK_ACTION_GROUP(groups->data); 
> >    GList *g = gtk_action_group_list_actions(action_group);
> > #ifdef GENERATE_INTERFACE_TO_SCRIPTING_LANGUAGE
> >      g_print("/* Interface (dummy) for a scripting engine */\n");
> >      g_print("typedef struct  arraytype {\nchar *command_name;\n void*
> > callback;\n}\narraytype;\n");
> >      g_print("arraytype interface_array[] = {\n");
> > #endif
> >    for(;g;g=g->next) {
> >      gint command_idx;
> >      keymap *the_keymap = Denemo.prefs.the_keymap;
> >      GSList *h = gtk_action_get_proxies (g->data);
> >      for(;h;h=h->next) {
> > #if (GTK_MINOR_VERSION <10)
> >        attach_action_to_widget(h->data, g->data, Denemo.gui);
> > #endif
> >        attach_set_accel_callback(h->data, g->data,"", Denemo.gui);
> >        command_idx = lookup_index_from_name(the_keymap,
> >                                         gtk_action_get_name(g->data));
> >        if (command_idx != -1) {
> >      update_accel_labels(the_keymap, command_idx);
> >        }
> >      }
> > #ifdef GENERATE_INTERFACE_TO_SCRIPTING_LANGUAGE
> >      GtkAction *action = g->data;
> >      g_print("{\"Denemo_%s\",(void*) %p},\n",
> > gtk_action_get_name(action), action);
> > #endif
> >    }
> > #ifdef GENERATE_INTERFACE_TO_SCRIPTING_LANGUAGE
> >      
> >      g_print("{\"\", 0x0}};\n");
> > #endif
> >    initialized = TRUE;
> >  }
> > ...
> > 
> 
> 
> 
> _______________________________________________
> Denemo-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/denemo-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]