Re: [Vala] GMP vapi
- From: Jeremiah Shaulov <thecoolfoobar gmail com>
- To: vala-list gnome org, Toineo <tux toineo gmail com>
- Subject: Re: [Vala] GMP vapi
- Date: Wed, 10 Aug 2011 23:20:49 +0300
On Thu, 2011-08-04 at 11:22 +0200, Toineo wrote:
Hi !
I'm very interested in your implementation of GMP in vala.
Do you accept to share it ?
You should maybe share it on
http://live.gnome.org/Vala/ExternalBindings ,
as L. Bruno suggested ; it would give it more visibility...
Best regards
Hi,
I posted gmp.vapi to live.gnome.org:
http://live.gnome.org/Vala/ExternalBindings?action=AttachFile&do=view&target=gmp.vapi
Everybody is welcome to download.
I found no way to make this binding standalone, and i wrote about this
in the list. So additional C header file is required to compile. Create
file named "gmp-vapi.h" with the following content (this is also noted
in gmp.vapi in top comment):
#include <stdio.h>
#include <string.h>
#include <gmp.h>
#
#ifndef vala_mpz_init
#
# define vala_mpz_init(self, bitcnt) (bitcnt==0 ? \
(void)mpz_init(self) : (void)mpz_init2(self, bitcnt))
# define vala_mpf_init(self, bitcnt) (bitcnt==0 ? \
(void)mpf_init(self) : (void)mpf_init2(self, bitcnt))
#
# define vala_gmp_randstate_copy(from, to) \
gmp_randinit_set(to, from)
# define vala_mpz_copy(from, to) mpz_init_set(to, from)
# define vala_mpf_copy(from, to) mpf_init_set(to, from)
#
#endif
Example program "test.vala":
using GLib;
using Gmp;
public class Test : Object
{ public static int main (string[] args)
{ var a = Float.string("123.456");
var b = Float.double(987.654);
a.mul(a, b); // a = a * b
Gmp.printf("Result: %Ff\n", a);
return 0;
}
}
Compile:
valac test2.vala --pkg gmp --vapidir="." -X -I. -X -lgmp
--vapidir="." is needed if gmp.vapi is located in current directory,
instead of default location (/usr/share/vala/vapi/).
-X -I. is needed if gmp-vapi.h is located in current directory, instead
of default location (/usr/include/).
-X -lgmp is always needed since GMP doesn't support pkg-config.
Please let me know if you have troubles with this, or if you find bugs.
Best regards
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]