NO.1005:命令名を省略するマクロ その3

命令名を省略するマクロ その2。では
スタックを利用しましたが
普通に定義したり、定義解除したりする方が
ややこしくないです

以下サンプル
サンプルでは
array_exモジュール。と
array_push_popモジュール。を使用しています

array_exモジュール

array_push_popモジュール


サンプル その1
#include "FILE_array_ex.hsp"
#include "FILE_array_push_pop.hsp"

newmod o,array_push_pop,"M"

#define hoge_func_A add_at_array_push_pop
#define piyo_obj_A o
#define that_A hoge_func_A piyo_obj_A

//	省略した命令とオブジェクトを利用
repeat 32,1
that_A ,cnt
loop

#define hoge_func_B get_add_index_at_array_push_pop
#define piyo_obj_B o
#define that_B hoge_func_B piyo_obj_B

//	省略した命令とオブジェクトを利用
repeat 32
r=0
that_B ,r
logmes "var : "+str(r)
loop

#undef hoge_func_A
#undef piyo_obj_A
#undef that_A

#undef hoge_func_B
#undef piyo_obj_B
#undef that_B

logmes ""

newmod o2,array_push_pop,"M"

#define hoge_func_A add_at_array_push_pop
#define piyo_obj_A o2
#define that_A hoge_func_A piyo_obj_A

//	省略した命令とオブジェクトを利用
repeat 32,1
that_A ,(cnt*2)
loop

#define hoge_func_B get_add_index_at_array_push_pop
#define piyo_obj_B o2
#define that_B hoge_func_B piyo_obj_B

//	省略した命令とオブジェクトを利用
repeat 32
r=0
that_B ,r
logmes "var : "+str(r)
loop

#undef hoge_func_A
#undef piyo_obj_A
#undef that_A

#undef hoge_func_B
#undef piyo_obj_B
#undef that_B
stop

サンプル その2
#include "FILE_array_ex.hsp"
#include "FILE_array_push_pop.hsp"

newmod o,array_push_pop,"M"

#define hoge_func_A add_at_array_push_pop
#define piyo_obj_A o
#define that_A hoge_func_A piyo_obj_A

//	省略した命令とオブジェクトを利用
repeat 32,1
that_A ,cnt
loop

#define hoge_func_B get_add_index_at_array_push_pop
#define piyo_obj_B o
#define that_B hoge_func_B piyo_obj_B

//	省略した命令とオブジェクトを利用
repeat 32
r=0
that_B ,r
logmes "var : "+str(r)
loop

logmes ""

newmod o2,array_push_pop,"M"

#define hoge_func_C add_at_array_push_pop
#define piyo_obj_C o2
#define that_C hoge_func_C piyo_obj_C

//	省略した命令とオブジェクトを利用
repeat 32,1
that_C ,(cnt*2)
loop

#define hoge_func_D get_add_index_at_array_push_pop
#define piyo_obj_D o2
#define that_D hoge_func_D piyo_obj_D

//	省略した命令とオブジェクトを利用
repeat 32
r=0
that_D ,r
logmes "var : "+str(r)
loop

#undef hoge_func_A
#undef piyo_obj_A
#undef that_A

#undef hoge_func_B
#undef piyo_obj_B
#undef that_B

#undef hoge_func_C
#undef piyo_obj_C
#undef that_C

#undef hoge_func_D
#undef piyo_obj_D
#undef that_D
stop

命令名を省略するマクロ その1。の
スタックを利用しないバージョン
サンプル その3
#define ctype dA(%1) %1_at_bbb

goto *@f
#deffunc aaa_at_bbb
mes "OK"
return
#deffunc aaaa_at_bbb int a
mes "this is "+a
return
*@

dA(aaa)
dA(aaaa) 1

goto *@f
#deffunc dA(ccc)
mes "OK"
return
#deffunc dA(cccc) int a
mes "this is "+a
return
*@

dA(ccc)
dA(cccc) 1

stop

サンプル その4
#include "FILE_array_ex.hsp"
#include "FILE_array_push_pop.hsp"

newmod o,array_push_pop,"M"

#define that_A add_at_array_push_pop o

//	省略した命令とオブジェクトを利用
repeat 32,1
that_A ,cnt
loop

#define that_B get_add_index_at_array_push_pop o

//	省略した命令とオブジェクトを利用
repeat 32
r=0
that_B ,r
logmes "var : "+str(r)
loop

#undef that_A
#undef that_B

logmes ""

newmod o2,array_push_pop,"M"

#define that add_at_array_push_pop o2

//	省略した命令とオブジェクトを利用
repeat 32,1
that ,(cnt*2)
loop
#undef that

#define that get_add_index_at_array_push_pop o2

//	省略した命令とオブジェクトを利用
repeat 32
r=0
that ,r
logmes "var : "+str(r)
loop

#undef that
stop