-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
638 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
hsptmp | ||
packfile | ||
*.exe | ||
*.dll | ||
*.dll | ||
*tmp* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# encoing Shift-JIS | ||
_PRODUCTVERSION=0.4 | ||
Comments=HSP3�e�X�g�t���[�����[�N | ||
FileDescription=HSP3�e�X�g�t���[�����[�N���s�t�@�C�� | ||
LegalCopyright=(c)2022 mass-0910 | ||
ProductName=hsptest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#ifndef append_data_hsp_included | ||
#define append_data_hsp_included | ||
|
||
#include "result_format.as" | ||
|
||
#module | ||
|
||
#define SUCCESS 1 | ||
#define FAILURE 0 | ||
|
||
#defcfunc is_name_alphabet int ch | ||
return ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') || ('0' <= ch && ch <= '9') || ch == '_' | ||
|
||
#defcfunc is_space int ch | ||
return ch == ' ' || ch == '\t' | ||
|
||
#defcfunc is_entry_inst str line_str | ||
index = 0 | ||
init_status = 1 | ||
line_str_buf = line_str | ||
status = init_status | ||
result = SUCCESS | ||
entry_inst = "deffunc defcfunc modfunc modcfunc modinit modterm" | ||
split entry_inst, " ", entry_inst_list | ||
repeat | ||
ch = peek(line_str_buf, index) | ||
if status == 1 { | ||
if ch == '*' { | ||
status = 2 | ||
} else : if ch == '#' { | ||
status = 6 | ||
} else : if is_space(ch) { | ||
status = 1 | ||
} else { | ||
result = FAILURE | ||
} | ||
} else : if status == 2 { | ||
if is_name_alphabet(ch) { | ||
status = 3 | ||
} else { | ||
result = FAILURE | ||
} | ||
} else : if status == 3 { | ||
if is_name_alphabet(ch) { | ||
status = 3 | ||
} else : if is_space(ch) { | ||
status = 4 | ||
} else { | ||
result = FAILURE | ||
} | ||
} else : if status == 4 { | ||
if is_space(ch) == 0 { | ||
result = FAILURE | ||
} | ||
} else : if status == 6 { | ||
repeat length(entry_inst_list) | ||
if instr(line_str_buf, index, entry_inst_list(cnt)) == 0 { | ||
status = 7 | ||
index += strlen(entry_inst_list(cnt)) - 1 | ||
break | ||
} | ||
loop | ||
if status == 6 : result = FAILURE | ||
} else : if status == 7 { | ||
if is_space(ch) { | ||
status = 8 | ||
} else { | ||
result = FAILURE | ||
} | ||
} else : if status == 8 { | ||
// success | ||
} | ||
if result == FAILURE : break | ||
index++ | ||
if index >= strlen(line_str_buf) : break | ||
loop | ||
return result | ||
|
||
#defcfunc is_multi_line str line_str | ||
line_str_buf = line_str | ||
result = 0 | ||
repeat strlen(line_str_buf) | ||
ch = peek(line_str_buf, strlen(line_str_buf) - 1 - cnt) | ||
if is_space(ch) : continue | ||
if ch == '\\' { | ||
result = 1 | ||
break | ||
} | ||
break | ||
loop | ||
return result | ||
|
||
#deffunc copy_with_edit str src_file_path, str dest_file_path | ||
notesel buf | ||
noteload src_file_path | ||
file_line_num = noteinfo(0) | ||
reading_index = 0 | ||
ignore_multiline_str = 0 | ||
ignore_multiline_inst = 0 | ||
repeat | ||
notesel buf | ||
; if cnt >= noteinfo(0) : break | ||
if cnt > file_line_num : break | ||
noteget l, reading_index | ||
reading_index++ | ||
if ignore_multiline_str == 0 && ignore_multiline_inst == 0{ | ||
if reading_index - 1 >= noteinfo(0) { | ||
p = -1 | ||
} else { | ||
p = reading_index - 1 | ||
} | ||
now_line_num = cnt + 1 | ||
noteadd "__errfile@ = __file__ : __errline@ = " + now_line_num, p | ||
reading_index++ | ||
} | ||
ignore_multiline_inst = 0 | ||
// マルチライン文字列には挿入しない | ||
if ignore_multiline_str == 0 && instr(l, 0, "{\"") != -1 && instr(l, 0, "\"}") == -1 { | ||
ignore_multiline_str = 1 | ||
} | ||
if ignore_multiline_str && instr(l, 0, "{\"") == -1 && instr(l, 0, "\"}") != -1 { | ||
ignore_multiline_str = 0 | ||
} | ||
if ignore_multiline_str == 0 && is_multi_line(l) { | ||
ignore_multiline_inst = 1 | ||
} | ||
loop | ||
notesel buf | ||
notesave dest_file_path | ||
return | ||
|
||
#global | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
#define __init_msg "Assertion was failed" | ||
#define assertTrue(%1, %2=__init_msg) if (%1)==0:mes "&RESULT&{"+"FAIL"+","+__line__+",42,"+%2+"}":return | ||
#define assertFalse(%1, %2=__init_msg) if (%1)!=0:mes "&RESULT&{"+"FAIL"+","+__line__+",42,"+%2+"}":return | ||
#define assertEqual(%1, %2, %3=__init_msg) if (%1)!=(%2):mes "&RESULT&{"+"FAIL"+","+__line__+",42,"+%3+"}":return | ||
#define assertNear(%1, %2, %3=0.0001, %4=__init_msg) if absf(double(%1)-double(%2))>(%3):mes "&RESULT&{"+"FAIL"+","+__line__+",42,"+%4+"}":return | ||
#ifndef assertion_as_included | ||
#define assertion_as_included | ||
|
||
#include "result_format.as" | ||
|
||
#module | ||
|
||
#define global __init_msg "Assertion was failed" | ||
#define global assertTrue(%1, %2=__init_msg) __errline_a=__errline@:__errfile_a=__errfile@:if (%1)==0:mes get_fail_result_format(__errline_a,__errfile_a,%2):return | ||
#define global assertFalse(%1, %2=__init_msg) __errline_a=__errline@:__errfile_a=__errfile@:if (%1)!=0:mes get_fail_result_format(__errline_a,__errfile_a,%2):return | ||
#define global assertEqual(%1, %2, %3=__init_msg) __errline_a=__errline@:__errfile_a=__errfile@:if (%1)!=(%2):mes get_fail_result_format(__errline_a,__errfile_a,%3):return | ||
#define global assertNear(%1, %2, %3=0.0001, %4=__init_msg) __errline_a=__errline@:__errfile_a=__errfile@:if absf(double(%1)-double(%2))>(%3):mes get_fail_result_format(__errline_a,__errfile_a,%3):return | ||
|
||
#global | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef result_format_as_included | ||
#define result_format_as_included | ||
|
||
#module | ||
|
||
/* | ||
成功時のstdout文字列を返す | ||
返り値 | ||
成功時のstdout文字列 | ||
*/ | ||
#defcfunc get_pass_result_format | ||
return "&RESULT&{PASS,0,#,#}" | ||
|
||
/* | ||
失敗時のstdout文字列を返す | ||
引数 | ||
error_line: エラー発生行数 | ||
error_message: エラーメッセージ | ||
返り値 | ||
失敗時のstdout文字列 | ||
*/ | ||
#defcfunc get_fail_result_format int error_line, str error_file, str error_message | ||
return "&RESULT&{FAIL," + error_line + "," + error_file + "," + error_message + "}" | ||
|
||
/* | ||
stdoutから結果をパースする | ||
引数 | ||
stdout: hspランタイムから出力された文字列 | ||
result: 結果("PASS"または"FAIL")を格納する変数 | ||
error_line: エラーが発生した行数を格納する変数 | ||
error_message: エラーメッセージを格納する変数 | ||
removed_stdout: 特殊フォーマット文字列を全て取り除いた標準出力が格納される変数 | ||
*/ | ||
#deffunc parse_result_format str stdout, var result, var error_line, var error_file, var error_message, var removed_stdout | ||
buf = stdout | ||
notesel buf | ||
resline = notefind("&RESULT&", 1) | ||
noteget resultstr, resline | ||
notedel resline | ||
notedel resline | ||
removed_stdout = buf | ||
resultstr = strmid(resultstr, 9, 1024) | ||
resultstr = strtrim(resultstr, , '}') | ||
getstr result, resultstr, 0, ',' | ||
i = strsize | ||
getstr error_line, resultstr, i, ',' | ||
i += strsize | ||
getstr error_file, resultstr, i, ',' | ||
i += strsize | ||
getstr error_message, resultstr, i, ',' | ||
return | ||
|
||
#global | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// hsptest.hspをexeにコンパイルするためのスクリプト | ||
|
||
#runtime "hsp3cl" | ||
#packopt name "compile" | ||
#packopt orgpath 0 | ||
#packopt version "VERSION" | ||
#include "hspcmp.as" | ||
|
||
*init | ||
fname = "./hsptest.hsp" | ||
|
||
*mkstart | ||
|
||
srcdir=getpath(fname,32+16) | ||
srcname=getpath(fname,1+8+16) | ||
|
||
chdir srcdir | ||
|
||
mes "Compiling..."+fname | ||
|
||
objname="start.ax" ; output object file | ||
cmpmode=0 | ||
ppmode=4 | ||
|
||
hsc_ini srcname+".hsp" | ||
hsc_objname objname | ||
hsc_comp cmpmode,ppmode,0 | ||
res=stat:if res!=0 : dialog "ERROR" : goto *goerror | ||
|
||
mes "Make .exe file..." | ||
mes srcname | ||
hsc3_make dirinfo(1)+"\\"+srcname+".dpm",1 | ||
|
||
mes "Done." | ||
end 0 | ||
|
||
*goerror | ||
hsc_getmes mesbuf | ||
mes mesbuf | ||
end 1 |
Oops, something went wrong.