[ZeroBrane Studio] Re: Debugging interoperation with middleclass.lua

  • From: Rob Probin <rob.probin@xxxxxxxxx>
  • To: zerobrane@xxxxxxxxxxxxx
  • Date: Wed, 12 Mar 2014 22:15:29 +0000

On 12/03/2014 16:40, Paul K wrote:
I haven't thought about this aspect, but why is it bad that
metamethods are called? Why did you need to comment them out? If
needed, this can be added to the monkeypatch above, but I want to
understand why that change may be required. Thank you.

I get Error: ../path/to/middleclass.lua:66: class GlyphEditor doesn't implement metamethod '__len'

without removing __len or

Error: ../path/to/middleclass.lua:66: class GlyphEditor doesn't implement metamethod '__pairs'

without removing __pairs.

These look like they are produced by _createLookupMetamethod.

local function _createLookupMetamethod(aClass, name)
   return function(...)
     local method = aClass.super[name]
     assert( type(method)=='function', tostring(aClass) .. " doesn't
implement metamethod '" .. name .. "'" )
     return method(...)
   end
end

local function _setClassMetamethods(aClass)
   for _,m in ipairs(aClass.__metamethods) do
     aClass[m]= _createLookupMetamethod(aClass, m)
   end
end



Other related posts: