hyperloop-macros
Advanced tools
Comparing version 0.1.1 to 0.2.0
40
obj-c.js
@@ -7,4 +7,12 @@ macro use { | ||
macro as { | ||
rule infix { $l:lit | $r:objc_type_name } => { | ||
$l.cast($r) | ||
} | ||
rule infix { $l:ident | $r:objc_type_name } => { | ||
($l != null) && $l.cast($r) | ||
} | ||
rule infix { $l:expr | $r:objc_type_name } => { | ||
(($l != null) && $l.cast($r)) | ||
(function (v) { | ||
return (v != null) && v.cast($r); | ||
})($l) | ||
} | ||
@@ -138,2 +146,31 @@ } | ||
macroclass objc_message_param_alias { | ||
pattern { rule { $part $[:] $arg:expr } } | ||
} | ||
macro (@) { | ||
case infix { | ||
$receiver:expr | $ctx $method ( $first:expr , $rest:objc_message_param_alias (,) ... ) | ||
} => { | ||
var parts = #{ $rest$part ... }; | ||
var name = #{ $method }.concat(#{ $rest$part ... }).map(unwrapSyntax).concat('').join(':'); | ||
letstx $name = [ makeValue(name, #{ $ctx }) ]; | ||
return #{ Hyperloop.method($receiver, $name).call( $first, $($rest$arg) (,) ... ) }; | ||
} | ||
case infix { | ||
$receiver:expr | $ctx $method ( $first:expr ) | ||
} => { | ||
var name = unwrapSyntax(#{ $method }) + ':'; | ||
letstx $name = [ makeValue(name, #{ $ctx }) ]; | ||
return #{ Hyperloop.method($receiver, $name).call( $first ) }; | ||
} | ||
case infix { | ||
$receiver:expr | $ctx $method ( ) | ||
} => { | ||
var name = unwrapSyntax(#{ $method }); | ||
letstx $name = [ makeValue(name, #{ $ctx }) ]; | ||
return #{ Hyperloop.method($receiver, $name).call( ) }; | ||
} | ||
} | ||
// Public | ||
@@ -144,2 +181,3 @@ | ||
export class; | ||
export (@); | ||
@@ -146,0 +184,0 @@ // Protected |
{ | ||
"name": "hyperloop-macros", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Macros to accelerate Hyperloop development", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -44,2 +44,8 @@ Hyperloop Macros | ||
locations = locations as (NSArray *); | ||
// Message passing is activated with `@` in dot-notation style | ||
locationManager@startUpdatingLocation(); | ||
// Since the second argument we follow Swift’s form | ||
locationManager@allowDeferredLocationUpdatesUntilTraveled(null, timeout: null); | ||
} | ||
@@ -46,0 +52,0 @@ } |
23
usage.js
@@ -84,9 +84,16 @@ | ||
console.log( objc_type_name (UIWindow * *) ) | ||
console.log( objc_type_name ((UIWindow*)*) ) | ||
console.log( objc_type_name (UIWindow*) ) | ||
console.log( objc_type_name (UIWindow) ) | ||
console.log( objc_type_name UIWindow ) | ||
console.log( objc_type_name 'UIWindow**' ) | ||
console.log( objc_type_name 'UIWindow*' ) | ||
console.log( objc_type_name 'UIWindow' ) | ||
console.log( objc_type_name (UIWindow * *) ); | ||
console.log( objc_type_name ((UIWindow*)*) ); | ||
console.log( objc_type_name (UIWindow*) ); | ||
console.log( objc_type_name (UIWindow) ); | ||
console.log( objc_type_name UIWindow ); | ||
console.log( objc_type_name 'UIWindow**' ); | ||
console.log( objc_type_name 'UIWindow*' ); | ||
console.log( objc_type_name 'UIWindow' ); | ||
var message; | ||
console.log( receiver@message( ) ); | ||
console.log( receiver@message( 42 as Answer ) ); | ||
console.log( receiver@message( 42, with: 32 ) ); | ||
console.log( receiver@message( 42, with: 24, and: 58 ) ); |
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
37274
248
79