From 69f364d7fe93e317cf7e315ef0eea400a3452c0b Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 8 Jun 2010 01:06:24 +0200 Subject: Fixing various loading issues with luagmp. --- Makefile | 2 +- src/lgmp.lua | 17 ++++++++++------- src/plugin-luagmp.cc | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 5f2c9d2..27dbb76 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ INCLUDES = \ -I $(FINK)/sw/include \ -I $(GMPDIR)/include \ -HAVES = -DHAVE_VSSCANF -DHAVE_LIBJPEG -DHAVE_FCNTL -DHAVE_UNISTD_H -DHAVE_FORK -DHAVE_PIPE -DHAVE_FSYNC -DHAVE_MALLOC_H -DHAVE_ASPRINTF -DHAVE_BYTESWAP_H -DCD_NO_OLD_INTERFACE -DGTK_DISABLE_DEPRECATED -DIUPLUA_USELOH -DUSE_STATIC +HAVES = -DHAVE_VSSCANF -DHAVE_LIBJPEG -DHAVE_FCNTL -DHAVE_UNISTD_H -DHAVE_FORK -DHAVE_PIPE -DHAVE_FSYNC -DHAVE_MALLOC_H -DHAVE_ASPRINTF -DHAVE_BYTESWAP_H -DUSE_STATIC CPPFLAGS_NO_ARCH += $(INCLUDES) -O4 -fexceptions -DSTDC_HEADERS -DREADLINE_STATIC -DHOOK_STDS -DWORDS_LITTLEENDIAN $(HAVES) -DTEC_LITTLEENDIAN -g -DNDEBUG -DUSE_MGL_NAMESPACE CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/src/lgmp.lua b/src/lgmp.lua index 2a09639..98bc6af 100644 --- a/src/lgmp.lua +++ b/src/lgmp.lua @@ -97,8 +97,8 @@ local function checkfopt(obj) assert(obj == nil or isf(obj), "gmp floating point expected") end -local dtoz = prv.mpz_init_set_d -local dtof = prv.mpf_init_set_d +local dtoz +local dtof function z(value, base) if value == nil then @@ -1281,8 +1281,6 @@ function fmeta:get_d_2exp() return prv.mpf_get_d_2exp(self) end -get_default_prec = prv.mpf_get_default_prec - function fmeta:get_prec() checkf(self) return prv.mpf_get_prec(self) @@ -1625,15 +1623,20 @@ function fmeta:format(fmt, p) end function lgmp_lua_init(l_prv, l_aux) + prv = l_prv + aux = l_aux + aux.randmeta = randmeta aux.zmeta = zmeta aux.fmeta = fmeta - prv = l_prv - aux = l_aux - lgmpversion = prv.version + dtoz = prv.mpz_init_set_d + dtof = prv.mpf_init_set_d + + get_default_prec = prv.mpf_get_default_prec + lgmp_init = nil end diff --git a/src/plugin-luagmp.cc b/src/plugin-luagmp.cc index 82c917f..354c48c 100644 --- a/src/plugin-luagmp.cc +++ b/src/plugin-luagmp.cc @@ -2503,6 +2503,7 @@ extern unsigned char lgmp[]; static int _init_plugin(Lua *L) { + while (L->gettop()) L->remove(1); L->newtable(); // [1] = prv L->newtable(); // [2] = aux L->wrap_open(lgmp_initialize); -- cgit v1.2.3