⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cln_test.cpp.svn-base

📁 本人找过多个在linux下c++的lua5.1封装库,但很少.luabind已经release的版本只支持lua5.0.这个版本是我从其cvs(svc)上取出的并支持最新的lua5.1.强烈推荐.
💻 SVN-BASE
字号:
#include <cln/cln.h>extern "C"{	#include "lua.h"	#include "lualib.h"	#include "lauxlib.h"}#include <luabind/luabind.hpp>void bind_cln(lua_State* L){	using namespace luabind;	using namespace cln;	module(L)	[		// real numbers		class_<cl_R>("cl_R")			.def(constructor<>())			.def(constructor<const cl_I&>())			.def(constructor<float>())			.def(constructor<const char*>())			.def(tostring(const_self))			.def(-self)			.def(const_self + const_self)			.def(const_self - const_self)			.def(const_self * const_self)			.def(const_self / const_self)			.def(const_self <= const_self)			.def(const_self < const_self)			.def(const_self == const_self)			.def(other<int>() + const_self)			.def(other<int>() - const_self)			.def(other<int>() * const_self)			.def(other<int>() / const_self)			.def(other<int>() <= const_self)			.def(other<int>() < const_self)			.def(const_self + other<int>())			.def(const_self - other<int>())			.def(const_self * other<int>())			.def(const_self / other<int>())			.def(const_self <= other<int>())			.def(const_self < other<int>())			,				// rational numbers		class_<cl_RA, cl_R>("cl_RA")			.def(constructor<>())			.def(constructor<const cl_I&>())			.def(constructor<int>())			.def(constructor<const char*>())			.def(tostring(const_self))			.def(-self)			.def(const_self + const_self)			.def(const_self - const_self)			.def(const_self * const_self)			.def(const_self / const_self)			.def(const_self <= const_self)			.def(const_self < const_self)			.def(const_self == const_self)			.def(other<int>() + const_self)			.def(other<int>() - const_self)			.def(other<int>() * const_self)			.def(other<int>() / const_self)			.def(other<int>() <= const_self)			.def(other<int>() < const_self)			.def(const_self + other<int>())			.def(const_self - other<int>())			.def(const_self * other<int>())			.def(const_self / other<int>())			.def(const_self <= other<int>())			.def(const_self < other<int>())			,		// integers		class_<cl_I, cl_RA>("cl_I")			.def(constructor<>())			.def(constructor<const cl_I&>())			.def(constructor<int>())			.def(constructor<const char*>())			.def(tostring(const_self))			.def(-self)			.def(const_self + const_self)			.def(const_self - const_self)			.def(const_self * const_self)			.def(const_self <= const_self)			.def(const_self < const_self)			.def(const_self == const_self)			.def(other<int>() + const_self)			.def(other<int>() - const_self)			.def(other<int>() * const_self)			.def(other<int>() <= const_self)			.def(other<int>() < const_self)			.def(const_self + other<int>())			.def(const_self - other<int>())			.def(const_self * other<int>())			.def(const_self <= other<int>())			.def(const_self < other<int>())			,					def("factorial", &cln::factorial),		def("sqrt", (const cl_R(*)(const cl_R&))&cln::sqrt)	];}int main(){	lua_State* L = lua_open();	lua_baselibopen(L);	lua_mathlibopen(L);	luabind::open(L);	bind_cln(L);	lua_dofile(L, "cln_test.lua");	lua_close(L);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -