forked from chaos-lang/chaos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chaos.h
189 lines (180 loc) · 7.46 KB
/
Chaos.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* Description: Chaos C extension interface
*
* Copyright (c) 2019-2021 Chaos Language Development Authority <info@chaos-lang.org>
*
* License: GNU General Public License v3.0
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*
* Authors: M. Mert Yildiran <me@mertyildiran.com>
*/
#ifndef KAOS_CHAOS_H
#define KAOS_CHAOS_H
#include <stdbool.h>
#if defined(CHAOS_INTERPRETER)
# include "enums.h"
# include "utilities/language.h"
#else
# include "chaos/enums.h"
# include "chaos/utilities/language.h"
#endif
typedef struct KaosValue {
bool b;
long long i;
char *s;
double f;
} KaosValue;
int defineFunction(
char *name,
enum Type type,
enum Type secondary_type,
char *params_name[],
unsigned params_type[],
unsigned params_secondary_type[],
unsigned short params_length,
KaosValue optional_params[],
unsigned short optional_params_length
);
bool getVariableBool(char *name);
long long getVariableInt(char *name);
double getVariableFloat(char *name);
char* getVariableString(char *name);
bool getVariableBoolByTypeCasting(char *name);
long long getVariableIntByTypeCasting(char *name);
double getVariableFloatByTypeCasting(char *name);
char* getVariableStringByTypeCasting(char *name);
unsigned long getListLength(char *name);
bool getListElementBool(char *name, long long i);
long long getListElementInt(char *name, long long i);
double getListElementFloat(char *name, long long i);
char* getListElementString(char *name, long long i);
bool getListElementBoolByTypeCasting(char *name, long long i);
long long getListElementIntByTypeCasting(char *name, long long i);
double getListElementFloatByTypeCasting(char *name, long long i);
char* getListElementStringByTypeCasting(char *name, long long i);
void copyListElement(char *name, long long i);
enum Type getListElementType(char *name, long long i);
enum ValueType getListElementValueType(char *name, long long i);
unsigned long getDictLength(char *name);
char* getDictKeyByIndex(char *name, long long i);
bool getDictElementBool(char *name, char *key);
long long getDictElementInt(char *name, char *key);
double getDictElementFloat(char *name, char *key);
char* getDictElementString(char *name, char *key);
bool getDictElementBoolByTypeCasting(char *name, char *key);
long long getDictElementIntByTypeCasting(char *name, char *key);
double getDictElementFloatByTypeCasting(char *name, char *key);
char* getDictElementStringByTypeCasting(char *name, char *key);
void copyDictElement(char *name, char *key);
enum Type getDictElementType(char *name, char *key);
enum ValueType getDictElementValueType(char *name, char *key);
char* dumpVariableToString(char *name, bool pretty, bool escaped, bool double_quotes);
void returnVariableBool(bool b);
void returnVariableInt(long long i);
void returnVariableFloat(double f);
void returnVariableString(char *s);
void createVariableBool(char *name, bool b);
void createVariableInt(char *name, long long i);
void createVariableFloat(char *name, double f);
void createVariableString(char *name, char *s);
void startBuildingList();
void returnList(enum Type type);
void startBuildingDict();
void returnDict(enum Type type);
void returnComplex(enum Type type);
void finishList(enum Type type);
void finishDict(enum Type type);
void finishComplex(enum Type type);
enum Type getListType(char *name);
enum Type getDictType(char *name);
enum ValueType getValueType(char *name);
enum Role getRole(char *name);
void raiseError(char *msg);
void parseJson(char *json);
struct Kaos {
int (*defineFunction)(
char *name,
enum Type type,
enum Type secondary_type,
char *params_name[],
unsigned params_type[],
unsigned params_secondary_type[],
unsigned short params_length,
KaosValue optional_params[],
unsigned short optional_params_length
);
bool (*getVariableBool)(char *name);
long long (*getVariableInt)(char *name);
double (*getVariableFloat)(char *name);
char* (*getVariableString)(char *name);
bool (*getVariableBoolByTypeCasting)(char *name);
long long (*getVariableIntByTypeCasting)(char *name);
double (*getVariableFloatByTypeCasting)(char *name);
char* (*getVariableStringByTypeCasting)(char *name);
unsigned long (*getListLength)(char *name);
bool (*getListElementBool)(char *name, long long i);
long long (*getListElementInt)(char *name, long long i);
double (*getListElementFloat)(char *name, long long i);
char* (*getListElementString)(char *name, long long i);
bool (*getListElementBoolByTypeCasting)(char *name, long long i);
long long (*getListElementIntByTypeCasting)(char *name, long long i);
double (*getListElementFloatByTypeCasting)(char *name, long long i);
char* (*getListElementStringByTypeCasting)(char *name, long long i);
void (*copyListElement)(char *name, long long i);
enum Type (*getListElementType)(char *name, long long i);
enum ValueType (*getListElementValueType)(char *name, long long i);
unsigned long (*getDictLength)(char *name);
char* (*getDictKeyByIndex)(char *name, long long i);
bool (*getDictElementBool)(char *name, char *key);
long long (*getDictElementInt)(char *name, char *key);
double (*getDictElementFloat)(char *name, char *key);
char* (*getDictElementString)(char *name, char *key);
bool (*getDictElementBoolByTypeCasting)(char *name, char *key);
long long (*getDictElementIntByTypeCasting)(char *name, char *key);
double (*getDictElementFloatByTypeCasting)(char *name, char *key);
char* (*getDictElementStringByTypeCasting)(char *name, char *key);
void (*copyDictElement)(char *name, char *key);
enum Type (*getDictElementType)(char *name, char *key);
enum ValueType (*getDictElementValueType)(char *name, char *key);
char* (*dumpVariableToString)(char *name, bool pretty, bool escaped, bool double_quotes);
void (*returnVariableBool)(bool b);
void (*returnVariableInt)(long long i);
void (*returnVariableFloat)(double f);
void (*returnVariableString)(char *s);
void (*createVariableBool)(char *name, bool b);
void (*createVariableInt)(char *name, long long i);
void (*createVariableFloat)(char *name, double f);
void (*createVariableString)(char *name, char *s);
void (*startBuildingList)();
void (*returnList)(enum Type type);
void (*startBuildingDict)();
void (*returnDict)(enum Type type);
void (*returnComplex)(enum Type type);
void (*finishList)(enum Type type);
void (*finishDict)(enum Type type);
void (*finishComplex)(enum Type type);
enum Type (*getListType)(char *name);
enum Type (*getDictType)(char *name);
enum ValueType (*getValueType)(char *name);
enum Role (*getRole)(char *name);
void (*raiseError)(char *msg);
void (*parseJson)(char *json);
};
struct Kaos kaos;
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
# define KAOS_EXPORT __declspec(dllexport)
#else
# define KAOS_EXPORT
#endif
#endif