Commit Graph

63 Commits

Author SHA1 Message Date
kikito
0f20fc4288 removes default includes(mixin) method and __mixins attribute 2015-12-13 01:13:49 +01:00
kikito
d5776a20ed makes Object a mixin instead of a global variable 2015-12-13 01:06:23 +01:00
mpeterv
ab1699bb05 Do not wrap __newindex 2015-11-28 18:10:35 +03:00
mpeterv
227705b3ec Support __index and __newindex metamethods
Separate instance dictionary and instance metatable.
When defining a metamethod and it's __index or __newindex,
wrap it in a function, so that it's used only when the key
is missing in the whole dictionary chain.

class.__metamethods table is now redundant; raw access of instance
dictionary can be used to check if a metamethod is defined in a class.
2015-11-24 18:26:53 +03:00
kikito
28c745f99e bump version to 3.2.0 2015-11-23 23:37:54 +01:00
kikito
15f6c82c50 Refactoring and renaming 2015-11-23 23:20:20 +01:00
kikito
3de0dc2166 propogate -> propagate 2015-11-23 22:47:50 +01:00
mpeterv
524d0ddc8c Fix not inheriting metamethods from grandparent class 2015-11-23 15:42:49 +03:00
mpeterv
beee81e36a Support inheriting __gc, __mode, __metatable
Do not directly set metatable of an instance dict to super's
instance dict so that special metamethods do not affect it.
2015-11-19 13:53:03 +03:00
mpeterv
d9f00351b2 Implement inheritable metamethods without stubs
In __newindex metamethods of each Class detect if
a metamethod is assigned. In that case, propogate assignment
to all child classes that do not overwrite the metamethod.
Track set of metamethods each class defines itself.
On subclassing, copy all parent metamethods to child.

Benefits of this approach:

* Objects only have metamethods when they are, in fact, defined.
  Ignoring overhead, the problem with stubs is that other libraries,
  seeing a stub metamethod, could try to call it and get an error
  if it's missing in the class. E.g. various deep comparison functions
  often try to detect and use __eq.
* Non-function metafields such as __metatable can be used.
* Less overhead when using metamethods (but more when defining them).
2015-11-19 13:05:09 +03:00
kikito
9fb0f72a74 bump version to 3.1.0 2015-11-02 17:37:30 +01:00
kikito
d6b5f5c22d do not stub __metatable or __mode 2015-10-31 16:26:20 +01:00
kikito
d97a1bfbd4 do not stub the __gc metamethod 2015-10-31 15:56:17 +01:00
kikito
512e6c2968 __gc metamethod for 5.3 2015-10-12 13:39:35 +02:00
kikito
fd02469814 Improve the static class lookup. Fixes #27 2015-10-12 12:46:28 +02:00
Enrique García
a8a8298a4c Add _URL 2014-04-01 23:27:36 +02:00
kikito
e196695517 pushed 3.0.1 2013-12-06 22:04:31 +01:00
kenshin
b89bf82db4 supplement unit test for __len, __pairs, __ipairs 2013-12-04 18:09:54 +08:00
kenshin
151c5b2c71 new metamethod __len,__pairs,__ipairs in lua 5.2 2013-12-02 11:48:20 +08:00
kikito
36379fd165 improved parameter error treatment 2013-09-18 23:47:07 +02:00
kikito
2208c84dae klass -> aClass 2013-09-18 23:43:53 +02:00
kikito
f5aac38418 made includes a private method 2013-09-17 01:14:57 +02:00
kikito
1be9e39deb fixed isInstanceOf 2013-09-17 00:48:47 +02:00
kikito
219550cd58 started working on 3.0 2013-09-16 10:37:56 +02:00
kikito
cd9609e1ae made Object non-global 2013-09-15 23:18:08 +02:00
kikito
88e84d13c2 made class non-global 2013-09-15 23:14:00 +02:00
kikito
491eb44628 if walks like a class and talks like a class, it is a class 2013-09-15 23:03:35 +02:00
kikito
f107a68a20 added header to middleclass, and returned it 2013-09-15 15:51:49 +02:00
Enrique García Cota
04ffc69a5e added license directly to middleclass.lua 2011-09-19 00:32:17 +02:00
Enrique García Cota
3f9ae1d6e8 merged branch 2.0 2011-09-19 00:21:14 +02:00
Enrique García Cota
c2e4fce043 mixins now support static methods 2011-09-18 17:40:50 +02:00
Enrique García Cota
1df9ccf178 added list of subclasses per class 2011-08-14 18:39:57 +02:00
Enrique García Cota
252b63f8f6 removed mixin parameters. Added possibility of including several mixins simultaneously 2011-08-14 18:07:44 +02:00
Enrique García Cota
21735533d5 updated README, removed unused lines 2011-08-14 00:17:29 +02:00
Enrique García Cota
69d469b67a added subclassed hook method 2011-08-14 00:08:33 +02:00
Enrique García Cota
6c9f6a0074 added mixin support 2011-08-13 23:58:55 +02:00
Enrique García Cota
ce3be2d45b Class.superclass -> Class.super . YEAH 2011-08-13 03:38:31 +02:00
Enrique García Cota
af03b4f6d8 fixed error in Object_spec that made other tests fail in some cases. Added some minor optimizations & fixes 2011-08-13 03:12:21 +02:00
Enrique García Cota
da557bb207 split tests more. refactorized class creation. included metamethod support 2011-08-12 10:33:58 +02:00
Enrique García Cota
90bef60d86 fixed test with Object() 2011-08-11 11:36:23 +02:00
Enrique Garcia Cota
40e14838a2 added instanceOf and subclassOf, as well as splitted into more files. Having issues with Object() (call metamethod) 2011-08-10 21:45:15 +02:00
Enrique García Cota
0e637ea8da separated into more files added instancemethods and attributes 2011-08-08 23:59:23 +02:00
Enrique García Cota
fc682e12dd initial implementation of allocate and new done 2011-08-08 23:18:15 +02:00
Enrique García Cota
7487c9ba79 added the initial subclass implementation. renamed Class.class to Class.static 2011-08-08 22:29:18 +02:00
Enrique García Cota
3461767eba discarded static() approach due to syntax error. Using Class.class for static variables 2011-08-08 07:38:11 +02:00
Enrique García Cota
25fcd5e030 bootstrapping and little else 2011-08-08 00:07:02 +02:00
Enrique García Cota
268004682c renamed "module" to "mixin" 2011-08-07 00:48:13 +02:00
Enrique García Cota
30b6195435 made the __metamethods table part of Object, so it can be reused in mixins 2011-04-14 00:33:42 +02:00
Enrique García Cota
01f2248ce1 small fix on Object.include param check 2011-04-12 00:00:40 +02:00
Enrique García
f775d375e3 changed date on initial comment. fixes #10 2011-04-06 15:28:35 +02:00