I wrote the original code for basic.lua.
This is a big hammer better easy to understand.
Maybe the code for remove_prefix could be simplified and made a little more explicit
local function remove_prefix(str)
local skip_contents = {
CCPointMake = "CCPointMake",
CCSizeMake = "CCSizeMake",
CCRectMake = "CCRectMake",
CCLOG = "CCLOG",
CCLog = "CCLog",
CCAssert = "CCAssert",
CCTexture2DPixelFormat = "CCTexture2DPixelFormat",
CCTextAlignment = "CCTextAlignment",
CCVerticalTextAlignment = "CCVerticalTextAlignment",
CCControlState = "CCControlState",
CCControlEvent = "CCControlEvent",
CCControlEventTouchDown = "CCControlEventTouchDown",
CCControlEventTouchDragInside = "CCControlEventTouchDragInside",
CCControlEventTouchDragOutside = "CCControlEventTouchDragOutside",
CCControlEventTouchCancel = "CCControlEventTouchCancel",
CCControlEventTouchDragEnter = "CCControlEventTouchDragEnter",
CCControlEventTouchDragExit = "CCControlEventTouchDragExit",
CCControlEventTouchUpInside = "CCControlEventTouchUpInside",
CCControlEventTouchUpOutside = "CCControlEventTouchUpOutside",
CCControlEventValueChanged = "CCControlEventValueChanged",
CCControlStateNormal = "CCControlStateNormal",
CCControlStateHighlighted = "CCControlStateHighlighted",
CCControlStateDisabled = "CCControlStateDisabled",
CCControlStateSelected = "CCControlStateSelected",
-- modified
tCCPositionType = 'tPositionType',
tCCImageFormat = 'tImageFormat',
tCCParticle = 'tParticle',
newCCImage = 'newImage', }
return string.gsub(str, '([^"_)k])(CC%u%w+)', function(p, m)
return p .. (skip_contents[m] or string.gsub(m, 'CC(%w+)', '%1'))
end)
end
This by the way is significantly faster
Andre