HSPでプチコンのCALL関数のようなもの

#include "hscallbk.as" #include "var_ass […]

#include "hscallbk.as" #include "var_ass […]

  • タグ:
  • タグはありません
#include "hscallbk.as"
#include "var_assoc.as"

#module
	#uselib ""
	#func global prm_add "" int, int
	#func global prm_sub "" int, int
	#defcfunc add int a, int b //加算
	return a + b
	#defcfunc sub int a, int b //減算
	return a - b
#global
#define initcall assoc pFuncList
#define regcall(%1=0,%2) setcallbk f_%2, prm_%2, *fwrap_%2:pFuncList("%2") = varptr(f_%2)
#define ctype call(%1, %2) callfunc(%2, pFuncList(%1), length(%2))

initcall
regcall ,add
regcall ,sub

call_prms = 2, 4
mes "2+4="+call("add", call_prms)

call_prms = 12, 2
mes "12-2="+call("sub", call_prms)

stop
*fwrap_add
return add(callbkarg(0), callbkarg(1))
*fwrap_sub
return sub(callbkarg(0), callbkarg(1))