ScalpiEditor

Diff
Login

Diff

Differences From Artifact [d39ddf34f8]:

To Artifact [b921aa9e82]:


556
557
558
559
560
561
562





563
564
565
566
567
568
569
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574







+
+
+
+
+







            #define __AlignedPtr_freeAny__(                 ret_data_addr,  size) \
                    __AlignedPtr_free__(      (uintptr_t)  (ret_data_addr), size)
        // # __ScalpiFileComplete_readToAny__
            #define __ScalpiFileComplete_readToAny__(             ret_data_ptr, ret_file_data_size, file_name,  file_name_len, align ) \
                    __ScalpiFileComplete_read__(      (uintptr_t*)ret_data_ptr, ret_file_data_size, file_name,  file_name_len, align )
// structs
    // core
        // # __Trace__
            struct __Trace__ {
                struct __Trace__  *__Trace_prevTrace__;
                size_t            __Trace_line__;
            };
        // memory
            // # __AlignedPtr__
                /* its a virtual struct becouse C not have "anytype" type.
                    struct __AlignedPtr__ {
                        char    gap[gap_size] // padding for aligning data. gap_size can be 0.
                        anytype your_data     // <- the pointer that the alloc function returns will be pointed here.
                        uint8_t gap_size
662
663
664
665
666
667
668
669

670
671
672
673
674
675
676
667
668
669
670
671
672
673

674
675
676
677
678
679
680
681







-
+







            // # __ScalpiWriter__
                struct __ScalpiWriter__ {
                    void*          context;
                    __WriteFnPtr__ write;
                };
            
            struct __ScalpiMemTree__ {
                struct __ScalpiMemTree__*     parent; // todo remove me. use link.list or __ ... 
                struct __ScalpiMemTree__*     parent; // todo remove me. create func __ScalpiMemTree_getParentByListLink__ 
                struct __ScalpiMemList__      childs;
                struct __ScalpiMemListLink__  link;
                size_t                        count;  // recurse. for get non recurse use childs.count
                size_t                        nested;
            };
        // math
            struct __Scalpi_math_d2_U_Pos__ {
823
824
825
826
827
828
829






































830
831
832
833
834
835
836
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







    bool   __OsFile_exist__(             const char* file_name, size_t file_name_len);
    size_t __OsFallbackConsole_write__(  void* unused_ctx, char* data, size_t len);
// globals
    struct App global_app;
// functions
    // CScpecific
    // core
        // TRACE        
            // # __Trace_init__
                void __Trace_init__(
                    struct __Trace__  *trace,
                    struct __Trace__  *prev_trace // can be null
                ) {
                    trace->__Trace_prevTrace__ = prev_trace;
                    trace->__Trace_line__      = 0; // не треубется знать где был создан трейс. т.к. трейсы нужны для того чтобы хранить номер строки вызывающего кода (устанавливается в prev_trace макросом TC()), но если мы будем смотреть программу в отладчике - было бы полезно проинициализировать нулём для того чтобы видеть что значение ещё не изменялось.
                }
            // # __Trace_print__
                void __Trace_print__(struct __Trace__ *trace) {
                    if (trace) {
                        printf("%zu", trace->__Trace_line__);
                        trace = trace->__Trace_prevTrace__;
                        
                        while (trace) {
                            printf("|%zu", trace->__Trace_line__);
                            trace = trace->__Trace_prevTrace__;
                        }
                    } else {
                        printf("nil");
                    }
                }
            // # print_trace_example        
                void print_trace_example(
                    int anyarg,
                    struct __Trace__* prev_trace
                ) {
                    struct __Trace__ trace; __Trace_init__(&trace, prev_trace);
                    trace.__Trace_line__ = __LINE__; __Trace_print__(&trace);
                }
            // # call_other_trace_example    
                void call_other_trace_example(
                    struct __Trace__* prev_trace // can be null
                ) {
                    struct __Trace__ trace; __Trace_init__(&trace, prev_trace);
                    trace.__Trace_line__ = __LINE__; print_trace_example(0, &trace);
                }
        // mem
            // bits operations
                uint8_t bits_rotl8(uint8_t value, unsigned int shift) {
                    shift %= 8;
                    return (value << shift) | (value >> (8 - shift));
                }
                
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2360
2361
2362
2363
2364
2365
2366


2367
2368
2369
2370
2371
2372
2373







-
-







                                } else {
                                    ok = false;
                                }
                                __OsFile_close__(file);
                            }
                        return ok;
                    }


        // formats
            // Base64
                uint32_t Base64_getEncodeSize(uint32_t src_len) {
                    int blocks = ceilDiv32(src_len, 3);
                    return blocks * 4;
                }
                
2567
2568
2569
2570
2571
2572
2573








2574
2575
2576
2577
2578





2579
2580
2581
2582
2583
2584
2585
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622





2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634







+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+







                for (size_t i = 0; i < __arrayLen__(t->writers); i++) {
                    struct __ScalpiWriter__* w = &t->writers[i];
                    if (w->write) {
                        size_t writed = w->write(w->context, bytes, len);
                    }
                }
            }
        // terminal
            
            // # __ScalpiTerminalInput_init__
                void __ScalpiTerminalInput_init__(
                    struct __ScalpiTerminalInput__ *t
                ) {
                    t->ungrabed = 0;
                }
        // __ScalpiTerminalOutput_CursorPos__
            void __ScalpiTerminalOutputCursorPos_init__(__ScalpiTerminalOutput_CursorPos__ *cursor_pos) {
                cursor_pos->x = 0;
                cursor_pos->y = 0;
            }
            // # __ScalpiTerminalOutput_CursorPos__
                void __ScalpiTerminalOutputCursorPos_init__(__ScalpiTerminalOutput_CursorPos__ *cursor_pos) {
                    cursor_pos->x = 0;
                    cursor_pos->y = 0;
                }
    // App
        // AppEditorHistoryNote
            // # __AppEditorHistoryNote_free__
                void __AppEditorHistoryNote_free__(
                    struct __AppEditorHistoryNote__* ptr
                ) {
                    __AlignedPtr_freeAny__(ptr, sizeof(struct __AppEditorHistoryNote__));
2671
2672
2673
2674
2675
2676
2677

2678
2679
2680
2681
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731







+




                    printf("%d fail tests \r\n", __LINE__);
                }
            return ok;
        }
        
        #ifndef __COMPILED_FROM_ZIG_FILE__
            int main(int args_len, char** args_ptr) {
                trace_example();
                if (real_main(args_len, args_ptr)) return 0;
                return 1;
            }
        #endif