Prev | Current Page 306 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

It is possible to see what a .neko file looks like,
adding the switch - - neko - source , which preserves the intermediate generated file. Any .n file is a
module that can contain an entire application or just a bunch of classes to use as a library. Usually the
best bet is to merge the main project and the external library using the class path switch ( - cp ), but there
are cases where this is not possible.
To illustrate the use of an external library dynamically loaded, one class External with one function
say() is created.
class External
{
public function new() { }
public function say() : String
{
return ???Hello world!???;
}
}
(continued)
157
Chapter 6: Organizing Your Code
The class is then compiled using the following command:
> haxe -neko external.n External
Because it does not make any sense to use this module alone, the - main switch has been omitted.
The external library is now ready to be loaded dynamically and to be used through reflection. Remember
to put the generated external.n file in the same output directory as the example.


Pages:
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318