Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CXX = g++
AR = ar

# CFLAGS_ENV = # 32bit
CFLAGS_ENV = -DHSP64 # 64bit
CFLAGS_ENV = -DHSP64 -Werror=int-to-pointer-cast # 64bit
CFLAGS_DISH = -Wno-write-strings --exec-charset=UTF-8 -DHSPDISH -DHSPLINUX -DHSPDEBUG -DUSE_OBAQ -DHSP_COM_UNSUPPORTED $(CFLAGS_ENV)
CFLAGS_GP = -Wno-write-strings --exec-charset=UTF-8 -DHSPDISH -DHSPDISHGP -DHSPLINUX -DHSPDEBUG -DHSP_COM_UNSUPPORTED -DPNG_ARM_NEON_OPT=0 -I src/hsp3dish/extlib/src -I src/hsp3dish/extlib/src/glew -I src/hsp3dish/gameplay/src -std=c++11 $(CFLAGS_ENV)
CFLAGS_CL = -Wno-write-strings -std=c++11 --exec-charset=UTF-8 -DHSPLINUX -DHSPDEBUG -DHSP_COM_UNSUPPORTED $(CFLAGS_ENV)
Expand All @@ -27,6 +27,8 @@ OBJS = \
src/hsp3/hspvar_label.do \
src/hsp3/hspvar_str.do \
src/hsp3/hspvar_struct.do \
src/hsp3/hspvar_float.do \
src/hsp3/hspvar_int64.do \
src/hsp3dish/hspwnd_dish.do \
src/hsp3dish/hspwnd_obj.do \
src/hsp3dish/hspwnd_edit.do \
Expand Down Expand Up @@ -87,6 +89,8 @@ OBJS_CL = \
src/hsp3/hspvar_label.o \
src/hsp3/hspvar_str.o \
src/hsp3/hspvar_struct.o \
src/hsp3/hspvar_float.o \
src/hsp3/hspvar_int64.o \
src/hsp3/stack.o \
src/hsp3/strbuf.o \
src/hsp3/strnote.o \
Expand Down Expand Up @@ -119,6 +123,8 @@ OBJS_GP = \
src/hsp3/hspvar_label.gpo \
src/hsp3/hspvar_str.gpo \
src/hsp3/hspvar_struct.gpo \
src/hsp3/hspvar_float.gpo \
src/hsp3/hspvar_int64.gpo \
src/hsp3dish/hspwnd_dish.gpo \
src/hsp3dish/hspwnd_obj.gpo \
src/hsp3dish/hspwnd_edit.gpo \
Expand Down
4 changes: 4 additions & 0 deletions makefile.emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ OBJS = \
src/hsp3/hspvar_label.js.o \
src/hsp3/hspvar_str.js.o \
src/hsp3/hspvar_struct.js.o \
src/hsp3/hspvar_float.js.o \
src/hsp3/hspvar_int64.js.o \
src/hsp3dish/hspwnd_dish.js.o \
src/hsp3dish/hspwnd_obj.js.o \
src/hsp3dish/hspwnd_edit.js.o \
Expand Down Expand Up @@ -98,6 +100,8 @@ OBJS_GP = \
src/hsp3/hspvar_label.g.o \
src/hsp3/hspvar_str.g.o \
src/hsp3/hspvar_struct.g.o \
src/hsp3/hspvar_float.g.o \
src/hsp3/hspvar_int64.g.o \
src/hsp3dish/hspwnd_dish.g.o \
src/hsp3dish/hspwnd_obj.g.o \
src/hsp3dish/hspwnd_edit.g.o \
Expand Down
5 changes: 3 additions & 2 deletions src/hsp3/hsp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ STRUCTDAT *Hsp3::copy_STRUCTDAT(HSPHED *hsphed, char *ptr, size_t size)
dst->index = org_dat.index;
dst->subid = org_dat.subid;
dst->prmindex = org_dat.prmindex;
dst->prmmax = org_dat.prmmax;
dst->prm.prmmax = org_dat.prm.prmmax;
dst->prm.rettype = org_dat.prm.rettype;
dst->nameidx = org_dat.nameidx;
dst->size = org_dat.size;
dst->otindex = org_dat.otindex;
Expand All @@ -420,7 +421,7 @@ STRUCTDAT *Hsp3::copy_STRUCTDAT(HSPHED *hsphed, char *ptr, size_t size)
// STRUCTPRMのoffset,size値を調整する (各メンバのサイズを2倍にする)
int j;
dst->size *= 2;
for (j = 0; j < dst->prmmax; j++) {
for (j = 0; j < dst->prm.prmmax; j++) {
STRUCTPRM *prm = &hspctx.mem_minfo[dst->prmindex + j];
if (prm->mptype == MPTYPE_STRUCTTAG) continue;
//Alertf("INIT: type%d: subid:%d offset:%d", prm->mptype, prm->subid, prm->offset);
Expand Down
51 changes: 48 additions & 3 deletions src/hsp3/hsp3code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,42 @@ int code_getdi( const int defval )
}


int64_t code_getl( void )
{
// 数値パラメーターを取得
//
int chk;
chk = code_get();
if ( chk<=PARAM_END ) { throw HSPERR_NO_DEFAULT; }
if ( mpval->flag != HSPVAR_FLAG_INT64 ) {
if ( mpval->flag == HSPVAR_FLAG_INT )
return (int64_t)(*(int *)(mpval->pt));
if ( mpval->flag == HSPVAR_FLAG_DOUBLE )
return (int64_t)(*(double *)(mpval->pt));
throw HSPERR_TYPE_MISMATCH;
}
return *(int64_t *)(mpval->pt);
}


int64_t code_getdl( const int64_t defval )
{
// 数値パラメーターを取得(デフォルト値あり)
//
int chk;
chk = code_get();
if ( chk<=PARAM_END ) { return defval; }
if ( mpval->flag != HSPVAR_FLAG_INT64 ) {
if ( mpval->flag == HSPVAR_FLAG_INT )
return (int64_t)(*(int *)(mpval->pt));
if ( mpval->flag == HSPVAR_FLAG_DOUBLE )
return (int64_t)(*(double *)(mpval->pt));
throw HSPERR_TYPE_MISMATCH;
}
return *(int64_t *)(mpval->pt);
}


double code_getd( void )
{
// 数値(double)パラメーターを取得
Expand Down Expand Up @@ -1279,7 +1315,7 @@ static void customstack_delete( STRUCTDAT *st, char *stackptr )
char *ss;
STRUCTPRM *prm;
prm = &hspctx->mem_minfo[ st->prmindex ];
for(i=0;i<st->prmmax;i++) { // パラメーターを取得
for(i=0;i<st->prm.prmmax;i++) { // パラメーターを取得
if ( prm->mptype == MPTYPE_LOCALSTRING ) {
out = stackptr + prm->offset;
ss = *(char **)out;
Expand Down Expand Up @@ -1487,7 +1523,7 @@ void code_expandstruct( char *p, STRUCTDAT *st, int option )
STRUCTPRM *prm;
prm = &hspctx->mem_minfo[ st->prmindex ];

for(i=0;i<st->prmmax;i++) { // パラメーターを取得
for(i=0;i<st->prm.prmmax;i++) { // パラメーターを取得
out = p + prm->offset;
switch( prm->mptype ) {
case MPTYPE_INUM:
Expand Down Expand Up @@ -1605,7 +1641,7 @@ void code_delstruct( PVal *in_pval, APTR in_aptr )
code_callbackfunc( st->otindex );
}

for(i=0;i<st->prmmax;i++) { // パラメーターを取得
for(i=0;i<st->prm.prmmax;i++) { // パラメーターを取得
out = p + prm->offset;
switch( prm->mptype ) {
case MPTYPE_LOCALVAR:
Expand Down Expand Up @@ -2036,6 +2072,7 @@ static int cmdfunc_prog( int cmd )
//

int p1,p2,p3,p4,p5;
int64_t lp1;

code_next(); // 次のコードを取得(最初に必ず必要です)

Expand Down Expand Up @@ -2237,13 +2274,21 @@ static int cmdfunc_prog( int cmd )
{
PVal *pval_m;
pval_m = code_getpval();
#ifdef HSP64
lp1 = code_getl();
#else
p1 = code_geti();
#endif
p2 = code_geti();
p3 = code_getdi( HSPVAR_FLAG_INT );
if ( p2<=0 ) throw HSPERR_ILLEGAL_FUNCTION;
if ( HspVarCoreGetProc(p3)->flag == 0 ) throw HSPERR_ILLEGAL_FUNCTION;
if (pval_m->support & HSPVAR_SUPPORT_FIXEDVALUE) throw HSPERR_FIXED_VARVALUE;
#ifdef HSP64
HspVarCoreDupPtr( pval_m, p3, (void *)lp1, p2 );
#else
HspVarCoreDupPtr( pval_m, p3, (void *)p1, p2 );
#endif
break;
}

Expand Down
2 changes: 2 additions & 0 deletions src/hsp3/hsp3code.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ char *code_getds( const char *defval );
char *code_getdsi( const char *defval );
int code_geti( void );
int code_getdi( const int defval );
int64_t code_getl( void );
int64_t code_getdl( const int64_t defval );
double code_getd( void );
double code_getdd( const double defval );
PVal *code_getpval( void );
Expand Down
13 changes: 13 additions & 0 deletions src/hsp3/hsp3int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ static int cmdfunc_intcmd( int cmd )
}

static int reffunc_intfunc_ivalue;
static int64_t reffunc_intfunc_lvalue;
static HSPREAL reffunc_intfunc_value;

static void *reffunc_intfunc( int *type_res, int arg )
Expand Down Expand Up @@ -1513,13 +1514,25 @@ static void *reffunc_intfunc( int *type_res, int arg )
STRUCTDAT *st;
if ( *type == TYPE_DLLFUNC ) {
st = &(ctx->mem_finfo[ *val ]);
#ifdef HSP64
reffunc_intfunc_lvalue = (int64_t)(st->proc);
*type_res = HSPVAR_FLAG_INT64;
ptr = &reffunc_intfunc_lvalue;
#else
reffunc_intfunc_ivalue = (int)(size_t)(st->proc);
#endif
code_next();
break;
}
aptr = code_getva( &pval );
pdat = HspVarCorePtrAPTR( pval, aptr );
#ifdef HSP64
reffunc_intfunc_lvalue = (int64_t)(pdat);
*type_res = HSPVAR_FLAG_INT64;
ptr = &reffunc_intfunc_lvalue;
#else
reffunc_intfunc_ivalue = (int)(size_t)(pdat);
#endif
HspVarCoreGetBlockSize(pval, pdat, &ctx->strsize);
break;
}
Expand Down
24 changes: 21 additions & 3 deletions src/hsp3/hsp3struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ typedef struct STRUCTDAT {
short index; // base LIBDAT index
short subid; // struct index
int prmindex; // STRUCTPRM index(MINFO)
int prmmax; // number of STRUCTPRM
union {
int oldprmmax; // number of STRUCTPRM
struct {
short prmmax; // number of STRUCTPRM
short rettype; // return type
} prm;
};
int nameidx; // name index (DS)
int size; // struct size (stack)
int otindex; // OT index(Module) / cleanup flag(Dll)
Expand All @@ -291,7 +297,13 @@ typedef struct HED_STRUCTDAT {
short index; // base LIBDAT index
short subid; // struct index
int prmindex; // STRUCTPRM index(MINFO)
int prmmax; // number of STRUCTPRM
union {
int oldprmmax; // number of STRUCTPRM
struct {
short prmmax; // number of STRUCTPRM
short rettype; // return type
} prm;
};
int nameidx; // name index (DS)
int size; // struct size (stack)
int otindex; // OT index(Module) / cleanup flag(Dll)
Expand All @@ -303,7 +315,13 @@ typedef struct STRUCTDAT {
short index; // base LIBDAT index
short subid; // struct index
int prmindex; // STRUCTPRM index(MINFO)
int prmmax; // number of STRUCTPRM
union {
int prmmax; // number of STRUCTPRM
struct {
short prmmax; // number of STRUCTPRM
short rettype; // return type
} prm;
};
int nameidx; // name index (DS)
int size; // struct size (stack)
int otindex; // OT index(Module) / cleanup flag(Dll)
Expand Down
5 changes: 5 additions & 0 deletions src/hsp3/hspvar_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ extern void HspVarInt_Init( HspVarProc *p );
extern void HspVarStr_Init( HspVarProc *p );
extern void HspVarDouble_Init( HspVarProc *p );
extern void HspVarStruct_Init( HspVarProc *p );
extern void HspVarInt64_Init( HspVarProc *p );
extern void HspVarFloat_Init( HspVarProc *p );

/*------------------------------------------------------------*/
/*
Expand Down Expand Up @@ -85,6 +87,9 @@ void HspVarCoreResetVartype( int expand )
HspVarCoreRegisterType( HSPVAR_FLAG_DOUBLE, (HSPVAR_COREFUNC)HspVarDouble_Init );
HspVarCoreRegisterType( HSPVAR_FLAG_STRUCT, (HSPVAR_COREFUNC)HspVarStruct_Init );
HspVarCoreRegisterType( HSPVAR_FLAG_LABEL, (HSPVAR_COREFUNC)HspVarLabel_Init ); // ラベル型(3.1)
// 追加型
HspVarCoreRegisterType( HSPVAR_FLAG_INT64, (HSPVAR_COREFUNC)HspVarInt64_Init );
HspVarCoreRegisterType( HSPVAR_FLAG_FLOAT, (HSPVAR_COREFUNC)HspVarFloat_Init );
}


Expand Down
6 changes: 4 additions & 2 deletions src/hsp3/hspvar_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

// 7はVARIANTで予約済み

#define HSPVAR_FLAG_USERDEF 8
#define HSPVAR_FLAG_MAX 8
#define HSPVAR_FLAG_INT64 8
#define HSPVAR_FLAG_FLOAT 9
#define HSPVAR_FLAG_USERDEF 10
#define HSPVAR_FLAG_MAX 10

#define HSPVAR_MODE_NONE -1
#define HSPVAR_MODE_MALLOC 1
Expand Down
6 changes: 6 additions & 0 deletions src/hsp3/hspvar_double.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ static void *HspVarDouble_Cnv( const void *buffer, int flag )
case HSPVAR_FLAG_INT:
conv = (double)( *(int *)buffer );
return &conv;
case HSPVAR_FLAG_INT64:
conv = (double)( *(int64_t *)buffer );
return &conv;
case HSPVAR_FLAG_FLOAT:
conv = (double)( *(float *)buffer );
return &conv;
case HSPVAR_FLAG_DOUBLE:
break;
default:
Expand Down
Loading