version 2.0
This commit is contained in:
parent
fb0b178ae9
commit
87acf68683
93
README.md
93
README.md
|
@ -1,41 +1,88 @@
|
|||
```
|
||||
import libc {...}
|
||||
|
||||
|
||||
priv data:char* = """
|
||||
player_coins=20;
|
||||
player_life=0;
|
||||
priv data:char* = """[
|
||||
player:{
|
||||
player_x=200;
|
||||
player_y=300;
|
||||
current_level=3;
|
||||
minor:{
|
||||
a=1;
|
||||
b=3;
|
||||
}
|
||||
|
||||
minor2:{
|
||||
hah= vlad;
|
||||
minor2_sub_minor1:{
|
||||
heh=dalv;
|
||||
}
|
||||
minor2_sub_minor2:{
|
||||
heha=lvda;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enemy:{
|
||||
damage=10;
|
||||
speed=120;
|
||||
}
|
||||
""";
|
||||
|
||||
|
||||
priv func print_sub_parent(parent:save_data_parent*) {
|
||||
for (i := 0; i < parent.sub_parents; i++) {
|
||||
p:save_data_parent* = parent.sub_parent[i];
|
||||
print_paires(p);
|
||||
if (p.has_sub_parent) {
|
||||
print_sub_parent(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
priv func print_paires(parent:save_data_parent*) {
|
||||
for (i := 0; i < parent.total; i++) {
|
||||
printf("Key: %s, Value: %s in parent: %s, id: %zu \n", parent.keys[i], parent.values[i], parent.name, parent.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
priv func print_parent(parent:save_data_parent*) {
|
||||
print_paires(parent);
|
||||
if (parent.has_sub_parent) {
|
||||
print_sub_parent(parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
priv func print_all(save:save_data*) {
|
||||
for (i := 0; i < save.total_parents; i++) {
|
||||
p:save_data_parent* = save.parents[i];
|
||||
print_parent(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func main(argc:int, argv:char**):int {
|
||||
|
||||
save:save_data;
|
||||
save_data_init(&save, "player.stat"); //Creates and overrides file "player.stat"
|
||||
|
||||
keys:char[1][16];
|
||||
strcpy(keys[0],"player_bombs");
|
||||
save_data_init(&save, "player.stat"); //Creates and overrides file "player.stat"
|
||||
|
||||
values:char[1][16];
|
||||
strcpy(values[0],"120");
|
||||
|
||||
data2:char* = save_data_serialize((:char*)keys[0], (:char*)values[0]);
|
||||
save_data_write(&save, data2, false);
|
||||
|
||||
save_data_write(&save, data2, false);
|
||||
manually:char* = save_data_serialize_parent("programatically1", "foo", "42", "", 32);
|
||||
manually2:char* = save_data_serialize_parent("programatically2", "foo", "42", manually, 64);
|
||||
|
||||
save_data_write(&save, data, true);
|
||||
save_data_write(&save, data2, false);
|
||||
save_data_write(&save, manually, false);
|
||||
save_data_write(&save, manually2, false);
|
||||
save_data_write(&save, "]", false);
|
||||
|
||||
// Read back what we have saved
|
||||
save_data_read(&save);
|
||||
|
||||
for (i := 0; i < save.total; i++) {
|
||||
printf("Pair: %s %s \n", save.keys[i], save.values[i]);
|
||||
}
|
||||
printf("Total parents: %zu\n", save.total_parents);
|
||||
|
||||
free(data2);
|
||||
print_all(&save);
|
||||
|
||||
save_data_free(&save);
|
||||
free(manually);
|
||||
free(manually2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
61
main.rii
61
main.rii
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2018 Muresan Vlad Mihail
|
||||
Contact Info muresanvladmihail@gmail.com murii@tilde.team
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. Shall you use this software
|
||||
in a product, an acknowledgment and the contact info(if there is any)
|
||||
of the author(s) must be placed in the product documentation.
|
||||
This notice may not be removed or altered from any source distribution.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import libc {...}
|
||||
|
||||
|
||||
priv data:char* = """
|
||||
player_coins=20;
|
||||
player_life=0;
|
||||
player_x=200;
|
||||
player_y=300;
|
||||
current_level=3;
|
||||
""";
|
||||
|
||||
|
||||
func main(argc:int, argv:char**):int {
|
||||
save:save_data;
|
||||
save_data_init(&save, "player.stat"); //Creates and overrides file "player.stat"
|
||||
|
||||
keys:char[1][16];
|
||||
strcpy(keys[0],"player_bombs");
|
||||
|
||||
values:char[1][16];
|
||||
strcpy(values[0],"120");
|
||||
|
||||
data2:char* = save_data_serialize((:char*)keys[0], (:char*)values[0]);
|
||||
save_data_write(&save, data2, false);
|
||||
|
||||
save_data_write(&save, data2, false);
|
||||
|
||||
save_data_write(&save, data, true);
|
||||
|
||||
save_data_write(&save, data2, false);
|
||||
|
||||
// Read back what we have saved
|
||||
save_data_read(&save);
|
||||
|
||||
for (i := 0; i < save.total; i++) {
|
||||
printf("Pair: %s %s \n", save.keys[i], save.values[i]);
|
||||
}
|
||||
|
||||
free(data2);
|
||||
return 0;
|
||||
}
|
||||
|
127
savier.rii
127
savier.rii
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2018 Muresan Vlad Mihail
|
||||
Contact Info muresanvladmihail@gmail.com murii@tilde.team
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. Shall you use this software
|
||||
in a product, an acknowledgment and the contact info(if there is any)
|
||||
of the author(s) must be placed in the product documentation.
|
||||
This notice may not be removed or altered from any source distribution.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
Version 1.1:
|
||||
- Added new function: save_data_serialize; used to make the saving process easier.
|
||||
- save_data_write takes another argument used for overriding the current data or not.
|
||||
*/
|
||||
|
||||
const SAVE_DATA_MAX_ENTRIES = 128;
|
||||
const SAVE_DATA_MAX_KEY_LEN = 64;
|
||||
const SAVE_DATA_MAX_VALUE_LEN = 64;
|
||||
|
||||
struct save_data {
|
||||
file:FILE*;
|
||||
path:char const*;
|
||||
|
||||
keys:char[SAVE_DATA_MAX_ENTRIES][SAVE_DATA_MAX_KEY_LEN];
|
||||
values:char[SAVE_DATA_MAX_ENTRIES][SAVE_DATA_MAX_VALUE_LEN];
|
||||
total:usize; // length of total parsed keys/values
|
||||
}
|
||||
|
||||
|
||||
func save_data_init(save:save_data*, path:char const*) {
|
||||
save.path = path;
|
||||
save.total = 0;
|
||||
}
|
||||
|
||||
|
||||
//NOTE: You have to manually free the return value!
|
||||
func save_data_serialize(key:char*, value:char*): char* {
|
||||
buffer:char* = malloc(sizeof(char) * (strlen(key) + strlen(value)));
|
||||
sprintf(buffer, "%s=%s;\n", key, value);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
func save_data_write(save:save_data*, data_to_be_saved:char const*, force_override:bool) {
|
||||
if (force_override) {
|
||||
save.file = fopen(save.path, "w");
|
||||
} else {
|
||||
save.file = fopen(save.path, "a");
|
||||
}
|
||||
|
||||
if (!save.file) {
|
||||
printf("Error opening file: %s\n", save.path);
|
||||
}
|
||||
fprintf(save.file, "%s", data_to_be_saved);
|
||||
fclose(save.file);
|
||||
}
|
||||
|
||||
|
||||
func save_data_read(save:save_data*) {
|
||||
save.file = fopen(save.path, "r");
|
||||
if (!save.file) {
|
||||
printf("Error opening file: %s\n", save.path);
|
||||
}
|
||||
|
||||
fseek(save.file, 0, SEEK_END);
|
||||
file_len:long = ftell(save.file);
|
||||
fseek(save.file, 0, SEEK_SET);
|
||||
|
||||
got:char* = malloc(file_len);
|
||||
fread(got, 1, file_len, save.file);
|
||||
|
||||
c:int;
|
||||
|
||||
key:char[SAVE_DATA_MAX_KEY_LEN];
|
||||
key_index:uchar = 0;
|
||||
value:char[SAVE_DATA_MAX_VALUE_LEN];
|
||||
value_index:uchar = 0;
|
||||
|
||||
while (c < file_len) {
|
||||
curr:int = got[c];
|
||||
if (curr != '=') { //parse key
|
||||
key[key_index++] = curr;
|
||||
if (key_index > SAVE_DATA_MAX_KEY_LEN) {
|
||||
printf("Error: The key's size you're trying to read is bigger than what we can store\n");
|
||||
}
|
||||
} else if (curr == '=') { // parse value
|
||||
c++;
|
||||
strcpy(save.keys[save.total], key);
|
||||
while (got[c] != ';') {
|
||||
value[value_index++] = got[c];
|
||||
if (value_index > SAVE_DATA_MAX_VALUE_LEN) {
|
||||
printf("Error: Value's size you're trying to read is bigger than what we can store for key: %s\n", key);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
strcpy(save.values[save.total], value);
|
||||
save.total++;
|
||||
if (save.total > SAVE_DATA_MAX_ENTRIES) {
|
||||
puts("Error: You're trying to parse more data than reserved space!");
|
||||
break;
|
||||
}
|
||||
|
||||
memset(key, 0, SAVE_DATA_MAX_KEY_LEN);
|
||||
memset(value, 0, SAVE_DATA_MAX_VALUE_LEN);
|
||||
key_index = 0;
|
||||
value_index = 0;
|
||||
c++;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
fclose(save.file);
|
||||
free(got);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Copyright (c) 2018 Muresan Vlad Mihail
|
||||
Contact Info muresanvladmihail@gmail.com murii@tilde.team
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. Shall you use this software
|
||||
in a product, an acknowledgment and the contact info(if there is any)
|
||||
of the author(s) must be placed in the product documentation.
|
||||
This notice may not be removed or altered from any source distribution.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import libc {...}
|
||||
|
||||
|
||||
priv data:char* = """[
|
||||
player:{
|
||||
player_x=200;
|
||||
player_y=300;
|
||||
minor:{
|
||||
a=1;
|
||||
b=3;
|
||||
}
|
||||
|
||||
minor2:{
|
||||
hah= vlad;
|
||||
minor2_sub_minor1:{
|
||||
heh=dalv;
|
||||
}
|
||||
minor2_sub_minor2:{
|
||||
heha=lvda;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enemy:{
|
||||
damage=10;
|
||||
speed=120;
|
||||
}
|
||||
""";
|
||||
|
||||
|
||||
priv func print_sub_parent(parent:save_data_parent*) {
|
||||
for (i := 0; i < parent.sub_parents; i++) {
|
||||
p:save_data_parent* = parent.sub_parent[i];
|
||||
print_paires(p);
|
||||
if (p.has_sub_parent) {
|
||||
print_sub_parent(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
priv func print_paires(parent:save_data_parent*) {
|
||||
for (i := 0; i < parent.total; i++) {
|
||||
printf("Key: %s, Value: %s in parent: %s, id: %zu \n", parent.keys[i], parent.values[i], parent.name, parent.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
priv func print_parent(parent:save_data_parent*) {
|
||||
print_paires(parent);
|
||||
if (parent.has_sub_parent) {
|
||||
print_sub_parent(parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
priv func print_all(save:save_data*) {
|
||||
for (i := 0; i < save.total_parents; i++) {
|
||||
p:save_data_parent* = save.parents[i];
|
||||
print_parent(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func main(argc:int, argv:char**):int {
|
||||
|
||||
save:save_data;
|
||||
save_data_init(&save, "player.stat"); //Creates and overrides file "player.stat"
|
||||
|
||||
manually:char* = save_data_serialize_parent("programatically1", "foo", "42", "", 32);
|
||||
manually2:char* = save_data_serialize_parent("programatically2", "foo", "42", manually, 64);
|
||||
|
||||
save_data_write(&save, data, true);
|
||||
save_data_write(&save, manually, false);
|
||||
save_data_write(&save, manually2, false);
|
||||
save_data_write(&save, "]", false);
|
||||
|
||||
// Read back what we have saved
|
||||
save_data_read(&save);
|
||||
|
||||
printf("Total parents: %zu\n", save.total_parents);
|
||||
|
||||
print_all(&save);
|
||||
|
||||
save_data_free(&save);
|
||||
free(manually);
|
||||
free(manually2);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
Copyright (c) 2018 Muresan Vlad Mihail
|
||||
Contact Info muresanvladmihail@gmail.com murii@tilde.team
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. Shall you use this software
|
||||
in a product, an acknowledgment and the contact info(if there is any)
|
||||
of the author(s) must be placed in the product documentation.
|
||||
This notice may not be removed or altered from any source distribution.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
Version 2.0:
|
||||
- Almost completely rewritten the system, its data structures are much more complex.
|
||||
Version 1.1:
|
||||
- Added new function: save_data_serialize; used to make the saving process easier.
|
||||
- save_data_write takes another argument used for overriding the current data or not.
|
||||
*/
|
||||
|
||||
const SAVE_DATA_MAX_PARENTS = 512;
|
||||
const SAVE_DATA_MAX_SUB_PARENTS = 8;
|
||||
const SAVE_DATA_MAX_ENTRIES = 128;
|
||||
const SAVE_DATA_MAX_KEY_LEN = 64;
|
||||
const SAVE_DATA_MAX_VALUE_LEN = 64;
|
||||
|
||||
struct save_data_parent {
|
||||
name:char[SAVE_DATA_MAX_KEY_LEN]; // name of this parent
|
||||
id:usize; // current position in document
|
||||
keys:char[SAVE_DATA_MAX_ENTRIES][SAVE_DATA_MAX_KEY_LEN];
|
||||
values:char[SAVE_DATA_MAX_ENTRIES][SAVE_DATA_MAX_VALUE_LEN];
|
||||
total:usize; // length of total parsed keys/values
|
||||
|
||||
has_sub_parent:bool;
|
||||
sub_parent:save_data_parent**; // actual subparents' data
|
||||
sub_parents:usize; // length of all subparents in this parent
|
||||
sub_parent_id:usize; // each time a subparent has been found this goes ++
|
||||
}
|
||||
|
||||
|
||||
struct save_data {
|
||||
raw_file:FILE*;
|
||||
path:char const*;
|
||||
file:char*; // the read content from disk
|
||||
file_size:long; // how long this file is
|
||||
c:int; //current parsed char
|
||||
|
||||
parents:save_data_parent**;
|
||||
total_parents:usize; // length of head parents has this save_data parsed
|
||||
}
|
||||
|
||||
|
||||
priv func init_parent(p:save_data_parent*) {
|
||||
p.sub_parent = malloc(sizeof(save_data_parent) * SAVE_DATA_MAX_SUB_PARENTS);
|
||||
p.id = 0;
|
||||
p.total = 0;
|
||||
p.sub_parents = 0;
|
||||
p.has_sub_parent = false;
|
||||
p.sub_parent_id = 0;
|
||||
}
|
||||
|
||||
|
||||
func save_data_init(save:save_data*, path:char const*) {
|
||||
save.path = path;
|
||||
save.total_parents = 0;
|
||||
save.file_size = 0;
|
||||
save.c = 0;
|
||||
|
||||
save.parents = malloc(sizeof(save_data_parent) * SAVE_DATA_MAX_PARENTS);
|
||||
for (i := 0; i < SAVE_DATA_MAX_PARENTS; i++) {
|
||||
parent:save_data_parent*;
|
||||
save.parents[i] = malloc(sizeof(save_data_parent));
|
||||
parent = save.parents[i];
|
||||
init_parent(parent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
priv func free_sub_parents(p:save_data_parent*) {
|
||||
for (j:usize = 0; j < p.sub_parents; j++) {
|
||||
p1:save_data_parent* = p.sub_parent[j];
|
||||
if (p1.has_sub_parent) {
|
||||
free_sub_parents(p1);
|
||||
}
|
||||
free(p1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func save_data_free(save:save_data*) {
|
||||
|
||||
for (i:usize = 0; i < save.total_parents; i++) {
|
||||
p1:save_data_parent* = save.parents[i];
|
||||
if (p1.has_sub_parent) {
|
||||
free_sub_parents(p1);
|
||||
}
|
||||
free(p1);
|
||||
}
|
||||
|
||||
free(save.parents);
|
||||
|
||||
if (save.file) {
|
||||
free(save.file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Programatically introduce parents and subparents to a save data file
|
||||
*
|
||||
* @parent_name - what name should the head parent have
|
||||
* @key - key value, eg: car
|
||||
* @value - value's value, eg: red
|
||||
* @sub_parent - if @parent_name must have a sub_parent what name should it have? Eg: Audi
|
||||
* @len - total length of all,above, values introduced
|
||||
* --------------------------------------------------
|
||||
* NOTE: You have to manually free the return char!
|
||||
* --------------------------------------------------
|
||||
*/
|
||||
func save_data_serialize_parent(parent_name:char*, key:char*, value:char*, sub_parent:char*, len:usize): char* {
|
||||
|
||||
buffer:char* = malloc(len);
|
||||
sprintf(buffer, "%s:{ \n%s=%s; \n%s }\n", parent_name, key, value, sub_parent);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
func save_data_write(save:save_data*, data_to_be_saved:char const*, force_override:bool) {
|
||||
save.raw_file = fopen(save.path, force_override == true ? "w" : "a");
|
||||
|
||||
if (!save.raw_file) {
|
||||
fprintf(stderr, "Error opening file: %s\n", save.path);
|
||||
}
|
||||
fprintf(save.raw_file, "%s", data_to_be_saved);
|
||||
fclose(save.raw_file);
|
||||
}
|
||||
|
||||
|
||||
priv func parse_child(save:save_data*, parent:save_data_parent*) {
|
||||
ki:int = 0; // key index
|
||||
vi:int = 0; // value index
|
||||
key:char[SAVE_DATA_MAX_KEY_LEN];
|
||||
value:char[SAVE_DATA_MAX_VALUE_LEN];
|
||||
|
||||
while (save.file[save.c] != '}') {
|
||||
if (save.file[save.c] != '=' && save.file[save.c] != ':') { //parse key or another parent
|
||||
if (!isspace(save.file[save.c])) { //ignore whitespace
|
||||
key[ki++] = save.file[save.c];
|
||||
}
|
||||
if (ki > SAVE_DATA_MAX_KEY_LEN) {
|
||||
fprintf(stderr, "Error: The key's size, %s, you're trying to read is bigger than what we can store\n",key);
|
||||
}
|
||||
}else if (save.file[save.c] == ':') { // this parent has sub parents
|
||||
save.c++;
|
||||
parent.has_sub_parent = true;
|
||||
parent.sub_parent[parent.sub_parents] = malloc(sizeof(save_data_parent));
|
||||
p:save_data_parent* = parent.sub_parent[parent.sub_parents];
|
||||
parent.sub_parent_id++;
|
||||
init_parent(p);
|
||||
strcpy(p.name, key);
|
||||
if (save.file[save.c] != '{') {
|
||||
fprintf(stderr, "Error: expected '{' when parsing parent: %s, got %c\n", parent.name, save.file[save.c]);
|
||||
return;
|
||||
}
|
||||
save.c++;
|
||||
parse_child(save, p);
|
||||
p.id = parent.sub_parent_id;
|
||||
parent.sub_parent[parent.sub_parents] = p;
|
||||
parent.sub_parents++;
|
||||
memset(key, 0, SAVE_DATA_MAX_KEY_LEN);
|
||||
ki = 0;
|
||||
} else if (save.file[save.c] == '=') {
|
||||
save.c++;
|
||||
while (save.file[save.c] != ';') {
|
||||
|
||||
if (!isspace(save.file[save.c])) { //ignore whitesapce
|
||||
value[vi++] = save.file[save.c];
|
||||
}
|
||||
if (vi > SAVE_DATA_MAX_VALUE_LEN) {
|
||||
fprintf(stderr, "Error: Value's size you're trying to read is bigger than what we can store for key: %s\n", key);
|
||||
|
||||
}
|
||||
save.c++;
|
||||
}
|
||||
strcpy(parent.keys[parent.total], key);
|
||||
strcpy(parent.values[parent.total], value);
|
||||
|
||||
parent.total++;
|
||||
if (parent.total > SAVE_DATA_MAX_ENTRIES) {
|
||||
fprintf(stderr, "Error: You're trying to parse more data than reserved space for this parent: %s!", parent.name);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(value, 0, SAVE_DATA_MAX_VALUE_LEN);
|
||||
memset(key, 0, SAVE_DATA_MAX_KEY_LEN);
|
||||
ki = 0;
|
||||
vi = 0;
|
||||
|
||||
save.c++;
|
||||
}
|
||||
save.c++;
|
||||
}
|
||||
parent.id = save.total_parents;
|
||||
}
|
||||
|
||||
|
||||
func save_data_read(save:save_data*) {
|
||||
save.raw_file = fopen(save.path, "r");
|
||||
if (!save.raw_file) {
|
||||
printf("Error opening file: %s\n", save.path);
|
||||
}
|
||||
|
||||
fseek(save.raw_file, 0, SEEK_END);
|
||||
file_len:long = ftell(save.raw_file);
|
||||
fseek(save.raw_file, 0, SEEK_SET);
|
||||
|
||||
save.file_size = file_len;
|
||||
|
||||
save.file = malloc(file_len);
|
||||
fread(save.file, 1, file_len, save.raw_file);
|
||||
|
||||
name:char[SAVE_DATA_MAX_KEY_LEN]; // current parent name
|
||||
ni:int = 0;
|
||||
|
||||
if (save.file[save.c] != '[') {
|
||||
fprintf(stderr, "Error: Expected '[' at the begginig of file, got %c\n", save.file[save.c]);
|
||||
return;
|
||||
} else {
|
||||
save.c++;
|
||||
}
|
||||
|
||||
while (save.c < file_len && save.file[save.c] != ']') {
|
||||
parent:save_data_parent*;
|
||||
parent = save.parents[save.total_parents];
|
||||
|
||||
while (isspace(save.file[save.c])) {
|
||||
save.c++;
|
||||
}
|
||||
|
||||
if (save.file[save.c] != ':') { //parse parent name
|
||||
name[ni++] = save.file[save.c];
|
||||
if (ni > SAVE_DATA_MAX_KEY_LEN) {
|
||||
fprintf(stderr, "Error: Parent's name is bigger than what we can store, %s\n",name);
|
||||
}
|
||||
} else if (save.file[save.c] == ':') { // we need to parse the content of this parent
|
||||
save.c++;
|
||||
strcpy(parent.name, name);
|
||||
memset(name, 0, SAVE_DATA_MAX_KEY_LEN);
|
||||
ni = 0;
|
||||
if (save.file[save.c] != '{') {
|
||||
fprintf(stderr, "Error: expected '{' when parsing parent: %s, got %c\n", parent.name, save.file[save.c]);
|
||||
return;
|
||||
} else {
|
||||
save.c++;
|
||||
parse_child(save, parent);
|
||||
save.total_parents++;
|
||||
}
|
||||
}
|
||||
save.c++;
|
||||
}
|
||||
|
||||
fclose(save.raw_file);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
// day, month, year, version major, version minor
|
||||
const RII__VERSION:int = 28111803;
|
|
@ -0,0 +1,2 @@
|
|||
#declare_note(extern)
|
||||
#declare_note(static_assert)
|
|
@ -0,0 +1,73 @@
|
|||
enum TypeKind {
|
||||
TYPE_NONE,
|
||||
TYPE_VOID,
|
||||
TYPE_BOOL,
|
||||
TYPE_CHAR,
|
||||
TYPE_UCHAR,
|
||||
TYPE_SCHAR,
|
||||
TYPE_SHORT,
|
||||
TYPE_USHORT,
|
||||
TYPE_INT,
|
||||
TYPE_UINT,
|
||||
TYPE_LONG,
|
||||
TYPE_ULONG,
|
||||
TYPE_LLONG,
|
||||
TYPE_ULLONG,
|
||||
TYPE_FLOAT,
|
||||
TYPE_DOUBLE,
|
||||
TYPE_CONST,
|
||||
TYPE_PTR,
|
||||
TYPE_ARRAY,
|
||||
TYPE_STRUCT,
|
||||
TYPE_UNION,
|
||||
TYPE_FUNC,
|
||||
}
|
||||
|
||||
struct TypeFieldInfo {
|
||||
name: char const*;
|
||||
type: typeid;
|
||||
offset: int;
|
||||
}
|
||||
|
||||
struct TypeInfo {
|
||||
kind: TypeKind;
|
||||
size: int;
|
||||
align: int;
|
||||
name: char const*;
|
||||
count: int;
|
||||
base: typeid;
|
||||
fields: TypeFieldInfo*;
|
||||
num_fields: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
global typeinfos: TypeInfo const**;
|
||||
|
||||
@extern
|
||||
global num_typeinfos: int;
|
||||
|
||||
func typeid_kind(type: typeid): TypeKind {
|
||||
return (:TypeKind)((type >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
func typeid_index(type: typeid): int {
|
||||
return (:int)(type & 0xFFFFFF);
|
||||
}
|
||||
|
||||
func typeid_size(type: typeid): usize {
|
||||
return (:usize)(type >> 32);
|
||||
}
|
||||
|
||||
func get_typeinfo(type: typeid): TypeInfo const* {
|
||||
index := typeid_index(type);
|
||||
if (typeinfos && index < num_typeinfos) {
|
||||
return typeinfos[index];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct Any {
|
||||
ptr: void*;
|
||||
type: typeid;
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
import libc { realloc, memcpy, free, malloc }
|
||||
|
||||
struct BufHdr
|
||||
{
|
||||
cap, len: usize;
|
||||
buf: char[1];
|
||||
}
|
||||
|
||||
priv func buf_hdr(buf: void*): BufHdr*
|
||||
{
|
||||
return (:BufHdr*)((:char *)(buf) - offsetof(BufHdr, buf));
|
||||
}
|
||||
|
||||
func std_buf_free(buf: void*)
|
||||
{
|
||||
if (buf)
|
||||
{
|
||||
free(buf_hdr(buf));
|
||||
}
|
||||
}
|
||||
|
||||
func std_buf_cap(buf: void*): usize
|
||||
{
|
||||
return buf ? buf_hdr(buf).cap : 0;
|
||||
}
|
||||
|
||||
func std_buf_len(buf: void*): usize
|
||||
{
|
||||
return buf ? buf_hdr(buf).len : 0;
|
||||
}
|
||||
|
||||
func std_buf_end(buf: void*, elem_size: usize): void*
|
||||
{
|
||||
return (:char*)buf + (std_buf_len(buf) * elem_size);
|
||||
}
|
||||
|
||||
priv func buf_grow(buf: void*, new_len: usize, elem_size: usize): void*
|
||||
{
|
||||
#assert(std_buf_cap(buf) <= (ULLONG_MAX - 1) / 2);
|
||||
new_cap := std_usize_max(8, std_usize_max(1 + 2 * std_buf_cap(buf), new_len));
|
||||
#assert(new_len <= new_cap);
|
||||
#assert(new_cap <= (ULLONG_MAX - offsetof(BufHdr, buf)) / elem_size);
|
||||
new_size := offsetof(BufHdr, buf) + new_cap * elem_size;
|
||||
new_hdr: BufHdr*;
|
||||
|
||||
if (buf)
|
||||
{
|
||||
new_hdr = realloc(buf_hdr(buf), new_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_hdr = malloc(new_size);
|
||||
new_hdr.len = 0;
|
||||
}
|
||||
new_hdr.cap = new_cap;
|
||||
return (:void*)new_hdr.buf;
|
||||
}
|
||||
|
||||
func std_buf_fit(buf: void*, size: usize, elem_size: usize): void*
|
||||
{
|
||||
if (size <= std_buf_cap(buf))
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
|
||||
return buf_grow(buf, size, elem_size);
|
||||
}
|
||||
|
||||
func std_buf_push(buf: void*, val: void*, elem_size: usize): void*
|
||||
{
|
||||
buf = std_buf_fit(buf, std_buf_len(buf) + 1, elem_size);
|
||||
memcpy((:char*)buf + (std_buf_len(buf) * elem_size), val, elem_size);
|
||||
hdr := buf_hdr(buf);
|
||||
hdr.len++;
|
||||
return buf;
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
struct std_list
|
||||
{
|
||||
d:void*;
|
||||
n:list*;
|
||||
p:list*;
|
||||
}
|
||||
|
||||
func std_list_init(): list*
|
||||
{
|
||||
l:list* = malloc(sizeof(list));
|
||||
l.p = NULL;
|
||||
l.d = NULL;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
func std_list_add(l:list*, d:void*)
|
||||
{
|
||||
while (l.d)
|
||||
{
|
||||
if (l.n)
|
||||
{
|
||||
l = l.n;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
l.d = d;
|
||||
l.n = malloc(sizeof(list));
|
||||
l.n.p = l;
|
||||
l.n.n = NULL;
|
||||
l.n.d = NULL;
|
||||
}
|
||||
|
||||
|
||||
func std_list_remove(l:list*, data:void*): list*
|
||||
{
|
||||
d:list* = l;
|
||||
|
||||
// find node with matching data
|
||||
while (l.d != data)
|
||||
{
|
||||
if (l.n)
|
||||
{
|
||||
l = l.n;
|
||||
}
|
||||
else
|
||||
{
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
// remove node and adjust root
|
||||
if (l.p)
|
||||
{
|
||||
if (l.n)
|
||||
{
|
||||
l.p.n = l.n;
|
||||
l.n.p = l.p;
|
||||
}
|
||||
else
|
||||
{
|
||||
l.p.n = NULL;
|
||||
}
|
||||
}
|
||||
else if (l.n)
|
||||
{
|
||||
//reset root node
|
||||
d = l.n;
|
||||
d.p = NULL;
|
||||
}
|
||||
l.d = NULL;
|
||||
free(l);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
func std_list_destroy(l:list*)
|
||||
{
|
||||
if (!l)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// remove first node
|
||||
n:list* = l.n;
|
||||
free(l);
|
||||
|
||||
while (n)
|
||||
{
|
||||
l = n;
|
||||
n = n.n;
|
||||
free(l);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
import libc { calloc, free }
|
||||
|
||||
const MAP_LOAD_FACTOR = 0.9;
|
||||
const MAP_MIN_SIZE = 8;
|
||||
global DEFAULT_HASH_FN: HashFn = hash_ptr;
|
||||
global DEFAULT_KEY_CMP_FN: KeyCmpFn = cmp_ptr;
|
||||
|
||||
struct std_map_entry
|
||||
{
|
||||
key, val: void*;
|
||||
hash: usize;
|
||||
}
|
||||
|
||||
typedef HashFn = func(key: void*): usize;
|
||||
typedef KeyCmpFn = func(key: void*, test: void*): bool;
|
||||
|
||||
struct std_map
|
||||
{
|
||||
hash_fn: HashFn;
|
||||
key_cmp_fn: KeyCmpFn;
|
||||
entries: std_map_entry*;
|
||||
size: usize;
|
||||
cap: usize;
|
||||
mask: usize;
|
||||
resize_at: usize;
|
||||
}
|
||||
|
||||
|
||||
priv func map__ideal_ix(map: std_map*, hash: usize): usize
|
||||
{
|
||||
return hash & map.mask;
|
||||
}
|
||||
|
||||
priv func map__probe_len(map: std_map*, hash: usize, ix: usize): usize
|
||||
{
|
||||
return (ix + map.cap - map__ideal_ix(map, hash)) & map.mask;
|
||||
}
|
||||
|
||||
func std_map_entry_is_empty(entry: std_map_entry*): bool
|
||||
{
|
||||
return entry.hash == 0;
|
||||
}
|
||||
|
||||
func map__entry_clear(m: std_map*, ix: usize)
|
||||
{
|
||||
m.entries[ix].hash = 0;
|
||||
}
|
||||
|
||||
func std_map_clear(m: std_map*)
|
||||
{
|
||||
if (m.size == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i := 0; i < m.cap; i++)
|
||||
{
|
||||
map__entry_clear(m, i);
|
||||
}
|
||||
|
||||
m.size = 0;
|
||||
}
|
||||
|
||||
func hash_u64(x: ullong): usize
|
||||
{
|
||||
x *= 0xff51afd7ed558ccd;
|
||||
x ^= x >> 32;
|
||||
return x;
|
||||
}
|
||||
|
||||
func hash_ptr(ptr: void*): usize
|
||||
{
|
||||
return (:usize)(hash_u64((:uintptr)ptr));
|
||||
}
|
||||
|
||||
func cmp_ptr(key: void*, test: void*): bool
|
||||
{
|
||||
return key == test;
|
||||
}
|
||||
|
||||
func std_map_init(m: std_map*, hash_fn: HashFn, key_cmp_fn: KeyCmpFn)
|
||||
{
|
||||
m.hash_fn = hash_fn;
|
||||
m.key_cmp_fn = key_cmp_fn;
|
||||
std_map_clear(m);
|
||||
}
|
||||
|
||||
func std_map_new(): std_map*
|
||||
{
|
||||
m: std_map* = calloc(1, sizeof(Map));
|
||||
std_map_init(m, DEFAULT_HASH_FN, DEFAULT_KEY_CMP_FN);
|
||||
return m;
|
||||
}
|
||||
|
||||
func std_map_free(m: std_map*)
|
||||
{
|
||||
free(m.entries);
|
||||
}
|
||||
|
||||
priv func map__grow(m: std_map*, new_cap: usize)
|
||||
{
|
||||
new_cap = std_usize_max(MAP_MIN_SIZE, new_cap);
|
||||
#assert(std_is_pow2(new_cap));
|
||||
|
||||
new_m: std_map = {
|
||||
hash_fn = m.hash_fn ? m.hash_fn : DEFAULT_HASH_FN,
|
||||
key_cmp_fn = m.key_cmp_fn ? m.key_cmp_fn : DEFAULT_KEY_CMP_FN,
|
||||
entries = calloc(new_cap, sizeof(std_map_entry)),
|
||||
cap = new_cap,
|
||||
mask = new_cap - 1,
|
||||
resize_at = (:usize)((:double)new_cap * MAP_LOAD_FACTOR)
|
||||
};
|
||||
|
||||
for (i: usize = 0; i < m.cap; i++)
|
||||
{
|
||||
if (!std_map_entry_is_empty(&m.entries[i]))
|
||||
{
|
||||
map__do_insert(&new_m, m.entries[i].key, m.entries[i].val);
|
||||
}
|
||||
}
|
||||
|
||||
free(m.entries);
|
||||
|
||||
*m = new_m;
|
||||
}
|
||||
|
||||
func std_map__get_hash(m: std_map *, key: void*): usize
|
||||
{
|
||||
hash := m.hash_fn(key);
|
||||
hash |= (hash == 0); // 0 indicates empty
|
||||
return hash;
|
||||
}
|
||||
|
||||
func std_map__find(m: std_map*, key: void*, ix_result: usize*): bool
|
||||
{
|
||||
if (m.size == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#assert(std_is_pow2(m.cap));
|
||||
#assert(m.size < m.cap);
|
||||
|
||||
hash := std_map__get_hash(m, key);
|
||||
ix := map__ideal_ix(m, hash);
|
||||
probe_len: usize = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (m.entries[ix].hash == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (probe_len > map__probe_len(m, m.entries[ix].hash, ix))
|
||||
{
|
||||
// Can early out here because an element with a longer probe count than probe_len would have been swapped on insert
|
||||
return false;
|
||||
}
|
||||
else if (m.entries[ix].hash == hash && m.key_cmp_fn(m.entries[ix].key, key))
|
||||
{
|
||||
*ix_result = ix;
|
||||
return true;
|
||||
}
|
||||
|
||||
ix = (ix + 1) & m.mask;
|
||||
probe_len++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
func std_map_has_key(m: std_map*, key: void*): bool
|
||||
{
|
||||
ix: usize;
|
||||
return std_map__find(m, key, &ix);
|
||||
}
|
||||
|
||||
func std_map_get(m: std_map*, key: void*): void*
|
||||
{
|
||||
ix: usize;
|
||||
return std_map__find(m, key, &ix) ? m.entries[ix].val : NULL;
|
||||
}
|
||||
|
||||
func std_map_remove(m: std_map*, key: void*): bool
|
||||
{
|
||||
ix: usize;
|
||||
if (!std_map__find(m, key, &ix))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
prev_ix := ix;
|
||||
ix = (ix + 1) & m.mask;
|
||||
if (std_map_entry_is_empty(&m.entries[ix]) || map__probe_len(m, m.entries[ix].hash, ix) == 0)
|
||||
{
|
||||
std_map__entry_clear(m, prev_ix);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
m.entries[prev_ix] = m.entries[ix];
|
||||
}
|
||||
}
|
||||
|
||||
m.size--;
|
||||
return true;
|
||||
}
|
||||
|
||||
priv func map__create_entry(m: std_map*, ix: usize, hash: usize, key: void*, val: void*)
|
||||
{
|
||||
m.size++;
|
||||
m.entries[ix].key = key;
|
||||
m.entries[ix].val = val;
|
||||
m.entries[ix].hash = hash;
|
||||
}
|
||||
|
||||
priv func map__do_insert(m: std_map*, key: void*, val: void*)
|
||||
{
|
||||
hash := std_map__get_hash(m, key);
|
||||
ix := map__ideal_ix(m, hash);
|
||||
probe_len: usize = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (std_map_entry_is_empty(&m.entries[ix]))
|
||||
{
|
||||
map__create_entry(m, ix, hash, key, val);
|
||||
return;
|
||||
}
|
||||
else if (m.key_cmp_fn(m.entries[ix].key, key))
|
||||
{
|
||||
m.entries[ix].val = val;
|
||||
m.entries[ix].hash = hash;
|
||||
return;
|
||||
}
|
||||
|
||||
occupant_probe_len := map__probe_len(m, m.entries[ix].hash, ix);
|
||||
|
||||
// If occupant is closer to its ideal slot, insert the new item here and continue looking for a slot for the evicted item
|
||||
if (occupant_probe_len < probe_len)
|
||||
{
|
||||
tmp: std_map_entry = m.entries[ix];
|
||||
m.entries[ix].key = key;
|
||||
m.entries[ix].val = val;
|
||||
m.entries[ix].hash = hash;
|
||||
key = tmp.key;
|
||||
val = tmp.val;
|
||||
hash = tmp.hash;
|
||||
|
||||
probe_len = occupant_probe_len;
|
||||
}
|
||||
|
||||
ix = (ix + 1) & m.mask;
|
||||
probe_len++;
|
||||
}
|
||||
}
|
||||
|
||||
func std_map_put(m: std_map*, key: void*, val: void*)
|
||||
{
|
||||
if (m.resize_at <= m.size)
|
||||
{
|
||||
map__grow(m, 2 * m.cap);
|
||||
}
|
||||
|
||||
map__do_insert(m, key, val);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
import libc { ... }
|
||||
|
||||
func std_hash_bytes(buf: uint8*, len: usize): ullong
|
||||
{
|
||||
x: ullong = 0xcbf29ce484222325;
|
||||
for (i := 0; i < len; i++)
|
||||
{
|
||||
x ^= buf[i];
|
||||
x *= 0x100000001b3;
|
||||
x ^= x >> 32;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
func std_hash_str(ptr: void*): ullong
|
||||
{
|
||||
return std_hash_bytes((:uint8*)ptr, strlen((:char*)ptr));
|
||||
}
|
||||
|
||||
func std_cmp_str(key: void*, test: void*): bool
|
||||
{
|
||||
a: char* = (:char*)key;
|
||||
b: char* = (:char*)test;
|
||||
return strcmp(a, b) == 0;
|
||||
}
|
||||
|
||||
func std_map_str_new(): std_map*
|
||||
{
|
||||
m: std_map* = calloc(1, sizeof(std_map));
|
||||
std_map_init(m, std_hash_str, std_cmp_str);
|
||||
return m;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
func std_usize_max(a: usize, b: usize): usize
|
||||
{
|
||||
return a >= b ? a : b;
|
||||
}
|
||||
|
||||
func std_is_pow2(x: usize): bool
|
||||
{
|
||||
return (x != 0) && ((x & (x - 1)) == 0);
|
||||
}
|
||||
|
||||
func std_next_pow2(x: usize): usize
|
||||
{
|
||||
if (is_pow2(x))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
x--;
|
||||
x |= (x >> 1);
|
||||
x |= (x >> 2);
|
||||
x |= (x >> 4);
|
||||
x |= (x >> 8);
|
||||
x |= (x >> 16);
|
||||
x |= (x >> 32);
|
||||
x++;
|
||||
return x;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
import libc { malloc, free, realloc}
|
||||
|
||||
const STD_VECTOR_CAP = 4;
|
||||
|
||||
struct std_vector
|
||||
{
|
||||
cap:usize;
|
||||
len:usize;
|
||||
items:void**;
|
||||
}
|
||||
|
||||
func std_vector_init(v:std_vector*)
|
||||
{
|
||||
v.cap = STD_VECTOR_CAP;
|
||||
v.len = 0;
|
||||
v.items = malloc(sizeof(:void*) * v.cap);
|
||||
}
|
||||
|
||||
func std_vector_len(v:std_vector*): usize
|
||||
{
|
||||
return v.len;
|
||||
}
|
||||
|
||||
func std_vector_free(v:std_vector*)
|
||||
{
|
||||
free(v.items);
|
||||
}
|
||||
|
||||
priv func vector_resize(v:std_vector*, cap:usize)
|
||||
{
|
||||
items:void** = realloc(v.items, sizeof(:void*) * cap);
|
||||
if (items)
|
||||
{
|
||||
v.items = items;
|
||||
v.cap = cap;
|
||||
}
|
||||
}
|
||||
|
||||
func std_vector_add(v:std_vector*, item:void*)
|
||||
{
|
||||
if (v.cap == v.len)
|
||||
{
|
||||
vector_resize(v, v.cap * 2);
|
||||
}
|
||||
v.items[v.len++] = item;
|
||||
}
|
||||
|
||||
func std_vector_set(v:std_vector*, val:void*, index:usize)
|
||||
{
|
||||
#assert(index < v.len);
|
||||
v.items[index] = val;
|
||||
}
|
||||
|
||||
func std_vector_get(v:std_vector*, index:usize): void*
|
||||
{
|
||||
#assert(index < v.len);
|
||||
return v.items[index];
|
||||
}
|
||||
|
||||
func std_vector_delete(v:std_vector*, index:usize)
|
||||
{
|
||||
#assert(index < v.len);
|
||||
v.items[index] = NULL;
|
||||
for (i:usize = index; i < v.len - 1; i++)
|
||||
{
|
||||
v.items[i] = v.items[i + 1];
|
||||
v.items[i + 1] = NULL;
|
||||
}
|
||||
v.len--;
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#extern(header = "<ctype.h>")
|
||||
|
||||
@extern
|
||||
func isalnum(c: int): int;
|
||||
|
||||
@extern
|
||||
func isalpha(c: int): int;
|
||||
|
||||
@extern
|
||||
func isblank(c: int): int;
|
||||
|
||||
@extern
|
||||
func iscntrl(c: int): int;
|
||||
|
||||
@extern
|
||||
func isdigit(c: int): int;
|
||||
|
||||
@extern
|
||||
func isgraph(c: int): int;
|
||||
|
||||
@extern
|
||||
func islower(c: int): int;
|
||||
|
||||
@extern
|
||||
func isprint(c: int): int;
|
||||
|
||||
@extern
|
||||
func ispunct(c: int): int;
|
||||
|
||||
@extern
|
||||
func isspace(c: int): int;
|
||||
|
||||
@extern
|
||||
func isupper(c: int): int;
|
||||
|
||||
@extern
|
||||
func isxdigit(c: int): int;
|
||||
|
||||
@extern
|
||||
func tolower(c: int): int;
|
||||
|
||||
@extern
|
||||
func toupper(c: int): int;
|
|
@ -0,0 +1,345 @@
|
|||
#extern(header = "<math.h>")
|
||||
|
||||
@extern("acosf")
|
||||
func acos(x: float): float;
|
||||
|
||||
@extern("acos")
|
||||
func acosd(x: double): double;
|
||||
|
||||
@extern("asinf")
|
||||
func asin(x: float): float;
|
||||
|
||||
@extern("asin")
|
||||
func asind(x: double): double;
|
||||
|
||||
@extern("atanf")
|
||||
func atan(x: float): float;
|
||||
|
||||
@extern("atan")
|
||||
func atand(x: double): double;
|
||||
|
||||
@extern("atan2f")
|
||||
func atan2(y: float, x: float): float;
|
||||
|
||||
@extern("atan2")
|
||||
func atan2d(y: double, x: double): double;
|
||||
|
||||
@extern("cosf")
|
||||
func cos(x: float): float;
|
||||
|
||||
@extern("cos")
|
||||
func cosd(x: double): double;
|
||||
|
||||
@extern("sinf")
|
||||
func sin(x: float): float;
|
||||
|
||||
@extern("sin")
|
||||
func sind(x: double): double;
|
||||
|
||||
@extern("tanf")
|
||||
func tan(x: float): float;
|
||||
|
||||
@extern("tan")
|
||||
func tand(x: double): double;
|
||||
|
||||
@extern("acoshf")
|
||||
func acosh(x: float): float;
|
||||
|
||||
@extern("acosh")
|
||||
func acoshd(x: double): double;
|
||||
|
||||
@extern("asinhf")
|
||||
func asinh(x: float): float;
|
||||
|
||||
@extern("asinh")
|
||||
func asinhd(x: double): double;
|
||||
|
||||
@extern("atanhf")
|
||||
func atanh(x: float): float;
|
||||
|
||||
@extern("atanh")
|
||||
func atanhd(x: double): double;
|
||||
|
||||
@extern("coshf")
|
||||
func cosh(x: float): float;
|
||||
|
||||
@extern("cosh")
|
||||
func coshd(x: double): double;
|
||||
|
||||
@extern("sinhf")
|
||||
func sinh(x: float): float;
|
||||
|
||||
@extern("sinh")
|
||||
func sinhd(x: double): double;
|
||||
|
||||
@extern("tanhf")
|
||||
func tanh(x: float): float;
|
||||
|
||||
@extern("tanh")
|
||||
func tanhd(x: double): double;
|
||||
|
||||
@extern("expf")
|
||||
func exp(x: float): float;
|
||||
|
||||
@extern("exp")
|
||||
func expd(x: double): double;
|
||||
|
||||
@extern("exp2f")
|
||||
func exp2(x: float): float;
|
||||
|
||||
@extern("exp2")
|
||||
func exp2d(x: double): double;
|
||||
|
||||
@extern("expm1f")
|
||||
func expm1(x: float): float;
|
||||
|
||||
@extern("expm1")
|
||||
func expm1d(x: double): double;
|
||||
|
||||
@extern("frexpf")
|
||||
func frexp(value: float, exp: int*): float;
|
||||
|
||||
@extern("frexp")
|
||||
func frexpd(value: double, exp: int*): double;
|
||||
|
||||
@extern("ilogbf")
|
||||
func ilogb(x: float): int;
|
||||
|
||||
@extern("ilogb")
|
||||
func ilogbd(x: double): int;
|
||||
|
||||
@extern("ldexpf")
|
||||
func ldexp(x: float, exp: int): float;
|
||||
|
||||
@extern("ldexp")
|
||||
func ldexpd(x: double, exp: int): double;
|
||||
|
||||
@extern("logf")
|
||||
func log(x: float): float;
|
||||
|
||||
@extern("log")
|
||||
func logd(x: double): double;
|
||||
|
||||
@extern("log10f")
|
||||
func log10(x: float): float;
|
||||
|
||||
@extern("log10")
|
||||
func log10d(x: double): double;
|
||||
|
||||
@extern("log1pf")
|
||||
func log1p(x: float): float;
|
||||
|
||||
@extern("log1p")
|
||||
func log1pd(x: double): double;
|
||||
|
||||
@extern("log2f")
|
||||
func log2(x: float): float;
|
||||
|
||||
@extern("log2")
|
||||
func log2d(x: double): double;
|
||||
|
||||
@extern("logbf")
|
||||
func logb(x: float): float;
|
||||
|
||||
@extern("logb")
|
||||
func logbd(x: double): double;
|
||||
|
||||
@extern("modff")
|
||||
func modf(value: float, iptr: float*): float;
|
||||
|
||||
@extern("modf")
|
||||
func modfd(value: double, iptr: double*): double;
|
||||
|
||||
@extern("scalbnf")
|
||||
func scalbn(x: float, n: int): float;
|
||||
|
||||
@extern("scalbn")
|
||||
func scalbnd(x: double, n: int): double;
|
||||
|
||||
@extern("scalblnf")
|
||||
func scalbln(x: float, n: long): float;
|
||||
|
||||
@extern("scalbln")
|
||||
func scalblnd(x: double, n: long): double;
|
||||
|
||||
@extern("cbrtf")
|
||||
func cbrt(x: float): float;
|
||||
|
||||
@extern("cbrt")
|
||||
func cbrtd(x: double): double;
|
||||
|
||||
@extern("fabsf")
|
||||
func fabs(x: float): float;
|
||||
|
||||
@extern("fabs")
|
||||
func fabsd(x: double): double;
|
||||
|
||||
@extern("hypotf")
|
||||
func hypot(x: float, y: float): float;
|
||||
|
||||
@extern("hypot")
|
||||
func hypotd(x: double, y: double): double;
|
||||
|
||||
@extern("powf")
|
||||
func pow(x: float, y: float): float;
|
||||
|
||||
@extern("pow")
|
||||
func powd(x: double, y: double): double;
|
||||
|
||||
@extern("sqrtf")
|
||||
func sqrt(x: float): float;
|
||||
|
||||
@extern("sqrt")
|
||||
func sqrtd(x: double): double;
|
||||
|
||||
@extern("erff")
|
||||
func erf(x: float): float;
|
||||
|
||||
@extern("erf")
|
||||
func erfd(x: double): double;
|
||||
|
||||
@extern("erfcf")
|
||||
func erfc(x: float): float;
|
||||
|
||||
@extern("erfc")
|
||||
func erfcd(x: double): double;
|
||||
|
||||
@extern("lgammaf")
|
||||
func lgamma(x: float): float;
|
||||
|
||||
@extern("lgamma")
|
||||
func lgammad(x: double): double;
|
||||
|
||||
@extern("tgammaf")
|
||||
func tgamma(x: float): float;
|
||||
|
||||
@extern("tgamma")
|
||||
func tgammad(x: double): double;
|
||||
|
||||
@extern("ceilf")
|
||||
func ceil(x: float): float;
|
||||
|
||||
@extern("ceil")
|
||||
func ceild(x: double): double;
|
||||
|
||||
@extern("floorf")
|
||||
func floor(x: float): float;
|
||||
|
||||
@extern("floor")
|
||||
func floord(x: double): double;
|
||||
|
||||
@extern("nearbyintf")
|
||||
func nearbyint(x: float): float;
|
||||
|
||||
@extern("nearbyint")
|
||||
func nearbyintd(x: double): double;
|
||||
|
||||
@extern("rintf")
|
||||
func rint(x: float): float;
|
||||
|
||||
@extern("rint")
|
||||
func rintd(x: double): double;
|
||||
|
||||
@extern("lrintf")
|
||||
func lrint(x: float): long;
|
||||
|
||||
@extern("lrint")
|
||||
func lrintd(x: double): long;
|
||||
|
||||
@extern("llrintf")
|
||||
func llrint(x: float): llong;
|
||||
|
||||
@extern("llrint")
|
||||
func llrintd(x: double): llong;
|
||||
|
||||
@extern("roundf")
|
||||
func round(x: float): float;
|
||||
|
||||
@extern("round")
|
||||
func roundd(x: double): double;
|
||||
|
||||
@extern("lroundf")
|
||||
func lroun(x: float): long;
|
||||
|
||||
@extern("lround")
|
||||
func lroundd(x: double): long;
|
||||
|
||||
@extern("lroundf")
|
||||
func llround(x: float): llong;
|
||||
|
||||
@extern("lround")
|
||||
func llroundd(x: double): llong;
|
||||
|
||||
@extern("truncf")
|
||||
func trunc(x: float): float;
|
||||
|
||||
@extern("trunc")
|
||||
func truncd(x: double): double;
|
||||
|
||||
@extern("fmodf")
|
||||
func fmod(x: float, y: float): float;
|
||||
|
||||
@extern("fmod")
|
||||
func fmodd(x: double, y: double): double;
|
||||
|
||||
@extern("remainderf")
|
||||
func remainder(x: float, y: float): float;
|
||||
|
||||
@extern("remainder")
|
||||
func remainderd(x: double, y: double): double;
|
||||
|
||||
@extern("remquof")
|
||||
func remquo(x: float, y: float, quo: int*): float;
|
||||
|
||||
@extern("remquo")
|
||||
func remquod(x: double, y: double, quo: int*): double;
|
||||
|
||||
@extern("copysignf")
|
||||
func copysign(x: float, y: float): float;
|
||||
|
||||
@extern("copysign")
|
||||
func copysignd(x: double, y: double): double;
|
||||
|
||||
@extern("nanf")
|
||||
func nan(tagp: char const*): float;
|
||||
|
||||
@extern("nan")
|
||||
func nand(tagp: char const*): double;
|
||||
|
||||
@extern("nextafterf")
|
||||
func nextafter(x: float, y: float): float;
|
||||
|
||||
@extern("nextafter")
|
||||
func nextafterd(x: double, y: double): double;
|
||||
|
||||
@extern("fdimf")
|
||||
func fdim(x: float, y: float): float;
|
||||
|
||||
@extern("fdim")
|
||||
func fdimd(x: double, y: double): double;
|
||||
|
||||
@extern("fmaxf")
|
||||
func fmax(x: float, y: float): float;
|
||||
|
||||
@extern("fmax")
|
||||
func fmaxd(x: double, y: double): double;
|
||||
|
||||
@extern("fminf")
|
||||
func fmin(x: float, y: float): float;
|
||||
|
||||
@extern("fmin")
|
||||
func fmind(x: double, y: double): double;
|
||||
|
||||
@extern("fmaf")
|
||||
func fma(x: float, y: float, z: float): float;
|
||||
|
||||
@extern("fma")
|
||||
func fmad(x: double, y: double, z: double): double;
|
||||
|
||||
func clampf(v: float, min:float, max:float): float {
|
||||
return fmin(max, fmax(v, min));
|
||||
}
|
||||
|
||||
func clampd(v: double, min:double, max:double): double {
|
||||
return fmind(max, fmaxd(v, min));
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
@extern("va_start_ptr")
|
||||
func va_start(args: va_list*, arg: void const*);
|
||||
|
||||
@extern("va_arg_ptr")
|
||||
func va_arg(args: va_list*, arg: Any);
|
||||
|
||||
@extern("va_end_ptr")
|
||||
func va_end(args: va_list*);
|
||||
|
||||
@extern("va_copy_ptr")
|
||||
func va_copy(dest: va_list*, src: va_list const*);
|
|
@ -0,0 +1,162 @@
|
|||
#extern(header = "<stdio.h>")
|
||||
|
||||
@extern
|
||||
struct FILE;
|
||||
|
||||
@extern
|
||||
global stdin: FILE*;
|
||||
|
||||
@extern
|
||||
global stdout: FILE*;
|
||||
|
||||
@extern
|
||||
global stderr: FILE*;
|
||||
|
||||
@extern
|
||||
typedef va_list = char*;
|
||||
|
||||
@extern
|
||||
struct fpos_t;
|
||||
|
||||
@extern const EOF = -1;
|
||||
@extern const SEEK_SET = 0;
|
||||
@extern const SEEK_CUR = 1;
|
||||
@extern const SEEK_END = 2;
|
||||
|
||||
@extern
|
||||
func remove(filename: char const*): int;
|
||||
|
||||
@extern
|
||||
func rename(old: char const*, new: char const*): int;
|
||||
|
||||
@extern
|
||||
func tmpfile(): FILE*;
|
||||
|
||||
@extern
|
||||
func tmpnam(s: char*): char*;
|
||||
|
||||
@extern
|
||||
func fclose(stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func fflush(stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func fopen(filename: char const*, mode: char const*): FILE*;
|
||||
|
||||
@extern
|
||||
func freopen(filename: char const*, mode: char const*, stream: FILE*): FILE*;
|
||||
|
||||
@extern
|
||||
func setbuf(stream: FILE*, buf: char*);
|
||||
|
||||
@extern
|
||||
func setvbuf(stream: FILE*, buf: char*, mode: int, size: usize): int;
|
||||
|
||||
@extern
|
||||
func fprintf(stream: FILE*, format: char const*, ...): int;
|
||||
|
||||
@extern
|
||||
func fscanf(stream: FILE*, format: char const*, ...): int;
|
||||
|
||||
@extern
|
||||
func printf(format: char const*, ...): int;
|
||||
|
||||
@extern
|
||||
func scanf(format: char const*, ...): int;
|
||||
|
||||
@extern
|
||||
func snprintf(s: char*, n: usize, format: char const*, ...): int;
|
||||
|
||||
@extern
|
||||
func sprintf(s: char*, format: char const*, ...): int;
|
||||
|
||||
@extern
|
||||
func sscanf(s: char const*, format: char const*, ...): int;
|
||||
|
||||
@extern
|
||||
func vfprintf(stream: FILE*, format: char const*, arg: va_list): int;
|
||||
|
||||
@extern
|
||||
func vfscanf(stream: FILE*, format: char const*, arg: va_list): int;
|
||||
|
||||
@extern
|
||||
func vprintf(format: char const*, arg: va_list): int;
|
||||
|
||||
@extern
|
||||
func vscanf(format: char const*, arg: va_list): int;
|
||||
|
||||
@extern
|
||||
func vsnprintf(s: char*, n: usize, format: char const*, arg: va_list): int;
|
||||
|
||||
@extern
|
||||
func vsprintf(s: char*, format: char const*, arg: va_list): int;
|
||||
|
||||
@extern
|
||||
func vsscanf(s: char const*, format: char const*, arg: va_list): int;
|
||||
|
||||
@extern
|
||||
func fgetc(stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func fgets(s: char*, n: int, stream: FILE*): char*;
|
||||
|
||||
@extern
|
||||
func fputc(c: int, stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func fputs(s: char const*, stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func getc(stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func getchar(): int;
|
||||
|
||||
@extern
|
||||
func gets(s: char*): char*;
|
||||
|
||||
@extern
|
||||
func putc(c: int, stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func putchar(c: int): int;
|
||||
|
||||
@extern
|
||||
func puts(s: char const*): int;
|
||||
|
||||
@extern
|
||||
func ungetc(c: int, stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func fread(ptr: void*, size: usize, nmemb: usize, stream: FILE*): usize;
|
||||
|
||||
@extern
|
||||
func fwrite(ptr: void const*, size: usize, nmemb: usize, stream: FILE*): usize;
|
||||
|
||||
@extern
|
||||
func fgetpos(stream: FILE*, pos: fpos_t*): int;
|
||||
|
||||
@extern
|
||||
func fseek(stream: FILE*, offset: long, whence: int): int;
|
||||
|
||||
@extern
|
||||
func fsetpos(stream: FILE*, pos: fpos_t*): int;
|
||||
|
||||
@extern
|
||||
func ftell(stream: FILE*): long;
|
||||
|
||||
@extern
|
||||
func rewind(stream: FILE*);
|
||||
|
||||
@extern
|
||||
func clearerr(stream: FILE*);
|
||||
|
||||
@extern
|
||||
func feof(stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func ferror(stream: FILE*): int;
|
||||
|
||||
@extern
|
||||
func perror(s: char const*);
|
|
@ -0,0 +1,127 @@
|
|||
#extern(header = "<stdlib.h>")
|
||||
|
||||
@extern
|
||||
struct div_t {
|
||||
quot: int;
|
||||
rem: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
struct ldiv_t {
|
||||
quot: long;
|
||||
rem: long;
|
||||
}
|
||||
|
||||
@extern
|
||||
struct lldiv_t {
|
||||
quot: llong;
|
||||
rem: llong;
|
||||
}
|
||||
|
||||
@extern global RAND_MAX: int;
|
||||
|
||||
@extern
|
||||
func atof(nptr: char const*): double;
|
||||
|
||||
@extern
|
||||
func atoi(nptr: char const*): int;
|
||||
|
||||
@extern
|
||||
func atol(nptr: char const*): long;
|
||||
|
||||
@extern
|
||||
func atoll(nptr: char const*): llong;
|
||||
|
||||
@extern
|
||||
func strtod(nptr: char const*, endptr: char**): double;
|
||||
|
||||
@extern
|
||||
func strtof(nptr: char const*, endptr: char**): float;
|
||||
|
||||
@extern
|
||||
func strtol(nptr: char const*, endptr: char**, base: int): long;
|
||||
|
||||
@extern
|
||||
func strtoll(nptr: char const*, endptr: char**, base: int): llong;
|
||||
|
||||
@extern
|
||||
func strtoul(nptr: char const*, endptr: char**, base: int): ulong;
|
||||
|
||||
@extern
|
||||
func strtoull(nptr: char const*, endptr: char**, base: int): ullong;
|
||||
|
||||
@extern
|
||||
func rand(): int;
|
||||
|
||||
@extern
|
||||
func srand(seed: void*);
|
||||
|
||||
@extern
|
||||
func calloc(nmemb: usize, size: usize): void*;
|
||||
|
||||
@extern
|
||||
func free(ptr: void*);
|
||||
|
||||
@extern
|
||||
func malloc(size: usize): void*;
|
||||
|
||||
@extern
|
||||
func realloc(ptr: void*, size: usize): void*;
|
||||
|
||||
@extern
|
||||
func abort();
|
||||
|
||||
@extern
|
||||
func atexit(fn: func()): int;
|
||||
|
||||
@extern
|
||||
func exit(status: int);
|
||||
|
||||
@extern
|
||||
func _Exit(status: int);
|
||||
|
||||
@extern
|
||||
func getenv(name: char const*): char*;
|
||||
|
||||
@extern
|
||||
func system(string: char const*): int;
|
||||
|
||||
@extern
|
||||
func bsearch(key: void const*, base: void const*, nmemb: usize, size: usize, compar: func(void const*, void const*): int): void*;
|
||||
|
||||
@extern
|
||||
func qsort(base: void*, nmemb: usize, size: usize, compar: func(void const*, void const*): int);
|
||||
|
||||
@extern
|
||||
func abs(j: int): int;
|
||||
|
||||
@extern
|
||||
func labs(j: long): long;
|
||||
|
||||
@extern
|
||||
func llabs(j: llong): llong;
|
||||
|
||||
@extern
|
||||
func div(numer: int, denom: int): div_t;
|
||||
|
||||
@extern
|
||||
func ldiv(numer: long, denom: long): ldiv_t;
|
||||
|
||||
@extern
|
||||
func lldiv(numer: llong, denom: llong): lldiv_t;
|
||||
|
||||
@extern
|
||||
func mblen(s: char const*, n: usize): int;
|
||||
|
||||
@extern
|
||||
func mbtowc(pwc: short*, s: char const*, n: usize): int;
|
||||
|
||||
@extern
|
||||
func wctomb(s: char*, wchar: short): int;
|
||||
|
||||
@extern
|
||||
func mbstowcs(pwcs: short*, s: char const*, n: usize): usize;
|
||||
|
||||
@extern
|
||||
func wcstombs(s: char*, pwcs: short const*, n: usize): usize;
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
#extern(header = "<string.h>")
|
||||
|
||||
@extern
|
||||
func memcpy(s1: void*, s2: void const*, n: usize): void*;
|
||||
|
||||
@extern
|
||||
func memmove(s1: void*, s2: void const*, n: usize): void*;
|
||||
|
||||
@extern
|
||||
func strcpy(s1: char*, s2: char const*): char*;
|
||||
|
||||
@extern
|
||||
func strncpy(s1: char*, s2: char const*, n: usize): char*;
|
||||
|
||||
@extern
|
||||
func strcat(s1: char*, s2: char const*): char*;
|
||||
|
||||
@extern
|
||||
func strncat(s1: char*, s2: char const*, n: usize): char*;
|
||||
|
||||
@extern
|
||||
func memcmp(s1: void const*, s2: void const*, n: usize): int;
|
||||
|
||||
@extern
|
||||
func strcmp(s1: char const*, s2: char const*): int;
|
||||
|
||||
@extern
|
||||
func strcoll(s1: char const*, s2: char const*): int;
|
||||
|
||||
@extern
|
||||
func strncmp(s1: char const*, s2: char const*, n: usize): int;
|
||||
|
||||
@extern
|
||||
func strxfrm(s1: char*, s2: char const*, n: usize): usize;
|
||||
|
||||
@extern
|
||||
func memchr(s: void const*, c: int, n: usize): void*;
|
||||
|
||||
@extern
|
||||
func strchr(s: char const*, c: int): char*;
|
||||
|
||||
@extern
|
||||
func strcspn(s1: char const*, s2: char const*): usize;
|
||||
|
||||
@extern
|
||||
func strpbrk(s1: char const*, s2: char const*): char*;
|
||||
|
||||
@extern
|
||||
func strrchr(s: char const*, c: int): char*;
|
||||
|
||||
@extern
|
||||
func strspn(s1: char const*, s2: char const*): usize;
|
||||
|
||||
@extern
|
||||
func strstr(s1: char const*, s2: char const*): char*;
|
||||
|
||||
@extern
|
||||
func strtok(s1: char*, s2: char const*): char*;
|
||||
|
||||
@extern
|
||||
func memset(s: void*, c: int, n: usize): void*;
|
||||
|
||||
@extern
|
||||
func strerror(errnum: int): char*;
|
||||
|
||||
@extern
|
||||
func strlen(s: char const*): usize;
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
#extern(header = "<time.h>")
|
||||
|
||||
@extern
|
||||
struct tm_t {
|
||||
tm_sec: int;
|
||||
tm_min: int;
|
||||
tm_hour: int;
|
||||
tm_mday: int;
|
||||
tm_mon: int;
|
||||
tm_year: int;
|
||||
tm_wday: int;
|
||||
tm_yday: int;
|
||||
tm_isdst: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
struct time_t {
|
||||
bogus:void*;
|
||||
}
|
||||
|
||||
|
||||
@extern
|
||||
struct clock_t {
|
||||
bogus:void*;
|
||||
}
|
||||
|
||||
@extern
|
||||
func clock(): clock_t;
|
||||
|
||||
@extern
|
||||
func difftime(time1: time_t, time0: time_t): double;
|
||||
|
||||
@extern
|
||||
func mktime(timeptr: tm_t*): time_t;
|
||||
|
||||
@extern
|
||||
func time(timer: time_t*): time_t*;
|
||||
|
||||
@extern
|
||||
func asctime(timeptr: tm_t const*): char*;
|
||||
|
||||
@extern
|
||||
func ctime(timer: time_t const*): char*;
|
||||
|
||||
@extern
|
||||
func gmtime(timer: time_t const*): tm_t*;
|
||||
|
||||
@extern
|
||||
func localtime(timer: time_t const*): tm_t*;
|
||||
|
||||
@extern
|
||||
func strftime(s: char*, maxsize: usize, format: char const*, timeptr: tm_t const*): usize;
|
|
@ -0,0 +1,157 @@
|
|||
#extern(header = "<limits.h>")
|
||||
#extern(header = "<stdint.h>")
|
||||
|
||||
|
||||
#static_assert(sizeof(bool) == 1)
|
||||
#static_assert(sizeof(char) == 1)
|
||||
#static_assert(sizeof(uchar) == 1)
|
||||
#static_assert(sizeof(schar) == 1)
|
||||
#static_assert(sizeof(short) == 2)
|
||||
#static_assert(sizeof(ushort) == 2)
|
||||
#static_assert(sizeof(int) == 4)
|
||||
#static_assert(sizeof(uint) == 4)
|
||||
#static_assert(sizeof(ullong) == 8)
|
||||
#static_assert(sizeof(llong) == 8)
|
||||
#static_assert(sizeof(float) == 4)
|
||||
#static_assert(sizeof(double) == 8)
|
||||
|
||||
|
||||
@extern("int8_t")
|
||||
typedef int8 = schar;
|
||||
|
||||
@extern("uint8_t")
|
||||
typedef uint8 = uchar;
|
||||
|
||||
@extern("int16_t")
|
||||
typedef int16 = short;
|
||||
|
||||
@extern("uint16_t")
|
||||
typedef uint16 = ushort;
|
||||
|
||||
@extern("int32_t")
|
||||
typedef int32 = int;
|
||||
|
||||
@extern("uint32_t")
|
||||
typedef uint32 = uint;
|
||||
|
||||
@extern("int64_t")
|
||||
typedef int64 = llong;
|
||||
|
||||
@extern("uint64_t")
|
||||
typedef uint64 = ullong;
|
||||
|
||||
typedef i8 = schar;
|
||||
|
||||
typedef ui8 = uchar;
|
||||
|
||||
typedef i16 = short;
|
||||
|
||||
typedef ui16 = ushort;
|
||||
|
||||
typedef i32 = int;
|
||||
|
||||
typedef ui32 = uint;
|
||||
|
||||
typedef i64 = llong;
|
||||
|
||||
typedef ui64 = ullong;
|
||||
|
||||
@extern
|
||||
const false = bool(0);
|
||||
|
||||
@extern
|
||||
const true = bool(1);
|
||||
|
||||
const UCHAR_MIN = uchar(0);
|
||||
|
||||
@extern
|
||||
const UCHAR_MAX = uchar(0xff);
|
||||
|
||||
@extern
|
||||
const SCHAR_MIN = schar(-128);
|
||||
|
||||
@extern
|
||||
const SCHAR_MAX = schar(127);
|
||||
|
||||
@extern
|
||||
const CHAR_MIN = char(SCHAR_MIN);
|
||||
|
||||
@extern
|
||||
const CHAR_MAX = char(SCHAR_MAX);
|
||||
|
||||
@extern("SHRT_MIN")
|
||||
const SHORT_MIN = short(-32768);
|
||||
|
||||
@extern("SHRT_MAX")
|
||||
const SHORT_MAX = short(32767);
|
||||
|
||||
const USHORT_MIN = short(0);
|
||||
|
||||
@extern("USHRT_MAX")
|
||||
const USHORT_MAX = ushort(0xffff);
|
||||
|
||||
@extern
|
||||
const INT_MIN = int(-2147483647 - 1);
|
||||
|
||||
@extern
|
||||
const INT_MAX = int(2147483647);
|
||||
|
||||
const UINT_MIN = uint(0);
|
||||
|
||||
@extern
|
||||
const UINT_MAX = uint(0xffffffff);
|
||||
|
||||
@extern
|
||||
const LLONG_MIN = llong(-9223372036854775807ll - 1);
|
||||
|
||||
@extern
|
||||
const LLONG_MAX = llong(9223372036854775807ll);
|
||||
|
||||
const ULLONG_MIN = ullong(0);
|
||||
|
||||
@extern
|
||||
const ULLONG_MAX = ullong(0xffffffffffffffffull);
|
||||
|
||||
const UINT8_MIN = UCHAR_MIN;
|
||||
|
||||
@extern
|
||||
const UINT8_MAX = UCHAR_MAX;
|
||||
|
||||
@extern
|
||||
const INT8_MIN = SCHAR_MIN;
|
||||
|
||||
@extern
|
||||
const INT8_MAX = SCHAR_MAX;
|
||||
|
||||
const UINT16_MIN = USHORT_MIN;
|
||||
|
||||
@extern
|
||||
const UINT16_MAX = USHORT_MAX;
|
||||
|
||||
@extern
|
||||
const INT16_MIN = SHORT_MIN;
|
||||
|
||||
@extern
|
||||
const INT16_MAX = SHORT_MAX;
|
||||
|
||||
const UINT32_MIN = UINT_MIN;
|
||||
|
||||
@extern
|
||||
const UINT32_MAX = UINT_MAX;
|
||||
|
||||
@extern
|
||||
const INT32_MIN = INT_MIN;
|
||||
|
||||
@extern
|
||||
const INT32_MAX = INT_MAX;
|
||||
|
||||
const UINT64_MIN = ULLONG_MIN;
|
||||
|
||||
@extern
|
||||
const UINT64_MAX = ULLONG_MAX;
|
||||
|
||||
@extern
|
||||
const INT64_MIN = LLONG_MIN;
|
||||
|
||||
@extern
|
||||
const INT64_MAX = LLONG_MAX;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,141 @@
|
|||
@extern
|
||||
const AUDIO_F32LSB = 0x8120;
|
||||
|
||||
@extern
|
||||
const AUDIO_F32 = AUDIO_F32LSB;
|
||||
|
||||
@extern
|
||||
typedef SDL_AudioFormat = uint16;
|
||||
|
||||
@extern
|
||||
typedef SDL_AudioCallback = func(userdata: void*, stream: uint8*, len: int);
|
||||
|
||||
@extern
|
||||
struct SDL_AudioSpec {
|
||||
freq: int;
|
||||
format: SDL_AudioFormat;
|
||||
channels: uint8;
|
||||
silence: uint8;
|
||||
samples: uint16;
|
||||
padding: uint16;
|
||||
size: uint32;
|
||||
callback: SDL_AudioCallback;
|
||||
userdata: void*;
|
||||
}
|
||||
|
||||
@extern
|
||||
typedef SDL_AudioDeviceID = uint32;
|
||||
|
||||
@extern
|
||||
struct SDL_AudioCVT {
|
||||
needed: int;
|
||||
src_format: SDL_AudioFormat;
|
||||
dst_format: SDL_AudioFormat;
|
||||
rate_incr: double;
|
||||
buf: uint8*;
|
||||
len: int;
|
||||
len_cvt: int;
|
||||
len_mult: int;
|
||||
len_ratio: double;
|
||||
filters: SDL_AudioFilter[10];
|
||||
filter_index: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_AudioStatus {
|
||||
SDL_AUDIO_STOPPED = 0,
|
||||
SDL_AUDIO_PLAYING,
|
||||
SDL_AUDIO_PAUSED
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_AudioInit(driver_name: char const*): int;
|
||||
|
||||
@extern
|
||||
func SDL_AudioQuit();
|
||||
|
||||
@extern
|
||||
func SDL_BuildAudioCVT(cvt: SDL_AudioCVT*, src_format: SDL_AudioFormat, src_channels: uint8,
|
||||
src_rate: int, dst_format: SDL_AudioFormat, dst_channels: uint8, dst_rate: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_ClearQueuedAudio(dev: SDL_AudioDeviceID);
|
||||
|
||||
@extern
|
||||
func SDL_CloseAudio();
|
||||
|
||||
@extern
|
||||
func SDL_CloseAudioDevice(dev: SDL_AudioDeviceID);
|
||||
|
||||
@extern
|
||||
func SDL_ConvertAudio(cvt: SDL_AudioCVT*): int;
|
||||
|
||||
@extern
|
||||
func SDL_DequeueAudio(dev: SDL_AudioDeviceID, data: void*, len: uint32): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_FreeWAV(audio_buf: uint8*);
|
||||
|
||||
@extern
|
||||
func SDL_GetAudioDeviceName(index: int, iscapture: int): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetAudioDeviceStatus(dev: SDL_AudioDeviceID): SDL_AudioStatus;
|
||||
|
||||
@extern
|
||||
func SDL_GetAudioDriver(index: int): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetAudioStatus(): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetCurrentAudioDriver();
|
||||
|
||||
@extern
|
||||
func SDL_GetNumAudioDevices(iscapture: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetNumAudioDrivers(): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetQueuedAudioSize(dev: SDL_AudioDeviceID): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_LoadWAV(file: char const*, spec: SDL_AudioSpec*, audio_buf: uint8**, audio_len: uint32*): SDL_AudioSpec*;
|
||||
|
||||
@extern
|
||||
func SDL_LoadWAV_RW(src: SDL_RWops*, freesrc: int, spec: SDL_AudioSpec*, audio_buf: uint8**, audio_len: uint32*): SDL_AudioSpec*;
|
||||
|
||||
@extern
|
||||
func SDL_LockAudio();
|
||||
|
||||
@extern
|
||||
func SDL_LockAudioDevice(dev: SDL_AudioDeviceID);
|
||||
|
||||
@extern
|
||||
func SDL_MixAudio(dst: uint8*, src: uint8 const*, len: uint32, volume: int);
|
||||
|
||||
@extern
|
||||
func SDL_MixAudioFormat(dst: uint8*, src: uint8 const*, format: SDL_AudioFormat, len: uint32, volume: int);
|
||||
|
||||
@extern
|
||||
func SDL_OpenAudio(desired: SDL_AudioSpec*, obtained: SDL_AudioSpec*): int;
|
||||
|
||||
@extern
|
||||
func SDL_OpenAudioDevice(device: char const*, iscapture: int, desired: SDL_AudioSpec const*,
|
||||
obtained: SDL_AudioSpec*, allowed_changes: int): SDL_AudioDeviceID;
|
||||
|
||||
@extern
|
||||
func SDL_PauseAudio(pause_on: int);
|
||||
|
||||
@extern
|
||||
func SDL_PauseAudioDevice(dev: SDL_AudioDeviceID, pause_on: int);
|
||||
|
||||
@extern
|
||||
func SDL_QueueAudio(dev: SDL_AudioDeviceID, data: void const*, len: uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_UnlockAudio();
|
||||
|
||||
@extern
|
||||
func SDL_UnlockAudioDevice(dev: SDL_AudioDeviceID);
|
|
@ -0,0 +1,8 @@
|
|||
@extern
|
||||
func SDL_SetClipboardText(text: char const*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetClipboardText(): char*;
|
||||
|
||||
@extern
|
||||
func SDL_HasClipboardText(): SDL_bool;
|
|
@ -0,0 +1,86 @@
|
|||
@extern struct SDL_RWops;
|
||||
|
||||
@extern
|
||||
func SDL_GetBasePath(): char*;
|
||||
|
||||
@extern
|
||||
func SDL_GetPrefPath(org: char const*, app: char const*): char*;
|
||||
|
||||
|
||||
@extern
|
||||
func SDL_AllocRW(): SDL_RWops*;
|
||||
|
||||
@extern
|
||||
func SDL_FreeRW(area: SDL_RWops*);
|
||||
|
||||
@extern
|
||||
func SDL_RWFromConstMem(mem: void const*, size: int): SDL_RWops*;
|
||||
|
||||
@extern
|
||||
func SDL_RWFromFP(fp: void*, autoclose: SDL_bool): SDL_RWops*;
|
||||
|
||||
@extern
|
||||
func SDL_RWFromFile(file: char const*, mode: char const*): SDL_RWops*;
|
||||
|
||||
@extern
|
||||
func SDL_RWFromMem(mem: void*, size: int): SDL_RWops*;
|
||||
|
||||
@extern
|
||||
func SDL_RWclose(context: SDL_RWops*): int;
|
||||
|
||||
@extern
|
||||
func SDL_RWread(context: SDL_RWops*, ptr: void*, size: usize, maxnum: usize): usize;
|
||||
|
||||
@extern
|
||||
func SDL_RWseek(context: SDL_RWops*, offset: int64, whence: int): int64;
|
||||
|
||||
@extern
|
||||
func SDL_RWsize(context: SDL_RWops*): int64;
|
||||
|
||||
@extern
|
||||
func SDL_RWtell(context: SDL_RWops*): int64;
|
||||
|
||||
@extern
|
||||
func SDL_RWwrite(context: SDL_RWops*, ptr: void const*, size: usize, num: usize): usize;
|
||||
|
||||
@extern
|
||||
func SDL_ReadBE16(src: SDL_RWops*): uint16;
|
||||
|
||||
@extern
|
||||
func SDL_ReadBE32(src: SDL_RWops*): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_ReadBE64(src: SDL_RWops*): uint64;
|
||||
|
||||
@extern
|
||||
func SDL_ReadLE16(src: SDL_RWops*): uint16;
|
||||
|
||||
@extern
|
||||
func SDL_ReadLE32(src: SDL_RWops*): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_ReadLE64(src: SDL_RWops*): uint64;
|
||||
|
||||
@extern
|
||||
func SDL_ReadU8(src: SDL_RWops*): uint8;
|
||||
|
||||
@extern
|
||||
func SDL_WriteBE16(dst: SDL_RWops*, value: uint16): usize;
|
||||
|
||||
@extern
|
||||
func SDL_WriteBE32(dst: SDL_RWops*, value: uint32): usize;
|
||||
|
||||
@extern
|
||||
func SDL_WriteBE64(dst: SDL_RWops*, value: uint64): usize;
|
||||
|
||||
@extern
|
||||
func SDL_WriteLE16(dst: SDL_RWops*, value: uint16): usize;
|
||||
|
||||
@extern
|
||||
func SDL_WriteLE32(dst: SDL_RWops*, value: uint32): usize;
|
||||
|
||||
@extern
|
||||
func SDL_WriteLE64(dst: SDL_RWops*, value: uint64): usize;
|
||||
|
||||
@extern
|
||||
func SDL_WriteU8(dst: SDL_RWops*, value: uint8): usize;
|
|
@ -0,0 +1,750 @@
|
|||
@extern
|
||||
const SDL_RELEASED = 0;
|
||||
|
||||
@extern
|
||||
const SDL_PRESSED = 1;
|
||||
|
||||
@extern
|
||||
func SDL_PumpEvents();
|
||||
|
||||
@extern
|
||||
func SDL_CaptureMouse(enabled: bool): int;
|
||||
|
||||
@extern
|
||||
func SDL_WarpMouseInWindow(window: SDL_Window*, x: int, y: int);
|
||||
|
||||
@extern
|
||||
func SDL_GetMouseState(x: int*, y: int*): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_WarpMouseGlobal(x: int, y: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetGlobalMouseState(x: int*, y: int*): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_GetScancodeFromName(name: char const*): SDL_Scancode;
|
||||
|
||||
@extern
|
||||
enum SDL_Scancode {
|
||||
SDL_SCANCODE_UNKNOWN = 0,
|
||||
SDL_SCANCODE_A = 4,
|
||||
SDL_SCANCODE_B = 5,
|
||||
SDL_SCANCODE_C = 6,
|
||||
SDL_SCANCODE_D = 7,
|
||||
SDL_SCANCODE_E = 8,
|
||||
SDL_SCANCODE_F = 9,
|
||||
SDL_SCANCODE_G = 10,
|
||||
SDL_SCANCODE_H = 11,
|
||||
SDL_SCANCODE_I = 12,
|
||||
SDL_SCANCODE_J = 13,
|
||||
SDL_SCANCODE_K = 14,
|
||||
SDL_SCANCODE_L = 15,
|
||||
SDL_SCANCODE_M = 16,
|
||||
SDL_SCANCODE_N = 17,
|
||||
SDL_SCANCODE_O = 18,
|
||||
SDL_SCANCODE_P = 19,
|
||||
SDL_SCANCODE_Q = 20,
|
||||
SDL_SCANCODE_R = 21,
|
||||
SDL_SCANCODE_S = 22,
|
||||
SDL_SCANCODE_T = 23,
|
||||
SDL_SCANCODE_U = 24,
|
||||
SDL_SCANCODE_V = 25,
|
||||
SDL_SCANCODE_W = 26,
|
||||
SDL_SCANCODE_X = 27,
|
||||
SDL_SCANCODE_Y = 28,
|
||||
SDL_SCANCODE_Z = 29,
|
||||
SDL_SCANCODE_1 = 30,
|
||||
SDL_SCANCODE_2 = 31,
|
||||
SDL_SCANCODE_3 = 32,
|
||||
SDL_SCANCODE_4 = 33,
|
||||
SDL_SCANCODE_5 = 34,
|
||||
SDL_SCANCODE_6 = 35,
|
||||
SDL_SCANCODE_7 = 36,
|
||||
SDL_SCANCODE_8 = 37,
|
||||
SDL_SCANCODE_9 = 38,
|
||||
SDL_SCANCODE_0 = 39,
|
||||
SDL_SCANCODE_RETURN = 40,
|
||||
SDL_SCANCODE_ESCAPE = 41,
|
||||
SDL_SCANCODE_BACKSPACE = 42,
|
||||
SDL_SCANCODE_TAB = 43,
|
||||
SDL_SCANCODE_SPACE = 44,
|
||||
SDL_SCANCODE_MINUS = 45,
|
||||
SDL_SCANCODE_EQUALS = 46,
|
||||
SDL_SCANCODE_LEFTBRACKET = 47,
|
||||
SDL_SCANCODE_RIGHTBRACKET = 48,
|
||||
SDL_SCANCODE_BACKSLASH = 49,
|
||||
SDL_SCANCODE_NONUSHASH = 50,
|
||||
SDL_SCANCODE_SEMICOLON = 51,
|
||||
SDL_SCANCODE_APOSTROPHE = 52,
|
||||
SDL_SCANCODE_GRAVE = 53,
|
||||
SDL_SCANCODE_COMMA = 54,
|
||||
SDL_SCANCODE_PERIOD = 55,
|
||||
SDL_SCANCODE_SLASH = 56,
|
||||
SDL_SCANCODE_CAPSLOCK = 57,
|
||||
SDL_SCANCODE_F1 = 58,
|
||||
SDL_SCANCODE_F2 = 59,
|
||||
SDL_SCANCODE_F3 = 60,
|
||||
SDL_SCANCODE_F4 = 61,
|
||||
SDL_SCANCODE_F5 = 62,
|
||||
SDL_SCANCODE_F6 = 63,
|
||||
SDL_SCANCODE_F7 = 64,
|
||||
SDL_SCANCODE_F8 = 65,
|
||||
SDL_SCANCODE_F9 = 66,
|
||||
SDL_SCANCODE_F10 = 67,
|
||||
SDL_SCANCODE_F11 = 68,
|
||||
SDL_SCANCODE_F12 = 69,
|
||||
SDL_SCANCODE_PRINTSCREEN = 70,
|
||||
SDL_SCANCODE_SCROLLLOCK = 71,
|
||||
SDL_SCANCODE_PAUSE = 72,
|
||||
SDL_SCANCODE_INSERT = 73,
|
||||
SDL_SCANCODE_HOME = 74,
|
||||
SDL_SCANCODE_PAGEUP = 75,
|
||||
SDL_SCANCODE_DELETE = 76,
|
||||
SDL_SCANCODE_END = 77,
|
||||
SDL_SCANCODE_PAGEDOWN = 78,
|
||||
SDL_SCANCODE_RIGHT = 79,
|
||||
SDL_SCANCODE_LEFT = 80,
|
||||
SDL_SCANCODE_DOWN = 81,
|
||||
SDL_SCANCODE_UP = 82,
|
||||
SDL_SCANCODE_NUMLOCKCLEAR = 83,
|
||||
SDL_SCANCODE_KP_DIVIDE = 84,
|
||||
SDL_SCANCODE_KP_MULTIPLY = 85,
|
||||
SDL_SCANCODE_KP_MINUS = 86,
|
||||
SDL_SCANCODE_KP_PLUS = 87,
|
||||
SDL_SCANCODE_KP_ENTER = 88,
|
||||
SDL_SCANCODE_KP_1 = 89,
|
||||
SDL_SCANCODE_KP_2 = 90,
|
||||
SDL_SCANCODE_KP_3 = 91,
|
||||
SDL_SCANCODE_KP_4 = 92,
|
||||
SDL_SCANCODE_KP_5 = 93,
|
||||
SDL_SCANCODE_KP_6 = 94,
|
||||
SDL_SCANCODE_KP_7 = 95,
|
||||
SDL_SCANCODE_KP_8 = 96,
|
||||
SDL_SCANCODE_KP_9 = 97,
|
||||
SDL_SCANCODE_KP_0 = 98,
|
||||
SDL_SCANCODE_KP_PERIOD = 99,
|
||||
SDL_SCANCODE_NONUSBACKSLASH = 100,
|
||||
SDL_SCANCODE_APPLICATION = 101,
|
||||
SDL_SCANCODE_POWER = 102,
|
||||
SDL_SCANCODE_KP_EQUALS = 103,
|
||||
SDL_SCANCODE_F13 = 104,
|
||||
SDL_SCANCODE_F14 = 105,
|
||||
SDL_SCANCODE_F15 = 106,
|
||||
SDL_SCANCODE_F16 = 107,
|
||||
SDL_SCANCODE_F17 = 108,
|
||||
SDL_SCANCODE_F18 = 109,
|
||||
SDL_SCANCODE_F19 = 110,
|
||||
SDL_SCANCODE_F20 = 111,
|
||||
SDL_SCANCODE_F21 = 112,
|
||||
SDL_SCANCODE_F22 = 113,
|
||||
SDL_SCANCODE_F23 = 114,
|
||||
SDL_SCANCODE_F24 = 115,
|
||||
SDL_SCANCODE_EXECUTE = 116,
|
||||
SDL_SCANCODE_HELP = 117,
|
||||
SDL_SCANCODE_MENU = 118,
|
||||
SDL_SCANCODE_SELECT = 119,
|
||||
SDL_SCANCODE_STOP = 120,
|
||||
SDL_SCANCODE_AGAIN = 121,
|
||||
SDL_SCANCODE_UNDO = 122,
|
||||
SDL_SCANCODE_CUT = 123,
|
||||
SDL_SCANCODE_COPY = 124,
|
||||
SDL_SCANCODE_PASTE = 125,
|
||||
SDL_SCANCODE_FIND = 126,
|
||||
SDL_SCANCODE_MUTE = 127,
|
||||
SDL_SCANCODE_VOLUMEUP = 128,
|
||||
SDL_SCANCODE_VOLUMEDOWN = 129,
|
||||
SDL_SCANCODE_KP_COMMA = 133,
|
||||
SDL_SCANCODE_KP_EQUALSAS400 = 134,
|
||||
SDL_SCANCODE_INTERNATIONAL1 = 135,
|
||||
SDL_SCANCODE_INTERNATIONAL2 = 136,
|
||||
SDL_SCANCODE_INTERNATIONAL3 = 137,
|
||||
SDL_SCANCODE_INTERNATIONAL4 = 138,
|
||||
SDL_SCANCODE_INTERNATIONAL5 = 139,
|
||||
SDL_SCANCODE_INTERNATIONAL6 = 140,
|
||||
SDL_SCANCODE_INTERNATIONAL7 = 141,
|
||||
SDL_SCANCODE_INTERNATIONAL8 = 142,
|
||||
SDL_SCANCODE_INTERNATIONAL9 = 143,
|
||||
SDL_SCANCODE_LANG1 = 144,
|
||||
SDL_SCANCODE_LANG2 = 145,
|
||||
SDL_SCANCODE_LANG3 = 146,
|
||||
SDL_SCANCODE_LANG4 = 147,
|
||||
SDL_SCANCODE_LANG5 = 148,
|
||||
SDL_SCANCODE_LANG6 = 149,
|
||||
SDL_SCANCODE_LANG7 = 150,
|
||||
SDL_SCANCODE_LANG8 = 151,
|
||||
SDL_SCANCODE_LANG9 = 152,
|
||||
SDL_SCANCODE_ALTERASE = 153,
|
||||
SDL_SCANCODE_SYSREQ = 154,
|
||||
SDL_SCANCODE_CANCEL = 155,
|
||||
SDL_SCANCODE_CLEAR = 156,
|
||||
SDL_SCANCODE_PRIOR = 157,
|
||||
SDL_SCANCODE_RETURN2 = 158,
|
||||
SDL_SCANCODE_SEPARATOR = 159,
|
||||
SDL_SCANCODE_OUT = 160,
|
||||
SDL_SCANCODE_OPER = 161,
|
||||
SDL_SCANCODE_CLEARAGAIN = 162,
|
||||
SDL_SCANCODE_CRSEL = 163,
|
||||
SDL_SCANCODE_EXSEL = 164,
|
||||
SDL_SCANCODE_KP_00 = 176,
|
||||
SDL_SCANCODE_KP_000 = 177,
|
||||
SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
|
||||
SDL_SCANCODE_DECIMALSEPARATOR = 179,
|
||||
SDL_SCANCODE_CURRENCYUNIT = 180,
|
||||
SDL_SCANCODE_CURRENCYSUBUNIT = 181,
|
||||
SDL_SCANCODE_KP_LEFTPAREN = 182,
|
||||
SDL_SCANCODE_KP_RIGHTPAREN = 183,
|
||||
SDL_SCANCODE_KP_LEFTBRACE = 184,
|
||||
SDL_SCANCODE_KP_RIGHTBRACE = 185,
|
||||
SDL_SCANCODE_KP_TAB = 186,
|
||||
SDL_SCANCODE_KP_BACKSPACE = 187,
|
||||
SDL_SCANCODE_KP_A = 188,
|
||||
SDL_SCANCODE_KP_B = 189,
|
||||
SDL_SCANCODE_KP_C = 190,
|
||||
SDL_SCANCODE_KP_D = 191,
|
||||
SDL_SCANCODE_KP_E = 192,
|
||||
SDL_SCANCODE_KP_F = 193,
|
||||
SDL_SCANCODE_KP_XOR = 194,
|
||||
SDL_SCANCODE_KP_POWER = 195,
|
||||
SDL_SCANCODE_KP_PERCENT = 196,
|
||||
SDL_SCANCODE_KP_LESS = 197,
|
||||
SDL_SCANCODE_KP_GREATER = 198,
|
||||
SDL_SCANCODE_KP_AMPERSAND = 199,
|
||||
SDL_SCANCODE_KP_DBLAMPERSAND = 200,
|
||||
SDL_SCANCODE_KP_VERTICALBAR = 201,
|
||||
SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
|
||||
SDL_SCANCODE_KP_COLON = 203,
|
||||
SDL_SCANCODE_KP_HASH = 204,
|
||||
SDL_SCANCODE_KP_SPACE = 205,
|
||||
SDL_SCANCODE_KP_AT = 206,
|
||||
SDL_SCANCODE_KP_EXCLAM = 207,
|
||||
SDL_SCANCODE_KP_MEMSTORE = 208,
|
||||
SDL_SCANCODE_KP_MEMRECALL = 209,
|
||||
SDL_SCANCODE_KP_MEMCLEAR = 210,
|
||||
SDL_SCANCODE_KP_MEMADD = 211,
|
||||
SDL_SCANCODE_KP_MEMSUBTRACT = 212,
|
||||
SDL_SCANCODE_KP_MEMMULTIPLY = 213,
|
||||
SDL_SCANCODE_KP_MEMDIVIDE = 214,
|
||||
SDL_SCANCODE_KP_PLUSMINUS = 215,
|
||||
SDL_SCANCODE_KP_CLEAR = 216,
|
||||
SDL_SCANCODE_KP_CLEARENTRY = 217,
|
||||
SDL_SCANCODE_KP_BINARY = 218,
|
||||
SDL_SCANCODE_KP_OCTAL = 219,
|
||||
SDL_SCANCODE_KP_DECIMAL = 220,
|
||||
SDL_SCANCODE_KP_HEXADECIMAL = 221,
|
||||
SDL_SCANCODE_LCTRL = 224,
|
||||
SDL_SCANCODE_LSHIFT = 225,
|
||||
SDL_SCANCODE_LALT = 226,
|
||||
SDL_SCANCODE_LGUI = 227,
|
||||
SDL_SCANCODE_RCTRL = 228,
|
||||
SDL_SCANCODE_RSHIFT = 229,
|
||||
SDL_SCANCODE_RALT = 230,
|
||||
SDL_SCANCODE_RGUI = 231,
|
||||
SDL_SCANCODE_MODE = 257,
|
||||
SDL_SCANCODE_AUDIONEXT = 258,
|
||||
SDL_SCANCODE_AUDIOPREV = 259,
|
||||
SDL_SCANCODE_AUDIOSTOP = 260,
|
||||
SDL_SCANCODE_AUDIOPLAY = 261,
|
||||
SDL_SCANCODE_AUDIOMUTE = 262,
|
||||
SDL_SCANCODE_MEDIASELECT = 263,
|
||||
SDL_SCANCODE_WWW = 264,
|
||||
SDL_SCANCODE_MAIL = 265,
|
||||
SDL_SCANCODE_CALCULATOR = 266,
|
||||
SDL_SCANCODE_COMPUTER = 267,
|
||||
SDL_SCANCODE_AC_SEARCH = 268,
|
||||
SDL_SCANCODE_AC_HOME = 269,
|
||||
SDL_SCANCODE_AC_BACK = 270,
|
||||
SDL_SCANCODE_AC_FORWARD = 271,
|
||||
SDL_SCANCODE_AC_STOP = 272,
|
||||
SDL_SCANCODE_AC_REFRESH = 273,
|
||||
SDL_SCANCODE_AC_BOOKMARKS = 274,
|
||||
SDL_SCANCODE_BRIGHTNESSDOWN = 275,
|
||||
SDL_SCANCODE_BRIGHTNESSUP = 276,
|
||||
SDL_SCANCODE_DISPLAYSWITCH = 277,
|
||||
SDL_SCANCODE_KBDILLUMTOGGLE = 278,
|
||||
SDL_SCANCODE_KBDILLUMDOWN = 279,
|
||||
SDL_SCANCODE_KBDILLUMUP = 280,
|
||||
SDL_SCANCODE_EJECT = 281,
|
||||
SDL_SCANCODE_SLEEP = 282,
|
||||
SDL_SCANCODE_APP1 = 283,
|
||||
SDL_SCANCODE_APP2 = 284,
|
||||
SDL_NUM_SCANCODES = 512,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_EventType {
|
||||
SDL_QUIT = 0x100,
|
||||
SDL_KEYDOWN = 0x300,
|
||||
SDL_KEYUP,
|
||||
SDL_TEXTEDITING,
|
||||
SDL_TEXTINPUT,
|
||||
SDL_MOUSEMOTION = 0x400,
|
||||
SDL_MOUSEBUTTONDOWN,
|
||||
SDL_MOUSEBUTTONUP,
|
||||
SDL_MOUSEWHEEL,
|
||||
}
|
||||
|
||||
@extern
|
||||
const SDL_BUTTON_LEFT = 1;
|
||||
|
||||
@extern
|
||||
const SDL_BUTTON_MIDDLE = 2;
|
||||
|
||||
@extern
|
||||
const SDL_BUTTON_RIGHT = 3;
|
||||
|
||||
@extern
|
||||
typedef SDL_Keycode = int32;
|
||||
|
||||
@extern
|
||||
struct SDL_Keysym {
|
||||
scancode: SDL_Scancode;
|
||||
sym: SDL_Keycode;
|
||||
mod: uint16;
|
||||
unused: uint32;
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_KeyboardEvent {
|
||||
type: uint32;
|
||||
timestamp: uint32;
|
||||
windowID: uint32;
|
||||
state: uint8;
|
||||
repeat: uint8;
|
||||
padding2: uint8;
|
||||
padding3: uint8;
|
||||
keysym: SDL_Keysym;
|
||||
}
|
||||
|
||||
@extern
|
||||
const SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
|
||||
|
||||
@extern
|
||||
struct SDL_TextInputEvent {
|
||||
type: uint32;
|
||||
timestamp: uint32;
|
||||
windowID: uint32;
|
||||
text: char[SDL_TEXTINPUTEVENT_TEXT_SIZE];
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_MouseMotionEvent {
|
||||
type: uint32;
|
||||
timestamp: uint32;
|
||||
windowID: uint32;
|
||||
which: uint32;
|
||||
state: uint32;
|
||||
x: int32;
|
||||
y: int32;
|
||||
xrel: int32;
|
||||
yrel: int32;
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_MouseButtonEvent {
|
||||
type: uint32;
|
||||
timestamp: uint32;
|
||||
windowID: uint32;
|
||||
which: uint32;
|
||||
button: uint8;
|
||||
state: uint8;
|
||||
clicks: uint8;
|
||||
padding1: uint8;
|
||||
x: int32;
|
||||
y: int32;
|
||||
}
|
||||
|
||||
|
||||
@extern
|
||||
struct SDL_MouseWheelEvent {
|
||||
type: uint32;
|
||||
timestamp: uint32;
|
||||
windowID: uint32;
|
||||
x: int32;
|
||||
y: int32;
|
||||
which: uint32;
|
||||
}
|
||||
|
||||
|
||||
@extern
|
||||
struct SDL_WindowEvent {
|
||||
type: uint32;
|
||||
timestamp: uint32;
|
||||
windowID: uint32;
|
||||
event:uint8;
|
||||
data1:int32;
|
||||
data2:int32;
|
||||
}
|
||||
|
||||
|
||||
@fake("This only specifies the subset of fields in the real struct we currently support")
|
||||
@extern
|
||||
union SDL_Event {
|
||||
type: uint32;
|
||||
wheel: SDL_MouseWheelEvent;
|
||||
window: SDL_WindowEvent;
|
||||
key: SDL_KeyboardEvent;
|
||||
text: SDL_TextInputEvent;
|
||||
motion: SDL_MouseMotionEvent;
|
||||
button: SDL_MouseButtonEvent;
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_PollEvent(event: SDL_Event*): int;
|
||||
|
||||
@extern
|
||||
enum SDL_eventaction {
|
||||
SDL_ADDEVENT,
|
||||
SDL_PEEKEVENT,
|
||||
SDL_GETEVENT,
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_PeepEvents(events: SDL_Event*, numevents: int, action: SDL_eventaction, minType: Uint32, maxType: Uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_HasEvent(type: Uint32): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasEvents(minType: Uint32, maxType: Uint32): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_FlushEvent(type: Uint32);
|
||||
|
||||
@extern
|
||||
func SDL_FlushEvents(minType: Uint32, maxType: Uint32);
|
||||
|
||||
@extern
|
||||
func SDL_WaitEvent(event: SDL_Event*): int;
|
||||
|
||||
@extern
|
||||
func SDL_WaitEventTimeout(event: SDL_Event*, timeout: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_PushEvent(event: SDL_Event*): int;
|
||||
|
||||
@extern
|
||||
typedef SDL_EventFilter = func(userdata: void*, event: SDL_Event*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetEventFilter(filter: SDL_EventFilter, userdata: void*);
|
||||
|
||||
@extern
|
||||
func SDL_GetEventFilter(filter: SDL_EventFilter*, userdata: void**): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_AddEventWatch(filter: SDL_EventFilter, userdata: void*);
|
||||
|
||||
@extern
|
||||
func SDL_DelEventWatch(filter: SDL_EventFilter, userdata: void*);
|
||||
|
||||
@extern
|
||||
func SDL_FilterEvents(filter: SDL_EventFilter, userdata: void*);
|
||||
|
||||
@extern
|
||||
func SDL_EventState(type: Uint32, state: int): Uint8;
|
||||
|
||||
@extern
|
||||
func SDL_RegisterEvents(numevents: int): Uint32;
|
||||
|
||||
@extern
|
||||
enum SDLK_KEYS {
|
||||
SDLK_UNKNOWN = 0,
|
||||
SDLK_BACKSPACE = 8,
|
||||
SDLK_TAB = 9,
|
||||
SDLK_RETURN = 13,
|
||||
SDLK_ESCAPE = 27,
|
||||
SDLK_SPACE = 32,
|
||||
SDLK_EXCLAIM = 33,
|
||||
SDLK_QUOTEDBL = 34,
|
||||
SDLK_HASH = 35,
|
||||
SDLK_DOLLAR = 36,
|
||||
SDLK_PERCENT = 37,
|
||||
SDLK_AMPERSAND = 38,
|
||||
SDLK_QUOTE = 39,
|
||||
SDLK_LEFTPAREN = 40,
|
||||
SDLK_RIGHTPAREN = 41,
|
||||
SDLK_ASTERISK = 42,
|
||||
SDLK_PLUS = 43,
|
||||
SDLK_COMMA = 44,
|
||||
SDLK_MINUS = 45,
|
||||
SDLK_PERIOD = 46,
|
||||
SDLK_SLASH = 47,
|
||||
SDLK_0 = 48,
|
||||
SDLK_1 = 49,
|
||||
SDLK_2 = 50,
|
||||
SDLK_3 = 51,
|
||||
SDLK_4 = 52,
|
||||
SDLK_5 = 53,
|
||||
SDLK_6 = 54,
|
||||
SDLK_7 = 55,
|
||||
SDLK_8 = 56,
|
||||
SDLK_9 = 57,
|
||||
SDLK_COLON = 58,
|
||||
SDLK_SEMICOLON = 59,
|
||||
SDLK_LESS = 60,
|
||||
SDLK_EQUALS = 61,
|
||||
SDLK_GREATER = 62,
|
||||
SDLK_QUESTION = 63,
|
||||
SDLK_AT = 64,
|
||||
SDLK_LEFTBRACKET = 91,
|
||||
SDLK_BACKSLASH = 92,
|
||||
SDLK_RIGHTBRACKET = 93,
|
||||
SDLK_CARET = 94,
|
||||
SDLK_UNDERSCORE = 95,
|
||||
SDLK_BACKQUOTE = 96,
|
||||
SDLK_a = 97,
|
||||
SDLK_b = 98,
|
||||
SDLK_c = 99,
|
||||
SDLK_d = 100,
|
||||
SDLK_e = 101,
|
||||
SDLK_f = 102,
|
||||
SDLK_g = 103,
|
||||
SDLK_h = 104,
|
||||
SDLK_i = 105,
|
||||
SDLK_j = 106,
|
||||
SDLK_k = 107,
|
||||
SDLK_l = 108,
|
||||
SDLK_m = 109,
|
||||
SDLK_n = 110,
|
||||
SDLK_o = 111,
|
||||
SDLK_p = 112,
|
||||
SDLK_q = 113,
|
||||
SDLK_r = 114,
|
||||
SDLK_s = 115,
|
||||
SDLK_t = 116,
|
||||
SDLK_u = 117,
|
||||
SDLK_v = 118,
|
||||
SDLK_w = 119,
|
||||
SDLK_x = 120,
|
||||
SDLK_y = 121,
|
||||
SDLK_z = 122,
|
||||
SDLK_DELETE = 127,
|
||||
SDLK_CAPSLOCK = 1073741881,
|
||||
SDLK_F1 = 1073741882,
|
||||
SDLK_F2 = 1073741883,
|
||||
SDLK_F3 = 1073741884,
|
||||
SDLK_F4 = 1073741885,
|
||||
SDLK_F5 = 1073741886,
|
||||
SDLK_F6 = 1073741887,
|
||||
SDLK_F7 = 1073741888,
|
||||
SDLK_F8 = 1073741889,
|
||||
SDLK_F9 = 1073741890,
|
||||
SDLK_F10 = 1073741891,
|
||||
SDLK_F11 = 1073741892,
|
||||
SDLK_F12 = 1073741893,
|
||||
SDLK_PRINTSCREEN = 1073741894,
|
||||
SDLK_SCROLLLOCK = 1073741895,
|
||||
SDLK_PAUSE = 1073741896,
|
||||
SDLK_INSERT = 1073741897,
|
||||
SDLK_HOME = 1073741898,
|
||||
SDLK_PAGEUP = 1073741899,
|
||||
SDLK_END = 1073741901,
|
||||
SDLK_PAGEDOWN = 1073741902,
|
||||
SDLK_RIGHT = 1073741903,
|
||||
SDLK_LEFT = 1073741904,
|
||||
SDLK_DOWN = 1073741905,
|
||||
SDLK_UP = 1073741906,
|
||||
SDLK_NUMLOCKCLEAR = 1073741907,
|
||||
SDLK_KP_DIVIDE = 1073741908,
|
||||
SDLK_KP_MULTIPLY = 1073741909,
|
||||
SDLK_KP_MINUS = 1073741910,
|
||||
SDLK_KP_PLUS = 1073741911,
|
||||
SDLK_KP_ENTER = 1073741912,
|
||||
SDLK_KP_1 = 1073741913,
|
||||
SDLK_KP_2 = 1073741914,
|
||||
SDLK_KP_3 = 1073741915,
|
||||
SDLK_KP_4 = 1073741916,
|
||||
SDLK_KP_5 = 1073741917,
|
||||
SDLK_KP_6 = 1073741918,
|
||||
SDLK_KP_7 = 1073741919,
|
||||
SDLK_KP_8 = 1073741920,
|
||||
SDLK_KP_9 = 1073741921,
|
||||
SDLK_KP_0 = 1073741922,
|
||||
SDLK_KP_PERIOD = 1073741923,
|
||||
SDLK_APPLICATION = 1073741925,
|
||||
SDLK_POWER = 1073741926,
|
||||
SDLK_KP_EQUALS = 1073741927,
|
||||
SDLK_F13 = 1073741928,
|
||||
SDLK_F14 = 1073741929,
|
||||
SDLK_F15 = 1073741930,
|
||||
SDLK_F16 = 1073741931,
|
||||
SDLK_F17 = 1073741932,
|
||||
SDLK_F18 = 1073741933,
|
||||
SDLK_F19 = 1073741934,
|
||||
SDLK_F20 = 1073741935,
|
||||
SDLK_F21 = 1073741936,
|
||||
SDLK_F22 = 1073741937,
|
||||
SDLK_F23 = 1073741938,
|
||||
SDLK_F24 = 1073741939,
|
||||
SDLK_EXECUTE = 1073741940,
|
||||
SDLK_HELP = 1073741941,
|
||||
SDLK_MENU = 1073741942,
|
||||
SDLK_SELECT = 1073741943,
|
||||
SDLK_STOP = 1073741944,
|
||||
SDLK_AGAIN = 1073741945,
|
||||
SDLK_UNDO = 1073741946,
|
||||
SDLK_CUT = 1073741947,
|
||||
SDLK_COPY = 1073741948,
|
||||
SDLK_PASTE = 1073741949,
|
||||
SDLK_FIND = 1073741950,
|
||||
SDLK_MUTE = 1073741951,
|
||||
SDLK_VOLUMEUP = 1073741952,
|
||||
SDLK_VOLUMEDOWN = 1073741953,
|
||||
SDLK_KP_COMMA = 1073741957,
|
||||
SDLK_KP_EQUALSAS400 = 1073741958,
|
||||
SDLK_ALTERASE = 1073741977,
|
||||
SDLK_SYSREQ = 1073741978,
|
||||
SDLK_CANCEL = 1073741979,
|
||||
SDLK_CLEAR = 1073741980,
|
||||
SDLK_PRIOR = 1073741981,
|
||||
SDLK_RETURN2 = 1073741982,
|
||||
SDLK_SEPARATOR = 1073741983,
|
||||
SDLK_OUT = 1073741984,
|
||||
SDLK_OPER = 1073741985,
|
||||
SDLK_CLEARAGAIN = 1073741986,
|
||||
SDLK_CRSEL = 1073741987,
|
||||
SDLK_EXSEL = 1073741988,
|
||||
SDLK_KP_00 = 1073742000,
|
||||
SDLK_KP_000 = 1073742001,
|
||||
SDLK_THOUSANDSSEPARATOR = 1073742002,
|
||||
SDLK_DECIMALSEPARATOR = 1073742003,
|
||||
SDLK_CURRENCYUNIT = 1073742004,
|
||||
SDLK_CURRENCYSUBUNIT = 1073742005,
|
||||
SDLK_KP_LEFTPAREN = 1073742006,
|
||||
SDLK_KP_RIGHTPAREN = 1073742007,
|
||||
SDLK_KP_LEFTBRACE = 1073742008,
|
||||
SDLK_KP_RIGHTBRACE = 1073742009,
|
||||
SDLK_KP_TAB = 1073742010,
|
||||
SDLK_KP_BACKSPACE = 1073742011,
|
||||
SDLK_KP_A = 1073742012,
|
||||
SDLK_KP_B = 1073742013,
|
||||
SDLK_KP_C = 1073742014,
|
||||
SDLK_KP_D = 1073742015,
|
||||
SDLK_KP_E = 1073742016,
|
||||
SDLK_KP_F = 1073742017,
|
||||
SDLK_KP_XOR = 1073742018,
|
||||
SDLK_KP_POWER = 1073742019,
|
||||
SDLK_KP_PERCENT = 1073742020,
|
||||
SDLK_KP_LESS = 1073742021,
|
||||
SDLK_KP_GREATER = 1073742022,
|
||||
SDLK_KP_AMPERSAND = 1073742023,
|
||||
SDLK_KP_DBLAMPERSAND = 1073742024,
|
||||
SDLK_KP_VERTICALBAR = 1073742025,
|
||||
SDLK_KP_DBLVERTICALBAR = 1073742026,
|
||||
SDLK_KP_COLON = 1073742027,
|
||||
SDLK_KP_HASH = 1073742028,
|
||||
SDLK_KP_SPACE = 1073742029,
|
||||
SDLK_KP_AT = 1073742030,
|
||||
SDLK_KP_EXCLAM = 1073742031,
|
||||
SDLK_KP_MEMSTORE = 1073742032,
|
||||
SDLK_KP_MEMRECALL = 1073742033,
|
||||
SDLK_KP_MEMCLEAR = 1073742034,
|
||||
SDLK_KP_MEMADD = 1073742035,
|
||||
SDLK_KP_MEMSUBTRACT = 1073742036,
|
||||
SDLK_KP_MEMMULTIPLY = 1073742037,
|
||||
SDLK_KP_MEMDIVIDE = 1073742038,
|
||||
SDLK_KP_PLUSMINUS = 1073742039,
|
||||
SDLK_KP_CLEAR = 1073742040,
|
||||
SDLK_KP_CLEARENTRY = 1073742041,
|
||||
SDLK_KP_BINARY = 1073742042,
|
||||
SDLK_KP_OCTAL = 1073742043,
|
||||
SDLK_KP_DECIMAL = 1073742044,
|
||||
SDLK_KP_HEXADECIMAL = 1073742045,
|
||||
SDLK_LCTRL = 1073742048,
|
||||
SDLK_LSHIFT = 1073742049,
|
||||
SDLK_LALT = 1073742050,
|
||||
SDLK_LGUI = 1073742051,
|
||||
SDLK_RCTRL = 1073742052,
|
||||
SDLK_RSHIFT = 1073742053,
|
||||
SDLK_RALT = 1073742054,
|
||||
SDLK_RGUI = 1073742055,
|
||||
SDLK_MODE = 1073742081,
|
||||
SDLK_AUDIONEXT = 1073742082,
|
||||
SDLK_AUDIOPREV = 1073742083,
|
||||
SDLK_AUDIOSTOP = 1073742084,
|
||||
SDLK_AUDIOPLAY = 1073742085,
|
||||
SDLK_AUDIOMUTE = 1073742086,
|
||||
SDLK_MEDIASELECT = 1073742087,
|
||||
SDLK_WWW = 1073742088,
|
||||
SDLK_MAIL = 1073742089,
|
||||
SDLK_CALCULATOR = 1073742090,
|
||||
SDLK_COMPUTER = 1073742091,
|
||||
SDLK_AC_SEARCH = 1073742092,
|
||||
SDLK_AC_HOME = 1073742093,
|
||||
SDLK_AC_BACK = 1073742094,
|
||||
SDLK_AC_FORWARD = 1073742095,
|
||||
SDLK_AC_STOP = 1073742096,
|
||||
SDLK_AC_REFRESH = 1073742097,
|
||||
SDLK_AC_BOOKMARKS = 1073742098,
|
||||
SDLK_BRIGHTNESSDOWN = 1073742099,
|
||||
SDLK_BRIGHTNESSUP = 1073742100,
|
||||
SDLK_DISPLAYSWITCH = 1073742101,
|
||||
SDLK_KBDILLUMTOGGLE = 1073742102,
|
||||
SDLK_KBDILLUMDOWN = 1073742103,
|
||||
SDLK_KBDILLUMUP = 1073742104,
|
||||
SDLK_EJECT = 1073742105,
|
||||
SDLK_SLEEP = 1073742106,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_Keymod {
|
||||
KMOD_NONE = 0,
|
||||
KMOD_LSHIFT = 1,
|
||||
KMOD_RSHIFT = 2,
|
||||
KMOD_LCTRL = 64,
|
||||
KMOD_RCTRL = 128,
|
||||
KMOD_LALT = 256,
|
||||
KMOD_RALT = 512,
|
||||
KMOD_LGUI = 1024,
|
||||
KMOD_RGUI = 2048,
|
||||
KMOD_NUM = 4096,
|
||||
KMOD_CAPS = 8192,
|
||||
KMOD_MODE = 16384,
|
||||
KMOD_RESERVED = 32768,
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_GetKeyboardFocus(): SDL_Window*;
|
||||
|
||||
@extern
|
||||
func SDL_GetKeyboardState(numkeys: int*): Uint8*;
|
||||
|
||||
@extern
|
||||
func SDL_GetModState(): SDL_Keymod;
|
||||
|
||||
@extern
|
||||
func SDL_SetModState(modstate: SDL_Keymod);
|
||||
|
||||
@extern
|
||||
func SDL_GetKeyFromScancode(scancode: SDL_Scancode): SDL_Keycode;
|
||||
|
||||
@extern
|
||||
func SDL_GetScancodeFromKey(key: SDL_Keycode): SDL_Scancode;
|
||||
|
||||
@extern
|
||||
func SDL_GetScancodeName(scancode: SDL_Scancode): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetKeyName(key: SDL_Keycode): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetKeyFromName(name: char const*): SDL_Keycode;
|
||||
|
||||
@extern
|
||||
func SDL_StartTextInput();
|
||||
|
||||
@extern
|
||||
func SDL_IsTextInputActive(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_StopTextInput();
|
||||
|
||||
@extern
|
||||
func SDL_SetTextInputRect(rect: SDL_Rect*);
|
||||
|
||||
@extern
|
||||
func SDL_HasScreenKeyboardSupport(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_IsScreenKeyboardShown(window: SDL_Window*): SDL_bool;
|
|
@ -0,0 +1,81 @@
|
|||
import libc { }
|
||||
|
||||
@extern
|
||||
enum SDL_LOG {
|
||||
SDL_LOG_CATEGORY_APPLICATION,
|
||||
SDL_LOG_CATEGORY_ERROR,
|
||||
SDL_LOG_CATEGORY_ASSERT,
|
||||
SDL_LOG_CATEGORY_SYSTEM,
|
||||
SDL_LOG_CATEGORY_AUDIO,
|
||||
SDL_LOG_CATEGORY_VIDEO,
|
||||
SDL_LOG_CATEGORY_RENDER,
|
||||
SDL_LOG_CATEGORY_INPUT,
|
||||
SDL_LOG_CATEGORY_TEST,
|
||||
SDL_LOG_CATEGORY_RESERVED1,
|
||||
SDL_LOG_CATEGORY_RESERVED2,
|
||||
SDL_LOG_CATEGORY_RESERVED3,
|
||||
SDL_LOG_CATEGORY_RESERVED4,
|
||||
SDL_LOG_CATEGORY_RESERVED5,
|
||||
SDL_LOG_CATEGORY_RESERVED6,
|
||||
SDL_LOG_CATEGORY_RESERVED7,
|
||||
SDL_LOG_CATEGORY_RESERVED8,
|
||||
SDL_LOG_CATEGORY_RESERVED9,
|
||||
SDL_LOG_CATEGORY_RESERVED10,
|
||||
SDL_LOG_CATEGORY_CUSTOM,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_LogPriority {
|
||||
SDL_LOG_PRIORITY_VERBOSE = 1,
|
||||
SDL_LOG_PRIORITY_DEBUG,
|
||||
SDL_LOG_PRIORITY_INFO,
|
||||
SDL_LOG_PRIORITY_WARN,
|
||||
SDL_LOG_PRIORITY_ERROR,
|
||||
SDL_LOG_PRIORITY_CRITICAL,
|
||||
SDL_NUM_LOG_PRIORITIES,
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_LogSetAllPriority(priority: SDL_LogPriority);
|
||||
|
||||
@extern
|
||||
func SDL_LogSetPriority(category: int, priority: SDL_LogPriority);
|
||||
|
||||
@extern
|
||||
func SDL_LogGetPriority(category: int): SDL_LogPriority;
|
||||
|
||||
@extern
|
||||
func SDL_LogResetPriorities();
|
||||
|
||||
@extern
|
||||
func SDL_Log(fmt: char const*, ...);
|
||||
|
||||
@extern
|
||||
func SDL_LogVerbose(category: int, fmt: char const*, ...);
|
||||
|
||||
@extern
|
||||
func SDL_LogDebug(category: int, fmt: char const*, ...);
|
||||
|
||||
@extern
|
||||
func SDL_LogInfo(category: int, fmt: char const*, ...);
|
||||
|
||||
@extern
|
||||
func SDL_LogWarn(category: int, fmt: char const*, ...);
|
||||
|
||||
@extern
|
||||
func SDL_LogError(category: int, fmt: char const*, ...);
|
||||
|
||||
@extern
|
||||
func SDL_LogCritical(category: int, fmt: char const*, ...);
|
||||
|
||||
@extern
|
||||
func SDL_LogMessage(category: int, priority: SDL_LogPriority, fmt: char const*, ...);
|
||||
|
||||
@extern
|
||||
typedef SDL_LogOutputfunction = func(userdata: void*, category: int, priority: SDL_LogPriority, message: char const*);
|
||||
|
||||
@extern
|
||||
func SDL_LogGetOutputfunction(callback: SDL_LogOutputfunction*, userdata: void**);
|
||||
|
||||
@extern
|
||||
func SDL_LogSetOutputfunction(callback: SDL_LogOutputfunction, userdata: void*);
|
|
@ -0,0 +1,185 @@
|
|||
@extern const SDL_ALPHA_OPAQUE = 255;
|
||||
@extern const SDL_ALPHA_TRANSPARENT = 0;
|
||||
|
||||
@extern
|
||||
enum SDL_PIXEL {
|
||||
SDL_PIXELTYPE_UNKNOWN,
|
||||
SDL_PIXELTYPE_INDEX1,
|
||||
SDL_PIXELTYPE_INDEX4,
|
||||
SDL_PIXELTYPE_INDEX8,
|
||||
SDL_PIXELTYPE_PACKED8,
|
||||
SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PIXELTYPE_ARRAYU8,
|
||||
SDL_PIXELTYPE_ARRAYU16,
|
||||
SDL_PIXELTYPE_ARRAYU32,
|
||||
SDL_PIXELTYPE_ARRAYF16,
|
||||
SDL_PIXELTYPE_ARRAYF32,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_BITMAP {
|
||||
SDL_BITMAPORDER_NONE,
|
||||
SDL_BITMAPORDER_4321,
|
||||
SDL_BITMAPORDER_1234,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_PACKEDORDER {
|
||||
SDL_PACKEDORDER_NONE,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDORDER_RGBX,
|
||||
SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDORDER_BGRX,
|
||||
SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDORDER_BGRA,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_ARRAYORDER {
|
||||
SDL_ARRAYORDER_NONE,
|
||||
SDL_ARRAYORDER_RGB,
|
||||
SDL_ARRAYORDER_RGBA,
|
||||
SDL_ARRAYORDER_ARGB,
|
||||
SDL_ARRAYORDER_BGR,
|
||||
SDL_ARRAYORDER_BGRA,
|
||||
SDL_ARRAYORDER_ABGR,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_PACKEDLAYOUT {
|
||||
SDL_PACKEDLAYOUT_NONE,
|
||||
SDL_PACKEDLAYOUT_332,
|
||||
SDL_PACKEDLAYOUT_4444,
|
||||
SDL_PACKEDLAYOUT_1555,
|
||||
SDL_PACKEDLAYOUT_5551,
|
||||
SDL_PACKEDLAYOUT_565,
|
||||
SDL_PACKEDLAYOUT_8888,
|
||||
SDL_PACKEDLAYOUT_2101010,
|
||||
SDL_PACKEDLAYOUT_1010102,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_PIXELFORMAT {
|
||||
SDL_PIXELFORMAT_UNKNOWN,
|
||||
SDL_PIXELFORMAT_INDEX1LSB = 286261504,
|
||||
SDL_PIXELFORMAT_INDEX1MSB = 287310080,
|
||||
SDL_PIXELFORMAT_INDEX4LSB = 303039488,
|
||||
SDL_PIXELFORMAT_INDEX4MSB = 304088064,
|
||||
SDL_PIXELFORMAT_INDEX8 = 318769153,
|
||||
SDL_PIXELFORMAT_RGB332 = 336660481,
|
||||
SDL_PIXELFORMAT_RGB444 = 353504258,
|
||||
SDL_PIXELFORMAT_RGB555 = 353570562,
|
||||
SDL_PIXELFORMAT_RGB565 = 353701890,
|
||||
SDL_PIXELFORMAT_ARGB4444 = 355602434,
|
||||
SDL_PIXELFORMAT_ARGB1555 = 355667970,
|
||||
SDL_PIXELFORMAT_RGBA4444 = 356651010,
|
||||
SDL_PIXELFORMAT_RGBA5551 = 356782082,
|
||||
SDL_PIXELFORMAT_BGR555 = 357764866,
|
||||
SDL_PIXELFORMAT_BGR565 = 357896194,
|
||||
SDL_PIXELFORMAT_ABGR4444 = 359796738,
|
||||
SDL_PIXELFORMAT_ABGR1555 = 359862274,
|
||||
SDL_PIXELFORMAT_BGRA4444 = 360845314,
|
||||
SDL_PIXELFORMAT_BGRA5551 = 360976386,
|
||||
SDL_PIXELFORMAT_RGB888 = 370546692,
|
||||
SDL_PIXELFORMAT_RGBX8888 = 371595268,
|
||||
SDL_PIXELFORMAT_ARGB8888 = 372645892,
|
||||
SDL_PIXELFORMAT_ARGB2101010 = 372711428,
|
||||
SDL_PIXELFORMAT_RGBA8888 = 373694468,
|
||||
SDL_PIXELFORMAT_BGR888 = 374740996,
|
||||
SDL_PIXELFORMAT_BGRX8888 = 375789572,
|
||||
SDL_PIXELFORMAT_ABGR8888 = 376840196,
|
||||
SDL_PIXELFORMAT_BGRA8888 = 377888772,
|
||||
SDL_PIXELFORMAT_RGB24 = 386930691,
|
||||
SDL_PIXELFORMAT_BGR24 = 390076419,
|
||||
SDL_PIXELFORMAT_NV21 = 825382478,
|
||||
SDL_PIXELFORMAT_NV12 = 842094158,
|
||||
SDL_PIXELFORMAT_YV12 = 842094169,
|
||||
SDL_PIXELFORMAT_YUY2 = 844715353,
|
||||
SDL_PIXELFORMAT_YVYU = 1431918169,
|
||||
SDL_PIXELFORMAT_IYUV = 1448433993,
|
||||
SDL_PIXELFORMAT_UYVY = 1498831189,
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_Color {
|
||||
r: Uint8;
|
||||
g: Uint8;
|
||||
b: Uint8;
|
||||
a: Uint8;
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_Palette {
|
||||
ncolors: int;
|
||||
colors: SDL_Color*;
|
||||
version: Uint32;
|
||||
refcount: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_PixelFormat {
|
||||
format: Uint32;
|
||||
palette: SDL_Palette*;
|
||||
BitsPerPixel: Uint8;
|
||||
BytesPerPixel: Uint8;
|
||||
padding: Uint8[2];
|
||||
Rmask: Uint32;
|
||||
Gmask: Uint32;
|
||||
Bmask: Uint32;
|
||||
Amask: Uint32;
|
||||
Rloss: Uint8;
|
||||
Gloss: Uint8;
|
||||
Bloss: Uint8;
|
||||
Aloss: Uint8;
|
||||
Rshift: Uint8;
|
||||
Gshift: Uint8;
|
||||
Bshift: Uint8;
|
||||
Ashift: Uint8;
|
||||
refcount: int;
|
||||
next: SDL_PixelFormat*;
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_GetPixelFormatName(format: Uint32): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_PixelFormatEnumToMasks(format: Uint32, bpp: int*, Rmask: Uint32*, Gmask: Uint32*, Bmask: Uint32*, Amask: Uint32*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_MasksToPixelFormatEnum(bpp: int, Rmask: Uint32, Gmask: Uint32, Bmask: Uint32, Amask: Uint32): Uint32;
|
||||
|
||||
@extern
|
||||
func SDL_AllocFormat(pixel_format: Uint32): SDL_PixelFormat*;
|
||||
|
||||
@extern
|
||||
func SDL_FreeFormat(format: SDL_PixelFormat*);
|
||||
|
||||
@extern
|
||||
func SDL_AllocPalette(ncolors: int): SDL_Palette*;
|
||||
|
||||
@extern
|
||||
func SDL_SetPixelFormatPalette(format: SDL_PixelFormat*, palette: SDL_Palette*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetPaletteColors(palette: SDL_Palette*, colors: SDL_Color*, firstcolor: int, ncolors: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_FreePalette(palette: SDL_Palette*);
|
||||
|
||||
@extern
|
||||
func SDL_MapRGB(format: SDL_PixelFormat*, r: Uint8, g: Uint8, b: Uint8): Uint32;
|
||||
|
||||
@extern
|
||||
func SDL_MapRGBA(format: SDL_PixelFormat*, r: Uint8, g: Uint8, b: Uint8, a: Uint8): Uint32;
|
||||
|
||||
@extern
|
||||
func SDL_GetRGB(pixel: Uint32, format: SDL_PixelFormat*, r: Uint8*, g: Uint8*, b: Uint8*);
|
||||
|
||||
@extern
|
||||
func SDL_GetRGBA(pixel: Uint32, format: SDL_PixelFormat*, r: Uint8*, g: Uint8*, b: Uint8*, a: Uint8*);
|
||||
|
||||
@extern
|
||||
func SDL_CalculateGammaRamp(gamma: float, ramp: Uint16*);
|
|
@ -0,0 +1,83 @@
|
|||
@extern
|
||||
func SDL_GetPlatform(): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetCPUCacheLineSize(): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetCPUCount(): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetSystemRAM(): int;
|
||||
|
||||
@extern
|
||||
func SDL_Has3DNow(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasAVX(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasAVX2(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasAltiVec(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasMMX(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasRDTSC(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasSSE(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasSSE2(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasSSE3(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasSSE41(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_HasSSE42(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_Swap16(x: uint16): uint16;
|
||||
|
||||
@extern
|
||||
func SDL_Swap32(x: uint32): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_Swap64(x: uint64): uint64;
|
||||
|
||||
@extern
|
||||
func SDL_SwapBE16(x: uint16): uint16;
|
||||
|
||||
@extern
|
||||
func SDL_SwapBE32(x: uint32): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_SwapBE64(x: uint64): uint64;
|
||||
|
||||
@extern
|
||||
func SDL_SwapFloat(x: float): float;
|
||||
|
||||
@extern
|
||||
func SDL_SwapFloatBE(x: float): float;
|
||||
|
||||
@extern
|
||||
func SDL_SwapFloatLE(x: float): float;
|
||||
|
||||
@extern
|
||||
func SDL_SwapLE16(x: uint16): uint16;
|
||||
|
||||
@extern
|
||||
func SDL_SwapLE32(x: uint32): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_SwapLE64(x: uint64): uint64;
|
||||
|
||||
@extern
|
||||
func SDL_MostSignificantBitIndex32(x: uint32): int;
|
|
@ -0,0 +1,28 @@
|
|||
@extern
|
||||
struct SDL_Point {
|
||||
x: int;
|
||||
y: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_Rect {
|
||||
x: int;
|
||||
y: int;
|
||||
w: int;
|
||||
h: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_HasIntersection(A: SDL_Rect*, B: SDL_Rect*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_IntersectRect(A: SDL_Rect*, B: SDL_Rect*, result: SDL_Rect*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_UnionRect(A: SDL_Rect*, B: SDL_Rect*, result: SDL_Rect*);
|
||||
|
||||
@extern
|
||||
func SDL_EnclosePoints(points: SDL_Point*, count: int, clip: SDL_Rect*, result: SDL_Rect*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_IntersectRectAndLine(rect: SDL_Rect*, X1: int*, Y1: int*, X2: int*, Y2: int*): SDL_bool;
|
|
@ -0,0 +1,220 @@
|
|||
@extern
|
||||
enum SDL_RendererFlags {
|
||||
SDL_RENDERER_SOFTWARE = 1,
|
||||
SDL_RENDERER_ACCELERATED = 2,
|
||||
SDL_RENDERER_PRESENTVSYNC = 4,
|
||||
SDL_RENDERER_TARGETTEXTURE = 8,
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_RendererInfo {
|
||||
name: char const*;
|
||||
flags: Uint32;
|
||||
num_texture_formats: Uint32;
|
||||
texture_formats: Uint32[16];
|
||||
max_texture_width: int;
|
||||
max_texture_height: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_TextureAccess {
|
||||
SDL_TEXTUREACCESS_STATIC,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
SDL_TEXTUREACCESS_TARGET,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_TextureModulate {
|
||||
SDL_TEXTUREMODULATE_NONE = 0,
|
||||
SDL_TEXTUREMODULATE_COLOR = 1,
|
||||
SDL_TEXTUREMODULATE_ALPHA = 2,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_RendererFlip {
|
||||
SDL_FLIP_NONE = 0,
|
||||
SDL_FLIP_HORIZONTAL = 1,
|
||||
SDL_FLIP_VERTICAL = 2,
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_BlendMode {
|
||||
SDL_BLENDMODE_NONE = 0,
|
||||
SDL_BLENDMODE_BLEND = 1,
|
||||
SDL_BLENDMODE_ADD = 2,
|
||||
SDL_BLENDMODE_MOD = 4,
|
||||
}
|
||||
|
||||
@extern
|
||||
struct SDL_Renderer;
|
||||
|
||||
@extern
|
||||
struct SDL_Texture;
|
||||
|
||||
@extern
|
||||
func SDL_GetNumRenderDrivers(): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetRenderDriverInfo(index: int, info: SDL_RendererInfo*): int;
|
||||
|
||||
@extern
|
||||
func SDL_CreateWindowAndRenderer(width: int, height: int, window_flags: Uint32, window: SDL_Window**, renderer: SDL_Renderer**): int;
|
||||
|
||||
@extern
|
||||
func SDL_CreateRenderer(window: SDL_Window*, index: int, flags: Uint32): SDL_Renderer*;
|
||||
|
||||
@extern
|
||||
func SDL_CreateSoftwareRenderer(surface: SDL_Surface*): SDL_Renderer*;
|
||||
|
||||
@extern
|
||||
func SDL_GetRenderer(window: SDL_Window*): SDL_Renderer*;
|
||||
|
||||
@extern
|
||||
func SDL_GetRendererInfo(renderer: SDL_Renderer*, info: SDL_RendererInfo*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetRendererOutputSize(renderer: SDL_Renderer*, w: int*, h: int*): int;
|
||||
|
||||
@extern
|
||||
func SDL_CreateTexture(renderer: SDL_Renderer*, format: Uint32, access: int, w: int, h: int): SDL_Texture*;
|
||||
|
||||
@extern
|
||||
func SDL_CreateTextureFromSurface(renderer: SDL_Renderer*, surface: SDL_Surface*): SDL_Texture*;
|
||||
|
||||
@extern
|
||||
func SDL_QueryTexture(texture: SDL_Texture*, format: Uint32*, access: int*, w: int*, h: int*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetTextureColorMod(texture: SDL_Texture*, r: Uint8, g: Uint8, b: Uint8): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetTextureColorMod(texture: SDL_Texture*, r: Uint8*, g: Uint8*, b: Uint8*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetTextureAlphaMod(texture: SDL_Texture*, alpha: Uint8): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetTextureAlphaMod(texture: SDL_Texture*, alpha: Uint8*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetTextureBlendMode(texture: SDL_Texture*, blendMode: SDL_BlendMode): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetTextureBlendMode(texture: SDL_Texture*, blendMode: SDL_BlendMode*): int;
|
||||
|
||||
@extern
|
||||
func SDL_UpdateTexture(texture: SDL_Texture*, rect: SDL_Rect*, pixels: void const*, pitch: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_UpdateYUVTexture(texture: SDL_Texture*, rect: SDL_Rect*, Yplane: Uint8*, Ypitch: int, Uplane: Uint8*, Upitch: int, Vplane: Uint8*, Vpitch: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_LockTexture(texture: SDL_Texture*, rect: SDL_Rect*, pixels: void**, pitch: int*): int;
|
||||
|
||||
@extern
|
||||
func SDL_UnlockTexture(texture: SDL_Texture*);
|
||||
|
||||
@extern
|
||||
func SDL_RenderTargetSupported(renderer: SDL_Renderer*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_SetRenderTarget(renderer: SDL_Renderer*, texture: SDL_Texture*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetRenderTarget(renderer: SDL_Renderer*): SDL_Texture*;
|
||||
|
||||
@extern
|
||||
func SDL_RenderSetLogicalSize(renderer: SDL_Renderer*, w: int, h: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderGetLogicalSize(renderer: SDL_Renderer*, w: int*, h: int*);
|
||||
|
||||
@extern
|
||||
func SDL_RenderSetIntegerScale(renderer: SDL_Renderer*, enable: SDL_bool): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderGetIntegerScale(renderer: SDL_Renderer*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_RenderSetViewport(renderer: SDL_Renderer*, rect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderGetViewport(renderer: SDL_Renderer*, rect: SDL_Rect*);
|
||||
|
||||
@extern
|
||||
func SDL_RenderSetClipRect(renderer: SDL_Renderer*, rect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderGetClipRect(renderer: SDL_Renderer*, rect: SDL_Rect*);
|
||||
|
||||
@extern
|
||||
func SDL_RenderIsClipEnabled(renderer: SDL_Renderer*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_RenderSetScale(renderer: SDL_Renderer*, scaleX: float, scaleY: float): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderGetScale(renderer: SDL_Renderer*, scaleX: float*, scaleY: float*);
|
||||
|
||||
@extern
|
||||
func SDL_SetRenderDrawColor(renderer: SDL_Renderer*, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetRenderDrawColor(renderer: SDL_Renderer*, r: Uint8*, g: Uint8*, b: Uint8*, a: Uint8*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetRenderDrawBlendMode(renderer: SDL_Renderer*, blendMode: SDL_BlendMode): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetRenderDrawBlendMode(renderer: SDL_Renderer*, blendMode: SDL_BlendMode*): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderClear(renderer: SDL_Renderer*): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderDrawPoint(renderer: SDL_Renderer*, x: int, y: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderDrawPoints(renderer: SDL_Renderer*, points: SDL_Point*, count: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderDrawLine(renderer: SDL_Renderer*, x1: int, y1: int, x2: int, y2: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderDrawLines(renderer: SDL_Renderer*, points: SDL_Point*, count: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderDrawRect(renderer: SDL_Renderer*, rect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderDrawRects(renderer: SDL_Renderer*, rects: SDL_Rect*, count: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderFillRect(renderer: SDL_Renderer*, rect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderFillRects(renderer: SDL_Renderer*, rects: SDL_Rect*, count: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderCopy(renderer: SDL_Renderer*, texture: SDL_Texture*, srcrect: SDL_Rect*, dstrect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderCopyEx(renderer: SDL_Renderer*, texture: SDL_Texture*, srcrect: SDL_Rect*, dstrect: SDL_Rect*, angle: double const, center: SDL_Point*, flip: SDL_RendererFlip): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderReadPixels(renderer: SDL_Renderer*, rect: SDL_Rect*, format: Uint32, pixels: void*, pitch: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_RenderPresent(renderer: SDL_Renderer*);
|
||||
|
||||
@extern
|
||||
func SDL_DestroyTexture(texture: SDL_Texture*);
|
||||
|
||||
@extern
|
||||
func SDL_DestroyRenderer(renderer: SDL_Renderer*);
|
||||
|
||||
@extern
|
||||
func SDL_GL_BindTexture(texture: SDL_Texture*, texw: float*, texh: float*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GL_UnbindTexture(texture: SDL_Texture*): int;
|
|
@ -0,0 +1,76 @@
|
|||
@extern
|
||||
typedef Sint8 = schar;
|
||||
|
||||
@extern
|
||||
typedef Uint8 = uchar;
|
||||
|
||||
@extern
|
||||
typedef Sint16 = short;
|
||||
|
||||
@extern
|
||||
typedef Uint16 = ushort;
|
||||
|
||||
@extern
|
||||
typedef Sint32 = int;
|
||||
|
||||
@extern
|
||||
typedef Uint32 = uint;
|
||||
|
||||
@extern
|
||||
typedef Sint64 = llong;
|
||||
|
||||
@extern
|
||||
typedef Uint64 = ullong;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_TIMER = 0x00000001u;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_AUDIO = 0x00000010u;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_VIDEO = 0x00000020u;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_JOYSTICK = 0x00000200u;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_HAPTIC = 0x00001000u;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_GAMECONTROLLER = 0x00002000u;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_EVENTS = 0x00004000u;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_NOPARACHUTE = 0x00100000u;
|
||||
|
||||
@extern
|
||||
const SDL_INIT_EVERYTHING = SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS |
|
||||
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER;
|
||||
|
||||
@extern
|
||||
func SDL_GetError(): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_strdup(str: char const*): char*;
|
||||
|
||||
@extern
|
||||
func SDL_free(mem: void*);
|
||||
|
||||
@extern
|
||||
func SDL_Init(flags: uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_ClearError();
|
||||
|
||||
@extern
|
||||
func SDL_Quit();
|
||||
|
||||
@extern
|
||||
enum SDL_bool {
|
||||
SDL_FALSE = 0,
|
||||
SDL_TRUE = 1
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
@extern
|
||||
func SDL_Loadfunction(handle: void*, name: char const*): void*;
|
||||
|
||||
@extern
|
||||
func SDL_LoadObject(sofile: char const*): void*;
|
||||
|
||||
@extern
|
||||
func SDL_UnloadObject(handle: void*);
|
|
@ -0,0 +1,104 @@
|
|||
@extern
|
||||
struct SDL_Surface {
|
||||
flags: Uint32;
|
||||
format: SDL_PixelFormat*;
|
||||
w: int;
|
||||
h: int;
|
||||
pitch: int;
|
||||
pixels: void*;
|
||||
userdata: void*;
|
||||
locked: int;
|
||||
lock_data: void*;
|
||||
clip_rect: SDL_Rect;
|
||||
refcount: int;
|
||||
}
|
||||
|
||||
@extern
|
||||
typedef SDL_blit = func(src: SDL_Surface*, srcrect: SDL_Rect*, dst: SDL_Surface*, dstrect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_CreateRGBSurface(flags: Uint32, width: int, height: int, depth: int, Rmask: Uint32, Gmask: Uint32, Bmask: Uint32, Amask: Uint32): SDL_Surface*;
|
||||
|
||||
@extern
|
||||
func SDL_CreateRGBSurfaceFrom(pixels: void*, width: int, height: int, depth: int, pitch: int, Rmask: Uint32, Gmask: Uint32, Bmask: Uint32, Amask: Uint32): SDL_Surface*;
|
||||
|
||||
@extern
|
||||
func SDL_FreeSurface(surface: SDL_Surface*);
|
||||
|
||||
@extern
|
||||
func SDL_SetSurfacePalette(surface: SDL_Surface*, palette: SDL_Palette*): int;
|
||||
|
||||
@extern
|
||||
func SDL_LockSurface(surface: SDL_Surface*): int;
|
||||
|
||||
@extern
|
||||
func SDL_UnlockSurface(surface: SDL_Surface*);
|
||||
|
||||
@extern
|
||||
func SDL_LoadBMP_RW(src: SDL_RWops*, freesrc: int): SDL_Surface*;
|
||||
|
||||
@extern
|
||||
func SDL_SaveBMP_RW(surface: SDL_Surface*, dst: SDL_RWops*, freedst: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetSurfaceRLE(surface: SDL_Surface*, flag: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetColorKey(surface: SDL_Surface*, flag: int, key: Uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetColorKey(surface: SDL_Surface*, key: Uint32*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetSurfaceColorMod(surface: SDL_Surface*, r: Uint8, g: Uint8, b: Uint8): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetSurfaceColorMod(surface: SDL_Surface*, r: Uint8*, g: Uint8*, b: Uint8*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetSurfaceAlphaMod(surface: SDL_Surface*, alpha: Uint8): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetSurfaceAlphaMod(surface: SDL_Surface*, alpha: Uint8*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetSurfaceBlendMode(surface: SDL_Surface*, blendMode: SDL_BlendMode): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetSurfaceBlendMode(surface: SDL_Surface*, blendMode: SDL_BlendMode*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetClipRect(surface: SDL_Surface*, rect: SDL_Rect*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_GetClipRect(surface: SDL_Surface*, rect: SDL_Rect*);
|
||||
|
||||
@extern
|
||||
func SDL_ConvertSurface(src: SDL_Surface*, fmt: SDL_PixelFormat*, flags: Uint32): SDL_Surface*;
|
||||
|
||||
@extern
|
||||
func SDL_ConvertSurfaceFormat(src: SDL_Surface*, pixel_format: Uint32, flags: Uint32): SDL_Surface*;
|
||||
|
||||
@extern
|
||||
func SDL_ConvertPixels(width: int, height: int, src_format: Uint32, src: void const*, src_pitch: int, dst_format: Uint32, dst: void*, dst_pitch: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_FillRect(dst: SDL_Surface*, rect: SDL_Rect*, color: Uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_FillRects(dst: SDL_Surface*, rects: SDL_Rect*, count: int, color: Uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_UpperBlit(src: SDL_Surface*, srcrect: SDL_Rect*, dst: SDL_Surface*, dstrect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_LowerBlit(src: SDL_Surface*, srcrect: SDL_Rect*, dst: SDL_Surface*, dstrect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SoftStretch(src: SDL_Surface*, srcrect: SDL_Rect*, dst: SDL_Surface*, dstrect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_UpperBlitScaled(src: SDL_Surface*, srcrect: SDL_Rect*, dst: SDL_Surface*, dstrect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_LowerBlitScaled(src: SDL_Surface*, srcrect: SDL_Rect*, dst: SDL_Surface*, dstrect: SDL_Rect*): int;
|
|
@ -0,0 +1,141 @@
|
|||
@extern
|
||||
enum SDL_ThreadPriority {
|
||||
SDL_THREAD_PRIORITY_LOW,
|
||||
SDL_THREAD_PRIORITY_NORMAL,
|
||||
SDL_THREAD_PRIORITY_HIGH,
|
||||
}
|
||||
|
||||
@extern struct SDL_Thread;
|
||||
@extern struct SDL_atomic_t;
|
||||
@extern struct SDL_cond;
|
||||
@extern struct SDL_mutex;
|
||||
@extern struct SDL_sem;
|
||||
|
||||
@extern typedef SDL_threadID = ulong;
|
||||
@extern typedef SDL_TLSID = uint;
|
||||
@extern typedef SDL_SpinLock = int;
|
||||
@extern typedef SDL_Threadfunction = func(data: void*): int;
|
||||
|
||||
|
||||
@extern
|
||||
func SDL_CreateThread(fn: SDL_Threadfunction, name: char const*, data: void*): SDL_Thread*;
|
||||
|
||||
@extern
|
||||
func SDL_DetachThread(thread: SDL_Thread*);
|
||||
|
||||
@extern
|
||||
func SDL_GetThreadID(thread: SDL_Thread*): SDL_threadID;
|
||||
|
||||
@extern
|
||||
func SDL_GetThreadName(thread: SDL_Thread*): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_SetThreadPriority(priority: SDL_ThreadPriority): int;
|
||||
|
||||
@extern
|
||||
func SDL_TLSCreate(): SDL_TLSID;
|
||||
|
||||
@extern
|
||||
func SDL_TLSGet(id: SDL_TLSID): void*;
|
||||
|
||||
@extern
|
||||
func SDL_TLSSet(id: SDL_TLSID, value: void const*, destructor: func(void*)): int;
|
||||
|
||||
@extern
|
||||
func SDL_ThreadID(): SDL_threadID;
|
||||
|
||||
@extern
|
||||
func SDL_WaitThread(thread: SDL_Thread*, status: int*);
|
||||
|
||||
@extern
|
||||
func SDL_CondBroadcast(cond: SDL_cond*): int;
|
||||
|
||||
@extern
|
||||
func SDL_CondSignal(cond: SDL_cond*): int;
|
||||
|
||||
@extern
|
||||
func SDL_CondWait(cond: SDL_cond*, mutex: SDL_mutex*): int;
|
||||
|
||||
@extern
|
||||
func SDL_CondWaitTimeout(cond: SDL_cond*, mutex: SDL_mutex*, ms: uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_CreateCond(): SDL_cond*;
|
||||
|
||||
@extern
|
||||
func SDL_CreateMutex(): SDL_mutex*;
|
||||
|
||||
@extern
|
||||
func SDL_CreateSemaphore(initial_value: uint32): SDL_sem*;
|
||||
|
||||
@extern
|
||||
func SDL_DestroyCond(cond: SDL_cond*);
|
||||
|
||||
@extern
|
||||
func SDL_DestroyMutex(mutex: SDL_mutex*);
|
||||
|
||||
@extern
|
||||
func SDL_DestroySemaphore(sem: SDL_sem*);
|
||||
|
||||
@extern
|
||||
func SDL_LockMutex(mutex: SDL_mutex*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SemPost(sem: SDL_sem*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SemTryWait(sem: SDL_sem*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SemValue(sem: SDL_sem*): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_SemWait(sem: SDL_sem*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SemWaitTimeout(sem: SDL_sem*, ms: uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_TryLockMutex(mutex: SDL_mutex*): int;
|
||||
|
||||
@extern
|
||||
func SDL_UnlockMutex(mutex: SDL_mutex*): int;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicLock(lock: SDL_SpinLock*);
|
||||
|
||||
@extern
|
||||
func SDL_AtomicUnlock(lock: SDL_SpinLock*);
|
||||
|
||||
@extern
|
||||
func SDL_AtomicIncRef(a: SDL_atomic_t*);
|
||||
|
||||
@extern
|
||||
func SDL_AtomicDecRef(a: SDL_atomic_t*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicAdd(a: SDL_atomic_t*, v: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicCAS(a: SDL_atomic_t*, oldval: int, newval: int): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicCASPtr(a: void**, oldval: void*, newval: void*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicGet(a: SDL_atomic_t*): int;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicGetPtr(a: void**): void*;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicSet(a: SDL_atomic_t*, v: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicSetPtr(a: void**, v: void*): void*;
|
||||
|
||||
@extern
|
||||
func SDL_AtomicTryLock(lock: SDL_SpinLock*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_CompilerBarrier();
|
|
@ -0,0 +1,23 @@
|
|||
@extern
|
||||
func SDL_GetPerformanceCounter(): uint64;
|
||||
|
||||
@extern
|
||||
func SDL_GetPerformanceFrequency(): uint64;
|
||||
|
||||
@extern
|
||||
typedef SDL_TimerCallback = func(interval: uint32, param: void*): uint32;
|
||||
|
||||
@extern
|
||||
typedef SDL_TimerID = int;
|
||||
|
||||
@extern
|
||||
func SDL_AddTimer(interval: uint32, callback: SDL_TimerCallback, param: void*): SDL_TimerID;
|
||||
|
||||
@extern
|
||||
func SDL_Delay(ms: uint32);
|
||||
|
||||
@extern
|
||||
func SDL_GetTicks(): uint32;
|
||||
|
||||
@extern
|
||||
func SDL_RemoveTimer(id: SDL_TimerID): SDL_bool;
|
|
@ -0,0 +1,15 @@
|
|||
@extern
|
||||
struct SDL_version {
|
||||
major: Uint8;
|
||||
minor: Uint8;
|
||||
patch: Uint8;
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_GetVersion(ver: SDL_version*);
|
||||
|
||||
@extern
|
||||
func SDL_GetRevision(): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetRevisionNumber(): int;
|
|
@ -0,0 +1,388 @@
|
|||
@extern
|
||||
enum SDL_WindowFlags {
|
||||
SDL_WINDOW_FULLSCREEN = 0x00000001,
|
||||
SDL_WINDOW_OPENGL = 0x00000002,
|
||||
SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN | 0x00001000,
|
||||
SDL_WINDOW_SHOWN = 0x00000002,
|
||||
SDL_WINDOW_HIDDEN = 0x00000008,
|
||||
SDL_WINDOW_BORDERLESS = 0x00000010,
|
||||
SDL_WINDOW_RESIZABLE = 0x00000020,
|
||||
SDL_WINDOW_MINIMIZED = 0x00000040,
|
||||
SDL_WINDOW_MAXIMIZED = 0x00000080,
|
||||
SDL_WINDOW_INPUT_GRABBED = 0x00000100,
|
||||
SDL_WINDOW_INPUT_FOCUS = 0x00000200,
|
||||
SDL_WINDOW_MOUSE_FOCUS = 0x00000400,
|
||||
SDL_WINDOW_FOREIGN = 0x00000800,
|
||||
SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000,
|
||||
SDL_WINDOW_MOUSE_CAPTURE = 0x00004000,
|
||||
SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000,
|
||||
SDL_WINDOW_SKIP_TASKBAR = 0x00010000,
|
||||
SDL_WINDOW_UTILITY = 0x00020000,
|
||||
SDL_WINDOW_TOOLTIP = 0x00040000,
|
||||
SDL_WINDOW_POPUP_MENU = 0x00080000
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_WindowEventID {
|
||||
SDL_WINDOWEVENT,
|
||||
SDL_WINDOWEVENT_NONE,
|
||||
SDL_WINDOWEVENT_SHOWN,
|
||||
SDL_WINDOWEVENT_HIDDEN,
|
||||
SDL_WINDOWEVENT_EXPOSED,
|
||||
SDL_WINDOWEVENT_MOVED,
|
||||
SDL_WINDOWEVENT_RESIZED,
|
||||
SDL_WINDOWEVENT_SIZE_CHANGED,
|
||||
SDL_WINDOWEVENT_MINIMIZED,
|
||||
SDL_WINDOWEVENT_MAXIMIZED,
|
||||
SDL_WINDOWEVENT_RESTORED,
|
||||
SDL_WINDOWEVENT_ENTER,
|
||||
SDL_WINDOWEVENT_LEAVE,
|
||||
SDL_WINDOWEVENT_FOCUS_GAINED,
|
||||
SDL_WINDOWEVENT_FOCUS_LOST,
|
||||
SDL_WINDOWEVENT_CLOSE,
|
||||
SDL_WINDOWEVENT_TAKE_FOCUS,
|
||||
SDL_WINDOWEVENT_HIT_TEST
|
||||
}
|
||||
|
||||
|
||||
@extern
|
||||
struct SDL_DisplayMode {
|
||||
format: uint32;
|
||||
w: int;
|
||||
h: int;
|
||||
refresh_rate: int;
|
||||
driverdata: void*;
|
||||
}
|
||||
|
||||
@extern
|
||||
const SDL_WINDOWPOS_UNDEFINED = 0x1FFF0000;
|
||||
|
||||
@extern
|
||||
const SDL_WINDOWPOS_CENTERED = 0x2FFF0000u;
|
||||
|
||||
@extern
|
||||
struct SDL_Window;
|
||||
|
||||
@extern
|
||||
typedef SDL_GLContext = void*;
|
||||
|
||||
@extern
|
||||
enum SDL_GLattr {
|
||||
SDL_GL_RED_SIZE,
|
||||
SDL_GL_GREEN_SIZE,
|
||||
SDL_GL_BLUE_SIZE,
|
||||
SDL_GL_ALPHA_SIZE,
|
||||
SDL_GL_BUFFER_SIZE,
|
||||
SDL_GL_DOUBLEBUFFER,
|
||||
SDL_GL_DEPTH_SIZE,
|
||||
SDL_GL_STENCIL_SIZE,
|
||||
SDL_GL_ACCUM_RED_SIZE,
|
||||
SDL_GL_ACCUM_GREEN_SIZE,
|
||||
SDL_GL_ACCUM_BLUE_SIZE,
|
||||
SDL_GL_ACCUM_ALPHA_SIZE,
|
||||
SDL_GL_STEREO,
|
||||
SDL_GL_MULTISAMPLEBUFFERS,
|
||||
SDL_GL_MULTISAMPLESAMPLES,
|
||||
SDL_GL_ACCELERATED_VISUAL,
|
||||
SDL_GL_RETAINED_BACKING,
|
||||
SDL_GL_CONTEXT_MAJOR_VERSION,
|
||||
SDL_GL_CONTEXT_MINOR_VERSION,
|
||||
SDL_GL_CONTEXT_EGL,
|
||||
SDL_GL_CONTEXT_FLAGS,
|
||||
SDL_GL_CONTEXT_PROFILE_MASK,
|
||||
SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
|
||||
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR,
|
||||
SDL_GL_CONTEXT_RESET_NOTIFICATION,
|
||||
SDL_GL_CONTEXT_NO_ERROR
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_GLprofile {
|
||||
SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,
|
||||
SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,
|
||||
SDL_GL_CONTEXT_PROFILE_ES = 0x0004
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_GLcontextFlag {
|
||||
SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,
|
||||
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
|
||||
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,
|
||||
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_GLcontextReleaseFlag {
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000,
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_GLContextResetNotification {
|
||||
SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0x0000,
|
||||
SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 0x0001
|
||||
}
|
||||
|
||||
@extern
|
||||
enum SDL_HitTestResult {
|
||||
SDL_HITTEST_NORMAL,
|
||||
SDL_HITTEST_DRAGGABLE,
|
||||
SDL_HITTEST_RESIZE_TOPLEFT,
|
||||
SDL_HITTEST_RESIZE_TOP,
|
||||
SDL_HITTEST_RESIZE_TOPRIGHT,
|
||||
SDL_HITTEST_RESIZE_RIGHT,
|
||||
SDL_HITTEST_RESIZE_BOTTOMRIGHT,
|
||||
SDL_HITTEST_RESIZE_BOTTOM,
|
||||
SDL_HITTEST_RESIZE_BOTTOMLEFT,
|
||||
SDL_HITTEST_RESIZE_LEFT
|
||||
}
|
||||
|
||||
@extern
|
||||
func SDL_GetNumVideoDrivers(): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetVideoDriver(index: int): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_VideoInit(driver_name: char const*): int;
|
||||
|
||||
@extern
|
||||
func SDL_VideoQuit();
|
||||
|
||||
@extern
|
||||
func SDL_GetCurrentVideoDriver(): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetNumVideoDisplays(): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetDisplayName(displayIndex: int): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_GetDisplayBounds(displayIndex: int, rect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetDisplayDPI(displayIndex: int, ddpi: float*, hdpi: float*, vdpi: float*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetDisplayUsableBounds(displayIndex: int, rect: SDL_Rect*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetNumDisplayModes(displayIndex: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetDisplayMode(displayIndex: int, modeIndex: int, mode: SDL_DisplayMode*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetDesktopDisplayMode(displayIndex: int, mode: SDL_DisplayMode*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetCurrentDisplayMode(displayIndex: int, mode: SDL_DisplayMode*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetClosestDisplayMode(displayIndex: int, mode: SDL_DisplayMode*, closest: SDL_DisplayMode*): SDL_DisplayMode*;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowDisplayIndex(window: SDL_Window*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowDisplayMode(window: SDL_Window*, mode: SDL_DisplayMode*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowDisplayMode(window: SDL_Window*, mode: SDL_DisplayMode*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowPixelFormat(window: SDL_Window*): Uint32;
|
||||
|
||||
@extern
|
||||
func SDL_CreateWindow(title: char const*, x: int, y: int, w: int, h: int, flags: Uint32): SDL_Window*;
|
||||
|
||||
@extern
|
||||
func SDL_CreateWindowFrom(data: void const*): SDL_Window*;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowID(window: SDL_Window*): Uint32;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowFromID(id: Uint32): SDL_Window*;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowFlags(window: SDL_Window*): Uint32;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowTitle(window: SDL_Window*, title: char const*);
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowTitle(window: SDL_Window*): char const*;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowIcon(window: SDL_Window*, icon: SDL_Surface*);
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowData(window: SDL_Window*, name: char const*, userdata: void*): void*;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowData(window: SDL_Window*, name: char const*): void*;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowPosition(window: SDL_Window*, x: int, y: int);
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowPosition(window: SDL_Window*, x: int*, y: int*);
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowSize(window: SDL_Window*, w: int, h: int);
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowSize(window: SDL_Window*, w: int*, h: int*);
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowBordersSize(window: SDL_Window*, top: int*, left: int*, bottom: int*, right: int*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowMinimumSize(window: SDL_Window*, min_w: int, min_h: int);
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowMinimumSize(window: SDL_Window*, w: int*, h: int*);
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowMaximumSize(window: SDL_Window*, max_w: int, max_h: int);
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowMaximumSize(window: SDL_Window*, w: int*, h: int*);
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowBordered(window: SDL_Window*, bordered: SDL_bool);
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowResizable(window: SDL_Window*, resizable: SDL_bool);
|
||||
|
||||
@extern
|
||||
func SDL_ShowWindow(window: SDL_Window*);
|
||||
|
||||
@extern
|
||||
func SDL_HideWindow(window: SDL_Window*);
|
||||
|
||||
@extern
|
||||
func SDL_RaiseWindow(window: SDL_Window*);
|
||||
|
||||
@extern
|
||||
func SDL_MaximizeWindow(window: SDL_Window*);
|
||||
|
||||
@extern
|
||||
func SDL_MinimizeWindow(window: SDL_Window*);
|
||||
|
||||
@extern
|
||||
func SDL_RestoreWindow(window: SDL_Window*);
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowFullscreen(window: SDL_Window*, flags: Uint32): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowSurface(window: SDL_Window*): SDL_Surface*;
|
||||
|
||||
@extern
|
||||
func SDL_UpdateWindowSurface(window: SDL_Window*): int;
|
||||
|
||||
@extern
|
||||
func SDL_UpdateWindowSurfaceRects(window: SDL_Window*, rects: SDL_Rect*, numrects: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowGrab(window: SDL_Window*, grabbed: SDL_bool);
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowGrab(window: SDL_Window*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_GetGrabbedWindow(): SDL_Window*;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowBrightness(window: SDL_Window*, brightness: float): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowBrightness(window: SDL_Window*): float;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowOpacity(window: SDL_Window*, opacity: float): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowOpacity(window: SDL_Window*, out_opacity: float*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowModalFor(modal_window: SDL_Window*, parent_window: SDL_Window*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowInputFocus(window: SDL_Window*): int;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowGammaRamp(window: SDL_Window*, red: Uint16*, green: Uint16*, blue: Uint16*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GetWindowGammaRamp(window: SDL_Window*, red: Uint16*, green: Uint16*, blue: Uint16*): int;
|
||||
|
||||
@extern
|
||||
typedef SDL_HitTest = func(win: SDL_Window*, area: SDL_Point*, data: void*): SDL_HitTestResult;
|
||||
|
||||
@extern
|
||||
func SDL_SetWindowHitTest(window: SDL_Window*, callback: SDL_HitTest, callback_data: void*): int;
|
||||
|
||||
@extern
|
||||
func SDL_DestroyWindow(window: SDL_Window*);
|
||||
|
||||
@extern
|
||||
func SDL_IsScreenSaverEnabled(): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_EnableScreenSaver();
|
||||
|
||||
@extern
|
||||
func SDL_DisableScreenSaver();
|
||||
|
||||
@extern
|
||||
func SDL_GL_LoadLibrary(path: char const*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GL_GetProcAddress(proc: char const*): void*;
|
||||
|
||||
@extern
|
||||
func SDL_GL_UnloadLibrary();
|
||||
|
||||
@extern
|
||||
func SDL_GL_ExtensionSupported(extension: char const*): SDL_bool;
|
||||
|
||||
@extern
|
||||
func SDL_GL_ResetAttributes();
|
||||
|
||||
@extern
|
||||
func SDL_GL_SetAttribute(attr: SDL_GLattr, value: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_GL_GetAttribute(attr: SDL_GLattr, value: int*): int;
|
||||
|
||||
@extern
|
||||
func SDL_GL_CreateContext(window: SDL_Window*): SDL_GLContext;
|
||||
|
||||
@extern
|
||||
func SDL_GL_MakeCurrent(window: SDL_Window*, context: SDL_GLContext): int;
|
||||
|
||||
@extern
|
||||
func SDL_GL_GetCurrentWindow(): SDL_Window*;
|
||||
|
||||
@extern
|
||||
func SDL_GL_GetCurrentContext(): SDL_GLContext;
|
||||
|
||||
@extern
|
||||
func SDL_GL_GetDrawableSize(window: SDL_Window*, w: int*, h: int*);
|
||||
|
||||
@extern
|
||||
func SDL_GL_SetSwapInterval(interval: int): int;
|
||||
|
||||
@extern
|
||||
func SDL_GL_GetSwapInterval(): int;
|
||||
|
||||
@extern
|
||||
func SDL_GL_SwapWindow(window: SDL_Window*);
|
||||
|
||||
@extern
|
||||
func SDL_GL_DeleteContext(context: SDL_GLContext);
|
Loading…
Reference in New Issue