302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
#include <windef.h>
#include <windows.h>
#include <winuser.h>
#include <commctrl.h>
#include <io.h>
#include <conio.h>
// HACK for zig 0.14
#define INVALID_HANDLE_VALUE (HANDLE)0xFFFFFFFF
#if __with_network__
#include <ws2tcpip.h>
#include <winsock2.h>
#endif
#elif __target_os__ == __TargetOs_linux__
#include <fcntl.h>
|
|
|
>
|
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
#include <windef.h>
#include <windows.h>
#include <winuser.h>
#include <commctrl.h>
#include <io.h>
#include <conio.h>
#ifdef __COMPILED_FROM_ZIG_FILE__
#define INVALID_HANDLE_VALUE (HANDLE)0xFFFFFFFF
#endif
#if __with_network__
#include <ws2tcpip.h>
#include <winsock2.h>
#endif
#elif __target_os__ == __TargetOs_linux__
#include <fcntl.h>
|
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
|
// i use this instead memcpy becouse clang-in-zig just replace memcpy to crash-zig-bloated-version code
size_t pos = 0;
while(pos < size) {
dest[pos] = src[pos];
pos++;
}
}
bool __ScalpiMem_isEql__(const char a[], const char b[], size_t len) {
for(size_t pos = 0; pos < len; pos ++) {
char ac = a[pos];
char bc = b[pos];
if (ac != bc) return false;
}
return true;
}
void writeWithOffset(char* dest, size_t* writed, char* data, size_t data_len) {
__ScalpiMem_copy__(&dest[*writed], data, data_len);
*writed += data_len;
}
// AlignedPtr
|
|
|
>
|
>
>
|
|
|
|
>
>
>
>
>
|
>
>
>
>
|
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
|
// i use this instead memcpy becouse clang-in-zig just replace memcpy to crash-zig-bloated-version code
size_t pos = 0;
while(pos < size) {
dest[pos] = src[pos];
pos++;
}
}
size_t __ScalpiMem_findDiffOrLen__(const char a[], const char b[], size_t len) {
size_t pos = 0;
while(pos < len) {
if (a[pos] != b[pos]) break;
pos++;
}
return pos;
}
bool __ScalpiMem_isEql__(const char a[], const char b[], size_t len) {
return __ScalpiMem_findDiffOrLen__(a, b, len) == len;
}
bool __ScalpiMem_isEql_test_() {
return true
and (__ScalpiMem_isEql__("abcd", "abcd", 4))
and (__ScalpiMem_isEql__("abcd", "abce", 4) == false)
and (__ScalpiMem_isEql__("abcdasdasd", "asd", 3) == false)
;
}
void writeWithOffset(char* dest, size_t* writed, char* data, size_t data_len) {
__ScalpiMem_copy__(&dest[*writed], data, data_len);
*writed += data_len;
}
// AlignedPtr
|
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
|
// App
// struct App
// AppEditorHistoryNote
// fn __AppEditorHistoryNote_free__
void __AppEditorHistoryNote_free__(
struct __AppEditorHistoryNote__* ptr
) {
__AlignedPtr_free__(ptr, sizeof(struct __AppEditorHistoryNote__));
}
// fn __AppEditorHistoryNote_alloc__
bool __AppEditorHistoryNote_alloc__(
struct __AppEditorHistoryNote__* *ptr
) {
return __AlignedPtr_alloc__(
ptr,
__alignOf__(struct __AppEditorHistoryNote__),
sizeof(struct __AppEditorHistoryNote__)
);
}
// fn App_init
bool App_init(struct App* t) {
bool ok = true;
|
|
|
|
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
|
// App
// struct App
// AppEditorHistoryNote
// fn __AppEditorHistoryNote_free__
void __AppEditorHistoryNote_free__(
struct __AppEditorHistoryNote__* ptr
) {
__AlignedPtr_free__((void*)ptr, sizeof(struct __AppEditorHistoryNote__));
}
// fn __AppEditorHistoryNote_alloc__
bool __AppEditorHistoryNote_alloc__(
struct __AppEditorHistoryNote__* *ptr
) {
return __AlignedPtr_alloc__(
(void*) ptr,
__alignOf__(struct __AppEditorHistoryNote__),
sizeof(struct __AppEditorHistoryNote__)
);
}
// fn App_init
bool App_init(struct App* t) {
bool ok = true;
|
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
|
}
// main
bool tests() {
// const char* test_file_name = "scalpi_testing_file.txt";
// size_t test_file_name_len = __ZText_countLen__(test_file_name);
if ( true
and cpu_checkNumberFormat()
// and __ScalpiFileComplete_write__(test_file_name, test_file_name_len, "abcd", 4)
// and __ScalpiFileComplete_write__(test_file_name, test_file_name_len, "efgh", 4)
// and __ScalpiFileComplete_write__(test_file_name, test_file_name_len, "ijkm", 4)
// and etc...
) {
return true;
} else {
printf("%d fail tests \r\n", __LINE__);
return false;
}
return true;
}
bool real_main(int args_len, char** args_ptr) {
if (tests()) {
if (App_init(&global_app)) {
while(true) {
if (!App_process(&global_app)) break;
App_waitToNextFrame(&global_app);
}
App_deinit(&global_app);
return true;
} else {
|
>
>
|
|
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
|
}
// main
bool tests() {
// const char* test_file_name = "scalpi_testing_file.txt";
// size_t test_file_name_len = __ZText_countLen__(test_file_name);
if ( true
and cpu_checkNumberFormat()
and __ScalpiMem_isEql_test_()
// and __ScalpiFileComplete_write__(test_file_name, test_file_name_len, "abcd", 4)
// and __ScalpiFileComplete_write__(test_file_name, test_file_name_len, "efgh", 4)
// and __ScalpiFileComplete_write__(test_file_name, test_file_name_len, "ijkm", 4)
// and etc...
) {
return true;
} else {
printf("%d fail tests \r\n", __LINE__);
return false;
}
return true;
}
bool real_main(int args_len, char** args_ptr) {
if (tests()) {
printf("%d success tests \r\n", __LINE__);
if (false and App_init(&global_app)) {
while(true) {
if (!App_process(&global_app)) break;
App_waitToNextFrame(&global_app);
}
App_deinit(&global_app);
return true;
} else {
|