Prev | Current Page 310 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

ndll that declares a function this way:
#include < neko.h >
value say()
{
return alloc_string(???Hello world???);
}
DEFINE_PRIM(say, 0);
In haXe it will possible to use the preceding function like this:
var say : Void - > Void = neko.Lib.load (???helloworld???, ???say???,0);
trace(say());
The loadPrimitive will pass a reference to the function say in the C library. The second parameter 0
is the number of arguments that the function requires. You can find more information about C
integration in the third part of the book and especially in Chapter 20 .
159
Chapter 6: Organizing Your Code
JavaScript External Libraries
The community of web developers has produced plenty of libraries in JavaScript from novice code to
very interesting frameworks and applications. Having the possibility to reuse this code without
reinventing the wheel can be a real timesaver. External libraries are neither dynamically loaded
(although possible) nor embedded (possible, too, but very clumsy). To be accessible the libraries must
only be included in the same HTML page where the haXe code is intended to be used.


Pages:
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322