関数と定数が DxLib.as として出力されます。めっちゃ手抜きです。構造体が引数に使われているもの(構造体の値渡し)に対応したつもり。チェックはしてないです。
関数と定数が DxLib.as として出力されます。めっちゃ手抜きです。構造体が引数に使われているもの(構造体の値渡し)に対応したつもり。チェックはしてないです。
#module// 指定オフセットから右から検索していき見つけた位置を返す。(1byteのみ)#defcfunc searchR1 str _in, int ps, int shidx = -1in = _inmax = strlen(in)repeat max, psif peek(in, max-cnt) == sh : idx = max-cnt : breakloopreturn idx// instr 右から検索版#defcfunc instrl var s1, str s2ind = 0repeatres = instr(s1, ind, s2)if res == -1 : breakind += res + 1loopreturn ind-1#defcfunc GetMacroName str _tmp, var macro, var constsdim tmp, 1024tmp = _tmpsdim macro, 128sdim const, 128flag = 0if instr(tmp, 0, "public const int ") != -1{flag = 1sdim res, 128split tmp, " ", res;markpos = -1repeat length(res)if res(cnt) == "="{tmpcnt = cnt// スペースの可能性を考慮して検索(マクロ名を取得)repeat tmpcnttmpcnt--if res(tmpcnt) != ""{macro = res(tmpcnt)break}loop// スペースの場合があるので連結処理をする(定数値を取得)tmpcnt = cnt + 1 // 足しておくsdim tmpconst, 128repeat length(res)-tmpcnt, tmpcnttmpconst += res(cnt)+" "loop// セミコロンを除去tmpconst = strtrim(tmpconst, 0, ' ')const = strtrim(tmpconst, 0, ';')//}loop}return flag#defcfunc GetFuncName str _tmp, var _fnc, array _argsdim tmp, 1024tmp = _tmpsdim _arg, 256 : sdim _fnc, 128num = -1if instr(tmp, 0, "extern") != -1{num = 0ks = instr(tmp, 0, "(")ke = instrl(tmp, ")")if ks != -1 | ke != -1{args = strmid(tmp, ks+1, ke-ks-1)tmp2 = strmid(tmp, 0, ks)tmp2 = strtrim(tmp2, 0, ' ')ps = searchR1(tmp2, 0, ' ')if ps != -1 {// 関数名を取得tmp3 = strmid(tmp2, ps, strlen(tmp2))_fnc = strtrim(tmp3, 0, ' ')// 引き続き引数を取得// 引数がないケースを取得cargs = argscargs = strtrim(cargs, 3, ' ')cargs = strtrim(cargs, 3, '\t')if cargs == "" : num = 0 : return num// 引数ありのケースsdim tmp2split args, ",", tmp2num = statrepeat numtmp3 = tmp2(cnt)tmp3 = strtrim(tmp3, 3, '\t')tmp3 = strtrim(tmp3, 0, ' ')ps = searchR1(tmp3, 0, ' ')if ps != -1{tmp4 = strmid(tmp3, 0, ps)tmp4 = strtrim(tmp4, 0, ' ')_arg(cnt) = tmp4}loop}}}return num#globaldialog "cs",16if stat == 0 : endfname = refstrnotesel bufnoteload fnamesdim def, 1024*512sdim fncs, 1024*512repeat notemaxnoteget tmp, cntif GetMacroName(tmp, macro, const){def += "#define global "+ macro +" "+ const +"\n"}num = GetFuncName(tmp, fnc, arg)if num != -1{sdim outargsrepeat num// 引数で使われているものだけピックアップしているので構造体は全部ではない。if arg(cnt) == "int" || arg(cnt) == "ulong"{outargs += "int"}else:if arg(cnt) == "System.Text.StringBuilder" || arg(cnt) == "string"{outargs += "str"}else:if arg(cnt) == "double"{outargs += "double"}else:if arg(cnt) == "float"{outargs += "float"}else:if arg(cnt) == "VECTOR"{outargs += "float,float,float"}else:if arg(cnt) == "UV"{outargs += "float,float"}else:if arg(cnt) == "COLOR_F" || arg(cnt) == "FLOAT4"{outargs += "float,float,float,float"}else:if arg(cnt) == "COLOR_U8"{outargs += "int"}else:if arg(cnt) == "IPDATA" || arg(cnt) == "IPDATA_IPv6"{outargs += "int"}else:if arg(cnt) == "RECT" || arg(cnt) == "INT4"{ // ポインタとかは "RECT *" といった感じに来ます。outargs += "int,int,int,int"}else:if arg(cnt) == "MATRIX"{outargs += "float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float"}else:if arg(cnt) == "MV1_COLL_RESULT_POLY"{outargs += "int,float,float,float,int,int,int,float,float,float,float,float,float,float,float,float,float,float,float"}else:if arg(cnt) == "MV1_REF_POLYGON"{outargs += "int,int,int,int,int,float,float,float,float,float,float"}else:if arg(cnt) == "MV1_REF_VERTEX"{outargs += "float,float,float,float,float,float"}else:if arg(cnt) == "MATERIALPARAM"{outargs += "float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float"}else{outargs += "sptr"}// 最後以外は , をつけるif cnt != num - 1 : outargs += ","loop// 接頭辞の dx_ を外す(手抜き)split fnc, "dx_", fnc2fncs += "#func global "+ fnc2(1) +" \""+ fnc +"\" "+outargs+"\n"}loopdef2 = {"// VECTOR => float, float, float#define global ctype VGet(%1,%2,%3) %1, %2, %3#define global ctype VAdd(%1,%2,%3,%4,%5,%6) %1+%4, %2+%5, %3+%6#define global ctype VSub(%1,%2,%3,%4,%5,%6) %1-%4, %2-%5, %3-%6#define global ctype VDot(%1,%2,%3,%4,%5,%6) %1*%4+%2*%5+%3*%6#define global ctype VCross(%1,%2,%3,%4,%5,%6) %2*%6-%3*%5, %3*%4-%1*%6, %1*%5-%2*%4#define global ctype VScale(%1,%2,%3,%4) %1*%4, %2*%4, %3*%4#define global ctype VSquareSize(%1,%2,%3) %1*%1+%2*%2+%3*%3// 行列だからdimの方が良いのか…(MATRIX 4x4)#define global ctype VTransform(%1,%2,%3, %4,%5,%6,%7, %8,%9,%10,%11, %12,%13,%14,%15, %16,%17,%18,%19) %1*%4 + %2*%8 + %3*%12 + %16, %1*%5 + %2*%9 + %3*%13 + %17, %1*%6 + %2*%10 + %3*%14 + %18#define global ctype VTransformSR(%1,%2,%3, %4,%5,%6,%7, %8,%9,%10,%11, %12,%13,%14,%15, %16,%17,%18,%19) %1*%4 + %2*%8 + %3*%12, %1*%5 + %2*%9 + %3*%13, %1*%6 + %2*%10 + %3*%14"}sdim outbuf, 1024*512notesel outbufnoteadd "#ifndef __DXLIB__"noteadd "#define __DXLIB__"noteadd "#uselib \"DxLib.dll\""noteadd fncsnoteadd defnoteadd def2noteadd "#endif"notesave "DxLib.as"end