Automatic binding creator from C to Lisaac

Mildred Ki'Lya ml.mildred593 at gmail.com
Thu Aug 27 08:30:59 UTC 2009


On 08/27/2009 09:23 AM, Nicolas Boulay wrote:
> I had an idea like that. Does it create a lisaac prototype from a .h file ?
Yes

Example of some C code:

  LLVMModuleRef mod = LLVMModuleCreateWithName("fac_module");
  LLVMTypeRef fac_args[] = { LLVMInt32Type() };
  LLVMValueRef fac = LLVMAddFunction(mod, "fac",
LLVMFunctionType(LLVMInt32Type(), fac_args, 1, 0));
  LLVMSetFunctionCallConv(fac, LLVMCCallConv);
  LLVMValueRef n = LLVMGetParam(fac, 0);

Lisaac equivalent:

    + mod :LLVM.MODULE_REF;
    + fac_args :FAST_ARRAY(LLVM.TYPE_REF);
    + fac, n :LLVM.VALUE_REF;

    fac_args := FAST_ARRAY(LLVM.TYPE_REF).create 1;

    mod := LLVM.CORE.module_create_with_name("fac_module");
    fac_args.add_last(LLVM.CORE.int32type);
    fac := LLVM.CORE.add_function(mod, "fac",
CORE.function_type(LLVM.CORE.int32type, fac_args.storage, 1, 0));
    CORE.set_function_call_conv(fac, LLVM.CALL_CONV.c_call_conv.to_integer);
    n := LLVM.CORE.get_param(fac, 0);

The only problem is that it seems that accessing the storage if a
FAST_ARRAY is not so good to get a C array, I get a segfault.

Remark: all functions are in CORE because I extracted Core.h


Mildred

-- 
Mildred Ki'Lya
╭───────── mildred593@online.fr ──────────
│ Jabber, GoogleTalk: <mildred at jabber.fr>
│ Website: <http://ki.lya.online.fr>           GPG ID: 9A7D 2E2B
│ Fingerprint: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 9A7D 2E2B


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/lisaac-devel/attachments/20090827/3f4e152e/attachment.pgp>


More information about the Lisaac-devel mailing list