1010#include < ctype.h>
1111#include < locale.h>
1212
13+ #ifndef HSPMAC
14+ #define USE_FFILIB
15+ #endif
16+
1317#include " ../hsp3config.h"
1418#include " ../hsp3code.h"
1519#include " ../hsp3debug.h"
1620#include " ../supio.h"
1721#include " ../strbuf.h"
1822
1923#include " hsp3ext_linux.h"
24+ #ifdef USE_FFILIB
2025#include " hsp3extlib_ffi.h"
26+ #endif
2127
2228static HSPCTX *hspctx = NULL ; // Current Context
2329static HSPEXINFO *exinfo = NULL ; // Info for Plugins
@@ -78,31 +84,31 @@ static void InitSystemInformation(void)
7884*/
7985/* ------------------------------------------------------------*/
8086
81-
87+ # ifdef USE_FFILIB
8288static void *reffunc_dllcmd ( int *type_res, int arg )
8389{
84- // reffunc : TYPE_DLLFUNC
85- // (拡張DLL関数)
86- //
87-
88- // '('で始まるかを調べる
89- //
90- if ( *type != TYPE_MARK ) throw ( HSPERR_INVALID_FUNCPARAM );
91- if ( *val != ' (' ) throw ( HSPERR_INVALID_FUNCPARAM );
92-
93- *type_res = HSPVAR_FLAG_INT;
94- exec_dllcmd ( arg, STRUCTDAT_OT_FUNCTION );
95- reffunc_intfunc_ivalue = hspctx->stat ;
96-
97- // ')'で終わるかを調べる
98- //
99- if ( *type != TYPE_MARK ) throw ( HSPERR_INVALID_FUNCPARAM );
100- if ( *val != ' )' ) throw ( HSPERR_INVALID_FUNCPARAM );
101- code_next ();
102-
103- return &reffunc_intfunc_ivalue;
90+ // reffunc : TYPE_DLLFUNC
91+ // (拡張DLL関数)
92+ //
93+
94+ // '('で始まるかを調べる
95+ //
96+ if ( *type != TYPE_MARK ) throw ( HSPERR_INVALID_FUNCPARAM );
97+ if ( *val != ' (' ) throw ( HSPERR_INVALID_FUNCPARAM );
98+
99+ *type_res = HSPVAR_FLAG_INT;
100+ exec_dllcmd ( arg, STRUCTDAT_OT_FUNCTION );
101+ reffunc_intfunc_ivalue = hspctx->stat ;
102+
103+ // ')'で終わるかを調べる
104+ //
105+ if ( *type != TYPE_MARK ) throw ( HSPERR_INVALID_FUNCPARAM );
106+ if ( *val != ' )' ) throw ( HSPERR_INVALID_FUNCPARAM );
107+ code_next ();
108+
109+ return &reffunc_intfunc_ivalue;
104110}
105-
111+ # endif
106112
107113static int termfunc_dllcmd ( int option )
108114{
@@ -119,12 +125,16 @@ void hsp3typeinit_dllcmd( HSP3TYPEINFO *info )
119125 val = exinfo->npval ;
120126 exflg = exinfo->npexflg ;
121127
128+ #ifdef USE_FFILIB
122129 info->cmdfunc = cmdfunc_dllcmd;
123130 info->reffunc = reffunc_dllcmd;
124- info->termfunc = termfunc_dllcmd;
131+ #endif
132+ info->termfunc = termfunc_dllcmd;
125133
126134 InitSystemInformation ();
135+ #ifdef USE_FFILIB
127136 Hsp3ExtLibInit ( info );
137+ #endif
128138}
129139
130140void hsp3typeinit_dllctrl ( HSP3TYPEINFO *info )
@@ -150,7 +160,12 @@ char *hsp3ext_sysinfo(int p2, int* res, char* outbuf)
150160
151161 switch (p2) {
152162 case 0 :
153- strcpy ( p1, " Linux" );
163+ #ifdef HSPLINUX
164+ strcpy ( p1, " Linux" );
165+ #endif
166+ #ifdef HSPMAC
167+ strcpy ( p1, " MacOS" );
168+ #endif
154169 fl=HSPVAR_FLAG_STR;
155170 break ;
156171 case 1 :
@@ -179,7 +194,7 @@ char* hsp3ext_getdir(int id)
179194
180195 switch ( id ) {
181196 case 0 : // カレント(現在の)ディレクトリ
182- #if defined(HSPLINUX)||defined(HSPEMSCRIPTEN)
197+ #if defined(HSPLINUX)||defined(HSPEMSCRIPTEN)||defined(HSPMAC)
183198 getcwd ( p, HSP_MAX_PATH );
184199 cutlast = 1 ;
185200#endif
@@ -222,7 +237,7 @@ char* hsp3ext_getdir(int id)
222237
223238void hsp3ext_execfile (char * msg, char * option, int mode)
224239{
225- #ifdef HSPLINUX
240+ #if defined( HSPLINUX)||defined(HSPMAC)
226241 system (msg);
227242#endif
228243}
0 commit comments