diff options
author | chai <chaifix@163.com> | 2019-03-29 22:51:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-29 22:51:04 +0800 |
commit | c302f5ae5f9e30a28e487e8a764d9cc31546bbea (patch) | |
tree | 7f18bedeece950600336ea7ced7c52c468552c98 /source/modules/asura-utils/io/binding/_io_task.cpp | |
parent | 157530b8b6e11efc5573d5a0db8987a440197aa1 (diff) |
*rename
Diffstat (limited to 'source/modules/asura-utils/io/binding/_io_task.cpp')
-rw-r--r-- | source/modules/asura-utils/io/binding/_io_task.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source/modules/asura-utils/io/binding/_io_task.cpp b/source/modules/asura-utils/io/binding/_io_task.cpp new file mode 100644 index 0000000..b3c5988 --- /dev/null +++ b/source/modules/asura-utils/io/binding/_io_task.cpp @@ -0,0 +1,46 @@ +#include "../io_task.h" + +using namespace std; + +namespace AsuraEngine +{ + namespace IO + { + + LUAX_REGISTRY(IOTask) + { + LUAX_REGISTER_METHODS(state, + { "New", _New } + ); + } + + LUAX_POSTPROCESS(IOTask) + { + LUAX_REGISTER_ENUM(state, "EIOTaskType", + { "READ", IOTASK_TYPE_READ }, + { "WRITE", IOTASK_TYPE_WRITE }, + { "APPEND", IOTASK_TYPE_APPEND } + ); + + } + + // task = IOTask.New(path, buffer, type, callback) + LUAX_IMPL_METHOD(IOTask, _New) + { + LUAX_STATE(L); + + cc8* path = state.CheckValue<cc8*>(1); + DataBuffer* db = state.CheckUserdata<DataBuffer>(2); + IOTaskType type = (IOTaskType)state.CheckValue<int>(3); + bool cbk = state.GetTop() >= 4 && state.IsType(4, LUA_TFUNCTION); + + IOTask* task = new IOTask(path, db, type); + task->SetLuaxMemberRef(state, task->mBufferRef, 2); + if(cbk) + task->SetLuaxMemberRef(state, task->mCallback, 4); + task->PushLuaxUserdata(state); + return 1; + } + + } +} |