From 0e34011e6c2d0a23c3b22a93bf2595ee11d92e0d Mon Sep 17 00:00:00 2001
From: Aleix Conchillo Flaque <aconchillo@gmail.com>
Date: Thu, 26 Jul 2012 18:21:40 -0700
Subject: [PATCH] add support for guile 2.0
---
configure.ac | 12 ++------
mixguile/mixguile_cmd_dispatcher.c | 2 +-
mixguile/xmixguile_cmd_dispatcher.c | 55 ++++++++++++++++++-----------------
mixguile/xmixguile_cmd_dispatcher.h | 2 +-
4 files changed, 33 insertions(+), 38 deletions(-)
diff --git a/configure.ac b/configure.ac
index 179297d..01b8fee 100644
a
|
b
|
AC_ARG_WITH(guile, |
90 | 90 | esac], [wguile=true]) |
91 | 91 | |
92 | 92 | if test x$wguile = xtrue; then |
93 | | dnl AC_CHECK_HEADER(guile/gh.h,,wguile=false) |
94 | | AC_MSG_CHECKING(for Guile) |
95 | | guile-config link > /dev/null || { |
96 | | AC_MSG_RESULT(no) |
97 | | wguile=false |
98 | | } |
| 93 | PKG_CHECK_MODULES(GUILE,guile-2.0 >= 2.0,[wguile=true],[wguile=false]) |
99 | 94 | fi |
100 | 95 | |
101 | 96 | if test x$wguile = xtrue; then |
102 | | GUILE_CFLAGS="`guile-config compile`" |
103 | | GUILE_LDFLAGS="`guile-config link`" |
104 | | LIBS="$LIBS $GUILE_LDFLAGS" |
| 97 | LIBS="$LIBS $GUILE_LIBS" |
105 | 98 | AM_CFLAGS="$AM_CFLAGS $GUILE_CFLAGS" |
106 | 99 | AC_SUBST(MAKE_GUILE) |
107 | | AC_MSG_RESULT(yes) |
108 | 100 | fi |
109 | 101 | |
110 | 102 | AM_CONDITIONAL(MAKE_GUILE, test x$wguile = xtrue) |
diff --git a/mixguile/mixguile_cmd_dispatcher.c b/mixguile/mixguile_cmd_dispatcher.c
index b302f39..a226423 100644
a
|
b
|
|
24 | 24 | #include <fcntl.h> |
25 | 25 | #include <errno.h> |
26 | 26 | |
27 | | #include <guile/gh.h> |
| 27 | #include <libguile.h> |
28 | 28 | #include "mixguile.h" |
29 | 29 | #include "xmixguile_cmd_dispatcher.h" |
30 | 30 | |
diff --git a/mixguile/xmixguile_cmd_dispatcher.c b/mixguile/xmixguile_cmd_dispatcher.c
index d6baf47..bbc411d 100644
a
|
b
|
|
22 | 22 | #include <string.h> |
23 | 23 | |
24 | 24 | #include <mixlib/mix.h> |
25 | | #include <guile/gh.h> |
| 25 | #include <libguile.h> |
26 | 26 | |
27 | 27 | #include "xmixguile_cmd_dispatcher.h" |
28 | 28 | |
… |
… |
|
30 | 30 | static mixguile_cmd_dispatcher_t *dispatcher_; |
31 | 31 | static mix_vm_cmd_dispatcher_t *vm_dispatcher_; |
32 | 32 | static mix_vm_t *vm_; |
| 33 | static SCM mutex_; |
33 | 34 | |
34 | 35 | /* register a NULL-terminated list of scm commands */ |
35 | 36 | void |
… |
… |
register_cmd_dispatcher_ (mixguile_cmd_dispatcher_t *dis) |
56 | 57 | dispatcher_ = dis; |
57 | 58 | vm_dispatcher_ = mixguile_cmd_dispatcher_get_vm_dispatcher (dis); |
58 | 59 | vm_ = (mix_vm_t *) mix_vm_cmd_dispatcher_get_vm (vm_dispatcher_); |
| 60 | mutex_ = scm_make_mutex (); |
59 | 61 | } |
60 | 62 | |
61 | 63 | /* commands */ |
… |
… |
mixvm_cmd_ (SCM cmd, SCM arg) |
65 | 67 | char *com = NULL, *argu = NULL; |
66 | 68 | gboolean result; |
67 | 69 | |
68 | | SCM_ASSERT (SCM_STRINGP (cmd) || SCM_SYMBOLP (cmd), |
69 | | cmd, SCM_ARG1, "mixvm-cmd"); |
70 | | SCM_ASSERT (SCM_STRINGP (arg) || SCM_SYMBOLP (arg), |
71 | | arg, SCM_ARG2, "mixvm-cmd"); |
| 70 | SCM_ASSERT (scm_is_string (cmd) || scm_is_symbol (cmd), |
| 71 | cmd, SCM_ARG1, "mixvm-cmd"); |
| 72 | SCM_ASSERT (scm_is_string (arg) || scm_is_symbol (arg), |
| 73 | arg, SCM_ARG2, "mixvm-cmd"); |
72 | 74 | |
73 | | SCM_DEFER_INTS; |
| 75 | scm_lock_mutex (mutex_); |
74 | 76 | com = scm_to_locale_string (cmd); |
75 | 77 | argu = scm_to_locale_string (arg); |
76 | 78 | result = mix_vm_cmd_dispatcher_dispatch (vm_dispatcher_, |
… |
… |
mixvm_cmd_ (SCM cmd, SCM arg) |
79 | 81 | g_free (com); |
80 | 82 | g_free (argu); |
81 | 83 | |
82 | | SCM_ALLOW_INTS; |
| 84 | scm_unlock_mutex (mutex_); |
83 | 85 | |
84 | 86 | return SCM_UNSPECIFIED; |
85 | 87 | } |
… |
… |
mix_reg_ (SCM reg) |
116 | 118 | char *regis; |
117 | 119 | long val = MIX_WORD_MAX + 1; |
118 | 120 | |
119 | | SCM_ASSERT (SCM_STRINGP (reg) || SCM_SYMBOLP (reg), reg, SCM_ARG1, "mix-reg"); |
| 121 | SCM_ASSERT (scm_is_string (reg) || scm_is_symbol (reg), |
| 122 | reg, SCM_ARG1, "mix-reg"); |
120 | 123 | |
121 | | SCM_DEFER_INTS; |
| 124 | scm_lock_mutex (mutex_); |
122 | 125 | if (SCM_SYMBOLP (reg)) reg = scm_symbol_to_string (reg); |
123 | 126 | regis = scm_to_locale_string (reg); |
124 | 127 | switch (regis[0]) |
… |
… |
mix_reg_ (SCM reg) |
140 | 143 | } |
141 | 144 | g_free (regis); |
142 | 145 | |
143 | | SCM_ALLOW_INTS; |
| 146 | scm_unlock_mutex (mutex_); |
144 | 147 | |
145 | 148 | SCM_ASSERT (val <= MIX_WORD_MAX, reg, SCM_ARG1, "mix-reg"); |
146 | 149 | |
… |
… |
mix_set_reg_ (SCM reg, SCM value) |
154 | 157 | long val; |
155 | 158 | gboolean result = TRUE; |
156 | 159 | |
157 | | SCM_ASSERT (SCM_STRINGP (reg) || SCM_SYMBOLP (reg), reg, SCM_ARG1, |
158 | | "mix-set-reg!"); |
159 | | SCM_ASSERT (SCM_NUMBERP (value), value, SCM_ARG2, "mix-set-reg!"); |
| 160 | SCM_ASSERT (scm_is_string (reg) || scm_is_symbol (reg), |
| 161 | reg, SCM_ARG1, "mix-set-reg!"); |
| 162 | SCM_ASSERT (scm_is_number (value), value, SCM_ARG2, "mix-set-reg!"); |
160 | 163 | |
161 | | SCM_DEFER_INTS; |
| 164 | scm_lock_mutex (mutex_); |
162 | 165 | if (SCM_SYMBOLP (reg)) reg = scm_symbol_to_string (reg); |
163 | 166 | regis = scm_to_locale_string (reg); |
164 | 167 | val = scm_to_long (value); |
… |
… |
mix_set_reg_ (SCM reg, SCM value) |
182 | 185 | } |
183 | 186 | g_free (regis); |
184 | 187 | |
185 | | SCM_ALLOW_INTS; |
| 188 | scm_unlock_mutex (mutex_); |
186 | 189 | |
187 | 190 | SCM_ASSERT (result, reg, SCM_ARG1, "mix-set-reg!"); |
188 | 191 | |
… |
… |
mix_set_cmp_ (SCM value) |
256 | 259 | gchar *val = NULL; |
257 | 260 | mix_cmpflag_t result = -1; |
258 | 261 | |
259 | | SCM_ASSERT (SCM_STRINGP (value) || SCM_SYMBOLP (value), value, SCM_ARG1, |
260 | | "mix-set-cmp!"); |
| 262 | SCM_ASSERT (scm_is_string (value) || scm_is_symbol (value), |
| 263 | value, SCM_ARG1, "mix-set-cmp!"); |
261 | 264 | |
262 | | SCM_DEFER_INTS; |
| 265 | scm_lock_mutex (mutex_); |
263 | 266 | val = scm_to_locale_string (value); |
264 | 267 | if (strlen (val) == 1) |
265 | 268 | { |
… |
… |
mix_set_cmp_ (SCM value) |
272 | 275 | } |
273 | 276 | } |
274 | 277 | g_free (val); |
275 | | SCM_ALLOW_INTS; |
| 278 | scm_unlock_mutex (mutex_); |
276 | 279 | SCM_ASSERT (result != -1, value, SCM_ARG1, "mix-set-cmp!"); |
277 | 280 | mix_vm_set_cmpflag (vm_, result); |
278 | 281 | return SCM_BOOL_T; |
… |
… |
mix_add_hook_ (SCM cmd, SCM function, gboolean pre) |
456 | 459 | mix_vm_command_t command; |
457 | 460 | const gchar *fun = pre? "mix-add-pre-hook" : "mix-add-post-hook"; |
458 | 461 | |
459 | | SCM_ASSERT (SCM_STRINGP (cmd) || SCM_SYMBOLP (cmd), cmd, SCM_ARG1, fun); |
| 462 | SCM_ASSERT (scm_is_string (cmd) || scm_is_symbol (cmd), cmd, SCM_ARG1, fun); |
460 | 463 | SCM_ASSERT (scm_is_true (scm_procedure_p (function)), function, SCM_ARG2, fun); |
461 | | SCM_DEFER_INTS; |
| 464 | scm_lock_mutex (mutex_); |
462 | 465 | cmdstr = scm_to_locale_string (cmd); |
463 | 466 | command = mix_vm_command_from_string (cmdstr); |
464 | 467 | g_free (cmdstr); |
465 | | SCM_ALLOW_INTS; |
| 468 | scm_unlock_mutex (mutex_); |
466 | 469 | SCM_ASSERT (command != MIX_CMD_INVALID, cmd, SCM_ARG1, fun); |
467 | | SCM_DEFER_INTS; |
| 470 | scm_lock_mutex (mutex_); |
468 | 471 | if (pre) |
469 | 472 | mix_vm_cmd_dispatcher_pre_hook (vm_dispatcher_, command, scm_hook_, |
470 | 473 | (gpointer) define_hook_procedure_ (function)); |
471 | 474 | else |
472 | 475 | mix_vm_cmd_dispatcher_post_hook (vm_dispatcher_, command, scm_hook_, |
473 | 476 | (gpointer) define_hook_procedure_ (function)); |
474 | | SCM_ALLOW_INTS; |
| 477 | scm_unlock_mutex (mutex_); |
475 | 478 | return SCM_BOOL_T; |
476 | 479 | } |
477 | 480 | |
… |
… |
mix_add_global_hook_ (SCM function, gboolean pre) |
482 | 485 | pre? "mix-add-global-pre-hook" : "mix-add-global-post-hook"; |
483 | 486 | |
484 | 487 | SCM_ASSERT (scm_is_true (scm_procedure_p (function)), function, SCM_ARG1, fun); |
485 | | SCM_DEFER_INTS; |
| 488 | scm_lock_mutex (mutex_); |
486 | 489 | if (pre) |
487 | 490 | mix_vm_cmd_dispatcher_global_pre_hook (vm_dispatcher_, scm_global_hook_, |
488 | 491 | (gpointer) define_hook_procedure_ (function)); |
489 | 492 | else |
490 | 493 | mix_vm_cmd_dispatcher_global_post_hook (vm_dispatcher_, scm_global_hook_, |
491 | 494 | (gpointer) define_hook_procedure_ (function)); |
492 | | SCM_ALLOW_INTS; |
| 495 | scm_unlock_mutex (mutex_); |
493 | 496 | return SCM_BOOL_T; |
494 | 497 | } |
495 | 498 | |
diff --git a/mixguile/xmixguile_cmd_dispatcher.h b/mixguile/xmixguile_cmd_dispatcher.h
index f6d987a..4298267 100644
a
|
b
|
|
26 | 26 | #include <stdlib.h> |
27 | 27 | #include <stdio.h> |
28 | 28 | |
29 | | #include <guile/gh.h> |
| 29 | #include <libguile.h> |
30 | 30 | #include "mixguile_cmd_dispatcher.h" |
31 | 31 | |
32 | 32 | /* the cmd dispatcher type */ |