Skip to content

Commit

Permalink
documentation, parameter naming
Browse files Browse the repository at this point in the history
* work on memory management tutorial (still not complete)
* screen_reader_output/speak now have their interrupt booleans set to true by default, update reflected in documentation.
* ad parameter names to various functions including the coordinate_map, tts_voice and screen reader speech, threading and library, etc.
  • Loading branch information
samtupy committed Sep 21, 2024
1 parent 321b2d9 commit 616a394
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 79 deletions.
48 changes: 45 additions & 3 deletions doc/src/manual/Memory Management Information.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
Speaks and brailles a string through the currently active screen reader, if supported.
bool screen_reader_output(string text, bool interrupt);
bool screen_reader_output(string text, bool interrupt = true);
## Arguments:
* string text: the text to output.
* bool interrupt: Whether or not the previously spoken speech should be interrupted or not when speaking the new string.
* bool interrupt = true: Whether or not the previously spoken speech should be interrupted or not when speaking the new string.
## Returns:
bool: true if the function succeeded, false otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
Speaks a string through the currently active screen reader, if supported.
bool screen_reader_speak(string text, bool interrupt);
bool screen_reader_speak(string text, bool interrupt = true);
## Arguments:
* string text: the text to speak.
* bool interrupt: Whether or not the previously spoken speech should be interrupted or not when speaking the new string.
* bool interrupt = true: Whether or not the previously spoken speech should be interrupted or not when speaking the new string.
## Returns:
bool: true if the function succeeded, false otherwise.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ std::string string_inflate(const std::string& str) {
}

void RegisterScriptCompression(asIScriptEngine* engine) {
engine->RegisterGlobalFunction("string string_deflate(const string& in, int = 9)", asFUNCTION(string_deflate), asCALL_CDECL);
engine->RegisterGlobalFunction("string string_inflate(const string& in)", asFUNCTION(string_inflate), asCALL_CDECL);
engine->RegisterGlobalFunction("string string_deflate(const string& in data, int compression_level = 9)", asFUNCTION(string_deflate), asCALL_CDECL);
engine->RegisterGlobalFunction("string string_inflate(const string& in deflated)", asFUNCTION(string_inflate), asCALL_CDECL);
}
6 changes: 3 additions & 3 deletions src/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ void RegisterScriptLibrary(asIScriptEngine* engine) {
engine->RegisterObjectBehaviour(_O("library"), asBEHAVE_FACTORY, _O("library @l()"), asFUNCTION(new_script_library), asCALL_CDECL);
engine->RegisterObjectBehaviour(_O("library"), asBEHAVE_ADDREF, _O("void f()"), asMETHOD(library, add_ref), asCALL_THISCALL);
engine->RegisterObjectBehaviour(_O("library"), asBEHAVE_RELEASE, _O("void f()"), asMETHOD(library, release), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("library"), _O("bool load(const string&in)"), asMETHOD(library, load), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("library"), _O("bool load(const string&in filename)"), asMETHOD(library, load), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("library"), _O("bool unload()"), asMETHOD(library, load), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("library"), _O("bool get_active() const property"), asMETHOD(library, is_active), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("library"), _O("dictionary@ call(const string&in, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null)"), asFUNCTION(library_call_generic), asCALL_GENERIC);
engine->RegisterGlobalFunction("string string_create_from_pointer(uint64, uint64)", asFUNCTION(string_create_from_pointer), asCALL_CDECL);
engine->RegisterObjectMethod(_O("library"), _O("dictionary@ call(const string&in signature, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null, ?&in=null)"), asFUNCTION(library_call_generic), asCALL_GENERIC);
engine->RegisterGlobalFunction("string string_create_from_pointer(uint64 ptr, uint64 length)", asFUNCTION(string_create_from_pointer), asCALL_CDECL);
}
20 changes: 10 additions & 10 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inline Vector3 VECTOR3(float x, float y, float z) {
return v;
}

Vector3 rotate(Vector3 p, Vector3 o, double theta, bool maintain_z = true) {
Vector3 rotate(const Vector3& p, const Vector3& o, double theta, bool maintain_z = true) {
int angle = (180.0 / M_PI) * theta;
Vector3 r;
Vector3 cs = VECTOR3(angle != 90 && angle != 270 ? cos(theta) : 0, angle != 180 ? sin(theta) : 0, 0);
Expand Down Expand Up @@ -384,7 +384,7 @@ coordinate_map* new_coordinate_map() {

void RegisterScriptMap(asIScriptEngine* engine) {
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_GENERAL);
engine->RegisterGlobalFunction(_O("vector rotate(vector, vector, double, bool = true)"), asFUNCTION(rotate), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("vector rotate(const vector&in point, const vector&in origin, double theta, bool maintain_z = true)"), asFUNCTION(rotate), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("bool boxes_intersect(float, float, float, float, float, float, float, float, float, float)"), asFUNCTION(boxes_intersect), asCALL_CDECL);
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_MAP);
engine->RegisterObjectType(_O("coordinate_map"), 0, asOBJ_REF);
Expand All @@ -409,16 +409,16 @@ void RegisterScriptMap(asIScriptEngine* engine) {
engine->RegisterObjectProperty(_O("coordinate_map_area"), _O("int64 flags"), asOFFSET(map_area, flags));
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("void unframe()"), asMETHOD(map_area, unframe), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("void reframe()"), asMETHOD(map_area, reframe), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("void set(float, float, float, float, float, float, float)"), asMETHOD(map_area, set), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("void set_area(float, float, float, float, float, float)"), asMETHOD(map_area, set_area), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("void set_rotation(float)"), asMETHOD(map_area, set_rotation), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("bool is_in_area(float, float, float, float = 0.0, coordinate_map_filter_callback@ = null, int64=0, int64=0) const"), asMETHOD(map_area, is_in_area), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("void set(float minx, float maxx, float miny, float maxy, float minz, float maxz, float theta)"), asMETHOD(map_area, set), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("void set_area(float minx, float maxx, float miny, float maxy, float minz, float maxz)"), asMETHOD(map_area, set_area), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("void set_rotation(float theta)"), asMETHOD(map_area, set_rotation), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map_area"), _O("bool is_in_area(float x, float y, float z, float d = 0.0, coordinate_map_filter_callback@ = null, int64 required_flags = 0, int64 excluded_flags = 0) const"), asMETHOD(map_area, is_in_area), asCALL_THISCALL);
engine->RegisterObjectBehaviour(_O("coordinate_map"), asBEHAVE_FACTORY, _O("coordinate_map @m()"), asFUNCTION(new_coordinate_map), asCALL_CDECL);
engine->RegisterObjectBehaviour(_O("coordinate_map"), asBEHAVE_ADDREF, _O("void f()"), asMETHOD(coordinate_map, add_ref), asCALL_THISCALL);
engine->RegisterObjectBehaviour(_O("coordinate_map"), asBEHAVE_RELEASE, _O("void f()"), asMETHOD(coordinate_map, release), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("coordinate_map_area@ add_area(float, float, float, float, float, float, float, any@, const string&in, const string&in, const string&in, int, int64=0)"), asMETHOD(coordinate_map, add_area), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("coordinate_map_area@[]@ get_areas(float, float, float, float = 0.0, coordinate_map_filter_callback@ = null, int64=0, int64=0) const"), asMETHOD(coordinate_map, get_areas_script), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("coordinate_map_area@[]@ get_areas(float, float, float, float, float, float, float = 0.0, coordinate_map_filter_callback@ = null, int64=0, int64=0) const"), asMETHOD(coordinate_map, get_areas_in_range_script), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("coordinate_map_area@ get_area(float, float, float, int = -1, float = 0.0, coordinate_map_filter_callback@ = null, int64=0, int64=0) const"), asMETHOD(coordinate_map, get_area), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("coordinate_map_area@ add_area(float minx, float maxx, float miny, float maxy, float minz, float maxz, float rotation, any@ primary_data, const string&in data1, const string&in data2, const string&in data3, int priority, int64 flags = 0)"), asMETHOD(coordinate_map, add_area), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("coordinate_map_area@[]@ get_areas(float x, float y, float z, float d = 0.0, coordinate_map_filter_callback@ = null, int64 required_flags = 0, int64 excluded_flags = 0) const"), asMETHOD(coordinate_map, get_areas_script), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("coordinate_map_area@[]@ get_areas(float minx, float maxx, float miny, float maxy, float minz, float maxz, float d = 0.0, coordinate_map_filter_callback@ = null, int64 required_flags = 0, int64 = excluded_flags = 0) const"), asMETHOD(coordinate_map, get_areas_in_range_script), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("coordinate_map_area@ get_area(float x, float y, float z, int priority = -1, float d = 0.0, coordinate_map_filter_callback@ = null, int64 required_flags = 0, int64 excluded_flags = 0) const"), asMETHOD(coordinate_map, get_area), asCALL_THISCALL);
engine->RegisterObjectMethod(_O("coordinate_map"), _O("void reset()"), asMETHOD(coordinate_map, reset), asCALL_THISCALL);
}
46 changes: 23 additions & 23 deletions src/misc_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,43 +304,43 @@ double parse_double(const std::string& val) {

void RegisterMiscFunctions(asIScriptEngine* engine) {
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_OS);
engine->RegisterGlobalFunction(_O("bool chdir(const string& in)"), asFUNCTION(ChDir), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("bool chdir(const string& in directory)"), asFUNCTION(ChDir), asCALL_CDECL);
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_DATA);
engine->RegisterGlobalFunction(_O("uint8 character_to_ascii(const string&in)"), asFUNCTION(character_to_ascii), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string ascii_to_character(uint8)"), asFUNCTION(ascii_to_character), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string string_base32_normalize(const string& in)"), asFUNCTION(base32_normalize), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("uint8 character_to_ascii(const string&in character)"), asFUNCTION(character_to_ascii), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string ascii_to_character(uint8 character_code)"), asFUNCTION(ascii_to_character), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string string_base32_normalize(const string& in base32encoded)"), asFUNCTION(base32_normalize), asCALL_CDECL);
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_DATETIME);
engine->RegisterGlobalFunction(_O("uint64 get_TIME_STAMP() property"), asFUNCTION(timestamp), asCALL_CDECL);
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_OS);
engine->RegisterGlobalFunction(_O("string[]@ get_preferred_locales()"), asFUNCTION(get_preferred_locales), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string get_COMMAND_LINE() property"), asFUNCTION(get_command_line), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("bool run(const string& in, const string& in, bool, bool)"), asFUNCTION(run), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("bool run(const string& in filename, const string& in arguments, bool wait_for_completion, bool background)"), asFUNCTION(run), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("bool is_debugger_present()"), asFUNCTION(debugger_present), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("int get_last_error()"), asFUNCTION(get_last_error), asCALL_CDECL);
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_GENERAL);
engine->RegisterGlobalFunction(_O("double round(double, int)"), asFUNCTION(Round), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("double tinyexpr(const string &in)"), asFUNCTION(tinyexpr), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("double round(double number, int place)"), asFUNCTION(Round), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("double tinyexpr(const string &in expression)"), asFUNCTION(tinyexpr), asCALL_CDECL);
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_DATA);
engine->RegisterGlobalFunction(_O("string number_to_words(int64, bool = true)"), asFUNCTION(number_to_words), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("uint string_distance(const string&in, const string&in, uint=1, uint=1, uint=1)"), asFUNCTION(string_distance), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string float_to_bytes(float)"), asFUNCTION(float_to_bytes), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("float bytes_to_float(const string&in)"), asFUNCTION(bytes_to_float), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string double_to_bytes(double)"), asFUNCTION(double_to_bytes), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("double bytes_to_double(const string&in)"), asFUNCTION(bytes_to_double), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("bool natural_number_sort(const string&in, const string&in)"), asFUNCTION(natural_number_sort), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("int utf8prev(const string&in, int)"), asFUNCTION(utf8prev), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("int utf8next(const string&in, int)"), asFUNCTION(utf8next), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("int utf8size(const string&in)"), asFUNCTION(utf8size), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string number_to_words(int64 number, bool include_and = true)"), asFUNCTION(number_to_words), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("uint string_distance(const string&in string1, const string&in string2, uint insert_cost = 1, uint delete_cost = 1, uint replace_cost = 1)"), asFUNCTION(string_distance), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string float_to_bytes(float number)"), asFUNCTION(float_to_bytes), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("float bytes_to_float(const string&in data)"), asFUNCTION(bytes_to_float), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("string double_to_bytes(double number)"), asFUNCTION(double_to_bytes), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("double bytes_to_double(const string&in data)"), asFUNCTION(bytes_to_double), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("bool natural_number_sort(const string&in string1, const string&in string2)"), asFUNCTION(natural_number_sort), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("int utf8prev(const string&in text, int cursor)"), asFUNCTION(utf8prev), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("int utf8next(const string&in text, int cursor)"), asFUNCTION(utf8next), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("int utf8size(const string&in character)"), asFUNCTION(utf8size), asCALL_CDECL);
engine->SetDefaultAccessMask(NVGT_SUBSYSTEM_GENERAL);
engine->RegisterObjectType(_O("refstring"), 0, asOBJ_REF);
engine->RegisterObjectBehaviour(_O("refstring"), asBEHAVE_FACTORY, _O("refstring @s()"), asFUNCTION(new_refstring), asCALL_CDECL);
engine->RegisterObjectBehaviour(_O("refstring"), asBEHAVE_ADDREF, _O("void f()"), asMETHOD(refstring, AddRef), asCALL_THISCALL);
engine->RegisterObjectBehaviour(_O("refstring"), asBEHAVE_RELEASE, _O("void f()"), asMETHOD(refstring, Release), asCALL_THISCALL);
engine->RegisterObjectProperty(_O("refstring"), _O("string str"), asOFFSET(refstring, str));
engine->RegisterGlobalFunction(_O("uint64 memory_allocate(uint64)"), asFUNCTION(malloc), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("uint64 memory_allocate_units(uint64, uint64)"), asFUNCTION(calloc), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("uint64 memory_reallocate(uint64, uint64)"), asFUNCTION(realloc), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("void memory_free(uint64)"), asFUNCTION(free), asCALL_CDECL);
engine->RegisterGlobalFunction("float parse_float(const string &in)", asFUNCTION(parse_float), asCALL_CDECL);
engine->RegisterGlobalFunction("double parse_double(const string &in)", asFUNCTION(parse_double), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("uint64 memory_allocate(uint64 size)"), asFUNCTION(malloc), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("uint64 memory_allocate_units(uint64 unit_size, uint64 unit_count)"), asFUNCTION(calloc), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("uint64 memory_reallocate(uint64 ptr, uint64 size)"), asFUNCTION(realloc), asCALL_CDECL);
engine->RegisterGlobalFunction(_O("void memory_free(uint64 ptr)"), asFUNCTION(free), asCALL_CDECL);
engine->RegisterGlobalFunction("float parse_float(const string &in number)", asFUNCTION(parse_float), asCALL_CDECL);
engine->RegisterGlobalFunction("double parse_double(const string &in number)", asFUNCTION(parse_double), asCALL_CDECL);
}
6 changes: 3 additions & 3 deletions src/srspeech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ void RegisterScreenReaderSpeech(asIScriptEngine* engine) {
engine->RegisterGlobalFunction("bool screen_reader_has_speech()", asFUNCTION(ScreenReaderHasSpeech), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_has_braille()", asFUNCTION(ScreenReaderHasBraille), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_is_speaking()", asFUNCTION(ScreenReaderIsSpeaking), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_output(const string &in, bool)", asFUNCTION(ScreenReaderOutput), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_speak(const string &in, bool)", asFUNCTION(ScreenReaderSpeak), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_braille(const string &in)", asFUNCTION(ScreenReaderBraille), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_output(const string &in text, bool interrupt = true)", asFUNCTION(ScreenReaderOutput), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_speak(const string &in text, bool interrupt = true)", asFUNCTION(ScreenReaderSpeak), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_braille(const string &in text)", asFUNCTION(ScreenReaderBraille), asCALL_CDECL);
engine->RegisterGlobalFunction("bool screen_reader_silence()", asFUNCTION(ScreenReaderSilence), asCALL_CDECL);
}
Loading

0 comments on commit 616a394

Please sign in to comment.