Tuesday, July 26, 2005

Edb.h to Edb.d

Anyway, just to Test my understanding of the .h to .d conversion process thoroughly, yesternite, i basically started and finished porting Edb (from the enlightenment EFL) to D. And you know what? I'm extremely IMPRESSED with those libraries. I was expecting to have lots of #defines to copy across, but NO NO NO NO NO!!!

Raster and guys are using really good C programming Semantics, with little used but beneficial features of C. Instead of using #define foo baa, like everyone else does, they use C's enums... And looking thru the header files, they read like a cool users manual. WOW!!! I'll tell you something... that library is WELL designed.

also, i've wrapped up the Edb into an Edb class, to make it feel more like a D programmer would expect. and the Edb class is ready as a version :)

What is left are three functions:

char **e_db_dump_multi_field( char *file, char *file2, int *num_ret);
char **e_db_dump_key_list( char *file, int *num_ret);
char **e_db_match_keys(E_DB_File *db, char *pattern, int *num_ret);

I have to make these module level functions, and give them D calling semantics, and encapsulate away the raw pointers.

And oh.. here's a sample program that worked for me yesternite:


import std.stdio;
import efl.edb;

int main(char[][] args)

Edb db = new Edb("afile.edb");

db.set("Magnus_i", 55);
db.set("Magnus_f", 55.59);
db.set("Magnus_s", "fifty-five");


Edb db2 = new Edb("afile.edb");

int ival = db2.get_int("Magnus_i");
float fval = db2.get_float("Magnus_f");
char[] sval = db2.get_string("Magnus_s");


writefln("Magnus = %d\t%f\t%s", ival, fval, sval);

return 0;


Oh... and i forgot to mention... since D has inherent support for unittests, the Edb.d module contains its own unittests.

Why am i doing this? I'm learning... Duh!!!

This means to me that i totally understand the C.h to D.d conversion process, and hey... its fun.

Once i totally wrap up the C parts of Xlib.h, then I can start giving them D objects to make D Xlib programming more fun.

Essien... out.


At Thursday, July 28, 2005 3:34:00 PM, Blogger kara said...

you really like gadgets.. good luck... update more..

At Friday, July 29, 2005 12:17:00 PM, Blogger Essien Ita Essien said...

Yup Kara,

I'm a gadget_o_freakazoid(tm) :)

thnx for dropping by.


Post a Comment

<< Home