I have a lua library that must be created like this
local Job = require"plenary.job"
local job = Job:new()
This forces me to do some weird things in the Haxe side. First, I need it to be a class because all the methods must be called with :method syntax, including the new method, which in Haxe seems to be always static.
In order for this to work I had to define it like this:
@:luaRequire("plenary.job")
extern class Job {
function new();
@:native('new')
function make(args:JobOpts):Job;
function start():Job;
}
Then called like this (which is a bit tedious)
final job = new Job().make(real_opts);
Is there any better way? I see Haxe has one annotation to force dot notation, but does not seem to have one to do the opposite.
Ok, it does not work even in that way. The generated lua code still calls new without colon first, then my method:
local job = __plenary_Job.new();
local ret = ({});
local _g = 0;
local _g1 = args.length;
while (_g < _g1) do
_g = _g + 1;
local idx = _g - 1;
ret[idx + 1] = args[idx];
end;
local this1 = ({command = "chezmoi", arguments = ret});
local job = job:new(this1);