[haXe] best strategy to port an existing js library

Danny Wilson danny at decube.net
Fri Dec 7 18:27:52 CET 2007


On Fri, 07 Dec 2007 18:22:38 +0100, Franco Ponticelli  
<franco.ponticelli at gmail.com> wrote:

> You are cheating ;-) Your methods are not static. And if I want to use  
> them
> in an instance I can't because there is no constructor. Which way is the  
> one
> you wanted to develop?
>

I assumed people know about prototyping so I'll just extend my example:


class MyWrappingClass
{
   static function __init__()
   {
     untyped MyWrappingClass.prototype.niceAlert = __js__("niceAlert");
   }

   /** Static call **/
   public static function niceAlert(txt:String):Void = untyped  
__js__("niceAlert");

   /** Instance call to the same function **/
   public function niceAlert(txt:String); // Returns void

   // This is actually a cheat, I agree.
   public function  
someOtherFunctionWhichReturnsSomething(txt:String):ReturnType
   {return null;} // To trick haxe compiler

   public function new(); // Happy Franco? ;-P
}

Good luck, hehe


Kind regards,

      Danny Wilson


deCube.net - http://decube.net/
web application design and development




More information about the Haxe mailing list