BEAST - Free Software Audio Synthesizer and Tracker  0.9.2
sfiglue.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __SFI_GLUE_H__
3 #define __SFI_GLUE_H__
4 
5 #include <sfi/sfiprimitives.hh>
6 #include <sfi/sfiring.hh>
7 #include <sfi/sfiparams.hh>
8 
9 G_BEGIN_DECLS
10 
11 /* Glue proxy (object handle) description in terms of
12  * supported interfaces and property names
13  */
14 typedef struct {
15  guint ref_count;
16  gchar *type_name; /* interface type name */
17  guint n_ifaces;
18  gchar **ifaces;/*NULL-term*/ /* supported interfaces */
19  guint n_props;
20  gchar **props;/*NULL-term*/ /* property names */
21 } SfiGlueIFace;
22 
23 gchar* sfi_glue_base_iface (void);
24 const gchar** sfi_glue_iface_children (const gchar *iface_name);
25 SfiGlueIFace* sfi_glue_describe_iface (const gchar *iface_name);
26 SfiGlueIFace* sfi_glue_iface_ref (SfiGlueIFace *iface);
27 void sfi_glue_iface_unref (SfiGlueIFace *iface);
28 
29 
30 
31 /* Procedure description in terms of it's parameters
32  */
33 typedef struct {
34  guint ref_count;
35  gchar *name;
36  gchar *help;
37  gchar *authors;
38  gchar *license;
39  GParamSpec *ret_param;
40  guint n_params;
41  GParamSpec **params;
42 } SfiGlueProc;
43 
44 SfiGlueProc* sfi_glue_describe_proc (const gchar *proc_name);
45 SfiGlueProc* sfi_glue_proc_ref (SfiGlueProc *proc);
46 void sfi_glue_proc_unref (SfiGlueProc *proc);
47 const gchar** sfi_glue_list_proc_names (void);
48 const gchar** sfi_glue_list_method_names (const gchar *iface_name);
49 
50 GValue* sfi_glue_call_seq (const gchar *proc_name,
51  SfiSeq *params);
52 GValue* sfi_glue_call_valist (const gchar *proc_name,
53  guint8 first_arg_type,
54  va_list var_args);
55 void sfi_glue_vcall_void (const gchar *proc_name,
56  guint8 first_arg_type,
57  ...);
58 SfiBool sfi_glue_vcall_bool (const gchar *proc_name,
59  guint8 first_arg_type,
60  ...);
61 SfiInt sfi_glue_vcall_int (const gchar *proc_name,
62  guint8 first_arg_type,
63  ...);
64 SfiNum sfi_glue_vcall_num (const gchar *proc_name,
65  guint8 first_arg_type,
66  ...);
67 SfiReal sfi_glue_vcall_real (const gchar *proc_name,
68  guint8 first_arg_type,
69  ...);
70 const gchar* sfi_glue_vcall_string (const gchar *proc_name,
71  guint8 first_arg_type,
72  ...);
73 const gchar* sfi_glue_vcall_choice (const gchar *proc_name,
74  guint8 first_arg_type,
75  ...);
76 SfiProxy sfi_glue_vcall_proxy (const gchar *proc_name,
77  guint8 first_arg_type,
78  ...);
79 SfiSeq* sfi_glue_vcall_seq (const gchar *proc_name,
80  guint8 first_arg_type,
81  ...);
82 SfiRec* sfi_glue_vcall_rec (const gchar *proc_name,
83  guint8 first_arg_type,
84  ...);
85 SfiFBlock* sfi_glue_vcall_fblock (const gchar *proc_name,
86  guint8 first_arg_type,
87  ...);
88 SfiBBlock* sfi_glue_vcall_bblock (const gchar *proc_name,
89  guint8 first_arg_type,
90  ...);
91 GValue* sfi_glue_client_msg (const gchar *msg,
92  GValue *value);
93 
94 
95 /* Glue context table, abstracts middleware implementation */
96 typedef struct _SfiGlueContext SfiGlueContext;
97 typedef struct {
98  /* core functions */
99  SfiGlueIFace* (*describe_iface) (SfiGlueContext *context,
100  const gchar *iface);
101  SfiGlueProc* (*describe_proc) (SfiGlueContext *context,
102  const gchar *proc_name);
103  gchar** (*list_proc_names) (SfiGlueContext *context);
104  gchar** (*list_method_names) (SfiGlueContext *context,
105  const gchar *iface_name);
106  gchar* (*base_iface) (SfiGlueContext *context);
107  gchar** (*iface_children) (SfiGlueContext *context,
108  const gchar *iface_name);
109  GValue* (*exec_proc) (SfiGlueContext *context,
110  const gchar *proc_name,
111  SfiSeq *params);
112  /* proxy functions */
113  gchar* (*proxy_iface) (SfiGlueContext *context,
114  SfiProxy proxy);
115  gboolean (*proxy_is_a) (SfiGlueContext *context,
116  SfiProxy proxy,
117  const gchar *iface);
118  gchar** (*proxy_list_properties) (SfiGlueContext *context,
119  SfiProxy proxy,
120  const gchar *first_ancestor,
121  const gchar *last_ancestor);
122  GParamSpec* (*proxy_get_pspec) (SfiGlueContext *context,
123  SfiProxy proxy,
124  const gchar *prop_name);
125  SfiSCategory (*proxy_get_pspec_scategory) (SfiGlueContext *context,
126  SfiProxy proxy,
127  const gchar *prop_name);
128  void (*proxy_set_property) (SfiGlueContext *context,
129  SfiProxy proxy,
130  const gchar *prop,
131  const GValue *value);
132  GValue* (*proxy_get_property) (SfiGlueContext *context,
133  SfiProxy proxy,
134  const gchar *prop);
135  gboolean (*proxy_watch_release) (SfiGlueContext *context,
136  SfiProxy proxy);
137  gboolean (*proxy_request_notify) (SfiGlueContext *context,
138  SfiProxy proxy,
139  const gchar *signal,
140  gboolean enable_notify);
141  void (*proxy_processed_notify) (SfiGlueContext *context,
142  guint notify_id);
143  /* misc extensions */
144  GValue* (*client_msg) (SfiGlueContext *context,
145  const gchar *msg,
146  GValue *value);
147  /* framework functions */
148  SfiRing* (*fetch_events) (SfiGlueContext *context);
149  SfiRing* (*list_poll_fds) (SfiGlueContext *context);
150  void (*destroy) (SfiGlueContext *context);
152 
153 
154 /* --- Glue Context --- */
156 {
157  /*< private >*/
158  SfiGlueContextTable table;
159  gulong seq_hook_id;
160  GHashTable *gc_hash;
161  SfiUStore *proxies;
162  SfiRing *pending_events;
163 };
164 void sfi_glue_context_push (SfiGlueContext *context);
165 SfiGlueContext* sfi_glue_context_current (void);
166 void sfi_glue_context_pop (void);
167 SfiRing* sfi_glue_context_list_poll_fds (void);
168 void sfi_glue_context_process_fd (void);
169 gboolean sfi_glue_context_pending (void);
170 void sfi_glue_context_dispatch (void);
171 SfiSeq* sfi_glue_context_fetch_event (void);
172 void sfi_glue_context_destroy (SfiGlueContext *context);
173 
174 
175 /* --- Glue utilities --- */
176 #ifdef __cplusplus
177 typedef void (*SfiGlueGcFreeFunc) (void*);
178 #else
179 typedef void *SfiGlueGcFreeFunc; // FIXME: remove C-legacy
180 #endif
181 
182 void sfi_glue_gc_add (gpointer data,
183  SfiGlueGcFreeFunc free_func);
184 void sfi_glue_gc_remove (gpointer data,
185  SfiGlueGcFreeFunc free_func);
186 void sfi_glue_gc_free_now (gpointer data,
187  SfiGlueGcFreeFunc free_func);
188 void sfi_glue_gc_run (void);
189 
190 
191 /* --- internal --- */
192 gboolean _sfi_glue_gc_test (gpointer data,
193  gpointer free_func);
194 SfiGlueIFace* sfi_glue_iface_new (const gchar *iface_name);
195 SfiGlueProc* sfi_glue_proc_new (const gchar *proc_name);
196 void sfi_glue_proc_add_param (SfiGlueProc *proc,
197  GParamSpec *param);
198 void sfi_glue_proc_add_ret_param (SfiGlueProc *proc,
199  GParamSpec *param);
200 gboolean _sfi_glue_proxy_request_notify (SfiProxy proxy,
201  const gchar *signal,
202  gboolean enable_notify);
203 
204 
205 /* --- implementations --- */
206 void _sfi_init_glue (void);
207 void sfi_glue_context_common_init (SfiGlueContext *context,
208  const SfiGlueContextTable *vtable);
209 static inline SfiGlueContext*
210 sfi_glue_fetch_context (const gchar *floc);
211 static inline SfiGlueContext*
212 sfi_glue_fetch_context (const gchar *floc)
213 {
214  SfiGlueContext *context = sfi_glue_context_current ();
215  if (!context)
216  g_error ("%s: SfiGlue function called without context (use sfi_glue_context_push())", floc);
217  return context;
218 }
219 
220 G_END_DECLS
221 
222 #endif /* __SFI_GLUE_H__ */
223 
224 /* vim:set ts=8 sts=2 sw=2: */
Definition: sfiglue.hh:155
Definition: sfiglue.hh:33
Definition: sfiglue.hh:97
signal
Definition: sfiring.hh:23
Definition: sfiglue.hh:14