Advertisement
Delfigamer

rsbin/storage.r.lua

Apr 16th, 2018
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.35 KB | None | 0 0
  1. local rptr = ...
  2. local ffi = require("ffi")
  3. local r_exceptionbox = require("reflection.exceptionbox")
  4. local r_wrapobject = require("reflection.wrapobject")
  5. local r_unwrapobject = require("reflection.unwrapobject")
  6. ffi.cdef([[
  7. ]] .. --[==[
  8.     src/rsbin/storage.hpp:10:2:
  9.     rsbin> StorageMap = class() [[r::name("storagemap")]] [[r::struct]]
  10. ]==] [[
  11.     typedef struct rsbin_storagemap {
  12.         uint8_t* ptr;
  13.         uint32_t length;
  14.     } rsbin_storagemap;
  15. ]] .. --[==[
  16.     src/rsbin/storage.hpp:16:2:
  17.     rsbin> MapTask = class(Task) [[r::class]] [[r::name("maptask")]]
  18. ]==] [[
  19.     typedef void rsbin_maptask;
  20.     typedef struct r_rsbin_maptask_box {
  21.         rsbin_maptask* object;
  22.         void(*cfreeptr)(struct r_rsbin_maptask_box* self);
  23.         void* freeptr;
  24.     } r_rsbin_maptask_box;
  25. ]] .. --[==[
  26.     src/rsbin/storage.hpp:21:11:
  27.     rsbin::MapTask> getmap = object function []: StorageMap [[r::method]]
  28. ]==] [[
  29. ]] .. --[==[
  30.     src/rsbin/storage.hpp:24:2:
  31.     rsbin> GetLimitTask = class(Task) [[r::class]] [[r::name("getlimittask")]]
  32. ]==] [[
  33.     typedef void rsbin_getlimittask;
  34.     typedef struct r_rsbin_getlimittask_box {
  35.         rsbin_getlimittask* object;
  36.         void(*cfreeptr)(struct r_rsbin_getlimittask_box* self);
  37.         void* freeptr;
  38.     } r_rsbin_getlimittask_box;
  39. ]] .. --[==[
  40.     src/rsbin/storage.hpp:29:11:
  41.     rsbin::GetLimitTask> getlimit = object function []: uint64_t [[r::method]]
  42. ]==] [[
  43. ]] .. --[==[
  44.     src/rsbin/storage.hpp:32:2:
  45.     rsbin> Storage = class(RefObject) [[r::class]] [[r::name("storage")]]
  46. ]==] [[
  47.     typedef void rsbin_storage;
  48.     typedef struct r_rsbin_storage_box {
  49.         rsbin_storage* object;
  50.         void(*cfreeptr)(struct r_rsbin_storage_box* self);
  51.         void* freeptr;
  52.     } r_rsbin_storage_box;
  53. ]] .. --[==[
  54.     src/rsbin/storage.hpp:41:11:
  55.     rsbin::Storage> startmap = object function [offset: uint64_t, length: uint32_t, flagread: bool, flagwrite: bool]: Ref<MapTask> [[r::method]]
  56. ]==] [[
  57. ]] .. --[==[
  58.     src/rsbin/storage.hpp:45:11:
  59.     rsbin::Storage> startgetlimit = object function [plimit: pointer uint64_t]: Ref<GetLimitTask> [[r::method]]
  60. ]==] [[
  61. ]] .. --[==[
  62.     src/rsbin/storage.hpp:47:11:
  63.     rsbin::Storage> startsetlimit = object function [limit: uint64_t]: Ref<Task> [[r::method]]
  64. ]==] [[
  65. ]] .. --[==[
  66.     src/rsbin/storage.hpp:49:11:
  67.     rsbin::Storage> startflush = object function []: Ref<Task> [[r::method]]
  68. ]==] [[
  69. ]] .. --[==[
  70.     src/rsbin/storage.hpp:51:11:
  71.     rsbin::Storage> startclose = object function []: Ref<Task> [[r::method]]
  72. ]==] [[
  73. ]] .. --[==[
  74.     src/rsbin/storage.hpp:55:1:
  75.     r_emit
  76. ]==] [[
  77. ]])
  78. local ptrtype = [[
  79.     struct{
  80. ]] .. --[==[
  81.     src/rsbin/storage.hpp:10:2:
  82.     rsbin> StorageMap = class() [[r::name("storagemap")]] [[r::struct]]
  83. ]==] [[
  84. ]] .. --[==[
  85.     src/rsbin/storage.hpp:16:2:
  86.     rsbin> MapTask = class(Task) [[r::class]] [[r::name("maptask")]]
  87. ]==] [[
  88. ]] .. --[==[
  89.     src/rsbin/storage.hpp:21:11:
  90.     rsbin::MapTask> getmap = object function []: StorageMap [[r::method]]
  91. ]==] [[
  92.         rsbin_storagemap (*rsbin_maptask_getmap)(rsbin_maptask* self, reflection_exceptionbox* exception);
  93. ]] .. --[==[
  94.     src/rsbin/storage.hpp:24:2:
  95.     rsbin> GetLimitTask = class(Task) [[r::class]] [[r::name("getlimittask")]]
  96. ]==] [[
  97. ]] .. --[==[
  98.     src/rsbin/storage.hpp:29:11:
  99.     rsbin::GetLimitTask> getlimit = object function []: uint64_t [[r::method]]
  100. ]==] [[
  101.         uint64_t (*rsbin_getlimittask_getlimit)(rsbin_getlimittask* self, reflection_exceptionbox* exception);
  102. ]] .. --[==[
  103.     src/rsbin/storage.hpp:32:2:
  104.     rsbin> Storage = class(RefObject) [[r::class]] [[r::name("storage")]]
  105. ]==] [[
  106. ]] .. --[==[
  107.     src/rsbin/storage.hpp:41:11:
  108.     rsbin::Storage> startmap = object function [offset: uint64_t, length: uint32_t, flagread: bool, flagwrite: bool]: Ref<MapTask> [[r::method]]
  109. ]==] [[
  110.         r_rsbin_maptask_box (*rsbin_storage_startmap)(rsbin_storage* self, uint64_t arg1, uint32_t arg2, bool arg3, bool arg4, reflection_exceptionbox* exception);
  111. ]] .. --[==[
  112.     src/rsbin/storage.hpp:45:11:
  113.     rsbin::Storage> startgetlimit = object function [plimit: pointer uint64_t]: Ref<GetLimitTask> [[r::method]]
  114. ]==] [[
  115.         r_rsbin_getlimittask_box (*rsbin_storage_startgetlimit)(rsbin_storage* self, uint64_t* arg1, reflection_exceptionbox* exception);
  116. ]] .. --[==[
  117.     src/rsbin/storage.hpp:47:11:
  118.     rsbin::Storage> startsetlimit = object function [limit: uint64_t]: Ref<Task> [[r::method]]
  119. ]==] [[
  120.         r_task_box (*rsbin_storage_startsetlimit)(rsbin_storage* self, uint64_t arg1, reflection_exceptionbox* exception);
  121. ]] .. --[==[
  122.     src/rsbin/storage.hpp:49:11:
  123.     rsbin::Storage> startflush = object function []: Ref<Task> [[r::method]]
  124. ]==] [[
  125.         r_task_box (*rsbin_storage_startflush)(rsbin_storage* self, reflection_exceptionbox* exception);
  126. ]] .. --[==[
  127.     src/rsbin/storage.hpp:51:11:
  128.     rsbin::Storage> startclose = object function []: Ref<Task> [[r::method]]
  129. ]==] [[
  130.         r_task_box (*rsbin_storage_startclose)(rsbin_storage* self, reflection_exceptionbox* exception);
  131. ]] .. --[==[
  132.     src/rsbin/storage.hpp:55:1:
  133.     r_emit
  134. ]==] [[
  135.     }*
  136. ]]
  137. local r = ffi.cast(ptrtype, rptr)
  138. --[==[
  139.     src/rsbin/storage.hpp:10:2:
  140.     rsbin> StorageMap = class() [[r::name("storagemap")]] [[r::struct]]
  141. ]==]
  142. local rsbin_storagemap = package.loaded["base.ffipure"]:module("rsbin.storagemap")
  143. rsbin_storagemap.typedef = "rsbin_storagemap"
  144. --[==[
  145.     src/rsbin/storage.hpp:16:2:
  146.     rsbin> MapTask = class(Task) [[r::class]] [[r::name("maptask")]]
  147. ]==]
  148. local rsbin_maptask = package.loaded["task"]:module("rsbin.maptask")
  149. rsbin_maptask.typedef = "r_rsbin_maptask_box"
  150. --[==[
  151.     src/rsbin/storage.hpp:21:11:
  152.     rsbin::MapTask> getmap = object function []: StorageMap [[r::method]]
  153. ]==]
  154. function rsbin_maptask:getmap()
  155.     local exception = r_exceptionbox:new()
  156.     local result = r.rsbin_maptask_getmap(self.object, exception)
  157.     if exception.whatptr ~= nil then
  158.         error(exception:what())
  159.     end
  160.     return result
  161. end
  162. --[==[
  163.     src/rsbin/storage.hpp:24:2:
  164.     rsbin> GetLimitTask = class(Task) [[r::class]] [[r::name("getlimittask")]]
  165. ]==]
  166. local rsbin_getlimittask = package.loaded["task"]:module("rsbin.getlimittask")
  167. rsbin_getlimittask.typedef = "r_rsbin_getlimittask_box"
  168. --[==[
  169.     src/rsbin/storage.hpp:29:11:
  170.     rsbin::GetLimitTask> getlimit = object function []: uint64_t [[r::method]]
  171. ]==]
  172. function rsbin_getlimittask:getlimit()
  173.     local exception = r_exceptionbox:new()
  174.     local result = r.rsbin_getlimittask_getlimit(self.object, exception)
  175.     if exception.whatptr ~= nil then
  176.         error(exception:what())
  177.     end
  178.     return result
  179. end
  180. --[==[
  181.     src/rsbin/storage.hpp:32:2:
  182.     rsbin> Storage = class(RefObject) [[r::class]] [[r::name("storage")]]
  183. ]==]
  184. local rsbin_storage = package.loaded["refobject"]:module("rsbin.storage")
  185. rsbin_storage.typedef = "r_rsbin_storage_box"
  186. --[==[
  187.     src/rsbin/storage.hpp:41:11:
  188.     rsbin::Storage> startmap = object function [offset: uint64_t, length: uint32_t, flagread: bool, flagwrite: bool]: Ref<MapTask> [[r::method]]
  189. ]==]
  190. function rsbin_storage:startmap(arg1, arg2, arg3, arg4)
  191.     local exception = r_exceptionbox:new()
  192.     local result = r.rsbin_storage_startmap(self.object, arg1, arg2, arg3, arg4, exception)
  193.     if exception.whatptr ~= nil then
  194.         error(exception:what())
  195.     end
  196.     return r_wrapobject(result)
  197. end
  198. --[==[
  199.     src/rsbin/storage.hpp:45:11:
  200.     rsbin::Storage> startgetlimit = object function [plimit: pointer uint64_t]: Ref<GetLimitTask> [[r::method]]
  201. ]==]
  202. function rsbin_storage:startgetlimit(arg1)
  203.     local exception = r_exceptionbox:new()
  204.     local result = r.rsbin_storage_startgetlimit(self.object, arg1, exception)
  205.     if exception.whatptr ~= nil then
  206.         error(exception:what())
  207.     end
  208.     return r_wrapobject(result)
  209. end
  210. --[==[
  211.     src/rsbin/storage.hpp:47:11:
  212.     rsbin::Storage> startsetlimit = object function [limit: uint64_t]: Ref<Task> [[r::method]]
  213. ]==]
  214. function rsbin_storage:startsetlimit(arg1)
  215.     local exception = r_exceptionbox:new()
  216.     local result = r.rsbin_storage_startsetlimit(self.object, arg1, exception)
  217.     if exception.whatptr ~= nil then
  218.         error(exception:what())
  219.     end
  220.     return r_wrapobject(result)
  221. end
  222. --[==[
  223.     src/rsbin/storage.hpp:49:11:
  224.     rsbin::Storage> startflush = object function []: Ref<Task> [[r::method]]
  225. ]==]
  226. function rsbin_storage:startflush()
  227.     local exception = r_exceptionbox:new()
  228.     local result = r.rsbin_storage_startflush(self.object, exception)
  229.     if exception.whatptr ~= nil then
  230.         error(exception:what())
  231.     end
  232.     return r_wrapobject(result)
  233. end
  234. --[==[
  235.     src/rsbin/storage.hpp:51:11:
  236.     rsbin::Storage> startclose = object function []: Ref<Task> [[r::method]]
  237. ]==]
  238. function rsbin_storage:startclose()
  239.     local exception = r_exceptionbox:new()
  240.     local result = r.rsbin_storage_startclose(self.object, exception)
  241.     if exception.whatptr ~= nil then
  242.         error(exception:what())
  243.     end
  244.     return r_wrapobject(result)
  245. end
  246. --[==[
  247.     src/rsbin/storage.hpp:55:1:
  248.     r_emit
  249. ]==]
  250.  
  251.     function rsbin_storage:map(offset, length, flagread, flagwrite)
  252.         local task = self:startmap(offset, length, flagread, flagwrite)
  253.         if not task then
  254.             return nil, nil, 0
  255.         end
  256.         while not task:poll() do
  257.             coroutine.yield()
  258.         end
  259.         local map = task:getmap()
  260.         if map.ptr == nil or map.length == 0 then
  261.             return task, nil, 0
  262.         else
  263.             return task, map.ptr, map.length
  264.         end
  265.     end
  266.  
  267.     function rsbin_storage:getlimit()
  268.         local limit = ffi.new('uint64_t[1]')
  269.         local task = self:startgetlimit(limit)
  270.         if task then
  271.             while not task:poll() do
  272.                 coroutine.yield()
  273.             end
  274.             local result = task:getlimit()
  275.             task:release()
  276.             return result
  277.         else
  278.             return limit[0]
  279.         end
  280.     end
  281.  
  282.     function rsbin_storage:setlimit(limit)
  283.         local task = self:startsetlimit(limit)
  284.         if task then
  285.             while not task:poll() do
  286.                 coroutine.yield()
  287.             end
  288.             task:release()
  289.         end
  290.     end
  291.  
  292.     function rsbin_storage:flush()
  293.         local task = self:startflush()
  294.         if task then
  295.             while not task:poll() do
  296.                 coroutine.yield()
  297.             end
  298.             task:release()
  299.         end
  300.     end
  301.  
  302.     function rsbin_storage:close()
  303.         local task = self:startclose()
  304.         if task then
  305.             while not task:poll() do
  306.                 coroutine.yield()
  307.             end
  308.             task:release()
  309.         end
  310.     end
  311. --[==[
  312.     src/rsbin/storage.hpp:10:2:
  313.     rsbin> StorageMap = class() [[r::name("storagemap")]] [[r::struct]]
  314. ]==]
  315. rsbin_storagemap:buildmetatype()
  316. --[==[
  317.     src/rsbin/storage.hpp:16:2:
  318.     rsbin> MapTask = class(Task) [[r::class]] [[r::name("maptask")]]
  319. ]==]
  320. rsbin_maptask:buildmetatype()
  321. --[==[
  322.     src/rsbin/storage.hpp:21:11:
  323.     rsbin::MapTask> getmap = object function []: StorageMap [[r::method]]
  324. ]==]
  325. --[==[
  326.     src/rsbin/storage.hpp:24:2:
  327.     rsbin> GetLimitTask = class(Task) [[r::class]] [[r::name("getlimittask")]]
  328. ]==]
  329. rsbin_getlimittask:buildmetatype()
  330. --[==[
  331.     src/rsbin/storage.hpp:29:11:
  332.     rsbin::GetLimitTask> getlimit = object function []: uint64_t [[r::method]]
  333. ]==]
  334. --[==[
  335.     src/rsbin/storage.hpp:32:2:
  336.     rsbin> Storage = class(RefObject) [[r::class]] [[r::name("storage")]]
  337. ]==]
  338. rsbin_storage:buildmetatype()
  339. --[==[
  340.     src/rsbin/storage.hpp:41:11:
  341.     rsbin::Storage> startmap = object function [offset: uint64_t, length: uint32_t, flagread: bool, flagwrite: bool]: Ref<MapTask> [[r::method]]
  342. ]==]
  343. --[==[
  344.     src/rsbin/storage.hpp:45:11:
  345.     rsbin::Storage> startgetlimit = object function [plimit: pointer uint64_t]: Ref<GetLimitTask> [[r::method]]
  346. ]==]
  347. --[==[
  348.     src/rsbin/storage.hpp:47:11:
  349.     rsbin::Storage> startsetlimit = object function [limit: uint64_t]: Ref<Task> [[r::method]]
  350. ]==]
  351. --[==[
  352.     src/rsbin/storage.hpp:49:11:
  353.     rsbin::Storage> startflush = object function []: Ref<Task> [[r::method]]
  354. ]==]
  355. --[==[
  356.     src/rsbin/storage.hpp:51:11:
  357.     rsbin::Storage> startclose = object function []: Ref<Task> [[r::method]]
  358. ]==]
  359. --[==[
  360.     src/rsbin/storage.hpp:55:1:
  361.     r_emit
  362. ]==]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement