~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to uim/uim-custom.c

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2007-04-21 03:46:09 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070421034609-gpcurkutp8vaysqj
Tags: 1:1.4.1-3
* Switch to dh_gtkmodules for the gtk 2.10 transition (Closes:
  #419318)
  - debian/control: Add ${misc:Depends} and remove libgtk2.0-bin on
    uim-gtk2.0.
  - debian/uim-gtk2.0.post{inst,rm}: Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 
3
 
  Copyright (c) 2003-2006 uim Project http://uim.freedesktop.org/
 
3
  Copyright (c) 2003-2007 uim Project http://uim.freedesktop.org/
4
4
 
5
5
  All rights reserved.
6
6
 
49
49
#include <stdlib.h>
50
50
#include <stdio.h>
51
51
#include <string.h>
 
52
 
 
53
#include "uim-stdint.h"
52
54
#include "uim-scm.h"
53
55
#include "uim-compat-scm.h"
54
56
#include "uim-custom.h"
136
138
 
137
139
#if UIM_SCM_GCC4_READY_GC
138
140
static char *literalize_string_internal(const char *str);
139
 
static uim_bool custom_cb_add_internal(const char *hook, const char *validator,
140
 
                                       const char *custom_sym, void *ptr,
141
 
                                       const char *gate_func, void (*cb)(void));
 
141
 
 
142
struct custom_cb_add_args {
 
143
  const char *hook;
 
144
  const char *validator;
 
145
  const char *custom_sym;
 
146
  void *ptr;
 
147
  const char *gate_func;
 
148
  void (*cb)(void);
 
149
};
 
150
static void *custom_cb_add_internal(struct custom_cb_add_args *args);
142
151
#endif
143
152
 
144
153
static const char str_list_arg[] = "uim-custom-c-str-list-arg";
152
161
literalize_string(const char *str)
153
162
#if UIM_SCM_GCC4_READY_GC
154
163
{
155
 
  char *ret;
156
 
 
157
 
  UIM_SCM_GC_PROTECTED_CALL(ret, char *, literalize_string_internal, (str));
158
 
 
159
 
  return ret;
 
164
  return uim_scm_call_with_gc_ready_stack((uim_gc_gate_func_ptr)literalize_string_internal, (void *)str);
160
165
}
161
166
 
162
167
static char *
821
826
{
822
827
  char *dir;
823
828
 
824
 
  UIM_EVAL_STRING(NULL, "(string-append (getenv \"HOME\") \"/.uim.d\")");
 
829
  UIM_EVAL_STRING(NULL, "(string-append (or (getenv \"HOME\") \"\") \"/.uim.d\")");
825
830
  dir = uim_scm_c_str(uim_scm_return_value());
826
831
  if (subpath) {
827
832
    UIM_EVAL_FSTRING2(NULL, "\"%s/%s\"", dir, subpath);
1463
1468
              const char *gate_func, void (*cb)(void))
1464
1469
#if UIM_SCM_GCC4_READY_GC
1465
1470
{
1466
 
  uim_bool ret;
1467
 
 
1468
 
  UIM_SCM_GC_PROTECTED_CALL(ret, uim_bool, custom_cb_add_internal,
1469
 
                            (hook, validator, custom_sym, ptr, gate_func, cb));
1470
 
 
1471
 
  return ret;
 
1471
  struct custom_cb_add_args args;
 
1472
 
 
1473
  args.hook = hook;
 
1474
  args.validator = validator;
 
1475
  args.custom_sym = custom_sym;
 
1476
  args.ptr = ptr;
 
1477
  args.gate_func = gate_func;
 
1478
  args.cb = cb;
 
1479
  return (uim_bool)(uintptr_t)uim_scm_call_with_gc_ready_stack((uim_gc_gate_func_ptr)custom_cb_add_internal, &args);
1472
1480
}
1473
1481
 
1474
 
static uim_bool
1475
 
custom_cb_add_internal(const char *hook, const char *validator,
1476
 
                       const char *custom_sym, void *ptr,
1477
 
                       const char *gate_func, void (*cb)(void))
 
1482
static void *
 
1483
custom_cb_add_internal(struct custom_cb_add_args *args)
1478
1484
#endif
1479
1485
{
1480
1486
  uim_bool succeeded;
1481
 
#if !UIM_SCM_GCC4_READY_GC
 
1487
#if UIM_SCM_GCC4_READY_GC
 
1488
  const char *hook;
 
1489
  const char *validator;
 
1490
  const char *custom_sym;
 
1491
  void *ptr;
 
1492
  const char *gate_func;
 
1493
  void (*cb)(void);
 
1494
#else
1482
1495
  uim_lisp stack_start;
1483
1496
#endif
1484
1497
  uim_lisp form;
1485
1498
 
1486
 
#if !UIM_SCM_GCC4_READY_GC
 
1499
#if UIM_SCM_GCC4_READY_GC
 
1500
  hook = args->hook;
 
1501
  validator = args->validator;
 
1502
  custom_sym = args->custom_sym;
 
1503
  ptr = args->ptr;
 
1504
  gate_func = args->gate_func;
 
1505
  cb = args->cb;
 
1506
#else
1487
1507
  uim_scm_gc_protect_stack(&stack_start);
1488
1508
#endif
1489
1509
 
1496
1516
  form = uim_scm_cons(uim_scm_make_symbol("custom-register-cb"), form);
1497
1517
  succeeded = uim_scm_c_bool(uim_scm_eval(form));
1498
1518
 
1499
 
#if !UIM_SCM_GCC4_READY_GC
 
1519
#if UIM_SCM_GCC4_READY_GC
 
1520
  return (void *)(uintptr_t)succeeded;
 
1521
#else
1500
1522
  uim_scm_gc_unprotect_stack(&stack_start);
 
1523
 
 
1524
  return succeeded;
1501
1525
#endif
1502
 
 
1503
 
  return succeeded;
1504
1526
}
1505
1527
 
1506
1528
static uim_bool