Externs and reserved words...

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Externs and reserved words...

sledorze
would be nice to be able to express (lol) that in externs :

                  express.static(__dirname + '/public'),

the problem being that static is a reserved word (back quotes??).

Stéphane
Reply | Threaded
Open this post in threaded view
|

Re: Externs and reserved words...

sledorze
just recalled:

@:native("static") function static_ (..)

does the trick.. :)
Reply | Threaded
Open this post in threaded view
|

Re: Externs and reserved words...

sledorze
I wasn't testing the right code.. in fact @:native("..") works for class, not functions .. :\
Problem still open for solutions..
Reply | Threaded
Open this post in threaded view
|

Re: Externs and reserved words...

Cauê W.
stephane, what do you need to do?
If you need to add an initialization code, you can try untyped __js__ on a static function __init__() block

2011/10/12 sledorze <[hidden email]>
I wasn't testing the right code.. in fact @:native("..") works for class, not
functions .. :\
Problem still open for solutions..


--
View this message in context: http://haxe.1354130.n2.nabble.com/Externs-and-reserved-words-tp6885385p6886778.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Externs and reserved words...

sledorze
I try to find a solution not to do that :)
(actually I'm doing that behind an extension method with a close name 'static_')
Reply | Threaded
Open this post in threaded view
|

Re: Externs and reserved words...

singmajesty
In some cases, I've had to do something like this:



Before:


extern class NativeClass {
       
        public static function restrictedMethodName () {}

}



After:


@:native ("NativeClass_haxe")
class NativeClass {
       
        public static function unrestrictedMethodName () {
               
                untyped __js__ ("NativeClass.restrictedMethodName") ();
               
        }
       
}


On Wed, 12 Oct 2011 14:40:11 -0700, sledorze <[hidden email]>  
wrote:

> I try to find a solution not to do that :)
> (actually I'm doing that behind an extension method with a close name
> 'static_')
>
>
> --
> View this message in context:  
> http://haxe.1354130.n2.nabble.com/Externs-and-reserved-words-tp6885385p6886840.html
> Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Externs and reserved words...

clemos
You also may want to inline it for optimization.
public static inline function unrestrictedMethodName () {

Cheers,
Clément

On Thu, Oct 13, 2011 at 4:05 AM, Joshua Granick
<[hidden email]> wrote:

> In some cases, I've had to do something like this:
>
>
>
> Before:
>
>
> extern class NativeClass {
>
>        public static function restrictedMethodName () {}
>
> }
>
>
>
> After:
>
>
> @:native ("NativeClass_haxe")
> class NativeClass {
>
>        public static function unrestrictedMethodName () {
>
>                untyped __js__ ("NativeClass.restrictedMethodName") ();
>
>        }
>
> }
>
>
> On Wed, 12 Oct 2011 14:40:11 -0700, sledorze <[hidden email]>
> wrote:
>
>> I try to find a solution not to do that :)
>> (actually I'm doing that behind an extension method with a close name
>> 'static_')
>>
>>
>> --
>> View this message in context:
>> http://haxe.1354130.n2.nabble.com/Externs-and-reserved-words-tp6885385p6886840.html
>> Sent from the Haxe mailing list archive at Nabble.com.
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Externs and reserved words...

sledorze
In reply to this post by singmajesty
The case is different in the sense that the class (or type) must be an extern, so here's what I came up (requires 'using')



extern
class Express {

public function cookieParser() :MiddleWare;
...
public function errorHandler (options :Dynamic) :MiddleWare;

public function logger() : MiddleWare;

inline public static function static_(exp : Express, path : String, ?option : Dynamic) : MiddleWare {
var x = exp;
var p = path;
var o = option;
return untyped __js__("x.static(p, o)");
}
}

On Thu, Oct 13, 2011 at 4:07 AM, singmajesty [via Haxe] <[hidden email]> wrote:
In some cases, I've had to do something like this:



Before:


extern class NativeClass {
       
        public static function restrictedMethodName () {}

}



After:


@:native ("NativeClass_haxe")
class NativeClass {
       
        public static function unrestrictedMethodName () {
               
                untyped __js__ ("NativeClass.restrictedMethodName") ();
               
        }
       
}


On Wed, 12 Oct 2011 14:40:11 -0700, sledorze <[hidden email]>  
wrote:

> I try to find a solution not to do that :)
> (actually I'm doing that behind an extension method with a close name
> 'static_')
>
>
> --
> View this message in context:  
> http://haxe.1354130.n2.nabble.com/Externs-and-reserved-words-tp6885385p6886840.html

> Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org



If you reply to this email, your message will be added to the discussion below:
http://haxe.1354130.n2.nabble.com/Externs-and-reserved-words-tp6885385p6887378.html
To unsubscribe from Externs and reserved words..., click here.



--
Stéphane Le Dorze