On Tue, 2007-05-22 at 12:23 -0600, Alan Silverstein wrote:
> > Judy makes the same mistake in the headers. Pvoid_t. Oh, come on,
> > this is a stupid choice of names and totally unnecessary. The correct
> > way to spell void* is 'void*'.
>
> Hmm... If it's truly a problem, mea culpa. We were trying for clarity
> and consistency. I've also run into big old code that used what I
> thought was "unnecessary" abstraction, which only made it harder to find
> instances, etc. Like #define'ing GLOBAL to "extern".
It is hard to choose a balance in C, since it is such a horrible
language to start with ;(
> Then again, taken out of context (not worrying about consistency or
> affinity with similar typedefs), it does seem kind of silly and I don't
> know why I might do it today. Perhaps we had what seemed like a good
> reason? We'd been burned by various portability issues, and tended to
> err on the side of creating our own consistent abstraction layer to hide
> the details of getting stuff right on each platform.
Well, I am finding the interface close to impenetrable.
For example some functions return PPvoid .. when they are
clearly intended to return a Word_t** .. it's inconsistent.
To be precise I have a some code that seems to work, using
J1First, J1Next, but I had to use casts to make it compile
JudyL bindings (I'm compiling under C++ not C).
The problem is when the pointer storage location
is moved from the heap onto the stack then J1First,
J1Next, etc, return rubbish.
Now I can't tell if this is a bug in Judy, or it is a bug
in my binding which 'just happens' to appear to work in
the first case but actually corrupts memory somewhere.
I've spent around 2 days trying to figure out what's going
on and can't. The following is some Felix binding code
for Judy.. I hope most of it is instantly comprehensible.
[Felix is a C++ code generator]
module Judy
{
requires package "judy";
requires header "#include <Judy.h>";
open C_hack;
type word = "Word_t";
fun _ctor_word: int -> word = "(Word_t)$1";
fun _ctor_int: word -> int = "(int)$1";
fun _ctor_ulong: word -> ulong = "(unsigned long int)$1";
type JError_t = "JError_t*";
gen _ctor_JError_t : 1 -> JError_t =
"(JError_t*)malloc(sizeof(JError_t))";
type J1Array = "void**";
gen _ctor_J1Array: 1 -> J1Array = "_mkj1()" requires body
"""
void **_mkj1(){
void **m =(void**)malloc(sizeof(void*));
*m=0;
return m;
}
""";
proc free: J1Array = "_j1free($1);" requires body
"""
void _j1free(void **p) { Judy1FreeArray(p); free(p); }
""";
proc Judy1Set: J1Array * word * JError_t * ptr[int] =
"*$4=Judy1Set($1,$2,$3);";
proc Judy1UnSet: J1Array * word * JError_t * ptr[int] =
"*$4=Judy1UnSet($1,$2,$3);";
proc Judy1Test: J1Array * word * JError_t * ptr[int] =
"*$4=Judy1Test(*$1,$2,$3);";
proc Judy1Count: J1Array * word * word* JError_t * ptr[word] =
"*$5=Judy1Count(*$1,$2,$3,$4);";
proc Judy1ByCount: J1Array * word * ptr[word] * JError_t * ptr[word]
=
"*$5=Judy1ByCount(*$1,$2,$3,$4);";
proc Judy1FreeArray: J1Array * JError_t * ptr[word] =
"*$3=Judy1Free($1,$2);";
proc Judy1MemUsed: J1Array * ptr[word] = "*$2=Judy1MemUsed(*$1);";
proc Judy1First: J1Array * ptr[word] * JError_t * ptr[int] =
"*$4=Judy1First(*$1,$2,$3);";
proc Judy1Next: J1Array * ptr[word] * JError_t * ptr[int] =
"*$4=Judy1Next(*$1,$2,$3);";
proc Judy1Last: J1Array * ptr[word] * JError_t * ptr[int] =
"*$4=Judy1Last(*$1,$2,$3);";
proc Judy1Prev: J1Array * ptr[word] * JError_t * ptr[int] =
"*$4=Judy1Prev(*$1,$2,$3);";
proc Judy1FirstEmpty: J1Array * ptr[word] * JError_t * ptr[int] =
"*$4=Judy1FirstEmpty(*$1,$2,$3);";
proc Judy1NextEmpty: J1Array * ptr[word] * JError_t * ptr[int] =
"*$4=Judy1NextEmpty(*$1,$2,$3);";
proc Judy1LastEmpty: J1Array * ptr[word] * JError_t * ptr[int] =
"*$4=Judy1LastEmpty(*$1,$2,$3);";
proc Judy1PrevEmpty: J1Array * ptr[word] * JError_t * ptr[int] =
"*$4=Judy1PrevEmpty(*$1,$2,$3);";
.....
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel