TheHippo / hxfcgi

CGI/FastCGI Wrapper for nekoVM and the haxe cpp target
Other
17 stars 5 forks source link

hxfcgi conflicts with SPOD macros in latest haXe nightly builds #8

Closed The-o closed 13 years ago

The-o commented 13 years ago

Using hxfcgi and SPOD macros in a program causes a compile-time error.

=== Main.hx === package ;

import neko.Lib; import neko.Web; class Main {

public static function main() {
    Web.cacheModule(processRequest);
}

public static function processRequest() {
    Web.setHeader("Content-type", "text/plain");
    Lib.print("OK");
}

}

import neko.db.Object; import neko.db.Manager;

@:id(id) class DbObj extends Object {

public var id:Int;
@:relation(DbObj)
public var parent(dynamic,dynamic):DbObj;

static var TABLE_NAME = "DbObj";
public static var manager:Manager<DbObj> = new Manager<DbObj>(DbObj);

} === /Main.hx ===

=== build.hxml === -lib hxfcgi -D HXFCGI -D spod_macro -neko test.n -main Main === /build.hxml ===

$haxe build.hxml /home/o/haxe/lib/hxfcgi/0,1,2/neko/Lib.hx:33: characters 17-68 : You cannot use the library '/home/o/HXFCGIhxfcgi' inside a macro /home/o/haxe/lib/hxfcgi/0,1,2/neko/Web.hx:338: characters 10-51 : Called from /home/o/haxe/lib/hxfcgi/0,1,2/neko/Web.hx:37: characters 35-70 : Called from Aborted

As far as I understand, SPOD macros (or haXe macroprocessor?) use neko.Lib class. But hxfcgi redefines (provided -D HXFCGI is set) neko.Lib.print() and neko.Lib.println() so they refer to neko.Web class which tries to load hxfcgi.ndll primitives at the static fields initialization time. But the hxfcgi library can't be used inside macros. I don't know why it can't be used. It worked fine with with 2.07 release. But i think it would be best not to allow redefined neko.Web class to appear in neko.Lib during macro execution process anyway.

So I think replacing "#if HXFCGI" to "#if (HXFCGI && !macro)" in hxfcgi's neko.Lib.print() and neko.Lib.println() should fix the problem and help to avoid some problems in future.

TheHippo commented 13 years ago

Thank for the report. We will take a look into this.

On 22.06.2011 21:59, The-o wrote:

Using hxfcgi and SPOD macros in a program causes a compile-time error.

=== Main.hx === package ;

import neko.Lib; import neko.Web; class Main {

public static function main() { Web.cacheModule(processRequest); }

public static function processRequest() { Web.setHeader("Content-type", "text/plain"); Lib.print("OK"); }

}

import neko.db.Object; import neko.db.Manager;

@:id(id) class DbObj extends Object {

public var id:Int; @:relation(DbObj) public var parent(dynamic,dynamic):DbObj;

static var TABLE_NAME = "DbObj"; public static var manager:Manager = new Manager(DbObj);

} === /Main.hx ===

=== build.hxml === -lib hxfcgi -D HXFCGI -D spod_macro -neko test.n -main Main === /build.hxml ===

$haxe build.hxml /home/o/haxe/lib/hxfcgi/0,1,2/neko/Lib.hx:33: characters 17-68 : You cannot use the library '/home/o/HXFCGIhxfcgi' inside a macro /home/o/haxe/lib/hxfcgi/0,1,2/neko/Web.hx:338: characters 10-51 : Called from /home/o/haxe/lib/hxfcgi/0,1,2/neko/Web.hx:37: characters 35-70 : Called from Aborted

As far as I understand, SPOD macros (or haXe macroprocessor?) use neko.Lib class. But hxfcgi redefines (provided -D HXFCGI is set) neko.Lib.print() and neko.Lib.println() so they refer to neko.Web class which tries to load hxfcgi.ndll primitives at the static fields initialization time. But the hxfcgi library can't be used inside macros. I don't know why it can't be used. It worked fine with with 2.07 release. But i think it would be best not to allow redefined neko.Web class to appear in neko.Lib during macro execution process anyway.

So I think replacing "#if HXFCGI" to "#if (HXFCGI&& !macro)" in hxfcgi's neko.Lib.print() and neko.Lib.println() should fix the problem and help to avoid some problems in future.

vixns commented 13 years ago

Thanks for your detailed report, fixed as suggested for neko and cpp targets.