[Vala] I'd like to write binding C library.



Hi. i'm noob at English and Vala langauge =)
I'd like to write binding "migemo(C library)".
I write code with using python ctypes.

migemo is Hiragana-Kanji converter.
http://www.kaoriya.net/dist/cmigemo-1.2-dll.tar.bz2

http://en.wikipedia.org/wiki/Hiragana
>Hiragana is a Japanese syllabary, one component of the
>Japanese writing system, along with katakana and kanji.

------------------------------------------------------------------------------

ferrow my python ctypes code.

------------------------------------------------------------------------------
C:\cmigemo-1.2-dll>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import ctypes
>>> lib = ctypes.CDLL('migemo.dll')
>>> lib
<CDLL 'migemo.dll', handle 1610000 at 216ea30>
>>>
>>> m=lib.migemo_open()
>>> m
43109528
>>> from ctypes import *
>>> lib.migemo_load(m, c_int(1), "migemo-dict")
1
>>> p=lib.migemo_query(m, "nezu")
>>> p
43061504
>>> printf=cdll.msvcrt.printf
>>> printf("C/Migemo: %s\n", p)
C/Migemo: nezu
15
>>>
>>> p=lib.migemo_query(m, "きんがしんねん")
>>> printf("C/Migemo: %s\n", p)
C/Migemo: (きんがしんねん|謹賀新年)
36
------------------------------------------------------------------------------

fellow C code.

------------------------------------------------------------------------------
/*
 * http://cvs.kaoriya.net/svn/CMigemo/tags/rel-1_2/doc/README_j.txt
*/
#include <stdio.h>
    #inlcude "migemo.h"
    int main(int argc, char** argv)
    {
        migemo *m;
        m = migemo_open(NULL);
        migemo_load(m, MIGEMO_DICTID_MIGEMO, "./dict/migemo-dict");
        {
            unsigned char* p;
            p = migemo_query(m, "nezu");
            printf("C/Migemo: %s\n", p);
            migemo_release(m, p);
        }
        migemo_close(m);
        return 0;
    }
------------------------------------------------------------------------------

umm... How do I write C library Binding code by Vala langauge
in this case?

Regard.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]