Skip to content

Instantly share code, notes, and snippets.

@AxGord
Created August 11, 2014 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AxGord/5ce2b9e63991a764fb65 to your computer and use it in GitHub Desktop.
Save AxGord/5ce2b9e63991a764fb65 to your computer and use it in GitHub Desktop.
package ;
import haxe.Log;
import pony.events.Event;
import pony.xr.modules.Object;
import pony.xr.modules.Op;
import pony.xr.modules.V;
import pony.xr.XmlRequest;
using pony.Tools;
/**
* ...
* @author AxGord <axgord@gmail.com>
*/
class XRExample {
static function main() {
var xr = new XmlRequest([new Op(), new V(), new pony.xr.modules.Array(), new Object()]);
xr.log << Log.trace;
xr.error << Log.trace;
xr.error << function() throw 'abort';
var op = '<op n="sqrt"><op n="sqrt">%custom%</op></op>';
var x = op.fast();
xr.run(x, [function(n, m) switch n {
case V:
var m:V = cast m;
m.values['custom'] = 16;
}], function(r) trace(r));
xr.run('<v set="my">0.5</v><op n="sum"><v>2</v><v>4</v><op n="neg">%my%</op></op>'.fast(), [], function(r) trace(r));
xr.run('<op n="*"><v>2</v><v>3</v><v>4</v></op>'.fast(), [], function(r) trace(r));
xr.run('<array><v>1</v><v>3</v><v>5</v><d/></array>'.fast(), [], function(r) trace(r), function(x) x.error << function(e:Event) { trace(e.args[0]); e.stopPropagation(); } );
xr.run('<array>
<object><e n="name">Vasya</e><e n="age"><op n="+"><v>30</v><v>3</v></op></e></object>
<object><e n="name">Petya</e><e n="age">20</e></object>
</array>'.fast(), [], function(r) trace(r));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment