+ (* return inline function *)
+ printf "\nstatic int luaM_ret_%s_%s(lua_State *L" pkg.name fn.fname;
+ let retlen = List.fold_left (fun i t ->
+ let i = i + 1 in
+ match t with
+ | true, typ -> printf ", const %s luaM_x%d" (t1 typ.ctype) i; i
+ | false, typ -> printf ", %s luaM_x%d" (t1 typ.ctype) i; i
+ ) 0 fn.rettype in
+ printf ")\n{\n";
+ ignore (List.fold_left (fun i (const, typ) ->
+ let i = i + 1 in
+ let (p, f, l) = typ.push in
+ put_line l f;
+ printf " %s;\n" (tplize p (sprintf "luaM_x%d" i));
+ if not const then (
+ match typ.dtor with
+ | None -> ()
+ | Some(dtor, f, l) ->
+ put_line l f;
+ printf " %s;\n" (tplize dtor (sprintf "&luaM_x%d" i))
+ ); i
+ ) 0 fn.rettype) ;
+ printf " return %d;\n}\n" retlen;
+
+ (* main function *)