Skip to content

Commit

Permalink
Add arguments to defineFunction() calls for specifying secondary type
Browse files Browse the repository at this point in the history
  • Loading branch information
mertyildiran committed Aug 14, 2020
1 parent 85bda5e commit c2765a6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
42 changes: 35 additions & 7 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ unsigned merge_params_type[] = {
K_LIST,
K_LIST
};
unsigned merge_params_secondary_type[] = {
K_ANY,
K_ANY
};
unsigned short merge_params_length = (unsigned short) sizeof(merge_params_type) / sizeof(unsigned);
int KAOS_EXPORT Kaos_merge()
{
Expand Down Expand Up @@ -50,6 +54,11 @@ unsigned insert_params_type[] = {
K_ANY,
K_NUMBER
};
unsigned insert_params_secondary_type[] = {
K_ANY,
K_ANY,
K_ANY
};
unsigned short insert_params_length = (unsigned short) sizeof(insert_params_type) / sizeof(unsigned);
int KAOS_EXPORT Kaos_insert()
{
Expand Down Expand Up @@ -98,6 +107,9 @@ char *reverse_params_name[] = {
unsigned reverse_params_type[] = {
K_LIST
};
unsigned reverse_params_secondary_type[] = {
K_ANY
};
unsigned short reverse_params_length = (unsigned short) sizeof(reverse_params_type) / sizeof(unsigned);
int KAOS_EXPORT Kaos_reverse()
{
Expand All @@ -121,6 +133,10 @@ unsigned chunk_params_type[] = {
K_LIST,
K_NUMBER
};
unsigned chunk_params_secondary_type[] = {
K_ANY,
K_ANY
};
unsigned short chunk_params_length = (unsigned short) sizeof(chunk_params_type) / sizeof(unsigned);
int KAOS_EXPORT Kaos_chunk()
{
Expand Down Expand Up @@ -160,6 +176,10 @@ unsigned search_params_type[] = {
K_LIST,
K_ANY
};
unsigned search_params_secondary_type[] = {
K_ANY,
K_ANY
};
unsigned short search_params_length = (unsigned short) sizeof(search_params_type) / sizeof(unsigned);
int KAOS_EXPORT Kaos_search()
{
Expand Down Expand Up @@ -228,6 +248,11 @@ unsigned replace_params_type[] = {
K_ANY,
K_ANY
};
unsigned replace_params_secondary_type[] = {
K_ANY,
K_ANY,
K_ANY
};
unsigned short replace_params_length = (unsigned short) sizeof(replace_params_type) / sizeof(unsigned);
int KAOS_EXPORT Kaos_replace()
{
Expand Down Expand Up @@ -307,6 +332,9 @@ char *length_params_name[] = {
unsigned length_params_type[] = {
K_LIST
};
unsigned length_params_secondary_type[] = {
K_ANY
};
unsigned short length_params_length = (unsigned short) sizeof(length_params_type) / sizeof(unsigned);
int KAOS_EXPORT Kaos_length()
{
Expand All @@ -326,17 +354,17 @@ int KAOS_EXPORT KaosRegister(struct Kaos _kaos)
};

// Array Operations
kaos.defineFunction("merge", K_LIST, K_ANY, merge_params_name, merge_params_type, merge_params_length, NULL, 0);
kaos.defineFunction("insert", K_LIST, K_ANY, insert_params_name, insert_params_type, insert_params_length, insert_optional_params, 1);
kaos.defineFunction("reverse", K_LIST, K_ANY, reverse_params_name, reverse_params_type, reverse_params_length, NULL, 0);
kaos.defineFunction("chunk", K_LIST, K_ANY, chunk_params_name, chunk_params_type, chunk_params_length, NULL, 0);
kaos.defineFunction("merge", K_LIST, K_ANY, merge_params_name, merge_params_type, merge_params_secondary_type, merge_params_length, NULL, 0);
kaos.defineFunction("insert", K_LIST, K_ANY, insert_params_name, insert_params_type, insert_params_secondary_type, insert_params_length, insert_optional_params, 1);
kaos.defineFunction("reverse", K_LIST, K_ANY, reverse_params_name, reverse_params_type, reverse_params_secondary_type, reverse_params_length, NULL, 0);
kaos.defineFunction("chunk", K_LIST, K_ANY, chunk_params_name, chunk_params_type, chunk_params_secondary_type, chunk_params_length, NULL, 0);

// Searching & Replacing
kaos.defineFunction("search", K_LIST, K_NUMBER, search_params_name, search_params_type, search_params_length, NULL, 0);
kaos.defineFunction("replace", K_LIST, K_ANY, replace_params_name, replace_params_type, replace_params_length, NULL, 0);
kaos.defineFunction("search", K_LIST, K_NUMBER, search_params_name, search_params_type, search_params_secondary_type, search_params_length, NULL, 0);
kaos.defineFunction("replace", K_LIST, K_ANY, replace_params_name, replace_params_type, replace_params_secondary_type, replace_params_length, NULL, 0);

// Information Functions
kaos.defineFunction("length", K_NUMBER, K_ANY, length_params_name, length_params_type, length_params_length, NULL, 0);
kaos.defineFunction("length", K_NUMBER, K_ANY, length_params_name, length_params_type, length_params_secondary_type, length_params_length, NULL, 0);

return 0;
}
2 changes: 1 addition & 1 deletion occultist.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "array",
"version": "1.0.1",
"version": "1.0.2",
"description": "Array library of the Chaos language.",
"tags": ["official", "array", "list"],
"type": "extension",
Expand Down

0 comments on commit c2765a6

Please sign in to comment.