Commit Graph

219 Commits

Author SHA1 Message Date
jojo59516
cc5cc98873 add test case for checking type of instance's __index 2019-11-27 11:21:56 +08:00
Chao Yin
63f83ea0ef reduce a conditional branch in wrapped __index function 2019-10-18 18:50:22 +08:00
Chao Yin
fd25b1a006 subclass's __instanceDict.__index should be a table if there is no custom __index 2019-10-18 18:49:15 +08:00
Enrique García Cota
6102f676c2 new rockspec 2018-03-10 12:39:15 +01:00
Enrique García Cota
dc0fb3612d update changelog 2018-03-10 12:36:26 +01:00
Enrique García Cota
d7725e5acd Bump version to 4.1.1 2018-03-10 12:36:16 +01:00
Enrique García Cota
ccab332079 isInstanceOf works on primitives.
Fixes #55
2018-03-07 09:27:56 -08:00
Enrique García Cota
f9955f9285
Merge pull request #51 from qaisjp/patch-1
Fix return of super.static if val false (fix #50)
2017-12-06 12:55:05 +01:00
Qais Patankar
c13b4a4f6a
Fix use of C-syntax 2017-11-08 13:45:31 +00:00
Qais Patankar
6b4bc410d6
Fix return of super.static if val false (fix #50) 2017-11-08 11:19:31 +00:00
kikito
27a64f107e updates rockspec 2016-07-02 06:13:25 +02:00
kikito
13e889d06c bump version to 4.1.0 2016-07-02 06:08:20 +02:00
Enrique García
0250f97bea Merge pull request #41 from kikito/simplify
simplifies isInstanceOf & isSubclassOf. Fixes #39
2016-07-02 06:05:55 +02:00
kikito
2bcef2b9ff simplifies isInstanceOf & isSubclassOf. Fixes #39 2016-07-02 06:00:03 +02:00
Enrique García
566a809333 Update UPDATING.md 2016-03-20 18:49:56 +01:00
kikito
bffb00b195 fixes luacheck errors 2016-01-02 09:57:00 +01:00
kikito
443dd5e3f5 adds luacheck to travis 2016-01-02 09:33:34 +01:00
kikito
49579a59f4 adds rockspec for v4.0 2015-12-31 18:58:13 +01:00
kikito
9cb11c4dd6 Merge branch 'v4.0' 2015-12-31 18:54:36 +01:00
kikito
3527b5cab9 eliminates innecessary metatable setting 2015-12-31 18:52:39 +01:00
kikito
958cae6c1c restores :allocate and adds more documentation 2015-12-31 00:47:37 +01:00
kikito
4789a39d14 update changelog 2015-12-28 10:58:49 +01:00
kikito
7894eb7790 Refactor & remove class:allocate 2015-12-27 23:53:10 +01:00
kikito
fc61416c81 first green version using unified method/metamethod resolver 2015-12-27 15:42:49 +01:00
kikito
13173150de adds coveralls badge 2015-12-27 12:51:50 +01:00
kikito
8baac4b8f0 attempts to exclude files from luacov 2015-12-26 13:27:36 +01:00
kikito
2e069c5e5b separates before_install & install steps in travis 2015-12-26 13:11:58 +01:00
kikito
052840502b attempts to use luacov 2015-12-26 13:04:33 +01:00
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
kikito
79a7e02954 Merge branch 'index-newindex' of https://github.com/mpeterv/middleclass into mpeterv-index-newindex 2015-12-10 09:25:13 +01:00
mpeterv
ab1699bb05 Do not wrap __newindex 2015-11-28 18:10:35 +03:00
mpeterv
7574380519 Add tests for custom __index and __newindex 2015-11-24 18:48:17 +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
0ffa9094c0 add 3.2.0 rockspec 2015-11-23 23:39:54 +01: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
b66ba54ccb Add tests for __mode 2015-11-19 14:10:38 +03:00
mpeterv
b0b655d1c0 Add tests for __metatable 2015-11-19 13:59:19 +03:00
mpeterv
f331dc4248 Fix __gc tests
Tests for inherited __gc used to pass even without the feature being
implemented, most likely because objects from previous tests got
collected just in time.
2015-11-19 13:53:51 +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
0f9d5c8e61 Add tests for overriding metamethods 2015-11-19 13:13:04 +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
e7d8bc00d6 add 3.1.0 rockspec 2015-11-02 17:40:47 +01:00
kikito
738c1968a5 add 3.1.0 rockspec 2015-11-02 17:39:06 +01:00
kikito
9fb0f72a74 bump version to 3.1.0 2015-11-02 17:37:30 +01:00
kikito
a5a334c775 splits 5.2 and 5.3 metamethods into separate files. Fixes 5.3 errors 2015-11-01 17:09:15 +01:00
kikito
cd8ce449e1 make lua < 5.3 not fret about new operators by using eval in 5.3 sections 2015-10-31 17:16:10 +01:00