aboutsummaryrefslogtreecommitdiff
path: root/src/lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-21 13:37:27 +0800
committerchai <chaifix@163.com>2018-10-21 13:37:27 +0800
commit066e5987c515dfc34537d73ca9d2a81ddd1f9e1b (patch)
treeec45fe523daa4f9e8a30db0a045a0eb9cee84822 /src/lua
parent3292019e55dd02a96420e72bad88711fd36ef249 (diff)
*注释
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/jin.cpp1
-rw-r--r--src/lua/main.cpp5
-rw-r--r--src/lua/modules/audio/audio.cpp4
-rw-r--r--src/lua/modules/filesystem/filesystem.cpp10
-rw-r--r--src/lua/modules/graphics/canvas.cpp6
-rw-r--r--src/lua/modules/graphics/graphics.cpp13
-rw-r--r--src/lua/modules/graphics/texture.cpp6
-rw-r--r--src/lua/resources/font.ttf.h11
8 files changed, 31 insertions, 25 deletions
diff --git a/src/lua/jin.cpp b/src/lua/jin.cpp
index 4d8837a..faae9b2 100644
--- a/src/lua/jin.cpp
+++ b/src/lua/jin.cpp
@@ -78,6 +78,7 @@ namespace JinEngine
{ "math", luaopen_math },
{ "thread", luaopen_thread },
{ "bit", luaopen_bit },
+ //{"ai", luaopen_ai },
{ 0, 0 }
};
diff --git a/src/lua/main.cpp b/src/lua/main.cpp
index a17ed1c..495ca6f 100644
--- a/src/lua/main.cpp
+++ b/src/lua/main.cpp
@@ -28,16 +28,17 @@ int main(int argc, char* argv[])
/* absolute directory */
Buffer cwd = Buffer(1024);
#ifdef _WIN32
- _getcwd((char*)cwd.data, cwd.size);
+ _getcwd((char*)&cwd, cwd.size());
#elif defined __unix__
#elif defined __APPLE__
#endif
- luax_setfieldstring(L, "cwd", (char*)cwd.data);
+ luax_setfieldstring(L, "cwd", (char*)&cwd);
luax_clear(L);
/* boot jin and run it */
boot(L);
luax_close(L);
+
return 0;
} \ No newline at end of file
diff --git a/src/lua/modules/audio/audio.cpp b/src/lua/modules/audio/audio.cpp
index 0aa4a29..198323d 100644
--- a/src/lua/modules/audio/audio.cpp
+++ b/src/lua/modules/audio/audio.cpp
@@ -70,12 +70,12 @@ namespace JinEngine
error(L, "No such image %s", f);
goto fail;
}
- if (!fs->read(f, &b))
+ if (!fs->read(f, b))
{
error(L, "Failed to read source file %s", f);
goto fail;
}
- Source* src = Source::createSource(b.data, b.size);
+ Source* src = Source::createSource((void*)&b, b.size());
if (src == nullptr)
{
error(L, "Failed to decode source file %s", f);
diff --git a/src/lua/modules/filesystem/filesystem.cpp b/src/lua/modules/filesystem/filesystem.cpp
index f46f8d9..7466ce8 100644
--- a/src/lua/modules/filesystem/filesystem.cpp
+++ b/src/lua/modules/filesystem/filesystem.cpp
@@ -55,8 +55,8 @@ namespace JinEngine
{
const char* filename = lua_tostring(L, -1);
Buffer bf;
- context.fs->read(filename, &bf);
- luax_loadbuffer(L, (const char*)bf.data, bf.size, filename);
+ context.fs->read(filename, bf);
+ luax_loadbuffer(L, (const char*)&bf, bf.size(), filename);
return 1;
}
@@ -113,9 +113,9 @@ namespace JinEngine
const char* file = luax_checkstring(L, 1);
unsigned int len;
Buffer buffer;
- buffer.data = (char*)fs->read(file, &buffer.size);
- luax_pushstring(L, (char*)buffer.data);
- luax_pushinteger(L, buffer.size);
+ fs->read(file, buffer);
+ luax_pushstring(L, (char*)&buffer);
+ luax_pushinteger(L, buffer.size());
return 2;
}
diff --git a/src/lua/modules/graphics/canvas.cpp b/src/lua/modules/graphics/canvas.cpp
index 79e7282..b64dc16 100644
--- a/src/lua/modules/graphics/canvas.cpp
+++ b/src/lua/modules/graphics/canvas.cpp
@@ -40,12 +40,12 @@ namespace JinEngine
return 2;
}
- static int l_setAnchor(lua_State* L)
+ static int l_setOrigin(lua_State* L)
{
CanvasRef ref = checkCanvas(L);
int x = luax_checknumber(L, 1);
int y = luax_checknumber(L, 2);
- ref->setAnchor(x, y);
+ ref->setOrigin(x, y);
return 0;
}
@@ -61,7 +61,7 @@ namespace JinEngine
{ "getWidth", l_getWidth },
{ "getHeight", l_getHeight },
{ "getSize", l_getSize },
- { "setAnchor", l_setAnchor },
+ { "setOrigin", l_setOrigin },
{ 0, 0 }
};
diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp
index 573f319..4ff0dfc 100644
--- a/src/lua/modules/graphics/graphics.cpp
+++ b/src/lua/modules/graphics/graphics.cpp
@@ -10,6 +10,7 @@ namespace JinEngine
{
namespace Lua
{
+
using namespace std;
using namespace JinEngine;
using namespace JinEngine::Graphics;
@@ -125,12 +126,12 @@ namespace JinEngine
goto fail;
}
Buffer b = {};
- if (!fs->read(f, &b))
+ if (!fs->read(f, b))
{
error(L, "Failed to read image %s", f);
goto fail;
}
- bitmap = Bitmap::createBitmap(b.data, b.size);
+ bitmap = Bitmap::createBitmap(&b, b.size());
//const Color* col = bitmap->getPixels();
//ofstream o = ofstream("img.txt", ios_base::app);
//for (int i = 0; i < bitmap->getWidth() * bitmap->getHeight(); ++i)
@@ -195,8 +196,8 @@ namespace JinEngine
return 1;
}
Buffer b;
- fs->read(path, &b);
- Shader* jsl = Shader::createShader((char*)b.data);
+ fs->read(path, b);
+ Shader* jsl = Shader::createShader((char*)&b);
if (jsl == nullptr)
{
error(L, "Failed to compile shader");
@@ -618,8 +619,8 @@ namespace JinEngine
return 1;
}
Buffer b;
- fs->read(path, &b);
- fd = TTFData::createTTFData((unsigned char*)b.data, b.size);
+ fs->read(path, b);
+ fd = TTFData::createTTFData(&b, b.size());
}
proxy->bind(new Ref<TTFData>(fd, JIN_GRAPHICS_TTFDATA));
return 1;
diff --git a/src/lua/modules/graphics/texture.cpp b/src/lua/modules/graphics/texture.cpp
index 63ab5f2..15e258c 100644
--- a/src/lua/modules/graphics/texture.cpp
+++ b/src/lua/modules/graphics/texture.cpp
@@ -32,12 +32,12 @@ namespace JinEngine
return 1;
}
- static int l_setAnchor(lua_State* L)
+ static int l_setOrigin(lua_State* L)
{
TextureRef ref = checkTexture(L);
int x = luax_checknumber(L, 2);
int y = luax_checknumber(L, 3);
- ref->setAnchor(x, y);
+ ref->setOrigin(x, y);
return 0;
}
@@ -61,7 +61,7 @@ namespace JinEngine
{ "getWidth", l_getWidth },
{ "getHeight", l_getHeight },
{ "getSize", l_getSize },
- { "setAnchor", l_setAnchor },
+ { "setOrigin", l_setOrigin },
{ 0, 0 }
};
diff --git a/src/lua/resources/font.ttf.h b/src/lua/resources/font.ttf.h
index 419adc5..d2c6bf1 100644
--- a/src/lua/resources/font.ttf.h
+++ b/src/lua/resources/font.ttf.h
@@ -1,5 +1,6 @@
-static const char default_font_bitmap[] =
-{ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,3,106,0,0,0,13,8,6,0,0,0,
+static const char
+default_font_bitmap[] = {
+137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,3,106,0,0,0,13,8,6,0,0,0,
216,50,157,116,0,0,0,4,103,65,77,65,0,0,177,143,11,252,97,5,0,0,0,9,112,72,89,
115,0,0,14,194,0,0,14,194,1,21,40,74,128,0,0,0,25,116,69,88,116,83,111,102,
116,119,97,114,101,0,112,97,105,110,116,46,110,101,116,32,52,46,48,46,50,49,
@@ -322,9 +323,11 @@ static const char default_font_bitmap[] =
83,181,165,129,61,165,34,198,166,11,125,27,121,156,150,195,96,159,235,175,173,
240,221,188,94,243,174,123,186,222,113,245,132,198,156,239,58,47,16,111,48,78,
129,254,4,62,41,102,5,254,227,227,255,0,188,211,66,64,172,137,134,157,0,0,0,0,
-73, 69, 78, 68, 174, 66, 96, 130 };
+73, 69, 78, 68, 174, 66, 96, 130
+};
-static const char* default_charset = R"( abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.!?;:-_/|\!'"+=*()[]{}&%$#@)";
+static const char*
+default_charset = R"( abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.!?;:-_/|\!'"+=*()[]{}&%$#@)";
#include "libjin/jin.h"