add eIOBytesAvailable and eIOCanReadLine

This commit is contained in:
Syping 2020-07-27 16:54:42 +02:00
parent ec0d999365
commit dacc426838
2 changed files with 32 additions and 0 deletions

View file

@ -44,6 +44,8 @@ void LuaEngineIO::pushClass(lua_State *L_p)
pushVariant(L_p, "Subdirectories", (int)4); pushVariant(L_p, "Subdirectories", (int)4);
// Engine IO // Engine IO
pushFunction(L_p, "eIOBytesAvailable", eIOBytesAvailable);
pushFunction(L_p, "eIOCanReadLine", eIOCanReadLine);
pushFunction(L_p, "eIORead", eIORead); pushFunction(L_p, "eIORead", eIORead);
pushFunction(L_p, "eIOReadAll", eIOReadAll); pushFunction(L_p, "eIOReadAll", eIOReadAll);
pushFunction(L_p, "eIOReadLine", eIOReadLine); pushFunction(L_p, "eIOReadLine", eIOReadLine);
@ -93,6 +95,34 @@ int LuaEngineIO::checkFileExists(lua_State *L_p)
return 1; return 1;
} }
int LuaEngineIO::eIOBytesAvailable(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 2) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QIODevice")) {
pushVariant(L_p, ((QIODevice*)pointer)->bytesAvailable());
return 1;
}
}
}
return 0;
}
int LuaEngineIO::eIOCanReadLine(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 2) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QIODevice")) {
pushVariant(L_p, ((QIODevice*)pointer)->canReadLine());
return 1;
}
}
}
return 0;
}
int LuaEngineIO::eIORead(lua_State *L_p) int LuaEngineIO::eIORead(lua_State *L_p)
{ {
if (getArgumentCount(L_p) >= 2) { if (getArgumentCount(L_p) >= 2) {

View file

@ -32,6 +32,8 @@ public:
static void pushClass(LuaEngine *luaEngine); static void pushClass(LuaEngine *luaEngine);
static int checkDirectoryExists(lua_State *L_p); static int checkDirectoryExists(lua_State *L_p);
static int checkFileExists(lua_State *L_p); static int checkFileExists(lua_State *L_p);
static int eIOBytesAvailable(lua_State *L_p);
static int eIOCanReadLine(lua_State *L_p);
static int eIORead(lua_State *L_p); static int eIORead(lua_State *L_p);
static int eIOReadAll(lua_State *L_p); static int eIOReadAll(lua_State *L_p);
static int eIOReadLine(lua_State *L_p); static int eIOReadLine(lua_State *L_p);