MiMoEngine ASM: x86-64 MASM汇编+C混合架构游戏引擎
核心热路径(数学/内存/字符串/性能分析)用MASM汇编(SSE/AVX2) 外围系统(窗口/渲染/ECS/音频/UI/脚本)用C语言 含自研编辑器、VisualScript积木编程、中文渲染(glyph_atlas)
This commit is contained in:
commit
2d56cb3bc9
91 files changed
+9988
No files matched your search
@@ -0,0 +1,60 @@
|
||||
#include "lua_engine.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Lua头文件 (需要单独下载或集成)
|
||||
// #include <lua.h>
|
||||
// #include <lualib.h>
|
||||
// #include <lauxlib.h>
|
||||
|
||||
// 由于Lua需要单独集成,这里提供占位实现
|
||||
// 实际使用时取消注释并链接Lua库
|
||||
|
||||
typedef struct lua_State lua_State;
|
||||
|
||||
static lua_State* luaL_newstate(void) { return NULL; }
|
||||
static void luaL_openlibs(lua_State* L) { (void)L; }
|
||||
static int luaL_dofile(lua_State* L, const char* fn) { (void)L; (void)fn; return -1; }
|
||||
static int luaL_dostring(lua_State* L, const char* s) { (void)L; (void)s; return -1; }
|
||||
static void lua_close(lua_State* L) { (void)L; }
|
||||
|
||||
LuaEngine* lua_engine_create(void) {
|
||||
return (LuaEngine*)calloc(1, sizeof(LuaEngine));
|
||||
}
|
||||
|
||||
void lua_engine_destroy(LuaEngine* engine) {
|
||||
if (!engine) return;
|
||||
if (engine->L) lua_close(engine->L);
|
||||
free(engine);
|
||||
}
|
||||
|
||||
int lua_engine_init(LuaEngine* engine) {
|
||||
engine->L = luaL_newstate();
|
||||
if (!engine->L) return -1;
|
||||
luaL_openlibs(engine->L);
|
||||
engine->initialized = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_engine_do_file(LuaEngine* engine, const char* path) {
|
||||
if (!engine->L) return -1;
|
||||
return luaL_dofile(engine->L, path);
|
||||
}
|
||||
|
||||
int lua_engine_do_string(LuaEngine* engine, const char* code) {
|
||||
if (!engine->L) return -1;
|
||||
return luaL_dostring(engine->L, code);
|
||||
}
|
||||
|
||||
void lua_engine_register_function(LuaEngine* engine, const char* name, void* func) {
|
||||
(void)engine;
|
||||
(void)name;
|
||||
(void)func;
|
||||
// lua_pushcfunction(engine->L, func);
|
||||
// lua_setglobal(engine->L, name);
|
||||
}
|
||||
|
||||
lua_State* lua_engine_get_state(LuaEngine* engine) {
|
||||
return engine->L;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
// ============================================================================
|
||||
// lua_engine.h - Lua脚本引擎
|
||||
// ============================================================================
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// 前向声明
|
||||
struct lua_State;
|
||||
|
||||
typedef struct {
|
||||
struct lua_State* L;
|
||||
int initialized;
|
||||
} LuaEngine;
|
||||
|
||||
// 创建/销毁
|
||||
LuaEngine* lua_engine_create(void);
|
||||
void lua_engine_destroy(LuaEngine* engine);
|
||||
|
||||
// 初始化
|
||||
int lua_engine_init(LuaEngine* engine);
|
||||
|
||||
// 执行
|
||||
int lua_engine_do_file(LuaEngine* engine, const char* path);
|
||||
int lua_engine_do_string(LuaEngine* engine, const char* code);
|
||||
|
||||
// 注册C函数
|
||||
void lua_engine_register_function(LuaEngine* engine, const char* name, void* func);
|
||||
|
||||
// 获取状态
|
||||
struct lua_State* lua_engine_get_state(LuaEngine* engine);
|
||||
Reference in new issue
Block a user