Lua 5.3 -- SOL2.0 用户指南 【1】
SOL2.2 是一个快速、简单的C++与LUA的绑定器。如果确定要在你的程序里面同时运行Lua和C++,SOL 是一个高性能的绑定器,是一个API使用方便的 GO-TO 框架。
简单看一下特点:这个链接到(未链接)大部分API。您也可以直接浏览API或阅读教程。要了解有关usertypes的实现的详细信息,请参阅此处要了解如何处理函数参数,请参阅此注释。看不到你想要的功能?向问题跟踪器发送有关特定抽象支持的请求。
下面的代码和更多示例可以在examples目录中找到
#define SOL_CHECK_ARGUMENTS 1 #include <sol.hpp>
#include "../assert.hpp" int main() {
sol::state lua;
int x = 0;
lua.set_function("beep", [&x]{ ++x; });
lua.script("beep()");
c_assert(x == 1); sol::function beep = lua["beep"];
beep();
c_assert(x == 2); return 0;
}
#define SOL_CHECK_ARGUMENTS 1 #include <sol.hpp>
#include "../assert.hpp" struct vars {
int boop = 0; int bop () const {
return boop + 1;
}
}; int main() {
sol::state lua;
lua.new_usertype<vars>("vars",
"boop", &vars::boop,
"bop", &vars::bop);
lua.script("beep = vars.new()\n"
"beep.boop = 1\n"
"bopvalue = beep:bop()"); vars& beep = lua["beep"];
int bopvalue = lua["bopvalue"]; c_assert(beep.boop == 1);
c_assert(lua.get<vars>("beep").boop == 1);
c_assert(beep.bop() == 2);
c_assert(bopvalue == 2); return 0;
}

Lua 5.3 -- SOL2.0 用户指南 【1】的更多相关文章
- Lua 5.3 -- SOL2.0 用户指南 【2】
系列教程指南[1] 注意 在你学习了sol的基础知识之后,建议你如果认为某些东西可以运行,你应该尝试一下.它可能会运行! 以下所有代码均可在sol2教程示例中找到. 断言/先决条件 The imple ...
- Gradle2.0用户指南翻译——第一章. 介绍
翻译项目请关注Github上的地址:https://github.com/msdx/gradledoc本文翻译所在分支:https://github.com/msdx/gradledoc/tree/2 ...
- Gradle2.0用户指南翻译——第三章. 教程
翻译项目请关注Github上的地址:https://github.com/msdx/gradledoc本文翻译所在分支:https://github.com/msdx/gradledoc/tree/2 ...
- Gradle2.0用户指南翻译——第二章. 概述
翻译项目请关注Github上的地址:https://github.com/msdx/gradledoc本文翻译所在分支:https://github.com/msdx/gradledoc/tree/2 ...
- Netty4.0 用户指南
原文链接http://netty.io/wiki/user-guide-for-4.x.html 前言 Nowadays we use general purpose applications or ...
- 【翻译】Flume 1.8.0 User Guide(用户指南) Processors
翻译自官网flume1.8用户指南,原文地址:Flume 1.8.0 User Guide 篇幅限制,分为以下5篇: [翻译]Flume 1.8.0 User Guide(用户指南) [翻译]Flum ...
- 【翻译】Flume 1.8.0 User Guide(用户指南) Channel
翻译自官网flume1.8用户指南,原文地址:Flume 1.8.0 User Guide 篇幅限制,分为以下5篇: [翻译]Flume 1.8.0 User Guide(用户指南) [翻译]Flum ...
- 【翻译】Flume 1.8.0 User Guide(用户指南) Sink
翻译自官网flume1.8用户指南,原文地址:Flume 1.8.0 User Guide 篇幅限制,分为以下5篇: [翻译]Flume 1.8.0 User Guide(用户指南) [翻译]Flum ...
- 【翻译】Flume 1.8.0 User Guide(用户指南) source
翻译自官网flume1.8用户指南,原文地址:Flume 1.8.0 User Guide 篇幅限制,分为以下5篇: [翻译]Flume 1.8.0 User Guide(用户指南) [翻译]Flum ...
随机推荐
- (转)SpringBoot :(has no explicit mapping for /error)
转载自:https://www.cnblogs.com/panchanggui/p/9945261.html 异常:This application has no explicit mapping f ...
- 广告行业中那些趣事系列7:实战腾讯开源的文本分类项目NeuralClassifier
摘要:本篇主要分享腾讯开源的文本分类项目NeuralClassifier.虽然实际项目中使用BERT进行文本分类,但是在不同的场景下我们可能还需要使用其他的文本分类算法,比如TextCNN.RCNN等 ...
- setTimeout和setImmediate到底谁先执行,本文让你彻底理解Event Loop
笔者以前面试的时候经常遇到写一堆setTimeout,setImmediate来问哪个先执行.本文主要就是来讲这个问题的,但是不是简单的讲讲哪个先,哪个后.笼统的知道setImmediate比setT ...
- Journal of Proteome Research | Improving Silkworm Genome Annotation Using a Proteogenomics Approach (分享人:张霞)
题目:Improving Silkworm Genome Annotation Using a Proteogenomics Approach 期刊:Journal of Proteome Resea ...
- Journal of Proteome Research | Quantifying Protein-Specific N-Glycome Profiles by Focused Protein and Immunoprecipitation Glycomics (分享人:潘火珍)
文献名:Quantifying Protein-Specific N-Glycome Profiles by Focused Protein and Immunoprecipitation Glyco ...
- Python之open()函数
Python内置了读写文件的函数open(). # 方法一 # 使用Python内置的open()函数,传入文件名和标示符 f = open('E:/test/driver.py', 'r', enc ...
- Linux 基础篇(二)
1.linux 关机和重启 关机: shutdown -h 10:20 # 指定时间关机 shutdown -h now # 马上关机 shutdown -h +10 # 10分钟后关机 ...
- Consider defining a bean named 'authenticator' in your configuration.
SpringBoot整合Shiro时出错: 异常日志: o.s.b.d.LoggingFailureAnalysisReporter: *************************** APPL ...
- sql学习~pivot和unpivot用法
pivot 可以把列值转换为输出中的多个列. pivot 可以在其他剩余的列的值上执行聚合函数. unpivot 将列转换为列值 语法 SELECT <non-pivoted column&g ...
- 【翻译】如何使用 OpenVINO 来优化 OpenCV
本文翻译自 Vishwesh Shrimali 的 "Using OpenVINO with OpenCV" 原文链接: https://www.learnopencv.com/ ...