Created
December 8, 2011 23:08
-
-
Save skial/1449156 to your computer and use it in GitHub Desktop.
Near to minimal php as possible - minimal code example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
/** | |
* ... | |
* @author Skial Bainn | |
*/ | |
extern class Date { | |
// http://www.php.net/manual/en/function.mktime.php | |
public inline function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ):Void { | |
return untyped __call__("mktime", hour, min, sec, month+1, day, year); | |
} | |
public inline function getTime():Float { | |
return untyped this * 1000; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Main { | |
public function __construct(){} | |
static function main() { | |
// this to be in its place - mktime(15, 25, 0, 12, 8, 2011) | |
$date = new Date(2011, 12, 8, 15, 25, 0); | |
$date * 1000; | |
} | |
function __toString() { return 'Main'; } | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import php.Lib; | |
/** | |
* ... | |
* @author Skial Bainn | |
*/ | |
class Main { | |
public static function main():Void { | |
var date = new Date(2011, 12, 08, 15, 25, 0); | |
date.getTime(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I currently need to output minimal code and files, so converting some haxe classes to output direct php methods, instead of the haxe generated classes which basically wrap the same php methods.
Every
inline
method gets generated correctly apart from the constructor, so I currently use a static method namedinit
or similar to start everything.I don't think I would be able to get around this using macros, if it is - just say and I'll start digging, but I think the compiler would complain of a missing constructor.
new
? example:// pseudo // replace.patch Date.new : static Date.init
As far as I can tell from looking at http://haxe.org/manual/swc and http://code.google.com/p/haxe/source/browse/trunk/doc/extract.patch I don't see anything like this, correct me if I'm wrong :)