diff options
author | chai <chaifix@163.com> | 2019-03-29 00:43:25 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-29 00:43:25 +0800 |
commit | f4c338c63f3456a8eccd56c35e233843687d55be (patch) | |
tree | 7278fe4723320c9ef310c5a04d92bf0be1bc778c /source/libs/asura-lib-utils/io/binding/_io_task.cpp | |
parent | 3bced067a4144381e59ce4bd0eb749eeff5ad1f4 (diff) |
*thread
Diffstat (limited to 'source/libs/asura-lib-utils/io/binding/_io_task.cpp')
-rw-r--r-- | source/libs/asura-lib-utils/io/binding/_io_task.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/libs/asura-lib-utils/io/binding/_io_task.cpp b/source/libs/asura-lib-utils/io/binding/_io_task.cpp index c03ff2a..b3c5988 100644 --- a/source/libs/asura-lib-utils/io/binding/_io_task.cpp +++ b/source/libs/asura-lib-utils/io/binding/_io_task.cpp @@ -16,19 +16,29 @@ namespace AsuraEngine LUAX_POSTPROCESS(IOTask) { + LUAX_REGISTER_ENUM(state, "EIOTaskType", + { "READ", IOTASK_TYPE_READ }, + { "WRITE", IOTASK_TYPE_WRITE }, + { "APPEND", IOTASK_TYPE_APPEND } + ); } - // task = IOTask.New(path, dst) + // task = IOTask.New(path, buffer, type, callback) LUAX_IMPL_METHOD(IOTask, _New) { LUAX_STATE(L); - cc8* path = state.CheckParam<cc8*>(1); + cc8* path = state.CheckValue<cc8*>(1); DataBuffer* db = state.CheckUserdata<DataBuffer>(2); - IOTask* task = new IOTask(path, db); + 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); - task->SetLuaxMemberRef(state, task->mDstRef, 2); return 1; } |