lua hotfix ios app
cd serverSample
node server.js
Objective-c
@implementation ViewController
- (void)doSomeThing
{
[self.view setBackgroundColor:[UIColor grayColor]];
}
lua
spa_class("ViewController")
function doSomeThing(self)
self:view():setBackgroundColor_(UIColor:grayColor())
end
Objective-c
@implementation ViewController
- (void)doSomeThing:(UIColor *)color
{
[self.view setBackgroundColor:color];
}
lua
spa_class("ViewController")
function doSomeThing_(self, color)
self:view():setBackgroundColor_(color)
end
Objective-c
@implementation ViewController
- (void)doSomeThing:(UIColor *)color
{
[self.view setBackgroundColor:color];
}
lua
spa_class("ViewController")
function doSomeThing_(self, color)
self:ORIGdoSomeThing_(color)
end
Objective-c
@implementation SUBViewController
- (void)doSomeThing:(UIColor *)color
{
[super doSomeThing:color];
}
lua
spa_class("ViewController")
function doSomeThing_(self, color)
self:SUPERdoSomeThing_(color)
end
Objective-c
@implementation SUBViewController
- (void)doSomeThing:(void(^)(int i))block
{
block(5);
}
lua
spa_class("ViewController")
function doSomeThing_(self, block)
block(5)
end
Objective-c
@implementation ViewController
- (void(^)(void))doSomeThing
{
void(^block)(void) = ^() { };
return block;
}
lua
spa_class("ViewController")
function doSomeThing_(self, block)
return function (i) end
end
Objective-c
@implementation ViewController
- (void(^)(int))doSomeThing
{
void(^block)(int) = ^(int i) { };
return block;
}
lua
spa_class("ViewController")
function doSomeThing_(self, block)
return block(function (i) end, 'v', {'i'})
end
Objective-c
@implementation ViewController
- (void)doSomeThing_(CGPoint)p
{
int x = p.x;
int y = p.y;
}
lua
spa_class("ViewController")
function doSomeThing_(self, p)
local x = p.x1
local y = p.x2
end
Objective-c
@implementation ViewController
- (CGPoint)doSomeThing
{
CGPoint p;
p.x = 3;
p.y = 4;
return p;
}
lua
spa_class("ViewController")
function doSomeThing(self)
return {3,4}
end
Objective-c
@implementation ViewController
- (void(^)(CGPoint, CGRect))doSomeThing
{
void(^block)(CGPoint, CGRect) = ^(CGPoint, CGRect) {
};
return block;
}
lua
spa_class("ViewController")
function doSomeThing()
return block(function (point, rect) end, 'v', {'{CGPoint=gg}', '{CGRect=gggg}'})
end
@implementation ViewController
- (void)doSomeThing
{
...
[self doSomeThingInternal];
...
}
- (void)doSomeThingInternal
{
...
}
lua
class_deep('ViewController', 'doSomeThing', 'ViewController', 'doSomeThingInternal', function () end) -- remove doSomeThingInternal impl in doSomeThing only
@implementation ViewController
- (void)doSomeThing
{
if(self.view == nil){
...
}
}
lua
spa_class("ViewController")
function doSomeThing()
if(spa.isNull(self:view()))
then
end
end
use spa.isNull to determinate whether instance is nil or not. hzfanfei#1