hyperloop-macros
Advanced tools
Comparing version 0.2.0 to 0.3.0
48
obj-c.js
@@ -11,8 +11,6 @@ macro use { | ||
rule infix { $l:ident | $r:objc_type_name } => { | ||
($l != null) && $l.cast($r) | ||
$l.cast($r) | ||
} | ||
rule infix { $l:expr | $r:objc_type_name } => { | ||
(function (v) { | ||
return (v != null) && v.cast($r); | ||
})($l) | ||
($l).cast($r) | ||
} | ||
@@ -80,4 +78,4 @@ } | ||
macroclass objc_method_alias { | ||
pattern { rule { + $returns:objc_type_name $params:objc_method_params $body } with $static = #{1} } | ||
pattern { rule { - $returns:objc_type_name $params:objc_method_params $body } with $static = #{0} } | ||
pattern { rule { + $returns:objc_type_name $params:objc_method_params { $body ... } } with $static = #{1} } | ||
pattern { rule { - $returns:objc_type_name $params:objc_method_params { $body ... } } with $static = #{0} } | ||
} | ||
@@ -90,23 +88,43 @@ | ||
var args = []; | ||
var argNames = []; | ||
var argTemps = []; | ||
var argValues = []; | ||
var i = 0, l = params.length; | ||
var argPart, argType; | ||
var argPart, argType, argTemp, argName; | ||
var ctx = #{ $ctx }; | ||
if (params[ 1 ].token.type !== parser.Token.NullLiteral) { | ||
for (; i < l; i += 3) { | ||
// The part of the method as a string value | ||
argPart = unwrapSyntax(params[ i + 0 ]); | ||
argPart = makeValue(String(argPart), ctx); | ||
// The type of the argument as a string value | ||
argType = unwrapSyntax(params[ i + 1 ]); | ||
argType = makeValue(String(argType), ctx); | ||
// The temporary _arg for storing an uncasted argument, as ident | ||
// (the underscore is not necessary because we have Sweet.js hygene, | ||
// just for style) | ||
argTemp = "_" + unwrapSyntax(params[ i + 2 ]); | ||
// Passing `null` as a context ensures that this new ident cannot be | ||
// referenced from the source code. | ||
argTemp = makeIdent(String(argTemp), null); | ||
// The actual name specified, as ident | ||
argName = unwrapSyntax(params[ i + 2 ]); | ||
argName = makeIdent(String(argName), ctx); | ||
args = args.concat(#{,}).concat([ makeDelim( '{}', #{name:}.concat(argPart).concat(#{,}).concat(#{type:}).concat(argType), ctx) ]); | ||
argNames = argNames.concat(#{,}).concat(argName); | ||
args = args.concat(#{,}).concat([ | ||
makeDelim( '{}', #{name:}.concat(argPart).concat(#{,}).concat(#{type:}).concat(argType), ctx) | ||
]); | ||
argTemps = argTemps.concat(#{,}).concat(argTemp); | ||
argValues = argValues.concat(#{,}).concat(argName).concat(#{=}).concat(argTemp).concat(#{as}).concat(argType); | ||
} | ||
args = args.slice(1); | ||
argNames = argNames.slice(1); | ||
argTemps = argTemps.slice(1); | ||
argValues = argValues.slice(1); | ||
} | ||
@@ -116,3 +134,4 @@ | ||
letstx $methodArgs = args; | ||
letstx $funcArgs = argNames; | ||
letstx $funcTemps = argTemps; | ||
letstx $funcValues = argValues; | ||
@@ -124,3 +143,6 @@ return #{{ | ||
arguments: [ $methodArgs ], | ||
action: function ( $funcArgs ) $m$body | ||
action: function ( $funcTemps ) { | ||
var $funcValues; | ||
$m$body ... | ||
} | ||
}} | ||
@@ -127,0 +149,0 @@ } |
{ | ||
"name": "hyperloop-macros", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Macros to accelerate Hyperloop development", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -42,4 +42,4 @@ Hyperloop Macros | ||
// Casting is done with the `as` keyword | ||
locations = locations as (NSArray *); | ||
// Casting is done with the `as` keyword, but for arguments is not necessary | ||
var locationsRecasted = locations as (NSArray *); | ||
@@ -46,0 +46,0 @@ // Message passing is activated with `@` in dot-notation style |
@@ -62,3 +62,7 @@ | ||
//+ ((UIWindow*)*) gestureRecognize { return this; } | ||
+ ((UIWindow*)*) gestureRecognize:(id)gesture lol:(id)x { return gesture + x; } | ||
- ((UIWindow*)*) gestureRecognize:(id)gesture lol:(id)x { return gesture + x; } | ||
- ((UIWindow*)*) gestureRecognize:(id)gesture lol:(id)x { | ||
var _gesture = 90, _x = 89; | ||
return gesture + x; | ||
} | ||
//+ (UIWindow*) gestureRecognize:(id) gesture { return this; } | ||
@@ -65,0 +69,0 @@ //+ (UIWindow) gestureRecognize:(id) gesture { return this; } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38260
269