-
Notifications
You must be signed in to change notification settings - Fork 11
/
fwk.lua
2570 lines (2567 loc) Β· 95.4 KB
/
fwk.lua
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
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
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--autogenerated luajit bindings. do not edit.
local ffi = require("ffi")
ffi.cdef([[
typedef struct FILE FILE;
typedef long int ptrdiff_t;
typedef long unsigned int size_t;
int less_64(uint64_t a, uint64_t b);
int less_int(int a, int b);
int less_ptr(void *a, void *b);
int less_str(char *a, char *b);
int less_64_ptr(const void *a, const void *b);
int less_int_ptr(const void *a, const void *b);
uint32_t unhash_32(uint32_t x);
uint32_t hash_32(uint32_t x);
uint64_t hash_64(uint64_t x);
uint64_t hash_flt(double x);
uint64_t hash_int(int key);
uint64_t hash_ptr(const void* ptr);
uint64_t hash_bin(const void* ptr, unsigned len);
uint64_t hash_str(const char* str);
uint64_t popcnt64(uint64_t x);
void* vrealloc( void* p, size_t sz );
size_t vlen( void* p );
unsigned array_c_;
unsigned array_n_;
typedef struct set_item {
struct set_item *next;
uint64_t keyhash;
void *key;
void *super;
} set_item;
typedef struct set {
set_item** array;
int (*cmp)(void *, void *);
uint64_t (*hash)(void *);
int count;
} set;
void (set_init)(set *m);
void (set_free)(set *m);
void (set_insert)(set *m, set_item *p, void *key, uint64_t keyhash, void *super);
void (set_erase)(set *m, void *key, uint64_t keyhash);
void* (set_find)(const set *m, void *key, uint64_t keyhash);
int (set_isempty)(const set *m);
int (set_count)(const set *m);
void (set_gc)(set *m);
void (set_clear)(set* m);
typedef struct pair {
struct pair *next;
uint64_t keyhash;
void *key;
void *value;
void *super;
} pair;
typedef struct map {
pair** array;
int (*cmp)(void *, void *);
uint64_t (*hash)(void *);
int count:31;
int is_sorted:1;
pair** sorted;
} map;
void (map_init)(map *m);
void (map_free)(map *m);
void (map_insert)(map *m, pair *p, void *key, void *value, uint64_t keyhash, void *super);
void (map_erase)(map *m, void *key, uint64_t keyhash);
void* (map_find)(map *m, void *key, uint64_t keyhash);
int (map_isempty)(map *m);
int (map_count)(map *m);
void (map_gc)(map *m);
bool (map_sort)(map* m);
void (map_clear)(map* m);
typedef union vec2i{ struct { int X,Y; }; struct { int x,y; }; struct { int r,g; }; struct { int w,h; }; struct { int min,max; }; struct { int from,to; }; struct { int src,dst; }; int v2[2]; int array[1]; } vec2i;
typedef union vec3i{ struct { int X,Y,Z; }; struct { int x,y,z; }; struct { int r,g,b; }; struct { int w,h,d; }; struct { int min,max; }; struct { int from,to,step; }; struct { int src,dst; }; int v3[3]; int array[1]; } vec3i;
typedef union vec2 { struct { float X,Y; }; struct { float x,y; }; struct { float r,g; }; struct { float w,h; }; struct { float min,max; }; struct { float from,to; }; struct { float src,dst; }; float v2[2]; float array[1]; } vec2;
typedef union vec3 { struct { float X,Y,Z; }; struct { float x,y,z; }; struct { float r,g,b; }; struct { float min,max; }; struct { float from,to; }; vec2 xy; vec2 rg; vec2 wh; float v3[3]; float array[1]; } vec3;
typedef union vec4 { struct { float X,Y,Z,W; }; struct { float x,y,z,w; }; struct { float r,g,b,a; }; struct { float min,max; }; struct { float from,to; }; vec2 xy; vec3 xyz; vec2 rg; vec3 rgb; vec2 wh; vec3 whd; float v4[4]; float array[1]; } vec4;
typedef union quat { struct { float X,Y,Z,W; }; struct { float x,y,z,w; }; vec3 xyz; vec4 xyzw; float v4[4]; float array[1]; } quat;
typedef float mat33[9];
typedef float mat34[12];
typedef float mat44[16];
void randset(uint64_t state);
uint64_t rand64(void);
double randf(void);
int randi(int mini, int maxi);
float simplex1( float x );
float simplex2( vec2 xy );
float simplex3( vec3 xyz );
float simplex4( vec4 xyzw );
float deg (float radians);
float rad (float degrees);
float cycle180 (float angle);
float cycle360 (float angle);
int mini (int a, int b);
int maxi (int a, int b);
int absi (int a );
int clampi (int v,int a,int b);
float minf (float a, float b);
float maxf (float a, float b);
float absf (float a );
float pmodf (float a, float b);
float signf (float a) ;
float clampf (float v,float a,float b);
float mixf (float a,float b,float t);
float unmixf (float a,float b,float t);
float mapf (float x,float a,float b,float c,float d);
float slerpf (float a,float b,float t);
float fractf (float a);
vec2 ptr2 (const float *a );
vec2 neg2 (vec2 a );
vec2 add2 (vec2 a, vec2 b);
vec2 sub2 (vec2 a, vec2 b);
vec2 mul2 (vec2 a, vec2 b);
vec2 div2 (vec2 a, vec2 b);
vec2 inc2 (vec2 a, float b);
vec2 dec2 (vec2 a, float b);
vec2 scale2 (vec2 a, float b);
vec2 pmod2 (vec2 a, float b);
vec2 min2 (vec2 a, vec2 b);
vec2 max2 (vec2 a, vec2 b);
vec2 abs2 (vec2 a );
vec2 floor2 (vec2 a );
vec2 fract2 (vec2 a );
vec2 ceil2 (vec2 a );
float dot2 (vec2 a, vec2 b);
vec2 refl2 (vec2 a, vec2 b);
float cross2 (vec2 a, vec2 b);
float len2sq (vec2 a );
float len2 (vec2 a );
vec2 norm2 (vec2 a );
int finite2 (vec2 a );
vec2 mix2 (vec2 a,vec2 b,float t);
vec2 clamp2(vec2 v,vec2 a,vec2 b);
vec2 clamp2f(vec2 v,float a,float b);
vec3 rnd3 (void);
vec3 ptr3 (const float *a );
vec3 vec23 (vec2 a, float z );
vec3 neg3 (vec3 a );
vec3 add3 (vec3 a, vec3 b);
vec3 sub3 (vec3 a, vec3 b);
vec3 mul3 (vec3 a, vec3 b);
vec3 div3 (vec3 a, vec3 b);
vec3 inc3 (vec3 a, float b);
vec3 dec3 (vec3 a, float b);
vec3 scale3 (vec3 a, float b);
vec3 pmod3 (vec3 a, float b);
vec3 min3 (vec3 a, vec3 b);
vec3 max3 (vec3 a, vec3 b);
vec3 abs3 (vec3 a );
vec3 floor3 (vec3 a );
vec3 fract3 (vec3 a );
vec3 ceil3 (vec3 a );
vec3 cross3 (vec3 a, vec3 b);
float dot3 (vec3 a, vec3 b);
vec3 refl3 (vec3 a, vec3 b);
float len3sq (vec3 a );
float len3 (vec3 a );
vec3 norm3 (vec3 a );
vec3 norm3sq (vec3 a );
int finite3 (vec3 a );
vec3 mix3 (vec3 a,vec3 b,float t);
vec3 clamp3(vec3 v,vec3 a,vec3 b);
vec3 clamp3f(vec3 v,float a,float b);
void ortho3 (vec3 *left, vec3 *up, vec3 v);
vec3 rotatex3 (vec3 dir, float degrees);
vec3 rotatey3 (vec3 dir, float degrees);
vec3 rotatez3 (vec3 dir, float degrees);
vec4 ptr4 (const float *a );
vec4 vec34 (vec3 a, float w );
vec4 neg4 (vec4 a );
vec4 add4 (vec4 a, vec4 b);
vec4 sub4 (vec4 a, vec4 b);
vec4 mul4 (vec4 a, vec4 b);
vec4 div4 (vec4 a, vec4 b);
vec4 inc4 (vec4 a, float b);
vec4 dec4 (vec4 a, float b);
vec4 scale4 (vec4 a, float b);
vec4 pmod4 (vec4 a, float b);
vec4 min4 (vec4 a, vec4 b);
vec4 max4 (vec4 a, vec4 b);
vec4 abs4 (vec4 a );
vec4 floor4 (vec4 a );
vec4 fract4 (vec4 a );
vec4 ceil4 (vec4 a );
float dot4 (vec4 a, vec4 b);
vec4 refl4 (vec4 a, vec4 b);
float len4sq (vec4 a );
float len4 (vec4 a );
vec4 norm4 (vec4 a );
vec4 norm4sq (vec4 a );
int finite4 (vec4 a );
vec4 mix4 (vec4 a,vec4 b,float t);
vec4 clamp4(vec4 v,vec4 a,vec4 b);
vec4 clamp4f(vec4 v,float a,float b);
quat idq ( );
quat ptrq (const float *a );
quat vec3q (vec3 a, float w );
quat vec4q (vec4 a );
quat negq (quat a );
quat conjq (quat a );
quat addq (quat a, quat b);
quat subq (quat a, quat b);
quat mulq (quat p, quat q);
quat scaleq (quat a, float s);
quat normq (quat a );
float dotq (quat a, quat b);
quat mixq(quat a, quat b, float t);
quat slerpq(quat a, quat b, float s);
quat rotationq(float deg,float x,float y,float z);
quat mat44q (mat44 M);
vec3 rotate3q_2(vec3 v, quat q);
vec3 rotate3q(vec3 v, quat r);
vec3 euler (quat q);
quat eulerq (vec3 pyr_degrees);
void scaling33(mat33 m, float x, float y, float z);
void scale33(mat33 m, float x, float y, float z);
void id33(mat33 m);
void extract33(mat33 m, const mat44 m4);
void copy33(mat33 m, const mat33 a);
vec3 mulv33(mat33 m, vec3 v);
void multiply33x2(mat33 m, const mat33 a, const mat33 b);
void rotation33(mat33 m, float degrees, float x,float y,float z);
void rotationq33(mat33 m, quat q);
void rotate33(mat33 r, float degrees, float x,float y,float z);
void compose33(mat33 m, quat r, vec3 s);
void id34(mat34 m);
void copy34(mat34 m, const mat34 a);
void scale34(mat34 m, float s);
void add34(mat34 m, mat34 n);
void muladd34(mat34 m, mat34 n, float s);
void add34x2(mat34 m, mat34 n, mat34 o);
void lerp34(mat34 m, mat34 n, mat34 o, float alpha);
void multiply34x2(mat34 m, const mat34 m0, const mat34 m1);
void multiply34(mat34 m, const mat34 a);
void multiply34x3(mat34 m, const mat34 a, const mat34 b, const mat34 c);
void compose34(mat34 m, vec3 t, quat q, vec3 s);
void invert34(mat34 m, const mat34 o);
void id44(mat44 m);
void identity44(mat44 m);
void copy44(mat44 m, const mat44 a);
void multiply44x2(mat44 m, const mat44 a, const mat44 b);
void multiply44x3(mat44 m, const mat44 a, const mat44 b, const mat44 c);
void multiply44(mat44 m, const mat44 a);
void ortho44(mat44 m, float l, float r, float b, float t, float n, float f);
void frustum44(mat44 m, float l, float r, float b, float t, float n, float f);
void perspective44(mat44 m, float fovy_degrees, float aspect, float nearp, float farp);
void lookat44(mat44 m, vec3 eye, vec3 center, vec3 up);
vec3 pos44(mat44 m);
void translation44(mat44 m, float x, float y, float z);
void translate44(mat44 m, float x, float y, float z);
void relocate44(mat44 m, float x, float y, float z);
void rotationq44(mat44 m, quat q);
void rotation44(mat44 m, float degrees, float x, float y, float z);
void rotate44(mat44 m, float degrees, float x, float y, float z);
void scaling44(mat44 m, float x, float y, float z);
void scale44(mat44 m, float x, float y, float z);
void transpose44(mat44 m, const mat44 a);
float det44(const mat44 M);
bool invert44(mat44 T, const mat44 M);
void compose44(mat44 m, vec3 t, quat q, vec3 s);
vec3 transformq(const quat q, const vec3 v);
vec3 transform33(const mat33 m, vec3 p);
vec3 transform344(const mat44 m, const vec3 p);
vec4 transform444(const mat44 m, const vec4 p);
bool unproject44(vec3 *out, vec3 xyd, vec4 viewport, mat44 mvp);
void print2i( vec2i v );
void print3i( vec3i v );
void print2( vec2 v );
void print3( vec3 v );
void print4( vec4 v );
void printq( quat q );
void print33( float *m );
void print34( float *m );
void print44( float *m );
uint32_t hh_mem(const void *data, size_t size);
uint32_t hh_str(const char* str);
uint32_t hh_float(float f);
uint32_t hh_int(int i);
uint32_t hh_vec2(vec2 v);
uint32_t hh_vec3(vec3 v);
uint32_t hh_vec4(vec4 v);
uint32_t hh_mat33(mat33 m);
uint32_t hh_mat44(mat44 m);
uintptr_t id_make(void *ptr);
void * id_handle(uintptr_t id);
void id_dispose(uintptr_t id);
bool id_valid(uintptr_t id);
typedef struct obj { struct { const char *objname; uintptr_t objheader; struct obj** objchildren; }; } obj;
typedef struct entity { struct { struct { const char *objname; uintptr_t objheader; struct obj** objchildren; }; uintptr_t cflags; void *c[32]; }; } entity;
obj *objtmp;
void* obj_malloc(unsigned sz);
void* obj_free(void *o);
extern void (*obj_ctor[256])();
extern void (*obj_dtor[256])();
extern char* (*obj_save[256])();
extern bool (*obj_load[256])();
extern int (*obj_test[256])();
extern int (*obj_init[256])();
extern int (*obj_quit[256])();
extern int (*obj_tick[256])();
extern int (*obj_draw[256])();
extern int (*obj_lerp[256])();
extern int (*obj_aabb[256])();
extern int (*obj_edit[256])();
extern int (*obj_menu[256])();
extern char* (*obj_icon[256])();
extern const char*OBJTYPES[256];
uintptr_t obj_header(const void *o);
uintptr_t obj_id(const void *o);
const char* obj_type(const void *o);
unsigned obj_typeid(const void *o);
int obj_sizeof(const void *o);
int obj_size(const void *o);
char* obj_data(void *o);
const char* obj_datac(const void *o);
void* obj_payload(const void *o);
void* obj_zero(void *o);
void* obj_ref(void *oo);
void* obj_unref(void *oo);
obj* obj_detach(void *c);
obj* obj_attach(void *o, void *c);
obj* obj_root(const void *o);
obj* obj_parent(const void *o);
obj***obj_children(const void *o);
obj***obj_siblings(const void *o);
int obj_dumptree(const void *o);
void* obj_setmeta(void *o, const char *key, const char *value);
const char* obj_meta(const void *o, const char *key);
void* obj_setname(void *o, const char *name);
const char* obj_name(const void *o);
void* obj_swap(void *dst, void *src);
void* obj_copy_fast(void *dst, const void *src);
void* obj_copy(void *dst, const void *src);
int obj_comp_fast(const void *a, const void *b);
int obj_comp(const void *a, const void *b);
int obj_lesser(const void *a, const void *b);
int obj_greater(const void *a, const void *b);
int obj_equal(const void *a, const void *b);
uint64_t obj_hash(const void *o);
bool obj_hexdump(const void *oo);
int obj_print(const void *o);
int obj_printf(const void *o, const char *text);
int obj_console(const void *o);
char* obj_saveini(const void *o);
obj* obj_mergeini(void *o, const char *ini);
obj* obj_loadini(void *o, const char *ini);
char* obj_savejson(const void *o);
obj* obj_mergejson(void *o, const char *json);
obj* obj_loadjson(void *o, const char *json);
char* obj_savebin(const void *o);
obj* obj_mergebin(void *o, const char *sav);
obj* obj_loadbin(void *o, const char *sav);
char* obj_savempack(const void *o);
obj* obj_mergempack(void *o, const char *sav);
obj* obj_loadmpack(void *o, const char *sav);
int obj_push(const void *o);
int obj_pop(void *o);
bool entity_addcomponent(entity *e, unsigned c, void *ptr);
bool entity_hascomponent(entity *e, unsigned c);
void* entity_getcomponent(entity *e, unsigned c);
bool entity_delcomponent(entity *e, unsigned c);
bool entity_usecomponent(entity *e, unsigned c);
bool entity_offcomponent(entity *e, unsigned c);
char* entity_save(entity *self);
void* obj_clone(const void *src);
void* obj_merge(void *dst, const void *src);
void* obj_mutate(void *dst, const void *src);
void* obj_make(const char *str);
typedef enum OBJTYPE_BUILTINS {
OBJTYPE_obj = 0,
OBJTYPE_entity = 1,
OBJTYPE_vec2 = 2,
OBJTYPE_vec3 = 3,
OBJTYPE_vec4 = 4,
OBJTYPE_quat = 5,
OBJTYPE_mat33 = 6,
OBJTYPE_mat34 = 7,
OBJTYPE_mat44 = 8,
OBJTYPE_vec2i = 9,
OBJTYPE_vec3i = 10,
OBJTYPE_sprite = 11,
OBJTYPE_camera = 12,
OBJTYPE_node = 13,
OBJTYPE_scene = 14,
OBJTYPE_light = 15,
} OBJTYPE_BUILTINS;
int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
typedef int (*bt_func)();
typedef struct bt_t {
uint64_t type;
int (*action)();
union {
int argi;
float argf;
};
struct bt_t* children;
} bt_t;
bt_t bt(const char *ini_file, unsigned flags);
int bt_run(bt_t *b);
void bt_addfun(const char *name, int(*func)());
bt_func bt_findfun(const char *name);
char *bt_funcname(bt_func fn);
int ui_bt(bt_t *b);
typedef enum SWARM_DISTANCE {
SWARM_DISTANCE_LINEAR,
SWARM_DISTANCE_INVERSE_LINEAR,
SWARM_DISTANCE_QUADRATIC,
SWARM_DISTANCE_INVERSE_QUADRATIC
} SWARM_DISTANCE;
typedef struct boid_t {
vec3 position;
vec3 velocity;
vec3 acceleration;
vec3 prev_position;
} boid_t;
typedef struct swarm_t {
boid_t* boids;
float perception_radius;
float separation_weight;
SWARM_DISTANCE separation_type;
float alignment_weight;
float cohesion_weight;
float steering_weight;
vec3* steering_targets;
SWARM_DISTANCE steering_target_type;
float blindspot_angledeg;
float max_acceleration;
float max_velocity;
struct { map base; struct { pair p; vec3* key; boid_t** val; } tmp, *ptr; boid_t*** tmpval; int (*typed_cmp)(vec3*, vec3*); uint64_t (*typed_hash)(vec3*); } * voxel_cache_;
float blindspot_angledeg_compare_value_;
} swarm_t;
swarm_t swarm();
void swarm_update(swarm_t *self, float delta);
void swarm_update_acceleration_only(swarm_t *self, float delta);
void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta);
int ui_swarm(swarm_t *self);
void midi_send(unsigned midi_msg);
typedef struct audio_handle* audio_t;
audio_t audio_clip( const char *pathfile );
audio_t audio_stream( const char *pathfile );
int audio_play( audio_t s, int flags );
int audio_play_gain( audio_t a, int flags, float gain );
int audio_play_gain_pitch( audio_t a, int flags, float gain, float pitch );
int audio_play_gain_pitch_pan( audio_t a, int flags, float gain, float pitch, float pan );
int audio_stop( audio_t a );
void audio_loop( audio_t a, bool loop );
bool audio_playing( audio_t a );
float audio_volume_clip(float gain);
float audio_volume_stream(float gain);
float audio_volume_master(float gain);
int audio_mute(int mute);
int audio_muted();
int ui_audio();
enum AUDIO_FLAGS {
AUDIO_1CH = 0,
AUDIO_2CH = 1,
AUDIO_8 = 2,
AUDIO_16 = 0,
AUDIO_32 = 4,
AUDIO_FLOAT = 8,
AUDIO_8KHZ = 16,
AUDIO_11KHZ = 32,
AUDIO_22KHZ = 0,
AUDIO_32KHZ = 64,
AUDIO_44KHZ = 128,
AUDIO_MIXER_GAIN = 0,
AUDIO_IGNORE_MIXER_GAIN = 256,
AUDIO_MULTIPLE_INSTANCES = 0,
AUDIO_SINGLE_INSTANCE = 512,
};
int audio_queue( const void *samples, int num_samples, int flags );
typedef struct line { vec3 a, b; } line;
typedef struct sphere { vec3 c; float r; } sphere;
typedef struct aabb { vec3 min, max; } aabb;
typedef struct plane { vec3 p, n; } plane;
typedef struct capsule { vec3 a, b; float r; } capsule;
typedef struct ray { vec3 p, d; } ray;
typedef struct triangle { vec3 p0,p1,p2; } triangle;
typedef struct poly { vec3* verts; int cnt; } poly;
typedef union frustum { struct { vec4 l, r, t, b, n, f; }; vec4 pl[6]; float v[24]; } frustum;
typedef struct hit {
union {
float depth;
struct { float t0, t1; };
struct { int hits; vec3 p0, p1; float distance2; int iterations; };
};
union { vec3 p; vec3 contact_point; };
union { vec3 n; vec3 normal; };
} hit;
float line_distance2_point(line l, vec3 p);
vec3 line_closest_point(line l, vec3 p);
float ray_test_plane(ray r, vec4 p4);
float ray_test_triangle(ray r, triangle t);
int ray_test_sphere(float *t0, float *t1, ray r, sphere s);
int ray_test_aabb(float *t0, float *t1, ray r, aabb a);
hit* ray_hit_plane(ray r, plane p);
hit* ray_hit_triangle(ray r, triangle t);
hit* ray_hit_sphere(ray r, sphere s);
hit* ray_hit_aabb(ray r, aabb a);
vec3 sphere_closest_point(sphere s, vec3 p);
hit* sphere_hit_aabb(sphere s, aabb a);
hit* sphere_hit_capsule(sphere s, capsule c);
hit* sphere_hit_sphere(sphere a, sphere b);
int sphere_test_aabb(sphere s, aabb a);
int sphere_test_capsule(sphere s, capsule c);
int sphere_test_sphere(sphere a, sphere b);
vec3 aabb_closest_point(aabb a, vec3 p);
float aabb_distance2_point(aabb a, vec3 p);
int aabb_contains_point(aabb a, vec3 p);
hit* aabb_hit_aabb(aabb a, aabb b);
hit* aabb_hit_capsule(aabb a, capsule c);
hit* aabb_hit_sphere(aabb a, sphere s);
int aabb_test_aabb(aabb a, aabb b);
int aabb_test_capsule(aabb a, capsule c);
int aabb_test_sphere(aabb a, sphere s);
float capsule_distance2_point(capsule c, vec3 p);
vec3 capsule_closest_point(capsule c, vec3 p);
hit* capsule_hit_aabb(capsule c, aabb a);
hit* capsule_hit_capsule(capsule a, capsule b);
hit* capsule_hit_sphere(capsule c, sphere s);
int capsule_test_aabb(capsule c, aabb a);
int capsule_test_capsule(capsule a, capsule b);
int capsule_test_sphere(capsule c, sphere s);
vec4 plane4(vec3 p, vec3 n);
frustum frustum_build(mat44 projview);
int frustum_test_sphere(frustum f, sphere s);
int frustum_test_aabb(frustum f, aabb a);
poly poly_alloc(int cnt);
void poly_free(poly *p);
poly pyramid(vec3 from, vec3 to, float size);
poly diamond(vec3 from, vec3 to, float size);
void collide_demo();
enum COOK_FLAGS {
COOK_SYNC = 0,
COOK_ASYNC = 1,
COOK_CANCELABLE = 2,
COOK_DEBUGLOG = 4,
};
void cook_config( const char *path_to_cook_ini );
bool cook_start( const char *path_to_cook_ini, const char *masks, int flags );
void cook_stop();
void cook_cancel();
int cook_jobs();
int cook_progress();
bool have_tools();
typedef union json_t { char* s; double f; int64_t i; uintptr_t p; union json_t* arr; } json_t;
bool json_push(const char *json_content);
const char* json_key(const char *keypath);
json_t* json_find(const char *type_keypath);
json_t json_get(const char *type_keypath);
int json_count(const char *keypath);
bool json_pop();
int xml_push(const char *xml_content);
const char * xml_string(char *key);
unsigned xml_count(char *key);
char* xml_blob(char *key);
void xml_pop();
bool data_tests();
void* dll(const char *filename, const char *symbol);
enum {
SCRIPT_LUA = 1,
SCRIPT_DEBUGGER = 2,
};
void script_init();
void *script_init_env(unsigned flags);
bool script_push(void *env);
void script_run(const char *script);
void script_runfile(const char *pathfile);
void script_bind_class(const char *objname, int num_methods, const char **c_names, void **c_functions);
void script_bind_function(const char *c_name, void *c_function);
void script_call(const char *lua_function);
bool script_tests();
bool script_pop();
char** file_list( const char *pathmasks );
bool file_write( const char *file, const void *ptr, int len );
bool file_append( const char *file, const void *ptr, int len );
char * file_read(const char *filename);
char * file_load(const char *filename, int *len);
uint64_t file_size(const char *pathfile);
bool file_directory(const char *pathfile);
char * file_pathabs(const char *pathfile);
char * file_path(const char *pathfile);
char * file_name(const char *pathfile);
char * file_base(const char *pathfile);
char * file_ext(const char *pathfile);
char * file_id(const char *pathfile);
char * file_normalize(const char *pathfile);
char * file_counter(const char *pathfile);
uint64_t file_stamp(const char *pathfile);
uint64_t file_stamp10(const char *pathfile);
bool file_exist(const char *pathfile);
bool file_delete(const char *pathfile);
bool file_copy(const char *src, const char *dst);
bool file_move(const char *src, const char *dst);
FILE* file_temp();
char* file_tempname();
void* file_md5(const char *file);
void* file_sha1(const char *file);
void* file_crc32(const char *file);
char** file_zip_list(const char *zipfile);
char* file_zip_extract(const char *zipfile, const char *filename);
bool file_zip_append(const char *zipfile, const char *filename, int clevel);
bool file_zip_appendmem(const char *zipfile, const char *entryname, const void *ptr, unsigned len, int clevel);
void storage_mount(const char* folder);
void storage_read();
void storage_flush();
bool vfs_mount(const char *mount_point);
char** vfs_list(const char *masks);
char * vfs_read(const char *pathfile);
char * vfs_load(const char *pathfile, int *size);
int vfs_size(const char *pathfile);
void vfs_reload();
const char * vfs_resolve(const char *fuzzyname);
FILE* vfs_handle(const char *pathfile);
void * cache_insert(const char *key, void *value, int size);
void * cache_lookup(const char *key, int *size);
typedef struct { map base; struct { pair p; char* key; char* val; } tmp, *ptr; char** tmpval; int (*typed_cmp)(char*, char*); uint64_t (*typed_hash)(char*); } * ini_t;
ini_t ini(const char *filename);
ini_t ini_from_mem(const char *data);
void ini_destroy(ini_t);
bool ini_write(const char *filename, const char *section, const char *key, const char *value);
enum FONT_FLAGS {
FONT_512 = 0x0,
FONT_1024 = 0x1,
FONT_2048 = 0x2,
FONT_4096 = 0x4,
FONT_NO_OVERSAMPLE = 0x0,
FONT_OVERSAMPLE_X = 0x08,
FONT_OVERSAMPLE_Y = 0x10,
FONT_ASCII = 0x800,
FONT_AR = 0x001000,
FONT_ZH = 0x002000,
FONT_EL = 0x004000,
FONT_EM = 0x008000,
FONT_EU = 0x010000,
FONT_HE = 0x020000,
FONT_JP = 0x040000,
FONT_KR = 0x080000,
FONT_RU = 0x100000,
FONT_TH = 0x200000,
FONT_VI = 0x400000,
FONT_CJK = FONT_ZH|FONT_JP|FONT_KR,
};
typedef struct font_metrics_t {
float ascent;
float descent;
float linegap;
float linedist;
} font_metrics_t;
void font_face(const char *face_tag, const char *filename_ttf, float font_size, unsigned flags);
void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
void font_scale(const char *face_tag, int scale_index, float value);
void font_scales(const char *face_tag, float h1, float h2, float h3, float h4, float h5, float h6);
void font_color(const char *color_tag, uint32_t color);
vec2 font_xy();
void font_goto(float x, float y);
vec2 font_print(const char *text);
vec2 font_clip(const char *text, vec4 rect);
const char* font_wrap(const char *text, float max_width);
vec2 font_rect(const char *text);
font_metrics_t font_metrics(const char *text);
void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords);
vec2 font_highlight(const char *text, const void *colors);
void ui_font();
int input_use( int controller_id );
float input( int vk );
vec2 input2( int vk );
float input_diff( int vk );
vec2 input_diff2( int vk );
const char* input_string( int vk );
float input_frame( int vk, int Nth_frame );
vec2 input_frame2( int vk, int Nth_frame );
int input_up( int vk );
int input_down( int vk );
int input_held( int vk );
int input_idle( int vk );
int input_click( int vk, int ms );
int input_click2( int vk, int ms );
int input_repeat( int vk, int ms );
int input_chord2( int vk1, int vk2 );
int input_chord3( int vk1, int vk2, int vk3 );
int input_chord4( int vk1, int vk2, int vk3, int vk4 );
float input_filter_positive( float v );
vec2 input_filter_positive2( vec2 v );
vec2 input_filter_deadzone( vec2 v, float deadzone_treshold );
vec2 input_filter_deadzone_4way( vec2 v, float deadzone_treshold );
enum TOUCH_BUTTONS {
TOUCH_0,
TOUCH_1,
};
void input_touch_area(unsigned button, vec2 begin_coord_ndc, vec2 end_coord_ndc);
vec2 input_touch(unsigned button, float sensitivity);
vec2 input_touch_delta(unsigned button, float sensitivity);
vec2 input_touch_delta_from_origin(unsigned button, float sensitivity);
bool input_touch_active();
void input_mappings(const char *filename);
char input_keychar(unsigned code);
int input_enum(const char *sym);
int input_anykey();
int input_eval(const char *expression);
void input_send( int vk );
char* save_input();
bool load_input(char* replay);
int ui_keyboard();
int ui_mouse();
int ui_gamepad(int id);
int ui_gamepads();
enum INPUT_ENUMS {
KEY_0,KEY_1,KEY_2,KEY_3,KEY_4,KEY_5,KEY_6,KEY_7,KEY_8,KEY_9, KEY_TICK,KEY_BS, KEY_ESC,
KEY_TAB, KEY_Q,KEY_W,KEY_E,KEY_R,KEY_T,KEY_Y,KEY_U,KEY_I,KEY_O,KEY_P,
KEY_CAPS, KEY_A,KEY_S,KEY_D,KEY_F,KEY_G,KEY_H,KEY_J,KEY_K,KEY_L, KEY_ENTER,
KEY_LSHIFT, KEY_Z,KEY_X,KEY_C,KEY_V,KEY_B,KEY_N,KEY_M, KEY_RSHIFT, KEY_UP,
KEY_LCTRL,KEY_LALT, KEY_SPACE, KEY_RALT,KEY_RCTRL, KEY_LEFT,KEY_DOWN,KEY_RIGHT,
KEY_INS,KEY_HOME,KEY_PGUP,KEY_DEL,KEY_END,KEY_PGDN,
KEY_LMETA,KEY_RMETA,KEY_MENU,KEY_PRINT,KEY_PAUSE,KEY_SCROLL,KEY_NUMLOCK,
KEY_MINUS,KEY_EQUAL,KEY_LSQUARE,KEY_RSQUARE,KEY_SEMICOLON,KEY_QUOTE,KEY_HASH,KEY_BAR,KEY_COMMA,KEY_DOT,KEY_SLASH,
KEY_F1,KEY_F2,KEY_F3,KEY_F4,KEY_F5,KEY_F6,KEY_F7,KEY_F8,KEY_F9,KEY_F10,KEY_F11,KEY_F12,
KEY_PAD1,KEY_PAD2,KEY_PAD3,KEY_PAD4,KEY_PAD5,KEY_PAD6,KEY_PAD7,KEY_PAD8,KEY_PAD9,KEY_PAD0,
KEY_PADADD,KEY_PADSUB,KEY_PADMUL,KEY_PADDIV,KEY_PADDOT,KEY_PADENTER,
MOUSE_L, MOUSE_M, MOUSE_R,
GAMEPAD_CONNECTED, GAMEPAD_A, GAMEPAD_B, GAMEPAD_X, GAMEPAD_Y,
GAMEPAD_UP, GAMEPAD_DOWN, GAMEPAD_LEFT, GAMEPAD_RIGHT, GAMEPAD_MENU, GAMEPAD_START,
GAMEPAD_LB, GAMEPAD_RB, GAMEPAD_LTHUMB, GAMEPAD_RTHUMB,
WINDOW_BLUR, WINDOW_FOCUS, WINDOW_CLOSE, WINDOW_MINIMIZE, WINDOW_MAXIMIZE, WINDOW_FULLSCREEN, WINDOW_WINDOWED,
GAMEPAD_LPAD, GAMEPAD_LPADX = GAMEPAD_LPAD, GAMEPAD_LPADY,
GAMEPAD_RPAD, GAMEPAD_RPADX = GAMEPAD_RPAD, GAMEPAD_RPADY,
GAMEPAD_LTRIGGER, GAMEPAD_LT = GAMEPAD_LTRIGGER, GAMEPAD_RTRIGGER, GAMEPAD_RT = GAMEPAD_RTRIGGER, GAMEPAD_BATTERY,
MOUSE, MOUSE_X = MOUSE, MOUSE_Y, MOUSE_W,
TOUCH_X1, TOUCH_Y1, TOUCH_X2, TOUCH_Y2,
WINDOW_RESIZE, WINDOW_RESIZEX = WINDOW_RESIZE, WINDOW_RESIZEY, WINDOW_ORIENTATION, WINDOW_BATTERY,
GAMEPAD_GUID, GAMEPAD_NAME,
};
enum INPUT_ALIASES {
KEY_SHIFT = KEY_LSHIFT,
KEY_ALT = KEY_LALT,
KEY_CTRL = KEY_LCTRL,
};
void* xrealloc(void* p, size_t sz);
size_t xsize(void* p);
char* xstats(void);
void* stack(int bytes);
void* watch( void *ptr, int sz );
void* forget( void *ptr );
inline void *(REALLOC_)(void *p, size_t n) { return n ? (xrealloc(p,n)) : xrealloc((p),0); }
inline void *(CALLOC_)(size_t m, size_t n) { return n *= m, memset(REALLOC_((0),(n)),0,n); }
inline char *(STRDUP_)(const char *s) { size_t n = strlen(s)+1; return ((char*)memcpy(REALLOC_((0),(n)), s, n)); }
char* download( const char *url );
int download_file( FILE *out, const char *url );
int portname( const char *service_name, unsigned retries );
bool network_tests();
int udp_bind(const char *address, const char *port);
int udp_open(const char *address, const char *port);
int udp_send(int, const void *buf, int len );
int udp_sendto(int, const char *ip, const char *port, const void *buf, int len );
int udp_recv(int, void *buf, int len );
int udp_peek(int);
int tcp_open(const char *address, const char *port);
int tcp_bind(const char *interface_, const char *port, int queue);
int tcp_peek(int, int(*callback)(int));
int tcp_send(int, const void* buf, int len);
int tcp_recv(int, void* buf, int len);
char* tcp_host(int);
char* tcp_port(int);
int tcp_close(int);
int tcp_debug(int);
enum { NETWORK_BIND = 2, NETWORK_CONNECT = 4, NETWORK_NOFAIL = 8 };
void network_create(unsigned max_clients, const char *ip, const char *port, unsigned flags);
enum { NETWORK_SEND = 2, NETWORK_RECV = 4 };
enum { NETWORK_UNRELIABLE = 8, NETWORK_UNORDERED = 16 };
void* network_buffer(void *ptr, unsigned sz, uint64_t flags, int64_t rank);
char** network_sync(unsigned timeout_ms);
enum {
NETWORK_EVENT_CONNECT,
NETWORK_EVENT_DISCONNECT,
NETWORK_EVENT_RECEIVE,
NETWORK_EVENT_DISCONNECT_TIMEOUT,
NETWORK_EVENT_RPC = 10,
NETWORK_EVENT_RPC_RESP,
};
int network_event(const char *msg, int *errcode, char **errstr);
enum { NETWORK_RANK = 0 };
enum { NETWORK_PING = 1 };
enum { NETWORK_PORT = 2, NETWORK_IP, NETWORK_LIVE };
enum { NETWORK_SEND_MS = 4 };
enum { NETWORK_BUF_CLEAR_ON_JOIN = 5 };
enum { NETWORK_USERID = 7, NETWORK_COUNT , NETWORK_CAPACITY };
int64_t network_get(uint64_t key);
int64_t network_put(uint64_t key, int64_t value);
void network_rpc(const char *signature, void *function);
void network_rpc_send_to(int64_t rank, unsigned id, const char *cmdline);
void network_rpc_send(unsigned id, const char *cmdline);
bool server_bind(int max_clients, int port);
char** server_poll(unsigned timeout_ms);
char** client_poll(unsigned timeout_ms);
void server_broadcast_bin_flags(const void *ptr, int len, uint64_t flags);
void server_broadcast_bin(const void *ptr, int len);
void server_broadcast_flags(const char *msg, uint64_t flags);
void server_broadcast(const char *msg);
void server_terminate();
void server_send(int64_t handle, const char *msg);
void server_send_bin(int64_t handle, const void *ptr, int len);
void server_drop(int64_t handle);
int64_t client_join(const char *ip, int port);
void client_send_flags(const char *msg, uint64_t flags);
void client_send(const char *msg);
void client_send_bin_flags(const void *ptr, int len, uint64_t flags);
void client_send_bin(const void *ptr, int len);
void client_terminate();
enum COMPRESS_FLAGS {
COMPRESS_RAW = 0,
COMPRESS_PPP = (1<<4),
COMPRESS_ULZ = (2<<4),
COMPRESS_LZ4 = (3<<4),
COMPRESS_CRUSH = (4<<4),
COMPRESS_DEFLATE = (5<<4),
COMPRESS_LZP1 = (6<<4),
COMPRESS_LZMA = (7<<4),
COMPRESS_BALZ = (8<<4),
COMPRESS_LZW3 = (9<<4),
COMPRESS_LZSS = (10<<4),
COMPRESS_BCM = (11<<4),
COMPRESS_ZLIB = (12<<4),
};
unsigned zbounds(unsigned inlen, unsigned flags);
unsigned zencode(void *out, unsigned outlen, const void *in, unsigned inlen, unsigned flags);
unsigned zexcess(unsigned flags);
unsigned zdecode(void *out, unsigned outlen, const void *in, unsigned inlen, unsigned flags);
void *interleave( void *out, const void *list, int list_count, int sizeof_item, unsigned columns );
unsigned cobs_bounds(unsigned len);
unsigned cobs_encode(const void *in, unsigned inlen, void *out, unsigned outlen);
unsigned cobs_decode(const void *in, unsigned inlen, void *out, unsigned outlen);
unsigned base92_encode(const void *in, unsigned inlen, void* out, unsigned outlen);
unsigned base92_decode(const void *in, unsigned inlen, void* out, unsigned outlen);
unsigned base92_bounds(unsigned inlen);
unsigned netstring_bounds(unsigned inlen);
unsigned netstring_encode(const char *in, unsigned inlen, char *out, unsigned outlen);
unsigned netstring_decode(const char *in, unsigned inlen, char *out, unsigned outlen);
void delta8_encode(void *buffer, unsigned count);
void delta8_decode(void *buffer, unsigned count);
void delta16_encode(void *buffer, unsigned count);
void delta16_decode(void *buffer, unsigned count);
void delta32_encode(void *buffer, unsigned count);
void delta32_decode(void *buffer, unsigned count);
void delta64_encode(void *buffer, unsigned count);
void delta64_decode(void *buffer, unsigned count);
uint64_t zig64( int64_t value );
int64_t zag64( uint64_t value );
uint32_t enczig32u( int32_t n);
uint64_t enczig64u( int64_t n);
int32_t deczig32i(uint32_t n);
int64_t deczig64i(uint64_t n);
void *arc4( void *buffer, unsigned buflen, const void *pass, unsigned passlen );
uint64_t crc64(uint64_t h, const void *ptr, uint64_t len);
void entropy( void *buf, unsigned n );
int semver( int major, int minor, int patch );
int semvercmp( int v1, int v2 );
typedef struct byte2 { uint8_t x,y; } byte2;
typedef struct byte3 { uint8_t x,y,z; } byte3;
typedef struct byte4 { uint8_t x,y,z,w; } byte4;
typedef struct int2 { int x,y; } int2;
typedef struct int3 { int x,y,z; } int3;
typedef struct int4 { int x,y,z,w; } int4;
typedef struct uint2 { unsigned int x,y; } uint2;
typedef struct uint3 { unsigned int x,y,z; } uint3;
typedef struct uint4 { unsigned int x,y,z,w; } uint4;
typedef struct float2 { float x,y; } float2;
typedef struct float3 { float x,y,z; } float3;
typedef struct float4 { float x,y,z,w; } float4;
typedef struct double2 { double x,y; } double2;
typedef struct double3 { double x,y,z; } double3;
typedef struct double4 { double x,y,z,w; } double4;
char *cc4str(unsigned cc);
char *cc8str(uint64_t cc);
enum {
cc__1 = '1', cc__2, cc__3, cc__4, cc__5, cc__6,cc__7, cc__8, cc__9, cc__0, cc___, cc__ = ' ',
cc__A = 'A', cc__B, cc__C, cc__D, cc__E, cc__F,cc__G, cc__H, cc__I, cc__J, cc__K,cc__L, cc__M, cc__N, cc__O, cc__P,cc__Q, cc__R, cc__S, cc__T, cc__U,cc__V, cc__W, cc__X, cc__Y, cc__Z,
cc__a = 'a', cc__b, cc__c, cc__d, cc__e, cc__f,cc__g, cc__h, cc__i, cc__j, cc__k,cc__l, cc__m, cc__n, cc__o, cc__p,cc__q, cc__r, cc__s, cc__t, cc__u,cc__v, cc__w, cc__x, cc__y, cc__z,
};
char* ftoa1(float v);
char* ftoa2(vec2 v);
char* ftoa3(vec3 v);
char* ftoa4(vec4 v);
float atof1(const char *s);
vec2 atof2(const char *s);
vec3 atof3(const char *s);
vec4 atof4(const char *s);
char* itoa1(int v);
char* itoa2(vec2i v);
char* itoa3(vec3i v);
int atoi1(const char *s);
vec2i atoi2(const char *s);
vec3i atoi3(const char *s);
int is_big();
int is_little();
uint16_t swap16( uint16_t x );
uint32_t swap32( uint32_t x );
uint64_t swap64( uint64_t x );
float swap32f(float n);
double swap64f(double n);
void swapf(float *a, float *b);
void swapf2(vec2 *a, vec2 *b);
void swapf3(vec3 *a, vec3 *b);
void swapf4(vec4 *a, vec4 *b);
uint16_t lil16(uint16_t n);
uint32_t lil32(uint32_t n);
uint64_t lil64(uint64_t n);
float lil32f(float n);
double lil64f(double n);
uint16_t big16(uint16_t n);
uint32_t big32(uint32_t n);
uint64_t big64(uint64_t n);
float big32f(float n);
double big64f(double n);
uint16_t* lil16p(void *p, int sz);
uint32_t* lil32p(void *p, int sz);
uint64_t* lil64p(void *p, int sz);
float * lil32pf(void *p, int sz);
double * lil64pf(void *p, int sz);
uint16_t* big16p(void *p, int sz);
uint32_t* big32p(void *p, int sz);
uint64_t* big64p(void *p, int sz);
float * big32pf(void *p, int sz);
double * big64pf(void *p, int sz);
typedef uint16_t half;
float half_to_float(half value);
half float_to_half(float value);
void pack16i(uint8_t *buf, uint16_t i, int swap);
void pack32i(uint8_t *buf, uint32_t i, int swap);
void pack64i(uint8_t *buf, uint64_t i, int swap);
int16_t unpack16i(const uint8_t *buf, int swap);
int32_t unpack32i(const uint8_t *buf, int swap);
int64_t unpack64i(const uint8_t *buf, int swap);
uint64_t pack754(long double f, unsigned bits, unsigned expbits);
long double unpack754(uint64_t i, unsigned bits, unsigned expbits);
uint64_t pack64uv( uint8_t *buffer, uint64_t value );
uint64_t unpack64uv( const uint8_t *buffer, uint64_t *value );
uint64_t pack64iv( uint8_t *buffer, int64_t value_ );
uint64_t unpack64iv( const uint8_t *buffer, int64_t *value );
int msgpack(const char *fmt, ... );
int msgunpack(const char *fmt, ... );
int msgpack_new(uint8_t *w, size_t l);
int msgpack_nil();
int msgpack_chr(bool n);
int msgpack_uns(uint64_t n);
int msgpack_int(int64_t n);
int msgpack_str(const char *s);
int msgpack_bin(const char *s, size_t n);
int msgpack_flt(double g);
int msgpack_ext(uint8_t key, void *val, size_t n);
int msgpack_arr(uint32_t n);
int msgpack_map(uint32_t n);
int msgpack_eof();
int msgpack_err();
bool msgunpack_new( const void *opaque_or_FILE, size_t bytes );
bool msgunpack_nil();
bool msgunpack_chr(bool *chr);
bool msgunpack_uns(uint64_t *uns);
bool msgunpack_int(int64_t *sig);
bool msgunpack_str(char **str);
bool msgunpack_bin(void **bin, uint64_t *len);
bool msgunpack_flt(float *flt);
bool msgunpack_dbl(double *dbl);
bool msgunpack_ext(uint8_t *key, void **val, uint64_t *len);
bool msgunpack_arr(uint64_t *len);
bool msgunpack_map(uint64_t *len);
bool msgunpack_eof();
bool msgunpack_err();
int savef(FILE *file, const char *format, ...);
int saveb(unsigned char *buf, const char *format, ...);
int loadf(FILE *file, const char *format, ...);
int loadb(const unsigned char *buf, const char *format, ...);
int profiler_enable(bool on);
struct profile_t { double stat; int32_t cost, avg; };
typedef struct { map base; struct { pair p; char * key; struct profile_t val; } tmp, *ptr; struct profile_t* tmpval; int (*typed_cmp)(char *, char *); uint64_t (*typed_hash)(char *); } * profiler_t;
extern profiler_t profiler;
extern int profiler_enabled;
typedef struct reflect_t {
unsigned id, objtype;
union {
unsigned sz;
unsigned member_offset;
unsigned enum_value;
};
const char *name;
const char *info;
void *addr;
unsigned parent;
const char *type;
unsigned bytes;
} reflect_t;
unsigned enum_find(const char *E);
void * function_find(const char *F);
reflect_t member_find(const char *T, const char *M);
void * member_findptr(void *obj, const char *T, const char *M);
reflect_t** members_find(const char *T);
void type_inscribe(const char *TY,unsigned TYsz,const char *infos);
void enum_inscribe(const char *E,unsigned Eval,const char *infos);
void struct_inscribe(const char *T,unsigned Tsz,unsigned OBJTYPEid, const char *infos);
void member_inscribe(const char *T, const char *M,unsigned Msz, const char *infos, const char *type, unsigned bytes);
void function_inscribe(const char *F,void *func,const char *infos);
const char* symbol_naked(const char *s);