From ce4b560ab4af67c936748534a415cdd252cba74c Mon Sep 17 00:00:00 2001 From: Jeff0S Date: Wed, 1 Apr 2015 15:59:12 +0200 Subject: [PATCH] ReaScript function export: added test, updated "doc" --- ReaScript.cpp | 10 ++++++---- reascript_test.c | 20 ++++++++++++++++++++ reascript_vararg.h | 5 +++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ReaScript.cpp b/ReaScript.cpp index 7aba0c528..06e183647 100644 --- a/ReaScript.cpp +++ b/ReaScript.cpp @@ -48,10 +48,11 @@ #endif -// Important, keep APIFUNC() as it is defined: -// both scripts reascript_vararg.php and reascript_python.pl parse g_apidefs (see below) to -// generate variable argument wrappers for EEL and Lua (reascript_vararg.h, generated by hand -// at the moment), as well as python wrappers (sws_python.py, automatically generated at compile-time). +// Important, keep APIFUNC() as it is defined: both scripts reascript_vararg.php +// and reascript_python.pl parse g_apidefs to generate variable argument wrappers +// for EEL and Lua (reascript_vararg.h, automatically generated at compilation time +// on OSX), as well as python wrappers (sws_python.py, automatically generated at +// compilation time both on Win & OSX). #define APIFUNC(x) (void*)x,#x,(void*)__vararg_ ## x,"APIvararg_" #x "","API_" #x "","APIdef_" #x "" @@ -100,6 +101,7 @@ APIdef g_apidefs[] = { APIFUNC(SNM_test5), "void", "const char*", "a", "", }, { APIFUNC(SNM_test6), "const char*", "char*", "a", "", }, // not an "Out" parm { APIFUNC(SNM_test7), "double", "int,int*,double*,bool*,char*,const char*", "i,aOut,bInOptional,cOutOptional,sOutOptional,csInOptional", "", }, + { APIFUNC(SNM_test8), "const char*", "char*,int,const char*,int,int,char*,int,int*", "buf1,buf1_sz,buf2,buf2_sz,i,buf3,buf3_sz,iOutOptional", "", }, #endif { APIFUNC(SNM_CreateFastString), "WDL_FastString*", "const char*", "str", "[S&M] Instantiates a new \"fast string\". You must delete this string, see SNM_DeleteFastString.", }, { APIFUNC(SNM_DeleteFastString), "void", "WDL_FastString*", "str", "[S&M] Deletes a \"fast string\" instance.", }, diff --git a/reascript_test.c b/reascript_test.c index 575255b27..827a4dc7b 100755 --- a/reascript_test.c +++ b/reascript_test.c @@ -40,6 +40,8 @@ double SNM_test7(int i, int* a, double* b, bool* c, char* s, const char* cs) char buf[128]=""; sprintf(buf, "---> %d\r\n", i); ShowConsoleMsg(buf); + sprintf(buf, "-------------> a = %d\r\n", a?*a:-1); + ShowConsoleMsg(buf); if (a) *a *= 2; if (b) *b *= 2.0; if (c) *c= !(*c); @@ -50,3 +52,21 @@ double SNM_test7(int i, int* a, double* b, bool* c, char* s, const char* cs) ShowConsoleMsg(buf); return 666.777; } +const char* SNM_test8(char* buf1, int buf1_sz, const char* buf2, int buf2_sz, int i, char* buf3, int buf3_sz, int* iOptionalOut) +{ + char buf[128]=""; + sprintf(buf, "---> %s\r\n", buf1); + ShowConsoleMsg(buf); + sprintf(buf, "---> %s\r\n", buf2); + ShowConsoleMsg(buf); + sprintf(buf, "---> %s\r\n", buf3); + ShowConsoleMsg(buf); + sprintf(buf, "---> %d\r\n", i); + ShowConsoleMsg(buf); + if (iOptionalOut) { sprintf(buf, "---> *iOptionalOut = %d\r\n", *iOptionalOut); *iOptionalOut=123456789; } + else strcpy(buf, "---> null iOptionalOut\r\n"); + ShowConsoleMsg(buf); + if (buf1) lstrcpyn(buf1,"SNM_test8 new parm val for buf1",buf1_sz); + if (buf3) lstrcpyn(buf3,"SNM_test8 new parm val for buf3",buf3_sz); + return "SNM_test8"; +} diff --git a/reascript_vararg.h b/reascript_vararg.h index ec35d0f78..f305ab86f 100644 --- a/reascript_vararg.h +++ b/reascript_vararg.h @@ -41,6 +41,11 @@ static void* __vararg_SNM_test7(void** arglist, int numparms) return p; } +static void* __vararg_SNM_test8(void** arglist, int numparms) +{ + return (void*)(INT_PTR)SNM_test8((char*)arglist[0], (int)(INT_PTR)arglist[1], (const char*)arglist[2], (int)(INT_PTR)arglist[3], (int)(INT_PTR)arglist[4], (char*)arglist[5], (int)(INT_PTR)arglist[6], (int*)arglist[7]); +} + static void* __vararg_SNM_CreateFastString(void** arglist, int numparms) { return (void*)(INT_PTR)SNM_CreateFastString((const char*)arglist[0]);