zoloypzuo / zeloengine Goto Github PK
View Code? Open in Web Editor NEWGame Engine in C++/OpenGL/Lua
License: MIT License
Game Engine in C++/OpenGL/Lua
License: MIT License
Detected memory leaks!
Dumping objects ->
{305} normal block at 0x00FE7738, 68 bytes long.
Data: <${$ > 24 7B 24 00 00 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
基本的概念已经有了
lua没有路径的标准
current dir或者working dir是固定的,就是lua.exe启动的地方,是由操作系统定义的
比如emmylua指定work dir,就是先cd到work dir,再启动lua.exe
我想要的是c的include的current script dir的概念,就是他自己搜索当前路径
我记得有一个搜索器的概念,我可以试一试
====
lua模块的组织
dll统一放在一个目录即可,luarocks是这么做的
这个dll就是lua用的(是包含导出到lua的专用函数的),所以没必要分散开来
lua脚本不一样,确实可能在不同地方
,模块要放在一起,确实可能有多个地方放模块
比如zelo需要这样
要添加Util目录
要填Src/Script目录
=====
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
> require "cmake_compiler"
add_executable(aaa ${SRC_LIST})
D:\ZeloEngine\Src\Script\list.lua:28: C stack overflow
stack traceback:
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
...
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:28: in metamethod '__index'
D:\ZeloEngine\Src\Script\list.lua:32: in metamethod '__newindex'
D:\ZeloEngine\Src\Script\list.lua:11: in field '_ctor'
D:\ZeloEngine\Src\Script\Class.lua:234: in global 'list'
D:\ZeloEngine\Util\cpp.lua:27: in function 'header_guard'
D:\ZeloEngine\Util\cmake_compiler\cmake_compiler.lua:36: in function 'example_project'
D:\ZeloEngine\Util\cmake_compiler\cmake_compiler.lua:45: in main chunk
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
// 初始化窗口(渲染窗口和console窗口)
// console输出helloword
PiL的例子上就封装过一些
但是我的建议是不要封装
暴露得如此彻底,而且auxlib提供了一些封装
说到底是为什么?
就是C API你可以发现一个操作比如push*,to*,*需要有各个lua类型的版本
所以当你试图去封装的时候,也是每个类型都要有一个版本
这种封装是非常低效的,通用性也可能不太好,经常需要改动,就变得复杂,背离了封装的本意
Detected memory leaks!
Dumping objects ->
{251} normal block at 0x00E5B7E8, 32 bytes long.
Data: <D 3 D 1 1 A p > 44 00 33 00 44 00 31 00 31 00 20 00 41 00 70 00
{250} normal block at 0x00E5E780, 8 bytes long.
Data: < > BC 82 E6 00 00 00 00 00
{249} normal block at 0x00E68290, 112 bytes long.
Data: <4Z h c ` > 34 5A 0A 00 68 13 98 03 B4 63 EF 00 60 EB F0 00
Detected memory leaks!
Dumping objects ->
{351} normal block at 0x008302D8, 8 bytes long.
Data: < 6 > B0 36 84 00 00 00 00 00
Object dump complete.
The program '[31096] Chapter4_Direct3D_Initialization.exe' has exited with code 0 (0x0).
比如我写cmake-compiler
我想写一个log-error函数
突然我想改个名字为error
注意动机是我在写另外一个语言,cmake和lua当然有重复的语言成分
我会习惯性地去一样地命名
然后就覆盖了lua的error
====
事实上,这个事情应该有一个自动的保护措施
比如,strict.lua里全局变量禁止修改
禁止修改又太那个了
有些时候,我自己要重写标准库,比如print,require,但是这个量很少
所以你要开辟一个地方去重写标准库
函数的话,没有意外确实不应该修改
但是值就不一定了
===
这里暂时不去想,目前还没有影响
参考unity标准库
用例如下:
o.pos=mul(UNITY_MVP, v.position);
就是每个脚本运行在自己的环境中,不要污染解释器的全局环境
还要提供自动的,将全局变量导出的功能,其他模块require一下就能访问全局变量
太多了
简单分析一下把
就是他的lua-binding,都没有finializer
lua调用createxxx去实例化一个东西,他都没有回收的过程
包括Sandbox-Cleanup这种函数,都是空的,手工回收也没有
之前就有想法
当时的一个想法是,编辑时导入一个伪api的lua脚本,运行时不走这个
Sandbox这里有一个问题,他是全局注入的,你不需要require就有了,这样不好
可以重写一下,封装,运行时也带着走,这样需要每次多调用一次函数
====
所以一个IDE,至少要支持Lua的智能提示,还要有方法显示C模块的智能提示
在饥荒项目运行lua脚本,因为环境变量运行了global.lua,他找不到同目录的std-extension.lua
D:\ZeloEngine\lua.exe: D:\ZeloEngine\Src\Script\global.lua:12: module 'std_extension' not found:
no field package.preload['std_extension']
no file 'D:\LuaRocks\lua\std_extension.lua'
no file '
D:\LuaRocks\lua\std_extension\init.lua'
no file '
D:\ZeloEngine\lua\std_extension.lua'
no file '
D:\ZeloEngine\lua\std_extension\init.lua'
no file '
D:\ZeloEngine\std_extension.lua'
no file '
D:\ZeloEngine\std_extension\init.lua'
no file '
D:\ZeloEngine\..\share\lua\5.3\std_extension.lua'
no file '
D:\ZeloEngine\..\share\lua\5.3\std_extension\init.lua'
no file '
.\std_extension.lua'
no file '
.\std_extension\init.lua'
no file '
C:\Users\91018\AppData\Roaming/luarocks/share/lua/5.3/std_extension.lua'
no file '
C:\Users\91018\AppData\Roaming/luarocks/share/lua/5.3/std_extension/init.lua'
no file '
D:\LuaRocks\systree/share/lua/5.3/std_extension.lua'
no file '
D:\LuaRocks\systree/share/lua/5.3/std_extension/init.lua'
no file '
D:\ZeloEngine\Src\Script\std_extension.lua'
no file 'D:\ZeloEngine\std_extension.dll'
no file '
D:\ZeloEngine\..\lib\lua\5.3\std_extension.dll'
no file '
D:\ZeloEngine\loadall.dll'
no file '.\std_extension.dll'
no file '
D:\ZeloEngine\std_extension53.dll'
no file '
.\std_extension53.dll'
no file '
C:\Users\91018\AppData\Roaming/luarocks/lib/lua/5.3/std_extension.dll'
no file '
D:\LuaRocks\systree/lib/lua/5.3/std_extension.dll'
stack traceback:
[C]: in function 'require'
D:\ZeloEngine\Src\Script\global.lua:12: in main chunk
[C]: in ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.