Kouksi44

Classic 2.0

Jan 30th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.84 KB | None | 0 0
  1.  
  2.  
  3. local Class = {}
  4. local ClassObject = {}
  5. local ClassProxy = {}
  6. local Object = {}
  7. local ObjectProxy = {}
  8. local ClassFunction = {}
  9. local ObjectFunction = {}
  10. local ClassValue = {}
  11. local ObjectValue = {}
  12. local ValueReference = {}
  13. local ClassParser = {}
  14. local Annotation = {}
  15. local AccessRequest = {}
  16.  
  17. setmetatable(Annotation,{__call=function(_,AnnotationType) return Annotation.new(AnnotationType) end})
  18.  
  19. local currentClass = {}
  20. local Utils = {}
  21. local ClassTree = {}
  22. setmetatable(getfenv(),{__index=ClassTree})
  23.  
  24. local pModifiers = {
  25.   ["public"] = true;
  26.   ["private"] = true;
  27.   ["static"] = true;
  28.   ["abstract"] = true;
  29.   ["final"] = true;
  30. }
  31.  
  32. local pTypes = {
  33.   ["number"] = true;
  34.   ["table"] = true;
  35.   ["thread"] = true;
  36.   ["function"] = true;
  37.   ["string"] = true;
  38.   ["boolean"] = true;
  39.   ["nil"] = true;
  40. }
  41.  
  42. local function instanceof(Obj)
  43.   if type(Obj) == "table" then
  44.     if Obj.isInstance then
  45.       return Obj.getClass().getName()
  46.     end
  47.   end
  48. end
  49.  
  50. local function annotationInstance(Annotation)
  51.   if type(Annotation) ~= "table" then
  52.     return false
  53.   end
  54.   if Annotation.__type then
  55.     return Annotation.__type == "Annotation"
  56.   end
  57. end
  58.  
  59. local function typeof(Value)
  60.   if type(Value) == "table" then
  61.     if Value.__obj and Value.__obj.className then
  62.       return "class"
  63.     end
  64.   end
  65.   return type(Value)
  66. end
  67.  
  68.  
  69.  
  70. function Utils.getClassByName(ClassName)
  71.     if not ClassTree[ClassName] then
  72.         error("Can't find class "..ClassName..". Has it been created ?")
  73.     end
  74.  
  75.     return ClassTree[ClassName]
  76. end
  77.  
  78. function Utils.makeGlobal(ClassObj) -- make the new class globally usable
  79.     currentClass = ClassObj
  80.     _G[ClassObj:getName()] = ClassObj
  81.     ClassTree[ClassObj:getName()] = ClassObj
  82. end
  83.  
  84. function Utils.parseClassPath(Location)
  85.   local isPath = string.find(Location,"%.") ~= nil
  86.   local currentLocation = ClassTree
  87.   if isPath then
  88.     local className = ""
  89.     Location = string.gsub(Location,"%.(%a+)$",function(name) className = name return "" end)
  90.     if #className == 0 then
  91.       error("Malformed classpath")
  92.     end
  93.  
  94.     string.gsub(Location,"(%a+)%.*",function(current)
  95.       if currentLocation[current] then
  96.         if currentLocation[current].__obj then
  97.           error("Classpath overwrites existing class "..currentLocation[current]:getName())
  98.         end
  99.         currentLocation = currentLocation[current]
  100.       else
  101.         currentLocation[current] = {}
  102.         currentLocation = currentLocation[current]
  103.       end
  104.     end)
  105.  
  106.     return currentLocation,className
  107.   else
  108.     return false
  109.   end
  110. end
  111.  
  112. function Utils.hasFieldAnnotation(FieldTable)
  113.  
  114.   return annotationInstance(FieldTable)
  115. end
  116.  
  117. function Utils.getFieldAnnotation(FieldTable)
  118.     return {
  119.       annotations = FieldTable.annotationList;
  120.       fieldValue = FieldTable.fieldValue;
  121.     }
  122. end
  123.  
  124. function Utils.isClassEntry(ClassTable,Field)
  125.   local field = ClassTable[Field]
  126.   if type(field) == "table" then
  127.     if field.visibility and field.modifiers and field.value then
  128.       return true
  129.     end
  130.   end
  131.   return false
  132. end
  133.  
  134. function Utils.getEqualPublicMethods(Sender,Object)
  135.   local indexMap = {}
  136.   local equalPublicMethods = {}
  137.  
  138.   for k,v in pairs(Object.raw) do
  139.     if v:getAccessLevel() == 0 and type(v.value) == "function" then
  140.       indexMap[k] = v
  141.     end
  142.   end
  143.   local cSender = nil
  144.   for i = #Sender,1, -1 do
  145.     cSender = Sender[i]
  146.     for k,v in pairs(cSender.raw) do
  147.       if v:getAccessLevel() == 0 and type(v.value) == "function" and indexMap[k] and indexMap[k].type == v.type and (k~="getClass" and k~="instanceof")  then
  148.         equalPublicMethods[k] = v
  149.       end
  150.     end
  151.   end
  152.  
  153.   return equalPublicMethods
  154. end
  155.  
  156. function Utils.checkType(FType,VType)
  157.   return ((FType == nil and true) or (FType == VType))
  158. end
  159.  
  160. local function parseAnnotations(Left,Right)
  161.   if annotationInstance(Left) and annotationInstance(Right) then
  162.     for _,annotation in pairs(Left.annotationList) do
  163.       table.insert(Right.annotationList,annotation)
  164.     end
  165.     return Right
  166.   elseif typeof(Left) == "class" or typeof(Right) == "class" then
  167.     local className = (typeof(Left) == "class" and Left:getName()) or Right:getName()
  168.  
  169.     if typeof(Left) == "class" then
  170.       if not annotationInstance(Right) then
  171.         local annotation = Annotation()
  172.         annotation.fieldValue = Right
  173.         for _,anno in pairs(rawget(Left,"annotationList")) do
  174.           table.insert(annotation.annotationList,anno)
  175.         end
  176.         return annotation
  177.       end
  178.       for _,annotation in pairs(rawget(Left,"annotationList")) do
  179.         table.insert(Right.annotationList,annotation)
  180.       end
  181.       return Right
  182.     else
  183.       for _,annotation in pairs(Left.annotationList) do
  184.         table.insert(rawget(Right,"annotationList"),annotation)
  185.       end
  186.       return Right
  187.     end
  188.   elseif annotationInstance(Left) and (not (annotationInstance(Right) or typeof(Right) == "class")) then
  189.     local annotation = Annotation()
  190.     annotation.fieldValue = Right
  191.     for _,anno in pairs(Left.annotationList) do
  192.       table.insert(annotation.annotationList,anno)
  193.     end
  194.     return annotation
  195.   end
  196. end
  197.  
  198. function Annotation.new(AnnotationType)
  199.   local object = {
  200.     __type = "Annotation";
  201.     annotationList = {[1] = AnnotationType;};
  202.     fieldValue = {};
  203.   }
  204.   return setmetatable(object,{
  205.     __index = Annotation,
  206.     __sub = parseAnnotations;
  207.   })
  208. end
  209.  
  210.  
  211. public = Annotation("public")
  212. private = Annotation("private")
  213. final = Annotation("final")
  214. static = Annotation("static")
  215. Number = Annotation("number")
  216. Table = Annotation("table")
  217. Thread = Annotation("thread")
  218. Function = Annotation("function")
  219. String = Annotation("string")
  220. Boolean = Annotation("boolean")
  221. void = Annotation("nil")
  222.  
  223.  
  224. -- _G.property = Annotation("property") WIP
  225. abstract = Annotation("abstract")
  226.  
  227. function using(ClassPath)
  228.   local cName = ""
  229.   ClassPath = string.gsub(ClassPath,"%.([%a%*]*)$",function(name) cName = name return "" end)
  230.   local isSingleImport = (cName ~= "*")
  231.   local currentLocation = ClassTree
  232.  
  233.   if isSingleImport then
  234.     string.gsub(ClassPath,"(%a+)%.*",function(current)
  235.       if currentLocation[current] then
  236.         if currentLocation[current].instanceof then
  237.           error("Malformed path to loaded class")
  238.         end
  239.         currentLocation = currentLocation[current]
  240.       else
  241.         currentLocation[current] = {}
  242.         currentLocation = currentLocation[current]
  243.       end
  244.     end)
  245.     if currentLocation[cName] then
  246.       _G[cName] = currentLocation[cName]
  247.       ClassTree[cName] = currentLocation[cName]
  248.     else
  249.       error("Can't find class at specified classpath. Has it been loaded ?")
  250.     end
  251.  
  252.   else
  253.     string.gsub(ClassPath,"(%a+)%.*",function(current)
  254.       if currentLocation[current] then
  255.         if currentLocation[current].instanceof then
  256.           error("Malformed path to loaded class")
  257.         end
  258.         currentLocation = currentLocation[current]
  259.       else
  260.         currentLocation[current] = {}
  261.         currentLocation = currentLocation[current]
  262.       end
  263.     end)
  264.  
  265.     for className, c in pairs(currentLocation) do
  266.       _G[className] = c
  267.       ClassTree[className] = c
  268.     end
  269.   end
  270. end
  271.  
  272.  
  273. setmetatable(ClassParser,{
  274.     __index = function(_,ClassName)
  275.         return function(_,ClassBody)
  276.             currentClass:setSuperByName(ClassName)
  277.             currentClass:buildClass(ClassBody,ClassBody)
  278.         end
  279.     end;
  280.     __call = function(_,ClassBody)
  281.         currentClass:buildClass(ClassBody,ClassBody)
  282.     end;
  283. })
  284.  
  285.  
  286. function Class.new(ClassName)
  287.  
  288.   local location, className = Utils.parseClassPath(ClassName)
  289.  
  290.   if location then
  291.     if not location[className] then
  292.       location[className] = ClassObject(ClassName)
  293.       currentClass = location[className]
  294.     else
  295.       error("Can't overwrite existing class at given classpath")
  296.     end
  297.   else
  298.     Utils.makeGlobal(ClassObject(ClassName))
  299.   end
  300.   return ClassParser
  301. end
  302.  
  303. function ClassObject.new(ClassName)
  304.   local object = {
  305.     type = "class";
  306.     className = ClassName;
  307.     inherits = false;
  308.     super = nil;
  309.     raw = setmetatable({},{__index = ClassObject});
  310.     properties = {};
  311.     interfaces = {};
  312.     annotationList = {[1] = ClassName};
  313.     constructed = false;
  314.   }
  315.  
  316.   local proxy = {__obj = object}
  317.   setmetatable (proxy,{
  318.     __index = function(_,k)
  319.       if Utils.isClassEntry(object.raw,k) then
  320.         return object.raw[k]:get()
  321.       elseif object.raw[k] then
  322.         return object.raw[k]
  323.       elseif object.super then
  324.         return object.super[k]
  325.       end
  326.       return nil
  327.     end;
  328.     __newindex = function(t,k,v)
  329.       if type(v) == "table" and v.value and v.visibility then
  330.         object.raw[k] = v
  331.       else
  332.         object.raw[k] = (type(v) == "function" and ClassFunction(v,{})) or ClassValue(v,{})
  333.       end
  334.     end;
  335.     __call = function(_,...) return proxy:createInstance(...) end -- TODO / WIP
  336.   })
  337.  
  338.   return proxy
  339. end
  340.  
  341. function ClassObject:createInstance(...)
  342.   local abstracts = {}
  343.   if self.__obj.super then
  344.     abstracts = self.__obj.super:getAbstractMethods()
  345.   end
  346.  
  347.   for k,v in pairs(abstracts) do
  348.     if self.__obj.raw[k] == nil then
  349.       error("Class "..self.__obj.className.." does not override abstract method "..k)
  350.     elseif not (self.__obj.raw[k] and type(self.__obj.raw[k].value) == "function" and self.__obj.raw[k].type == abstracts[k].type and self.__obj.raw[k]:getAccessLevel() == 0) then
  351.       error("Class "..self.__obj.className.." does not override abstract method "..k)
  352.     end
  353.   end
  354.  
  355.   local nObject = Object(self)
  356.   local proxy = ObjectProxy(nObject)
  357.  
  358.   if nObject:getField(self:getName()) ~= nil then
  359.     nObject:getField(self:getName())(...)
  360.   end
  361.  
  362.   return proxy
  363. end
  364.  
  365. function ClassObject:setSuperByName(ClassName)
  366.     local super = Utils.getClassByName(ClassName)
  367.  
  368.     self.__obj.super = super
  369.     self.__obj.inherits = true
  370. end
  371.  
  372. function ClassObject:buildClass(ClassBody)
  373.   for fieldName, value in pairs(ClassBody) do
  374.     if type(value) ~= "function" then
  375.       self:addValue(fieldName,value)
  376.     else
  377.       self:addFunction(fieldName,value)
  378.     end
  379.   end
  380.   self.__obj.constructed = true;
  381. end
  382.  
  383. function ClassObject:getName()
  384.   return self.__obj.className
  385. end
  386.  
  387. function ClassObject:hasSuper()
  388.   if self.__obj.super ~= nil then
  389.     return true
  390.   end
  391.   return false
  392. end
  393.  
  394. function ClassObject:getSuper()
  395.   return self.__obj.super
  396. end
  397.  
  398.  
  399. function ClassObject:addValue(FieldName,Value)
  400.     if Utils.hasFieldAnnotation(Value) then
  401.       local annotations = Utils.getFieldAnnotation(Value)
  402.       local fieldValue = annotations.fieldValue
  403.       if type(fieldValue) == "function" then
  404.         self:addFunction(FieldName,fieldValue,annotations)
  405.         return
  406.       end
  407.       self[FieldName] = ClassValue(fieldValue,annotations)
  408.     else
  409.       self[FieldName] = ClassValue(Value,{})
  410.     end
  411. end
  412.  
  413. function ClassObject:addFunction(FieldName,Value,Annotations)
  414.   self[FieldName] = ClassFunction(Value,Annotations or {})
  415. end
  416.  
  417. function ClassObject:getAbstractMethods()
  418.   local m = {}
  419.   for k,v in pairs(self.__obj.raw) do
  420.     if type(v.value) == "function" and v.modifiers.abstract then
  421.       m[k] = v
  422.     end
  423.   end
  424.   return m
  425. end
  426.  
  427.  
  428.  
  429. function ClassValue.new(Value,Annotations)
  430.   local object = setmetatable({
  431.     value = Value;
  432.     visibility = {};
  433.     modifiers = {};
  434.     type = nil;
  435.   },{
  436.     __index = ClassValue;
  437.   })
  438.   object:getVisibility(Annotations)
  439.   object:getModifiers(Annotations)
  440.   return object
  441. end
  442.  
  443. function ClassValue:get()
  444.   return self.value
  445. end
  446.  
  447. function ClassValue:getVisibility(Annotations)
  448.   for k,v in pairs(Annotations.annotations or {}) do
  449.     if v == "private" then
  450.       self.visibility = 1
  451.     elseif v == "public" then
  452.       self.visibility = 0
  453.     end
  454.   end
  455.   if type(self.visibility) == "table" then
  456.     self.visibility = 0
  457.   end
  458. end
  459.  
  460. function ClassValue:getModifiers(Annotations)
  461.   for k,v in pairs(Annotations.annotations or {}) do
  462.     if v ~= "private" and v ~= "public" then
  463.       if pModifiers[v] then
  464.         self.modifiers[v] = true
  465.       elseif pTypes[v] then
  466.         self.type = v
  467.       end
  468.     end
  469.   end
  470. end
  471.  
  472. function ClassValue:getAccessLevel()
  473.   return self.visibility
  474. end
  475.  
  476.  
  477. function ClassFunction.new(Value,Annotations)
  478.   local object = {
  479.     value = Value;
  480.     visibility = 0;
  481.     modifiers = {};
  482.   }
  483.  
  484.   setmetatable (object,{
  485.     __index = ClassFunction;
  486.     __call = function() error("Attempt to call class function") end;
  487.   })
  488.  
  489.   object:getVisibility(Annotations)
  490.   object:getModifiers(Annotations)
  491.  
  492.   return object
  493. end
  494.  
  495. function ClassFunction:get()
  496.   return self
  497. end
  498.  
  499. function ClassFunction:getVisibility(Annotations)
  500.   for k,v in pairs(Annotations.annotations or {}) do
  501.     if v == "private" then
  502.       self.visibility = 1
  503.     elseif v == "public" then
  504.       self.visibility = 0
  505.     end
  506.   end
  507. end
  508.  
  509. function ClassFunction:getModifiers(Annotations)
  510.   for k,v in pairs(Annotations.annotations or {}) do
  511.     if v ~= "private" and v ~= "public" then
  512.       if pModifiers[v] then
  513.         self.modifiers[v] = true
  514.       elseif pTypes[v] then
  515.         self.type = v
  516.       end
  517.     end
  518.   end
  519. end
  520.  
  521. function ClassFunction:getAccessLevel()
  522.   return self.visibility
  523. end
  524.  
  525. function Object.new(Class)
  526.   local object = {
  527.     type = "Object";
  528.     raw = {};
  529.     super = nil;
  530.     class = Class;
  531.   }
  532.  
  533.   if Class:hasSuper() then
  534.     object.super = Class.__obj.super:createInstance()
  535.   end
  536.  
  537.   setmetatable(object,{
  538.     __index = Object;
  539.   })
  540.  
  541.   object:parseClassbody(Class)
  542.   return object
  543. end
  544.  
  545. function Object:parseClassbody(Class)
  546.   local proxy = ObjectProxy(self,true)
  547.   for fieldName,classValue in pairs(Class.__obj.raw) do
  548.     self.raw[fieldName] = (type(classValue.value) == "function" and ObjectFunction(classValue,proxy)) or ObjectValue(classValue)
  549.   end
  550.   self.raw.super = ObjectValue({
  551.     value = self.super;
  552.     visibility = 0;
  553.     modifiers = {final = true};
  554.     type = nil;
  555.     proxy = {};
  556.   })
  557.   self:addHelperFunctions(proxy)
  558. end
  559.  
  560. function Object:addHelperFunctions(Proxy)
  561.   local struct = {
  562.     value = nil;
  563.     visibility = 0;
  564.     modifiers = {};
  565.     type = nil;
  566.     proxy = {};
  567.   }
  568.   local _name = self.class:getName()
  569.   local _class = self.class
  570.   local instanceof = function(_,ClassName)
  571.  
  572.     if _name == ClassName then
  573.       return true
  574.     elseif self.super then
  575.       return self.super : instanceof(ClassName)
  576.     end
  577.     return false
  578.   end
  579.   local getClass = function() return _class end
  580.   struct.value = instanceof
  581.   self.raw.instanceof = ObjectFunction(struct,Proxy)
  582.   struct.value = getClass
  583.   self.raw.getClass = ObjectFunction(struct,Proxy)
  584. end
  585.  
  586. function Object:getField(Field)
  587.   return self.raw[Field]
  588. end
  589.  
  590.  
  591.  
  592. function Object:requestGet(Request)
  593.   local field = Request.field
  594.   local access = Request.access
  595.   local sender = Request.sender
  596.   local selfLookup = (sender[1] == self) or (sender == nil)
  597.  
  598.   if self.raw[field] and self.raw[field]:getAccessLevel() == 0 then
  599.     Request.result = self.raw[field]:get(sender,selfLookup)
  600.     return true
  601.   elseif self.raw[field] and self.raw[field]:getAccessLevel() == 1 then
  602.     if self.raw[field]:getAccessLevel() > access then
  603.       Request.result = self.raw[field]:get(sender,selfLookup)
  604.       return true
  605.     end
  606.   end
  607.   Request.access = Request.access + 1
  608.   return false
  609. end
  610.  
  611. function Object:requestSet(Request)
  612.   local field = Request.field
  613.   local access = Request.access
  614.   local value = Request.value
  615.  
  616.   if self.raw[field] and self.raw[field]:getAccessLevel() == 0 then
  617.     self.raw[field]:set(value)
  618.     return true
  619.   elseif self.raw[field] and self.raw[field]:getAccessLevel() == 1 then
  620.     if self.raw[field]:getAccessLevel() > access then
  621.       self.raw[field]:set(value)
  622.       return true
  623.     end
  624.   end
  625.   Request.access = Request.access + 1
  626.   return false
  627. end
  628.  
  629. function Object:hasSuper()
  630.   return self.super ~= nil
  631. end
  632.  
  633. function Object:getSuper()
  634.   if self:hasSuper() then
  635.     return self.super
  636.   end
  637. end
  638.  
  639. function ObjectProxy.new(Object,isInner,RemapsToSender)
  640.   local object = {
  641.     __cObj = Object
  642.   }
  643.  
  644.   setmetatable(object,{
  645.     __index = function(_,k)
  646.       if RemapsToSender and RemapsToSender[k] then
  647.         return RemapsToSender[k]:get()
  648.       end
  649.       local req = nil
  650.  
  651.       if type(k) == "table" then
  652.         req = k
  653.         table.insert(req.sender,Object)
  654.       else
  655.         req = AccessRequest((isInner and 0) or 1,k,nil,Object)
  656.       end
  657.       if object.__cObj:requestGet(req) then
  658.         return req.result
  659.       elseif Object:hasSuper() then
  660.         return Object:getSuper()[req]
  661.       end
  662.       return nil
  663.     end;
  664.    
  665.     __newindex = function(_,k,v)
  666.       local req = nil
  667.  
  668.       if type(k) == "table" then
  669.         req = k
  670.       else
  671.         req = AccessRequest(1,k,v)
  672.       end
  673.       if object.__cObj:requestSet(req) ~= true then
  674.         if object.__cObj:hasSuper() and object.__cObj:getSuper()[req] then
  675.           object.__cObj:getSuper()[req] = v
  676.         end
  677.       end
  678.     end
  679.   })
  680.   return object
  681. end
  682.  
  683.  
  684. function ObjectValue.new(ClassValue)
  685.   local object = setmetatable({
  686.     value = ClassValue.value;
  687.     visibility = ClassValue.visibility;
  688.     modifiers = ClassValue.modifiers;
  689.     type = ClassValue.type;
  690.     __static = ClassValue
  691.   },{
  692.     __index = ObjectValue;
  693.   })
  694.   return object
  695. end
  696.  
  697. function ObjectValue:get(Sender,IsSelf)
  698.   if self.modifiers.static then
  699.     return self.__static.value
  700.   end
  701.   return self.value
  702. end
  703.  
  704. function ObjectValue:set(NewValue)
  705.   if self.modifiers.final then
  706.     error("Members flagged as final can't be modified")
  707.   end
  708.  
  709.   if self.modifiers.static then
  710.     if type(NewValue) == self.__static.type or self.__static.type == nil or type(NewValue) == "nil" then
  711.       self.__static.value = NewValue
  712.     else
  713.       error("Type of  :"..type(NewValue).." - "..self.__static.type)
  714.     end
  715.   else
  716.     if type(NewValue) == self.type or self.type == nil or type(NewValue) == "nil" then
  717.       self.value = NewValue
  718.     else
  719.       error("Incompatible types : "..type(NewValue).." - "..self.type)
  720.     end
  721.   end
  722. end
  723.  
  724. function ObjectValue:getAccessLevel()
  725.   return self.visibility
  726. end
  727.  
  728. function ObjectFunction.new(ClassFunction,ObjectProxy)
  729.   local object = {
  730.     value = ClassFunction.value;
  731.     visibility = ClassFunction.visibility;
  732.     modifiers = ClassFunction.modifiers;
  733.     type = ClassFunction.type;
  734.     proxy = ObjectProxy;
  735.     useSenderInstance = false;
  736.     senderInstance = nil;
  737.   }
  738.   setmetatable(object,{
  739.     __index = ObjectFunction;
  740.     __call = function(_,...)
  741.         if object.modifiers.abstract then
  742.           error("Attempt to call abstract method in "..object.proxy.__cObj.class:getName().."@"..tostring(object.proxy):sub(8))
  743.         end
  744.         local args = {...}
  745.         local _self = args[1]
  746.         if type(_self) == "table" and _self.__cObj and _self.__cObj.class:getName() == object.proxy.__cObj.class:getName() then
  747.           table.remove(args,1)
  748.         end
  749.         return object.value((object.useSenderInstance and object.senderInstance) or object.proxy,unpack(args))
  750.       end;
  751.   })
  752.   return object
  753. end
  754.  
  755. function ObjectFunction:getAccessLevel()
  756.   return self.visibility
  757. end
  758.  
  759. function ObjectFunction:get(Sender,IsSelf)
  760.  
  761.   if IsSelf == false then
  762.     self.useSenderInstance = true
  763.     self.senderInstance = ObjectProxy(self.proxy.__cObj,true,Utils.getEqualPublicMethods(Sender,self.proxy.__cObj))
  764.   else
  765.     self.useSenderInstance = false
  766.   end
  767.   return self
  768. end
  769.  
  770.  
  771. function AccessRequest.new(Level,Field,Value,Sender)
  772.   local object = {
  773.     access = Level;
  774.     field = Field;
  775.     value = Value;
  776.     result = nil;
  777.     sender = {[1] = Sender};
  778.   }
  779.   setmetatable(object,{
  780.     __index = AccessRequest;
  781.   })
  782.   return object
  783. end
  784.  
  785.  
  786. setmetatable(Class,{__call=function(_,ClassName) return Class.new(ClassName) end})
  787. setmetatable(ClassObject,{__call=function(_,ClassName) return ClassObject.new(ClassName) end})
  788. setmetatable(ClassProxy,{__call=function() return ClassProxy.new() end})
  789. setmetatable(Object,{__call=function(_,Class) return Object.new(Class) end})
  790. setmetatable(ObjectProxy,{__call=function(_,OfObject,IsInner,RemapToSender) return ObjectProxy.new(OfObject,IsInner,RemapToSender) end})
  791. setmetatable(ClassFunction,{__call=function(_,Value,Annotations) return ClassFunction.new(Value,Annotations) end})
  792. setmetatable(ObjectFunction,{__call=function(_,Value,Annotations) return ObjectFunction.new(Value,Annotations) end})
  793. setmetatable(ClassValue,{__call=function(_,Value,Annotations) return ClassValue.new(Value,Annotations) end})
  794. setmetatable(ObjectValue,{__call=function(_,Value,Annotations) return ObjectValue.new(Value,Annotations) end})
  795. setmetatable(ValueReference,{__call=function() return ValueReference.new() end})
  796. setmetatable(AccessRequest,{__call=function(_,Level,Field,Value,Sender) return AccessRequest.new(Level,Field,Value,Sender) end})
  797.  
  798. _G.class = Class
Advertisement
Add Comment
Please, Sign In to add comment