* Accessing Lisp variables from C
@ 2006-05-04 6:19 Oliver Scholz
2006-05-04 6:34 ` Oliver Scholz
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Scholz @ 2006-05-04 6:19 UTC (permalink / raw)
I decided to make a stab at porting `decode-char' to C. The better
part of it was indeed fairly trivial, but it turned out that I
obviously don't understand something very fundamental about the
interpreter. `decode-char' checks whether `utf-translate-cjk-mode' is
non-nil; if it is, it calls `utf-lookup-subst-table-for-decode'. This
one gets a translation hash table from the property
`translation-hash-table' on the symbol `utf-subst-table-for-decode'.
But before that, it checks whether the translation hash tables are
loaded, and calls `utf-translate-cjk-load-tables'.
I had the impression that in C this would look like this:
int
ucs_to_internal (ucs)
int ucs;
{
int c = 0;
Lisp_Object tmp_char;
if (! EQ (Qnil, SYMBOL_VALUE (intern ("utf-translate-cjk-mode"))))
/* cf. `utf-lookup-subst-table-for-decode' */
{
if (EQ (Qnil, SYMBOL_VALUE (intern ("utf-translate-cjk-lang-env"))))
call0 (intern ("utf-translate-cjk-load-tables"));
tmp_char = Fgethash (ucs,
Fget (intern ("utf-subst-table-for-decode"),
intern ("translation-hash-table")),
Qnil);
if (! EQ (Qnil, tmp_char))
{
CHECK_NUMBER (tmp_char);
c = XFASTINT (tmp_char);
}
}
[...]
But, oddly, this is not equivalent to what is supposed to be its Lisp
counterpart. `(utf-lookup-subst-table-for-decode #x9662)' returns a
nice Japanese character. This (alleged) C equivalent doesn't.
Besides, debugging is rather painful, since gdb insists on stepping
into `intern' and then into `oblookup' and then into `hash_string'
etc. I wonder what I am doing wrong here. The behaviour when stepping
is rather erratic, because for instance the gdb command "return"
causes a segfault when in `intern', but not when I step through it.
(The garbage collector is "mark and sweep", isn't it? Besides garbage
collection is triggered in the above only by `call0', right?)
Oliver
--
15 Floréal an 214 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-05-04 6:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-04 6:19 Accessing Lisp variables from C Oliver Scholz
2006-05-04 6:34 ` Oliver Scholz
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.