這是最近完成的RapScript的0.0.0.1版的源代碼。
這份代碼目前比較糟糕,有點(diǎn)亂,而且沒(méi)有錯(cuò)誤處理,但開(kāi)源是一種習(xí)慣。。。
先介紹一下怎么用:
把RapScript.h RapScript.cpp RapStack.h加入工程,然后在自己的main.cpp里加入
#include "RapScript.h"
RapScript XXX;
XXX是對(duì)象名,可以自己取。
關(guān)于函數(shù)互交:
比如說(shuō),你在C++中寫(xiě)了一個(gè)函數(shù):
void test(int a,int b)
{
cout <<"In void test(int a,int b) a:"<<a<<" b: "<<b<<endl;
}
要調(diào)用它,要在寫(xiě)一個(gè):
void rap_test()
{
int a=rapscript.para[0].v_int;//參數(shù)一
int b=rapscript.para[1].v_int;//參數(shù)二
test(a,b);
}
然后在合適的位置(比如int main()中)加入
rapscript.tmp_cmd.cmd_name="test";
rapscript.tmp_cmd.v_type=rapscript.CMD_VOID;
rapscript.tmp_cmd.fp_void=rap_test;
rapscript.cmd_list.push_back(rapscript.tmp_cmd);
調(diào)用rapscript.run_rap();
腳本就會(huì)執(zhí)行了。
說(shuō)明一下:
1.在腳本中寫(xiě)命令時(shí)要這樣:test(a;b;);//我偷懶了
2.所有變量用前必須聲明(如int a;string b;)
目前只支持int 和 string
3.Bug超多。
4.if()和 for()等暫時(shí)不支持
5.如果你愿意修改源代碼,只要合理,就會(huì)被采用,名字也會(huì)加入Author里。。。
下載RapScript V0.0.0.1源代碼
┏━┓ ┏━━┓ ┏┓
┃┃┣━┳━┫━━╋━┳┳╋╋━┳━━┓
┃ ┫━┃┃┣━━┃┣┫┏┫┃┃┣┓┏┛
┗┻┻┻┫┏┻━━┻━┻┛┗┫┏┛┗┛
┗┛ ┗┛