├── .gitattributes ├── .github └── workflows │ └── build_code.yml ├── .gitignore ├── .gitmodules ├── .readthedocs.yaml ├── Configurations ├── ESP32-8048S070.ini ├── Hardware_Development_Kit.ini ├── WT32-SC01.ini └── WT32-SC01_Plus.ini ├── Drive └── Xila │ └── Sounds │ ├── Shutdown.wav │ └── Startup.wav ├── LICENSE ├── Partitions.csv ├── README.md ├── Xila Embedded.code-workspace ├── boards └── wt32-sc01-plus.json ├── hal └── sdl2 │ ├── app_hal.c │ └── app_hal.h ├── lib ├── Xila │ ├── .gitignore │ ├── .vscode │ │ ├── extensions.json │ │ └── settings.json │ ├── examples │ │ └── Custom_Software │ │ │ └── Custom_Software.ino │ ├── include │ │ ├── Account │ │ │ └── Accounts.hpp │ │ ├── Clipboard │ │ │ └── Clipboard.hpp │ │ ├── Communication │ │ │ ├── Communication.hpp │ │ │ ├── HTTP_Client.hpp │ │ │ ├── IP_Address.hpp │ │ │ ├── WiFi.hpp │ │ │ └── WiFi_Client.hpp │ │ ├── Configuration │ │ │ └── Path.hpp │ │ ├── Core.hpp │ │ ├── Display │ │ │ ├── Configuration.hpp │ │ │ └── Display.hpp │ │ ├── Drive │ │ │ ├── Drive.hpp │ │ │ └── File.hpp │ │ ├── Flash │ │ │ └── Flash.hpp │ │ ├── Graphics │ │ │ ├── Animation.hpp │ │ │ ├── Arc.hpp │ │ │ ├── Area.hpp │ │ │ ├── Bar.hpp │ │ │ ├── Button.hpp │ │ │ ├── Button_Matrix.hpp │ │ │ ├── Calendar.hpp │ │ │ ├── Canvas.hpp │ │ │ ├── Chart.hpp │ │ │ ├── Checkbox.hpp │ │ │ ├── Color.hpp │ │ │ ├── Color_Wheel.hpp │ │ │ ├── Dialog.hpp │ │ │ ├── Drop_Down_List.hpp │ │ │ ├── File_Explorer.hpp │ │ │ ├── Graphics.hpp │ │ │ ├── Image.hpp │ │ │ ├── Keyboard.hpp │ │ │ ├── Label.hpp │ │ │ ├── Line.hpp │ │ │ ├── List.hpp │ │ │ ├── Menu.hpp │ │ │ ├── Meter.hpp │ │ │ ├── Object.hpp │ │ │ ├── Point.hpp │ │ │ ├── QRCode.hpp │ │ │ ├── Roller.hpp │ │ │ ├── Screen.hpp │ │ │ ├── Slider.hpp │ │ │ ├── Spinbox.hpp │ │ │ ├── Style.hpp │ │ │ ├── Switch.hpp │ │ │ ├── Table.hpp │ │ │ ├── Tabs.hpp │ │ │ ├── Text_Area.hpp │ │ │ ├── Types.hpp │ │ │ └── Window.hpp │ │ ├── Header.hpp │ │ ├── Keyboard │ │ │ └── Keyboard.hpp │ │ ├── Log │ │ │ └── Log.hpp │ │ ├── Mathematics │ │ │ ├── Hash.hpp │ │ │ ├── Mathematics.hpp │ │ │ └── Rational.hpp │ │ ├── Memory │ │ │ └── Memory.hpp │ │ ├── Module │ │ │ ├── Base_Types.hpp │ │ │ ├── Date.hpp │ │ │ ├── Instruction.hpp │ │ │ ├── Module.hpp │ │ │ ├── Queue.hpp │ │ │ ├── Registry.hpp │ │ │ ├── Semaphore.hpp │ │ │ ├── Stream.hpp │ │ │ ├── String.hpp │ │ │ ├── Task.hpp │ │ │ └── Time.hpp │ │ ├── Pin │ │ │ ├── Pin.hpp │ │ │ ├── Serial.hpp │ │ │ └── Two_Wire_Interface.hpp │ │ ├── Power │ │ │ └── Power.hpp │ │ ├── Software │ │ │ ├── Software.hpp │ │ │ ├── Software_Handle.hpp │ │ │ └── Softwares.hpp │ │ ├── Sound │ │ │ ├── Configuration.hpp │ │ │ ├── Decoder.hpp │ │ │ ├── File_Player.hpp │ │ │ ├── I2S.hpp │ │ │ ├── Sound.hpp │ │ │ ├── Stream.hpp │ │ │ └── Volume.hpp │ │ ├── System │ │ │ └── System.hpp │ │ └── Xila.hpp │ ├── keyword.txt │ ├── library.json │ ├── library.properties │ ├── src │ │ ├── Accounts │ │ │ ├── Accounts.cpp │ │ │ └── User.cpp │ │ ├── Clipboard │ │ │ └── Clipboard.cpp │ │ ├── Communication │ │ │ ├── Communication.cpp │ │ │ ├── HTTP_Client.cpp │ │ │ ├── IP_Address.cpp │ │ │ ├── WiFi │ │ │ │ ├── Drivers │ │ │ │ │ └── ESP32.cpp │ │ │ │ └── WiFi.cpp │ │ │ └── WiFi_Client.cpp │ │ ├── Core.cpp │ │ ├── Display │ │ │ ├── Display.cpp │ │ │ └── Drivers │ │ │ │ ├── ESP32-8048S070.cpp │ │ │ │ ├── Native.cpp │ │ │ │ ├── WT32-SC01-Plus.cpp │ │ │ │ └── WT32-SC01.cpp │ │ ├── Drive │ │ │ ├── Drive.cpp │ │ │ ├── Drivers │ │ │ │ ├── SD_MMC.cpp │ │ │ │ └── SD_SPI.cpp │ │ │ └── File.cpp │ │ ├── Flash │ │ │ └── Flash.cpp │ │ ├── Graphics │ │ │ ├── Animation.cpp │ │ │ ├── Arc.cpp │ │ │ ├── Area.cpp │ │ │ ├── Bar.cpp │ │ │ ├── Button.cpp │ │ │ ├── Button_Matrix.cpp │ │ │ ├── Calendar.cpp │ │ │ ├── Canvas.cpp │ │ │ ├── Checkbox.cpp │ │ │ ├── Color.cpp │ │ │ ├── Color_Wheel.cpp │ │ │ ├── Dialog.cpp │ │ │ ├── Dialog │ │ │ │ └── Color_Dialog.cpp │ │ │ ├── Drop_Down_List.cpp │ │ │ ├── File_Explorer.cpp │ │ │ ├── Graphics.cpp │ │ │ ├── Image.cpp │ │ │ ├── Keyboard.cpp │ │ │ ├── Label.cpp │ │ │ ├── Line.cpp │ │ │ ├── List.cpp │ │ │ ├── Object.cpp │ │ │ ├── QRCode.cpp │ │ │ ├── Roller.cpp │ │ │ ├── Screen.cpp │ │ │ ├── Slider.cpp │ │ │ ├── Spinbox.cpp │ │ │ ├── Style.cpp │ │ │ ├── Switch.cpp │ │ │ ├── Table.cpp │ │ │ ├── Tabs.cpp │ │ │ ├── Text_Area.cpp │ │ │ └── Window.cpp │ │ ├── Keyboard │ │ │ ├── Drivers │ │ │ │ ├── Keyboard_None.cpp │ │ │ │ └── Keyboard_PS2.cpp │ │ │ └── Keyboard.cpp │ │ ├── Log │ │ │ └── Log.cpp │ │ ├── Mathematics │ │ │ ├── Hash.cpp │ │ │ ├── Mathematics.cpp │ │ │ └── Rational.cpp │ │ ├── Memory │ │ │ └── Memory.cpp │ │ ├── Module │ │ │ ├── Auto_Semaphore.cpp │ │ │ ├── Base_Types.cpp │ │ │ ├── Date.cpp │ │ │ ├── Instruction.cpp │ │ │ ├── Module.cpp │ │ │ ├── Queue.cpp │ │ │ ├── Registry.cpp │ │ │ ├── Semaphore.cpp │ │ │ ├── String.cpp │ │ │ ├── Task.cpp │ │ │ └── Time.cpp │ │ ├── Pin │ │ │ ├── Drivers │ │ │ │ ├── ESP32.cpp │ │ │ │ └── ESP32_S3.cpp │ │ │ ├── Pin.cpp │ │ │ ├── Serial.cpp │ │ │ └── Two_Wire_Interface.cpp │ │ ├── Power │ │ │ ├── Drivers │ │ │ │ └── Regular_Battery.cpp │ │ │ └── Power.cpp │ │ ├── Software │ │ │ ├── Software.cpp │ │ │ ├── Software_Handle.cpp │ │ │ └── Softwares.cpp │ │ ├── Sound │ │ │ ├── File_Player.cpp │ │ │ └── Sound.cpp │ │ └── System │ │ │ ├── Animation.cpp │ │ │ ├── Informations.cpp │ │ │ ├── Registry.cpp │ │ │ ├── Shutdown.cpp │ │ │ ├── Start.cpp │ │ │ ├── System.cpp │ │ │ └── Time.cpp │ └── versions_registry.xrf ├── berry │ ├── .github │ │ └── workflows │ │ │ └── c-cpp.yml │ ├── .gitignore │ ├── Generate.sh │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── berry-logo.png │ ├── default │ │ ├── be_modtab.c │ │ ├── be_port.c │ │ ├── berry.c │ │ └── berry_conf.h │ ├── docs │ │ ├── Doxyfile │ │ ├── Makefile │ │ ├── conf.py │ │ ├── index.rst │ │ ├── make.bat │ │ ├── requirements.txt │ │ └── source │ │ │ ├── api.rst │ │ │ ├── en │ │ │ ├── Appendix-A.rst │ │ │ ├── Appendix-B.rst │ │ │ ├── Appendix-C.rst │ │ │ ├── Chapter-1.rst │ │ │ ├── Chapter-2.rst │ │ │ ├── Chapter-3.rst │ │ │ ├── Chapter-4.rst │ │ │ ├── Chapter-5.rst │ │ │ ├── Chapter-6.rst │ │ │ ├── Chapter-7.rst │ │ │ ├── Chapter-8.rst │ │ │ ├── Chapter-9.rst │ │ │ ├── FFI-Example.rst │ │ │ ├── Home.rst │ │ │ ├── Memory-Requirements.rst │ │ │ ├── Reference.rst │ │ │ └── Roadmap.rst │ │ │ └── es │ │ │ ├── Apendice-A.rst │ │ │ ├── Apendice-B.rst │ │ │ ├── Apendice-C.rst │ │ │ ├── Capitulo-1.rst │ │ │ ├── Capitulo-2.rst │ │ │ ├── Capitulo-3.rst │ │ │ ├── Capitulo-4.rst │ │ │ ├── Capitulo-5.rst │ │ │ ├── Capitulo-6.rst │ │ │ ├── Capitulo-7.rst │ │ │ ├── Capitulo-8.rst │ │ │ ├── Capitulo-9.rst │ │ │ ├── FFI-Ejemplo.rst │ │ │ ├── Hoja-de-ruta.rst │ │ │ ├── Home.rst │ │ │ ├── Referencia.rst │ │ │ └── Requerimientos-de-Memoria.rst │ ├── examples │ │ ├── anon_func.be │ │ ├── bigloop.be │ │ ├── bintree.be │ │ ├── calcpi.be │ │ ├── exception.be │ │ ├── fib_rec.be │ │ ├── guess_number.be │ │ ├── json.be │ │ ├── lambda.be │ │ ├── listdir.be │ │ ├── qsort.be │ │ ├── repl.be │ │ ├── string.be │ │ └── strmod.be │ ├── generate │ │ ├── be_const_strtab.h │ │ ├── be_const_strtab_def.h │ │ ├── be_fixed_Berry_Arc_Type.h │ │ ├── be_fixed_Berry_Area_Type.h │ │ ├── be_fixed_Berry_Bar_Type.h │ │ ├── be_fixed_Berry_Button_Matrix_Type.h │ │ ├── be_fixed_Berry_Button_Type.h │ │ ├── be_fixed_Berry_Calendar_Type.h │ │ ├── be_fixed_Berry_Checkbox_Type.h │ │ ├── be_fixed_Berry_Color_Dialog_Type.h │ │ ├── be_fixed_Berry_Color_Filter_Descriptor_Type.h │ │ ├── be_fixed_Berry_Color_Type.h │ │ ├── be_fixed_Berry_Color_Wheel_Type.h │ │ ├── be_fixed_Berry_Configuration_Type.h │ │ ├── be_fixed_Berry_Decoder_Type.h │ │ ├── be_fixed_Berry_Dialog_Type.h │ │ ├── be_fixed_Berry_Drop_Down_List_Type.h │ │ ├── be_fixed_Berry_File_Explorer_Type.h │ │ ├── be_fixed_Berry_File_Player_Type.h │ │ ├── be_fixed_Berry_File_Type.h │ │ ├── be_fixed_Berry_HTTPS_Client_Type.h │ │ ├── be_fixed_Berry_Hash_Type.h │ │ ├── be_fixed_Berry_I2S_Configuration_Type.h │ │ ├── be_fixed_Berry_I2S_Type.h │ │ ├── be_fixed_Berry_IP_Address_Type.h │ │ ├── be_fixed_Berry_Image_Type.h │ │ ├── be_fixed_Berry_Keyboard_Type.h │ │ ├── be_fixed_Berry_Label_Type.h │ │ ├── be_fixed_Berry_Line_Type.h │ │ ├── be_fixed_Berry_List_Type.h │ │ ├── be_fixed_Berry_Message_Dialog_Type.h │ │ ├── be_fixed_Berry_Object_Type.h │ │ ├── be_fixed_Berry_Point_Type.h │ │ ├── be_fixed_Berry_Progress_Dialog_Type.h │ │ ├── be_fixed_Berry_QRCode_Type.h │ │ ├── be_fixed_Berry_Rational_Type.h │ │ ├── be_fixed_Berry_Roller_Type.h │ │ ├── be_fixed_Berry_Screen_Type.h │ │ ├── be_fixed_Berry_Serial_Type.h │ │ ├── be_fixed_Berry_Slider_Type.h │ │ ├── be_fixed_Berry_Software_Handle_Type.h │ │ ├── be_fixed_Berry_Software_Type.h │ │ ├── be_fixed_Berry_Spinbox_Type.h │ │ ├── be_fixed_Berry_Stream_Type.h │ │ ├── be_fixed_Berry_Style_Type.h │ │ ├── be_fixed_Berry_Switch_Type.h │ │ ├── be_fixed_Berry_Table_Type.h │ │ ├── be_fixed_Berry_Tabs_Type.h │ │ ├── be_fixed_Berry_Text_Area_Type.h │ │ ├── be_fixed_Berry_Two_Wire_Type.h │ │ ├── be_fixed_Berry_Volume_Configuration_Type.h │ │ ├── be_fixed_Berry_Volume_Type.h │ │ ├── be_fixed_Berry_WAV_Decoder_Type.h │ │ ├── be_fixed_Berry_WiFi_Client_Type.h │ │ ├── be_fixed_Berry_Window_Type.h │ │ ├── be_fixed_Clipboard.h │ │ ├── be_fixed_Communication.h │ │ ├── be_fixed_Drive.h │ │ ├── be_fixed_Flash.h │ │ ├── be_fixed_Graphics.h │ │ ├── be_fixed_Mathematics.h │ │ ├── be_fixed_Memory.h │ │ ├── be_fixed_Pin.h │ │ ├── be_fixed_Softwares.h │ │ ├── be_fixed_Sound.h │ │ ├── be_fixed_System.h │ │ ├── be_fixed_This.h │ │ ├── be_fixed_be_class_Berry_Date_Type.h │ │ ├── be_fixed_be_class_Berry_Instruction_Type.h │ │ ├── be_fixed_be_class_Berry_Long_Integer_Type.h │ │ ├── be_fixed_be_class_Berry_Long_Real_Type.h │ │ ├── be_fixed_be_class_Berry_Module_Type.h │ │ ├── be_fixed_be_class_Berry_Time_Type.h │ │ ├── be_fixed_be_class_bytes.h │ │ ├── be_fixed_be_class_list.h │ │ ├── be_fixed_be_class_map.h │ │ ├── be_fixed_be_class_range.h │ │ ├── be_fixed_cb.h │ │ ├── be_fixed_debug.h │ │ ├── be_fixed_gc.h │ │ ├── be_fixed_global.h │ │ ├── be_fixed_introspect.h │ │ ├── be_fixed_json.h │ │ ├── be_fixed_m_builtin.h │ │ ├── be_fixed_math.h │ │ ├── be_fixed_os.h │ │ ├── be_fixed_os_path.h │ │ ├── be_fixed_solidify.h │ │ ├── be_fixed_strict.h │ │ ├── be_fixed_string.h │ │ ├── be_fixed_sys.h │ │ ├── be_fixed_time.h │ │ └── be_fixed_undefined.h │ ├── get-pip.py │ ├── src │ │ ├── be_api.c │ │ ├── be_baselib.c │ │ ├── be_bytecode.c │ │ ├── be_bytecode.h │ │ ├── be_byteslib.c │ │ ├── be_class.c │ │ ├── be_class.h │ │ ├── be_code.c │ │ ├── be_code.h │ │ ├── be_constobj.h │ │ ├── be_debug.c │ │ ├── be_debug.h │ │ ├── be_debuglib.c │ │ ├── be_decoder.h │ │ ├── be_exec.c │ │ ├── be_exec.h │ │ ├── be_filelib.c │ │ ├── be_func.c │ │ ├── be_func.h │ │ ├── be_gc.c │ │ ├── be_gc.h │ │ ├── be_gclib.c │ │ ├── be_globallib.c │ │ ├── be_introspectlib.c │ │ ├── be_jsonlib.c │ │ ├── be_lexer.c │ │ ├── be_lexer.h │ │ ├── be_libs.c │ │ ├── be_libs.h │ │ ├── be_list.c │ │ ├── be_list.h │ │ ├── be_listlib.c │ │ ├── be_map.c │ │ ├── be_map.h │ │ ├── be_maplib.c │ │ ├── be_mathlib.c │ │ ├── be_mem.c │ │ ├── be_mem.h │ │ ├── be_module.c │ │ ├── be_module.h │ │ ├── be_object.c │ │ ├── be_object.h │ │ ├── be_opcodes.h │ │ ├── be_oslib.c │ │ ├── be_parser.c │ │ ├── be_parser.h │ │ ├── be_rangelib.c │ │ ├── be_repl.c │ │ ├── be_repl.h │ │ ├── be_solidifylib.c │ │ ├── be_strictlib.c │ │ ├── be_string.c │ │ ├── be_string.h │ │ ├── be_strlib.c │ │ ├── be_strlib.h │ │ ├── be_sys.h │ │ ├── be_syslib.c │ │ ├── be_timelib.c │ │ ├── be_undefinedlib.c │ │ ├── be_var.c │ │ ├── be_var.h │ │ ├── be_vector.c │ │ ├── be_vector.h │ │ ├── be_vm.c │ │ ├── be_vm.h │ │ ├── berry.h │ │ └── berry_conf.h │ ├── testall.be │ ├── tests │ │ ├── assignment.be │ │ ├── bitwise.be │ │ ├── bool.be │ │ ├── bytes.be │ │ ├── bytes_b64.be │ │ ├── bytes_fixed.be │ │ ├── call.be │ │ ├── checkspace.be │ │ ├── class.be │ │ ├── class_const.be │ │ ├── class_static.be │ │ ├── closure.be │ │ ├── compiler.be │ │ ├── compound.be │ │ ├── cond_expr.be │ │ ├── debug.be │ │ ├── exceptions.be │ │ ├── for.be │ │ ├── function.be │ │ ├── global.be │ │ ├── int.be │ │ ├── introspect.be │ │ ├── introspect_ismethod.be │ │ ├── json.be │ │ ├── json_advanced.be │ │ ├── json_test_cases.json │ │ ├── json_test_stack_size.be │ │ ├── lexer.be │ │ ├── lexergc.be │ │ ├── list.be │ │ ├── map.be │ │ ├── math.be │ │ ├── member_indirect.be │ │ ├── module.be │ │ ├── os.be │ │ ├── overload.be │ │ ├── reference.be │ │ ├── relop.be │ │ ├── string.be │ │ ├── subobject.be │ │ ├── suffix.be │ │ ├── super_auto.be │ │ ├── super_leveled.be │ │ ├── vararg.be │ │ ├── virtual_methods.be │ │ └── virtual_methods2.be │ └── tools │ │ ├── coc │ │ ├── block_builder.py │ │ ├── coc │ │ ├── coc_parser.py │ │ ├── coc_string.py │ │ ├── coc_string_test.py │ │ ├── hash_map.py │ │ ├── macro_table.py │ │ └── str_build.py │ │ ├── grammar │ │ ├── berry.bytecode │ │ ├── berry.ebnf │ │ ├── const_obj.ebnf │ │ └── json.ebnf │ │ ├── highlighters │ │ └── Pygments │ │ │ └── berry.py │ │ └── plugins │ │ └── vscode │ │ └── skiars.berry-0.1.0 │ │ ├── .vsixmanifest │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── berry-configuration.json │ │ ├── berry-icon.png │ │ ├── package.json │ │ └── syntaxes │ │ ├── berry.json │ │ └── bytecode.json └── berry_mapping │ ├── LICENSE │ ├── README.md │ └── src │ ├── be_cb_module.c │ ├── be_class_wrapper.c │ ├── be_const_members.c │ ├── be_mapping.h │ ├── be_mapping_utils.c │ └── be_raisef.c ├── platformio.ini ├── src └── main.cpp └── test ├── README ├── Rational └── test_Rational.cpp └── test_String ├── Unit_Test_String.cpp ├── Unit_Test_String.hpp └── main.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | *.py linguist-vendored 2 | *.c linguist-vendored 3 | *.h linguist-vendored 4 | -------------------------------------------------------------------------------- /.github/workflows/build_code.yml: -------------------------------------------------------------------------------- 1 | name: PlatformIO CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | with: 12 | submodules: recursive 13 | - uses: actions/cache@v3 14 | with: 15 | path: | 16 | ~/.cache/pip 17 | ~/.platformio/.cache 18 | key: ${{ runner.os }}-pio 19 | - uses: actions/setup-python@v4 20 | with: 21 | python-version: '3.9' 22 | - name: Install PlatformIO Core 23 | run: pip install --upgrade platformio 24 | 25 | - name: Build PlatformIO Project 26 | run: pio run --project-dir="./" 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode 3 | 4 | *.d 5 | 6 | *.pyc 7 | 8 | .VSCodeCounter -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/File_Manager"] 2 | path = lib/File_Manager 3 | url = https://github.com/Xila-Project/File_Manager.git 4 | [submodule "lib/Preferences"] 5 | path = lib/Preferences 6 | url = https://github.com/Xila-Project/Preferences.git 7 | [submodule "lib/Berry"] 8 | path = lib/Berry 9 | url = https://github.com/Xila-Project/Berry.git 10 | [submodule "lib/Shell"] 11 | path = lib/Shell 12 | url = https://github.com/Xila-Project/Shell.git 13 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Build documentation in the docs/ directory with Sphinx 9 | sphinx: 10 | configuration: Documentation/source/conf.py 11 | 12 | # Optionally build your docs in additional formats such as PDF 13 | formats: all 14 | 15 | # Optionally set the version of Python and requirements required to build your docs 16 | python: 17 | version: 3.7 18 | install: 19 | - requirements: Documentation/requirements.txt -------------------------------------------------------------------------------- /Configurations/ESP32-8048S070.ini: -------------------------------------------------------------------------------- 1 | [env:ESP32-8048S070] 2 | 3 | ; - - Board 4 | platform = espressif32 5 | board = wt32-sc01-plus 6 | board_build.arduino.memory_type = dio_opi 7 | 8 | upload_protocol = esptool 9 | 10 | monitor_filters = ${env.monitor_filters} 11 | esp32_exception_decoder 12 | 13 | lib_deps = 14 | ${env.lib_deps} 15 | moononournation/GFX Library for Arduino @ ^1.3.6 16 | https://github.com/TAMCTec/gt911-arduino.git ; - Touch screen 17 | 18 | build_flags = 19 | ${env.build_flags} 20 | 21 | 22 | -D Arduino 23 | 24 | ; - Board 25 | -D Xila_Board_Hardware_ESP32_8048S070 26 | 27 | ; - Display 28 | -D Xila_Display_Hardware_ESP32_8048S070 29 | 30 | ; Drive 31 | -D Xila_Drive_Hardware_SD_SPI 32 | -D SD_SPI_Clock_Pin=12 33 | -D SD_SPI_Select_Pin=10 34 | -D SD_SPI_Master_In=13 35 | -D SD_SPI_Master_Out=11 36 | -D SD_SPI_Frequency=4000000 37 | 38 | ; Sound 39 | -D Xila_Sound_Default_I2S_Clock_Pin=0 40 | -D Xila_Sound_Default_I2S_Word_Select_Pin=18 41 | -D Xila_Sound_Default_I2S_Data_Pin=17 42 | 43 | ; Keyboard 44 | -D Xila_Keyboard_Hardware_None 45 | -D Default_Keyboard_Data_Pin=GPIO_NUM_32 46 | -D Default_Keyboard_Clock_Pin=GPIO_NUM_22 47 | 48 | ; WiFi 49 | -D Xila_WiFi_Hardware_ESP32 50 | 51 | ; Input / Output 52 | -D Xila_Pin_Hardware_ESP32_S3 53 | 54 | -D CORE_DEBUG_LEVEL=5 55 | 56 | -D USE_LV_LOG=1 57 | -D LV_CONF_SKIP -------------------------------------------------------------------------------- /Configurations/Hardware_Development_Kit.ini: -------------------------------------------------------------------------------- 1 | ; Hardware configuration file. 2 | 3 | [env:Hardware_Development_Kit] 4 | 5 | platform = ${env:WT32-SC01_Plus.platform} 6 | board = ${env:WT32-SC01_Plus.board} 7 | 8 | upload_protocol = ${env:WT32-SC01_Plus.upload_protocol} 9 | 10 | monitor_filters = ${env:WT32-SC01_Plus.monitor_filters} 11 | 12 | build_flags = 13 | ${env:WT32-SC01_Plus.build_flags} 14 | 15 | ; - Power 16 | ; - - Power button 17 | -D Xila_Power_Button_Default_Pin=14 18 | -D Xila_Power_Button_Default_Long_Press_Time=4000 19 | ; - - Battery 20 | -D Xila_Power_Battery_Default_Sensing_Pin=10 21 | -D Xila_Power_Battery_Default_Conversion_Factor=2 22 | -D Xila_Power_Default_Shutdown_Pin=21 23 | -D Xila_Power_Battery_Default_Minimum_Voltage=3100 ; Minimum voltage of the provided IC. 24 | -D Xila_Power_Battery_Default_Maximum_Voltage=4050 ; Compensate the lack of precision of the ADC. 25 | 26 | ; - Audio 27 | -D Xila_Sound_Default_Maximum_Volume=0.6 ; Maximum volume of the 1W speaker. -------------------------------------------------------------------------------- /Configurations/WT32-SC01.ini: -------------------------------------------------------------------------------- 1 | 2 | [env:WT32-SC01] 3 | 4 | ; - - Board 5 | platform = espressif32 6 | board = esp-wrover-kit 7 | ; - - Upload 8 | upload_protocol = esptool 9 | upload_speed = 921600 10 | ; - - Partition 11 | 12 | ; - - Associated constants 13 | monitor_filters = ${env.monitor_filters} 14 | esp32_exception_decoder 15 | 16 | lib_deps = 17 | ${env.lib_deps} 18 | lovyan03/LovyanGFX @ ^0.4.1 19 | 20 | build_flags = 21 | 22 | 23 | ${env.build_flags} 24 | 25 | -D Arduino 26 | ; Board 27 | 28 | -D Xila_Board_Hardware_Wireless_Tag_WT32_SC01 29 | 30 | ; Processor 31 | 32 | -D Xila_Processor_Hardware_ESP32 33 | 34 | -D Xila_Processor_Hardware_Register_Size=32 35 | 36 | ; Display 37 | -D Xila_Display_Hardware_Wireless_Tag_WT32_SC01 38 | 39 | ; Drive 40 | -D Xila_Drive_Hardware_SD_SPI 41 | -D SD_SPI_Clock_Pin=4 42 | -D SD_SPI_Select_Pin=2 43 | -D SD_SPI_Master_In=27 44 | -D SD_SPI_Master_Out=5 45 | -D SD_SPI_Frequency=4000000 46 | 47 | ; Sound 48 | -D Xila_Sound_Default_I2S_Clock_Pin=23 49 | -D Xila_Sound_Default_I2S_Word_Select_Pin=26 50 | -D Xila_Sound_Default_I2S_Data_Pin=25 51 | 52 | ; Keyboard 53 | -D Xila_Keyboard_Hardware_PS2 54 | -D Default_Keyboard_Data_Pin=GPIO_NUM_32 55 | -D Default_Keyboard_Clock_Pin=GPIO_NUM_22 56 | 57 | ; WiFi 58 | -D Xila_WiFi_Hardware_ESP32 59 | 60 | ; Input / Output 61 | -D Xila_Pin_Hardware_ESP32 62 | -------------------------------------------------------------------------------- /Configurations/WT32-SC01_Plus.ini: -------------------------------------------------------------------------------- 1 | [env:WT32-SC01_Plus] 2 | 3 | ; - - Board 4 | platform = espressif32 5 | board = wt32-sc01-plus 6 | ; - - Upload 7 | ;upload_protocol = esp-tools 8 | ;upload_protocol = esp-prog 9 | upload_protocol = esp-builtin 10 | 11 | 12 | board_upload.before_reset = usb_reset 13 | ; - - Associated constants 14 | monitor_filters = ${env.monitor_filters} 15 | esp32_exception_decoder 16 | 17 | lib_deps = 18 | ${env.lib_deps} 19 | lovyan03/LovyanGFX @ ^0.4.1 20 | USB 21 | 22 | build_flags = 23 | ${env.build_flags} 24 | 25 | -D Arduino 26 | 27 | ; - Board 28 | -D Xila_Board_Hardware_Wireless_Tag_WT32_SC01_Plus 29 | 30 | ; - Display 31 | -D Xila_Display_Hardware_Wireless_Tag_WT32_SC01_Plus 32 | 33 | ; Drive 34 | -D Xila_Drive_Hardware_SD_SPI 35 | -D SD_SPI_Clock_Pin=39 36 | -D SD_SPI_Select_Pin=41 37 | -D SD_SPI_Master_In=38 38 | -D SD_SPI_Master_Out=40 39 | -D SD_SPI_Frequency=4000000 40 | 41 | 42 | ; Sound 43 | -D Xila_Sound_Default_I2S_Clock_Pin=36 44 | -D Xila_Sound_Default_I2S_Word_Select_Pin=35 45 | -D Xila_Sound_Default_I2S_Data_Pin=37 46 | 47 | ; Keyboard 48 | -D Xila_Keyboard_Hardware_None 49 | -D Default_Keyboard_Data_Pin=GPIO_NUM_32 50 | -D Default_Keyboard_Clock_Pin=GPIO_NUM_22 51 | 52 | ; WiFi 53 | -D Xila_WiFi_Hardware_ESP32 54 | 55 | ; Input / Output 56 | -D Xila_Pin_Hardware_ESP32_S3 57 | 58 | -D CORE_DEBUG_LEVEL=5 59 | 60 | -D USE_LV_LOG=1 61 | -D LV_CONF_SKIP 62 | -D LV_CONF_INCLUDE_SIMPLE 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Drive/Xila/Sounds/Shutdown.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xila-Project/Old_core/4a8fc6a3a11cefc460a450c76e6231681c53be6a/Drive/Xila/Sounds/Shutdown.wav -------------------------------------------------------------------------------- /Drive/Xila/Sounds/Startup.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xila-Project/Old_core/4a8fc6a3a11cefc460a450c76e6231681c53be6a/Drive/Xila/Sounds/Startup.wav -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 AlixFaitGrr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | app0, app, ota_0, 0x10000, 0x300000, 5 | spiffs, data, spiffs, 0x310000,0xE0000, 6 | coredump, data, coredump,0x3F0000,0x10000, -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Xila Code repository 2 | 3 | This repository contains all of the source code of Xila. 4 | -------------------------------------------------------------------------------- /boards/wt32-sc01-plus.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino":{ 4 | "ldscript": "esp32s3_out.ld", 5 | "partitions": "default_16MB.csv" 6 | }, 7 | "core": "esp32", 8 | "extra_flags": [ 9 | "-DARDUINO_ESP32S3_DEV", 10 | "-DARDUINO_USB_MODE=1", 11 | "-DARDUINO_RUNNING_CORE=1", 12 | "-DARDUINO_EVENT_RUNNING_CORE=1" 13 | ], 14 | "f_cpu": "240000000L", 15 | "f_flash": "80000000L", 16 | "flash_mode": "qio", 17 | "hwids": [ 18 | [ 19 | "0x303A", 20 | "0x1001" 21 | ] 22 | ], 23 | "mcu": "esp32s3", 24 | "variant": "esp32s3" 25 | }, 26 | "connectivity": [ 27 | "wifi" 28 | ], 29 | "debug": { 30 | "default_tool": "esp-builtin", 31 | "onboard_tools": [ 32 | "esp-builtin" 33 | ], 34 | "openocd_target": "esp32s3.cfg" 35 | }, 36 | "frameworks": [ 37 | "arduino", 38 | "espidf" 39 | ], 40 | "name": "Wireless Tag WT32-SC01 Plus", 41 | "upload": { 42 | "flash_size": "16MB", 43 | "maximum_ram_size": 327680, 44 | "maximum_size": 8388608, 45 | "require_upload_port": true, 46 | "speed": 460800 47 | }, 48 | "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", 49 | "vendor": "Wireless Tag" 50 | } -------------------------------------------------------------------------------- /hal/sdl2/app_hal.h: -------------------------------------------------------------------------------- 1 | #ifndef DRIVER_H 2 | #define DRIVER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | 9 | void hal_setup(void); 10 | void hal_loop(void); 11 | 12 | 13 | #ifdef __cplusplus 14 | } /* extern "C" */ 15 | #endif 16 | 17 | #endif /*DRIVER_H*/ 18 | -------------------------------------------------------------------------------- /lib/Xila/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /lib/Xila/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/Xila/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.XRF": "json", 4 | "system_error": "cpp", 5 | "array": "cpp", 6 | "functional": "cpp", 7 | "tuple": "cpp", 8 | "type_traits": "cpp", 9 | "utility": "cpp", 10 | "algorithm": "cpp", 11 | "string": "cpp", 12 | "*.tcc": "cpp", 13 | "fstream": "cpp" 14 | }, 15 | "C_Cpp.dimInactiveRegions": false 16 | } -------------------------------------------------------------------------------- /lib/Xila/include/Communication/Communication.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Communication.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 20-07-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef Communication_Hpp_Included 12 | #define Communication_Hpp_Included 13 | 14 | #include "IP_Address.hpp" 15 | #include "WiFi.hpp" 16 | #include "HTTP_Client.hpp" 17 | 18 | namespace Xila_Namespace 19 | { 20 | namespace Communication_Types 21 | { 22 | 23 | } 24 | 25 | /// @brief Communication module class. 26 | typedef class Communication_Class 27 | { 28 | public: 29 | 30 | /// @brief Start the communication module and sub-modules. 31 | /// @return `Result_Type` 32 | Result_Type Start(); 33 | 34 | /// @brief Stop the communication module and sub-modules. 35 | /// @return `Result_Type` 36 | Result_Type Stop(); 37 | 38 | /// @brief WiFi sub-module instance. 39 | Communication_Types::WiFi_Type WiFi; 40 | 41 | } Communication_Type; 42 | 43 | /// @brief Communication module instance. 44 | extern Communication_Type Communication; 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/Xila/include/Configuration/Path.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Path.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.2 6 | /// @date 11-07-2021 7 | /// 8 | /// @copyright Copyright (c) 2021 9 | /// 10 | 11 | #ifndef PATH_HPP_INCLUDED 12 | #define PATH_HPP_INCLUDED 13 | 14 | #define String_Concat(first, second) first second 15 | 16 | #define Xila_Directory_Path "/Xila" 17 | #define Software_Directory_Path "/Software" 18 | #define Users_Directory_Path "/Users" 19 | 20 | #define Registry_File_Extension ".xrf" 21 | #define Data_File_Extension ".xdf" // mainly used for undefined data type 22 | #define Executable_File_Extension ".xef" 23 | #define Sound_File_Extension ".wav" 24 | #define Basic_File_Extension ".bas" 25 | 26 | // -- Main system directory 27 | #define Temporary_Directory_Path Xila_Directory_Path "/Temporary" 28 | #define Sounds_Directory_Path Xila_Directory_Path "/Sounds" 29 | #define Executable_Directory_Path Xila_Directory_Path "/Executab" 30 | #define Variable_Directory_Path Xila_Directory_Path "/Variable" 31 | #define Registry_Directory_Path Xila_Directory_Path "/Registry" 32 | 33 | #define Registry(name) Registry_Directory_Path "/" name Registry_File_Extension //shortcut 34 | #define Variable(name) Variable_Directory_Path "/" name 35 | #define Sounds(name) Sounds_Directory_Path "/" name 36 | #define Executable(name) Executable_Directory_Path "/" name 37 | #define Temporary(name) Temporary_Directory_Path "/" name 38 | 39 | #define Dump_Registry_Path Temporary_Directory_Path "/Dump" Registry_File_Extension 40 | 41 | #define Clipboard_Path Temporary_Directory_Path "/Clipboar" Data_File_Extension 42 | #define Test_Path Temporary_Directory_Path "/Test" Data_File_Extension 43 | 44 | #define Display_Executable_Path "/tft" 45 | #define Microcontroller_Executable_Path Executable_Directory_Path "/xef" 46 | 47 | #undef String_Concat 48 | 49 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Display/Configuration.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Configuration.hpp 3 | /// @author Alix ANNERAUD (alix@anneraud.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 05-03-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #pragma once 12 | 13 | #ifdef Xila_Board_Hardware_Wireless_Tag_WT32_SC01 14 | #define Display_Horizontal_Definition=480 15 | #define Display_Vertical_Definition=320 16 | #endif 17 | 18 | #ifdef Xila_Board_Hardware_Wireless_Tag_WT32_SC01 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Area.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Area.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 09-07-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef Area_Hpp_Included 12 | #define Area_Hpp_Included 13 | 14 | #include "lvgl.h" 15 | 16 | #include "Types.hpp" 17 | 18 | namespace Xila_Namespace 19 | { 20 | namespace Graphics_Types 21 | { 22 | /// @brief Area class. 23 | typedef class Area_Class 24 | { 25 | public: 26 | // - Types 27 | 28 | 29 | // - Methods 30 | 31 | // - - Management 32 | 33 | void Increase(Coordinate_Type Extra_Width, Coordinate_Type Extra_Height); 34 | void Move(Coordinate_Type X_Offset, Coordinate_Type Y_Offset); 35 | void Align(Area_Class To_Align_To, Alignment_Type Alignment, Coordinate_Type X_Offset, Coordinate_Type Y_Offset); 36 | 37 | // - - Setters 38 | 39 | void Set(lv_area_t Area); 40 | 41 | void Set(Coordinate_Type X_1, Coordinate_Type Y_1, Coordinate_Type X_2, Coordinate_Type Y_2); 42 | void Set_Width(Coordinate_Type Width); 43 | void Set_Height(Coordinate_Type Height); 44 | 45 | // - - Getters 46 | 47 | Coordinate_Type Get_Width(); 48 | Coordinate_Type Get_Height(); 49 | uint32_t Get_Size(); 50 | 51 | operator lv_area_t() 52 | { 53 | return LVGL_Area; 54 | } 55 | 56 | lv_area_t LVGL_Area; 57 | } Area_Type; 58 | 59 | } // namespace Graphics_Types 60 | } // namespace Xila_Namespace 61 | 62 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Checkbox.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Checkbox.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 08-05-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef Checkbox_Hpp_Included 12 | #define Checkbox_Hpp_Included 13 | 14 | #include "Object.hpp" 15 | 16 | namespace Xila_Namespace 17 | { 18 | 19 | namespace Graphics_Types 20 | { 21 | /// @brief Checkbox class. 22 | typedef class Checkbox_Class : public Object_Class 23 | { 24 | public: 25 | // - Types 26 | 27 | typedef enum Draw_Part_Enumeration 28 | { 29 | Box = LV_CHECKBOX_DRAW_PART_BOX, 30 | } Draw_Part_Type; 31 | 32 | // - Methods 33 | Checkbox_Class(); 34 | Checkbox_Class(const Object_Class &Object_To_Copy); 35 | 36 | virtual void Create(Object_Class Parent_Object) override; 37 | // - - Setters. 38 | 39 | virtual bool Set_Pointer(lv_obj_t *LVGL_Object_Pointer) override; 40 | 41 | void Set_Text(const char *Text); 42 | void Set_Text_Static(const char *Text); 43 | 44 | // - - Getters. 45 | const char *Get_Text(); 46 | 47 | // - Attributes 48 | static const Class_Type &Class; 49 | 50 | } Checkbox_Type; 51 | } // namespace Graphics_Types 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Color_Wheel.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Color_Picker.hpp 3 | /// @author () 4 | /// @brief 5 | /// @version 0.1 6 | /// @date 04-05-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef Color_Wheel_Hpp_Included 12 | #define Color_Wheel_Hpp_Included 13 | 14 | #include "Object.hpp" 15 | 16 | namespace Xila_Namespace 17 | { 18 | namespace Graphics_Types 19 | { 20 | enum class Color_Wheel_Mode_Type : lv_colorwheel_mode_t 21 | { 22 | Hue = LV_COLORWHEEL_MODE_HUE, 23 | Saturation = LV_COLORWHEEL_MODE_SATURATION, 24 | Value = LV_COLORWHEEL_MODE_VALUE 25 | }; 26 | 27 | typedef class Color_Wheel_Class : public Object_Class 28 | { 29 | public: 30 | // - Methods 31 | 32 | // - - Constructors / destructors 33 | Color_Wheel_Class(); 34 | Color_Wheel_Class(const Object_Class &Object_To_Copy); 35 | 36 | // - - Manipulation 37 | virtual void Create(Object_Class Parent_Object) override; 38 | virtual void Create(Object_Class Parent_Object, bool Knob_Recolor); 39 | 40 | // - - Getters 41 | Color_Wheel_Mode_Type Get_Mode(); 42 | bool Get_Mode_Fixed(); 43 | Color_Type Get_Color(); 44 | 45 | // - - Setters 46 | bool Set_Color(Color_Type Color); 47 | void Set_Mode(Color_Wheel_Mode_Type Mode); 48 | void Set_Mode_Fixed(bool Fixed); 49 | virtual bool Set_Pointer(lv_obj_t *LVGL_Object_Pointer) override; 50 | 51 | // - Attributes 52 | static const Class_Type &Class; 53 | 54 | } Color_Wheel_Type; 55 | } // namespace Graphics_Types 56 | } // namespace Xila_Namespace 57 | 58 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Line.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Line.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 10-05-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef LINE_HPP_INCLUDED 12 | #define LINE_HPP_INCLUDED 13 | 14 | #include "Object.hpp" 15 | 16 | namespace Xila_Namespace 17 | { 18 | namespace Graphics_Types 19 | { 20 | /// @brief Line class. 21 | typedef class Line_Class : public Object_Class 22 | { 23 | public: 24 | // - Methods 25 | 26 | // - - Constructors / destructors 27 | Line_Class(); 28 | Line_Class(const Object_Class &Object_To_Copy); 29 | 30 | // - - Manipulation 31 | virtual void Create(Object_Class Parent_Object) override; 32 | 33 | // - - Setters 34 | virtual bool Set_Pointer(lv_obj_t *LVGL_Object_Pointer) override; 35 | 36 | void Set_Points(const Point_Type *Points, uint16_t Number); 37 | void Set_Y_Inversion(bool Inversion); 38 | 39 | // - - Getters 40 | bool Get_Y_Inversion(); 41 | 42 | // - - Attributes 43 | static const Class_Type &Class; 44 | } Line_Type; 45 | } // namespace Graphics_Types 46 | } // namespace Xila_Namespace 47 | 48 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/List.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file List.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 04-05-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef LIST_HPP_INCLUDED 12 | #define LIST_HPP_INCLUDED 13 | 14 | #include "Object.hpp" 15 | #include "Label.hpp" 16 | #include "Button.hpp" 17 | 18 | namespace Xila_Namespace 19 | { 20 | namespace Graphics_Types 21 | { 22 | /// @brief List class. 23 | typedef class List_Class : public Object_Class 24 | { 25 | public: 26 | // - Methods 27 | 28 | // - - Constructors / destructors 29 | List_Class(); 30 | List_Class(const Object_Class &Object_To_Copy); 31 | 32 | // - - Manipulation 33 | virtual void Create(Object_Class Parent_Object) override; 34 | 35 | Object_Type Add_Text(const char *Text); 36 | Object_Type Add_Button(const char *Icon, const char *Text); 37 | 38 | // - - Setters 39 | virtual bool Set_Pointer(lv_obj_t *LVGL_Object_Pointer) override; 40 | 41 | // - - Getters 42 | const char *Get_Button_Text(Button_Class &Button); 43 | 44 | // - Attributes 45 | static const Class_Type &Class; 46 | } List_Type; 47 | 48 | } // namespace Graphics_Types 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Menu.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Menu.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 18-07-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef Menu_Hpp_Included 12 | #define Menu_Hpp_Included 13 | 14 | /* 15 | /// @brief Menu class 16 | class Menu_Class : public Object_Class 17 | { 18 | public: 19 | // -- Methods 20 | typedef lv_menu_mode_header_t Mode_Header_Type; 21 | 22 | enum 23 | { 24 | Top_Fixed = LV_MENU_HEADER_TOP_FIXED, 25 | Top_Unfixed = LV_MENU_HEADER_TOP_UNFIXED, 26 | Bottom_Fixed = LV_MENU_HEADER_BOTTOM_FIXED, 27 | }; 28 | 29 | typedef lv_menu_mode_root_back_btn_t Mode_Root_Back_Button_Type; 30 | 31 | enum 32 | { 33 | Back_Button_Disabled = LV_MENU_ROOT_BACK_BTN_DISABLED, 34 | Back_Button_Enabled = LV_MENU_ROOT_BACK_BTN_ENABLED, 35 | }; 36 | 37 | Object_Class Create_Content(Object_Class Parent_Object); 38 | Object_Class Create_Section(Object_Class Parent_Object); 39 | Object_Class Create_Separator(Object_Class Parent_Object); 40 | 41 | void Set_Page(Object_Class Page); 42 | void Set_Sidebar_Page(Object_Class Page); 43 | }; 44 | */ 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Meter.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xila-Project/Old_core/4a8fc6a3a11cefc460a450c76e6231681c53be6a/lib/Xila/include/Graphics/Meter.hpp -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Point.hpp: -------------------------------------------------------------------------------- 1 | /// @file Point.hpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief 4 | /// @version 0.1.0 5 | /// @date 07-05-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | 9 | #ifndef Point_Hpp_Included 10 | #define Point_Hpp_Included 11 | 12 | #include "Types.hpp" 13 | #include "lvgl.h" 14 | 15 | namespace Xila_Namespace 16 | { 17 | namespace Graphics_Types 18 | { 19 | typedef class Point_Class 20 | { 21 | public: 22 | Point_Class() 23 | { 24 | Point.x = 0; 25 | Point.y = 0; 26 | } 27 | Point_Class(Coordinate_Type X, Coordinate_Type Y) 28 | { 29 | Point.x = X; 30 | Point.y = Y; 31 | } 32 | 33 | void Set(Coordinate_Type X, Coordinate_Type Y) 34 | { 35 | this->Point.x = X; 36 | this->Point.y = Y; 37 | } 38 | 39 | void Set_X(Coordinate_Type X) 40 | { 41 | this->Point.x = X; 42 | } 43 | 44 | void Set_Y(Coordinate_Type Y) 45 | { 46 | this->Point.y = Y; 47 | } 48 | 49 | Coordinate_Type Get_X() const 50 | { 51 | return Point.x; 52 | } 53 | 54 | Coordinate_Type Get_Y() const 55 | { 56 | return Point.y; 57 | } 58 | 59 | operator lv_point_t() const 60 | { 61 | return Point; 62 | } 63 | 64 | operator lv_point_t *() 65 | { 66 | return &Point; 67 | } 68 | 69 | private: 70 | lv_point_t Point; 71 | } Point_Type; 72 | 73 | } 74 | } 75 | 76 | #endif // Point_Hpp_Included -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/QRCode.hpp: -------------------------------------------------------------------------------- 1 | /// @file QRCode.hpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief 4 | /// @version 0.1.0 5 | /// @date 23-03-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | /// 9 | 10 | #if LV_USE_QRCODE != 0 11 | #ifndef QRCode_Hpp_Included 12 | #define QRCode_Hpp_Included 13 | 14 | #include "Object.hpp" 15 | 16 | namespace Xila_Namespace 17 | { 18 | namespace Graphics_Types 19 | { 20 | typedef class QRCode_Class : public Object_Class 21 | { 22 | public: 23 | // - Methods 24 | 25 | // - - Constructor / destructor 26 | QRCode_Class(const Object_Type &Object); 27 | QRCode_Class(); 28 | ~QRCode_Class(); 29 | 30 | // - - Manipulation 31 | virtual void Create(Object_Type Parent_Object) override; 32 | void Create(Object_Type Parent_Object, const void* Data, uint32_t Length, Coordinate_Type Size, Color_Type Dark_Color = Color_Type::Black, Color_Type Light_Color = Color_Type::White); 33 | 34 | void Update(const void* Data, uint32_t Length); 35 | 36 | // - Attributes 37 | 38 | /// @brief QRCode class type. 39 | static const Class_Type &Class; 40 | } QRCode_Type; 41 | } // namespace Graphics_Namespace 42 | 43 | } // namespace Xila_Namespace 44 | 45 | #endif // QRCode_Hpp_Included 46 | #endif // LV_USE_QRCODE != 0 -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Roller.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Roller.hpp 3 | /// @author () 4 | /// @brief 5 | /// @version 0.1 6 | /// @date 04-05-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef Roller_Hpp_Included 12 | #define Roller_Hpp_Included 13 | 14 | #include "Object.hpp" 15 | 16 | namespace Xila_Namespace 17 | { 18 | namespace Graphics_Types 19 | { 20 | enum class Roller_Mode_Type 21 | { 22 | Normal = LV_ROLLER_MODE_NORMAL, 23 | Infinite = LV_ROLLER_MODE_INFINITE 24 | }; 25 | 26 | /// @brief Roller class. 27 | typedef class Roller_Class : public Object_Class 28 | { 29 | public: 30 | // -- Types 31 | 32 | // - Methods 33 | 34 | // - - Constructors / destructors 35 | Roller_Class(); 36 | Roller_Class(const Object_Class &Object_To_Copy); 37 | 38 | // - - Manipulation 39 | virtual void Create(Object_Class Parent_Object) override; 40 | 41 | // - - Setters 42 | virtual bool Set_Pointer(lv_obj_t *LVGL_Object_Pointer) override; 43 | 44 | void Set_Options(const char *Options, Roller_Mode_Type Mode); 45 | void Set_Selected(uint16_t Index, bool Animated); 46 | void Set_Visible_Row_Count(uint8_t Row_Count); 47 | 48 | // - - Getters 49 | uint16_t Get_Selected(); 50 | String_Type &Get_Selected_String(String_Type &String); 51 | const char *Get_Options(); 52 | uint16_t Get_Option_Count(); 53 | 54 | // - Attributes 55 | static const Class_Type &Class; 56 | } Roller_Type; 57 | } // namespace Graphics_Types 58 | } // namespace Xila_Namespace 59 | 60 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Switch.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Switch.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 14-07-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef Switch_Hpp_Included 12 | #define Switch_Hpp_Included 13 | 14 | #include "Object.hpp" 15 | 16 | namespace Xila_Namespace 17 | { 18 | namespace Graphics_Types 19 | { 20 | typedef class Switch_Class : public Object_Class 21 | { 22 | public: 23 | // - Methods 24 | 25 | // - - Constructors / destructors 26 | Switch_Class(); 27 | Switch_Class(const Object_Class &Object_To_Copy); 28 | 29 | // - - Manipulation 30 | virtual void Create(Object_Class Parent_Object) override; 31 | 32 | // - - Setters 33 | virtual bool Set_Pointer(lv_obj_t *LVGL_Object_Pointer) override; 34 | 35 | // - Attributes 36 | static const Class_Type &Class; 37 | 38 | } Switch_Type; 39 | } // namespace Graphics_Types 40 | } // namespace Xila_Namespace 41 | 42 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Graphics/Tabs.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Tabs.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 10-05-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #ifndef Tabs_Hpp_Included 12 | #define Tabs_Hpp_Included 13 | 14 | #include "Object.hpp" 15 | #include "Button.hpp" 16 | 17 | namespace Xila_Namespace 18 | { 19 | namespace Graphics_Types 20 | { 21 | typedef class Tabs_Class : public Object_Class 22 | { 23 | public: 24 | // - Methods 25 | 26 | // - - Constructors / destructors 27 | Tabs_Class(); 28 | Tabs_Class(const Object_Class &Object_To_Copy); 29 | 30 | // - - Manipulation 31 | virtual void Create(Object_Class Parent_Object) override; 32 | virtual void Create(Object_Class Parent_Object, Direction_Type Direction, Coordinate_Type Size); 33 | 34 | Object_Class Add_Tab(const char*Name); 35 | void Rename_Tab(uint32_t Index, const char*New_name); 36 | 37 | // - - Setters. 38 | virtual bool Set_Pointer(lv_obj_t *LVGL_Object_Pointer) override; 39 | 40 | void Set_Active_Tab(uint32_t Identifier, bool Animation); 41 | 42 | // - - Getters. 43 | uint16_t Get_Tab_Active(); 44 | 45 | Object_Class Get_Content(); 46 | Button_Matrix_Type Get_Tab_Buttons(); 47 | 48 | // - Attributes 49 | static const Class_Type &Class; 50 | } Tabs_Type; 51 | } // namespace Graphics_Types 52 | } // namespace Xila_Namespace 53 | 54 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Header.hpp: -------------------------------------------------------------------------------- 1 | /// @file Header.hpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief Main header file 4 | /// @version 0.1.0 5 | /// @date 14-03-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | 9 | #ifndef Header_Hpp_Included 10 | #define Header_Hpp_Included 11 | 12 | #ifdef ARDUINO 13 | // #define Arduino 14 | #endif 15 | 16 | #ifdef Arduino 17 | #include "Arduino.h" 18 | #endif 19 | 20 | #ifdef Native 21 | #include 22 | #include 23 | #include 24 | #endif 25 | 26 | #include 27 | 28 | #define Stringize_Helper(x) #x 29 | #define Stringize(x) Stringize_Helper(x) 30 | 31 | #define Xila_Version_Major_String Stringize(Xila_Version_Major) 32 | #define Xila_Version_Minor_String Stringize(Xila_Version_Minor) 33 | #define Xila_Version_Revision_String Stringize(Xila_Version_Revision) 34 | 35 | #define Xila_Version_String Xila_Version_Major_String "." Xila_Version_Minor_String "." Xila_Version_Revision_String 36 | 37 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Memory/Memory.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Memory.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.2 6 | /// @date 24-06-2021 7 | /// 8 | /// @copyright Copyright (c) 2021 9 | /// 10 | 11 | #ifndef Memory_Hpp_Included 12 | #define Memory_Hpp_Included 13 | 14 | #include "../Module/Module.hpp" 15 | 16 | //==============================================================================// 17 | /// 18 | /// @brief Memory management class. 19 | /// 20 | 21 | namespace Xila_Namespace 22 | { 23 | namespace Memory_Types 24 | { 25 | } 26 | 27 | 28 | /// @brief Memory management module. 29 | typedef class Memory_Class : public Module_Class 30 | { 31 | public: 32 | // -- Methods 33 | 34 | /// @brief Get the heap size. 35 | /// @return Size_Type 36 | Size_Type Get_Heap_Size(); 37 | 38 | /// @brief Get the free heap. 39 | /// @return Size_Type 40 | Size_Type Get_Free_Heap(); 41 | 42 | /// @brief Get the minimum free heap. 43 | /// @return Size_Type 44 | Size_Type Get_Minimum_Free_Heap(); 45 | 46 | /// @brief Get the maximum allocated heap. 47 | /// @return Size_Type 48 | Size_Type Get_Maximum_Allocated_Heap(); 49 | 50 | /// @brief Get the PSRAM size. 51 | /// @return Size_Type 52 | Size_Type Get_PSRAM_Size(); 53 | 54 | /// @brief Get the free PSRAM. 55 | /// @return Size_Type 56 | Size_Type Get_Free_PSRAM(); 57 | 58 | /// @brief Get the minimum free PSRAM. 59 | /// @return Size_Type 60 | Size_Type Get_Minimum_Free_PSRAM(); 61 | 62 | /// @brief Get the maximum allocated PSRAM. 63 | /// @return Size_Type 64 | Size_Type Get_Maximum_Allocated_PSRAM(); 65 | } Memory_Type; 66 | 67 | extern Memory_Type Memory; 68 | } 69 | 70 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Module/Registry.hpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Registry.hpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 03-03-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #ifndef Registry_Hpp_Included 12 | #define Registry_Hpp_Included 13 | 14 | #include "String.hpp" 15 | #include "ArduinoJson.h" 16 | 17 | namespace Xila_Namespace 18 | { 19 | bool convertToJson(const char*String, JsonVariant variant); 20 | 21 | } 22 | 23 | #endif -------------------------------------------------------------------------------- /lib/Xila/include/Xila.hpp: -------------------------------------------------------------------------------- 1 | #ifndef Xila_Hpp_Included 2 | #define Xila_Hpp_Included 3 | 4 | #include "Core.hpp" 5 | 6 | /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 7 | || __________ __ __ _____ _ || 8 | || | | | \ \ / / |_ _| | | /\ || 9 | || |______| | \ V / | | | | / \ || 10 | || | |__|___| | | | | | | / /\ \ || 11 | || | | | / . \ _| |_ | |____ / ____ \ || 12 | || |___|______| /_/ \_\ |_____| |______| /_/ \_\ || 13 | || || 14 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/ 15 | 16 | #endif -------------------------------------------------------------------------------- /lib/Xila/keyword.txt: -------------------------------------------------------------------------------- 1 | ###################### 2 | # Datatypes (KEYWORD1) 3 | ###################### 4 | 5 | Xila KEYWORD1 6 | 7 | ################################## 8 | # Methods and Functions (KEYWORD2) 9 | ################################## 10 | 11 | ###################### 12 | # Instances (KEYWORD2) 13 | ###################### 14 | 15 | ###################### 16 | # Instances (KEYWORD3) 17 | ###################### 18 | 19 | Xila KEYWORD3 20 | 21 | ###################### 22 | # Constants (LITERAL1) 23 | ###################### -------------------------------------------------------------------------------- /lib/Xila/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Xila", 3 | "version": "0.1.0", 4 | "description": "A graphical operating system for embedded devices.", 5 | "keywords": "operating system, user interface, freertos, shell, esp32", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/AlixANNERAUD/Xila" 9 | }, 10 | "authors": { 11 | "name": "Alix ANNERAUD", 12 | "email": "alix.anneraud@outlook.fr", 13 | "url": "https://alixfaitgrr.fr/", 14 | "maintainer": "true" 15 | }, 16 | "license": "MIT", 17 | "homepage": "https://xila.dev/", 18 | "dependencies": [ 19 | ], 20 | "examples": [ 21 | { 22 | "name": "Default_Software", 23 | "base": "examples/Default_Software", 24 | "files": ["Default_Software.ino"] 25 | }, 26 | { 27 | "name": "Custom_Software", 28 | "base": "examples/Custom_Software", 29 | "files": ["Custom_Software.ino"] 30 | } 31 | ], 32 | "build": 33 | { 34 | 35 | }, 36 | "frameworks": "arduino", 37 | "platforms": ["espressif32"] 38 | } -------------------------------------------------------------------------------- /lib/Xila/library.properties: -------------------------------------------------------------------------------- 1 | name=Xila 2 | version=0.2.0 3 | author=Alix ANNERAUD 4 | maintainer=Alix ANNERAUD 5 | sentence=A graphical operting system for embedded devices 6 | paragraph=That allow to use and develop software in a unified ecosystem. 7 | category=Other 8 | url=https://github.com/AlixANNERAUD/Xila 9 | architectures=* 10 | depends= -------------------------------------------------------------------------------- /lib/Xila/src/Communication/Communication.cpp: -------------------------------------------------------------------------------- 1 | /// @file Communication.cpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief 4 | /// @version 0.1.0 5 | /// @date 24-04-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | 9 | #include "Communication/Communication.hpp" 10 | #include "Log/Log.hpp" 11 | 12 | // - Namespaces 13 | 14 | using namespace Xila_Namespace; 15 | using namespace Xila_Namespace::Communication_Types; 16 | 17 | // - Variable 18 | 19 | Communication_Type Xila_Namespace::Communication; 20 | 21 | // - Methods 22 | 23 | Result_Type Communication_Class::Start() 24 | { 25 | Log_Information("WiFi", "Start Communication module..."); 26 | if (WiFi.Start() == Result_Type::Success) 27 | return Result_Type::Success; 28 | 29 | return Result_Type::Error; 30 | } 31 | 32 | Result_Type Communication_Class::Stop() 33 | { 34 | if (WiFi.Stop() == Result_Type::Success) 35 | return Result_Type::Success; 36 | 37 | return Result_Type::Error; 38 | } -------------------------------------------------------------------------------- /lib/Xila/src/Core.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Core.cpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief Xila core component source file. 5 | /// @version 0.1 6 | /// @date 08-04-2021 7 | /// 8 | /// @copyright Copyright (c) 2021 9 | /// 10 | 11 | #include "Core.hpp" 12 | -------------------------------------------------------------------------------- /lib/Xila/src/Display/Drivers/Native.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file WT32-SC01-Plus.cpp 3 | /// @author Alix ANNERAUD (alix@anneraud.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 02-02-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #ifdef Xila_Display_Hardware_Native 12 | 13 | // - Include header 14 | #include "Display/Display.hpp" 15 | 16 | // - Include external libraries 17 | #include 18 | #define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/ 19 | #include 20 | #include "display/monitor.h" 21 | #include "indev/mouse.h" 22 | #include "indev/mousewheel.h" 23 | #include "indev/keyboard.h" 24 | #include "sdl/sdl.h" 25 | 26 | using namespace Xila_Namespace; 27 | 28 | /** 29 | * A task to measure the elapsed time for LittlevGL 30 | * @param data unused 31 | * @return never return 32 | */ 33 | static int tick_thread(void * data) 34 | { 35 | (void)data; 36 | 37 | while(1) { 38 | SDL_Delay(5); /*Sleep for 5 millisecond*/ 39 | lv_tick_inc(5); /*Tell LittelvGL that 5 milliseconds were elapsed*/ 40 | } 41 | 42 | return 0; 43 | } 44 | 45 | 46 | Result_Type Display_Class::Initialize() 47 | { 48 | } 49 | 50 | void Display_Class::Sleep() 51 | { 52 | 53 | } 54 | 55 | void Display_Class::Wake_Up() 56 | { 57 | 58 | } 59 | 60 | void Display_Class::Set_Brightness(uint8_t Brightness) 61 | { 62 | 63 | }; 64 | 65 | uint8_t Display_Class::Get_Brightness() 66 | { 67 | return 100; 68 | }; 69 | 70 | void Display_Class::Output_Flush(lv_disp_drv_t *Display_Driver_Interface, const lv_area_t *Area, lv_color_t *Buffer) 71 | { 72 | 73 | }; 74 | 75 | void Display_Class::Input_Read(lv_indev_drv_t *Input_Device_Driver_Interface, lv_indev_data_t *Data) 76 | { 77 | 78 | }; 79 | 80 | void Display_Class::Calibrate() 81 | { 82 | 83 | }; 84 | 85 | #endif -------------------------------------------------------------------------------- /lib/Xila/src/Drive/Drive.cpp: -------------------------------------------------------------------------------- 1 | /// @file Drive.cpp 2 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 3 | /// @brief 4 | /// @version 0.1 5 | /// @date 28-03-2021 6 | /// 7 | /// @copyright Copyright (c) 2021 8 | 9 | #include "Drive/Drive.hpp" 10 | 11 | #include "System/System.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | using namespace Xila_Namespace::Drive_Types; 15 | 16 | Drive_Type Xila_Namespace::Drive; 17 | 18 | // Custom methods 19 | 20 | Result_Type Drive_Class::Remove_Directory(const char* Path, bool Recursive) 21 | { 22 | if (!Recursive) 23 | return Remove_Directory(Path); 24 | 25 | Drive_Types::File_Type Directory = Open(Path); 26 | 27 | if (!Directory || !Directory.Is_Directory()) 28 | return Result_Type::Error; 29 | 30 | Drive_Types::File_Type Item; 31 | while (Item = Directory.Open_Next_File()) 32 | { 33 | if (Item.Is_Directory()) 34 | Remove_Directory(Item.Get_Path(), true); 35 | else 36 | Remove_File(Item.Get_Path()); 37 | 38 | Item.Close(); 39 | } 40 | 41 | Directory.Close(); 42 | 43 | return Remove_Directory(Path); 44 | } 45 | 46 | Result_Type Drive_Class::Remove(const char *Path) 47 | { 48 | Drive_Types::File_Type File = Open(Path); 49 | if (!File) 50 | return Result_Type::Error; 51 | 52 | if (File.Is_Directory()) 53 | return Remove_Directory(Path, true); 54 | else 55 | return Remove_File(Path); 56 | } -------------------------------------------------------------------------------- /lib/Xila/src/Graphics/Dialog/Color_Dialog.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Color_Dialog.cpp 3 | /// @author Alix ANNERAUD (alix@anneraud.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 13-02-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #include "Graphics/Dialog.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | using namespace Xila_Namespace::Graphics_Types; 15 | 16 | void Color_Dialog_Class::Create(Object_Class Parent_Object) 17 | { 18 | if (!Parent_Object) 19 | { 20 | return; 21 | } 22 | 23 | this->Set_Pointer(lv_obj_create(Parent_Object)); 24 | this->Set_Interface(); 25 | this->Set_Size(Percentage(75), Percentage(75)); 26 | 27 | Color_Wheel.Create(this->Get_Body()); 28 | Color_Wheel.Set_Size(Percentage(100), Percentage(100)); 29 | } 30 | 31 | Color_Type Color_Dialog_Class::Get_Color() 32 | { 33 | return Color_Wheel.Get_Color(); 34 | } 35 | 36 | 37 | void Color_Dialog_Class::Set_Color(Color_Type Color) 38 | { 39 | Color_Wheel.Set_Color(Color); 40 | } 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /lib/Xila/src/Graphics/QRCode.cpp: -------------------------------------------------------------------------------- 1 | /// @file QRCode.cpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief 4 | /// @version 0.1.0 5 | /// @date 23-03-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | /// 9 | 10 | #if LV_USE_QRCODE != 0 11 | 12 | #include "Graphics/QRCode.hpp" 13 | #include "Graphics/Graphics.hpp" 14 | 15 | using namespace Xila_Namespace; 16 | using namespace Xila_Namespace::Graphics_Types; 17 | 18 | // - Attributes 19 | 20 | const Class_Type &Class = lv_qrcode_class; 21 | 22 | // - Methods 23 | 24 | // - - Constructor / destructor 25 | 26 | QRCode_Class::QRCode_Class() : Object_Class() 27 | { 28 | } 29 | 30 | QRCode_Class::QRCode_Class(const Object_Class &Object) 31 | { 32 | this->Set_Pointer(Object); 33 | } 34 | 35 | QRCode_Class::~QRCode_Class() 36 | { 37 | } 38 | 39 | // - - Manipulation 40 | 41 | void QRCode_Class::Create(Object_Type Parent_Object) 42 | { 43 | if (!Parent_Object) 44 | return; 45 | 46 | Auto_Semaphore_Type Semaphore = Graphics.Take_Semaphore_Auto(); 47 | this->LVGL_Object_Pointer = lv_qrcode_create(Parent_Object, 32, Color_Type::Black.Get_LVGL_Color(), Color_Type::White.Get_LVGL_Color()); 48 | } 49 | 50 | void QRCode_Class::Create(Object_Type Parent_Object, const void *Data, Size_Type Length, Coordinate_Type Size, Color_Type Dark_Color, Color_Type Light_Color) 51 | { 52 | if (!Parent_Object) 53 | return; 54 | 55 | Auto_Semaphore_Type Semaphore = Graphics.Take_Semaphore_Auto(); 56 | this->LVGL_Object_Pointer = lv_qrcode_create(Parent_Object, Size, Dark_Color.Get_LVGL_Color(), Light_Color.Get_LVGL_Color()); 57 | 58 | if (Data && (Length != 0)) 59 | this->Update(Data, Length); 60 | } 61 | 62 | void QRCode_Class::Update(const void *Data, Size_Type Length) 63 | { 64 | Auto_Semaphore_Type Semaphore = Graphics.Take_Semaphore_Auto(); 65 | lv_qrcode_update(Get_Pointer(), Data, Length); 66 | } 67 | 68 | #endif // LV_USE_QRCODE != 0 -------------------------------------------------------------------------------- /lib/Xila/src/Graphics/Switch.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Switch.cpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 14-07-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #include "Graphics/Switch.hpp" 12 | #include "Graphics/Graphics.hpp" 13 | 14 | using namespace Xila_Namespace; 15 | using namespace Xila_Namespace::Graphics_Types; 16 | 17 | // - Attributes 18 | 19 | const Class_Type& Switch_Class::Class = lv_switch_class; 20 | 21 | // - Methods 22 | 23 | // - - Constructors / Destructors 24 | 25 | Switch_Class::Switch_Class() : Object_Class() 26 | { 27 | } 28 | 29 | Switch_Class::Switch_Class(const Object_Class &Object_To_Copy) 30 | { 31 | Set_Pointer(Object_To_Copy); 32 | } 33 | 34 | // - - Manipulation 35 | 36 | void Switch_Class::Create(Object_Class Parent_Object) 37 | { 38 | if (Parent_Object) 39 | { 40 | Auto_Semaphore_Type Semaphore = Graphics.Take_Semaphore_Auto(); 41 | this->LVGL_Object_Pointer = lv_switch_create(Parent_Object); 42 | } 43 | } 44 | 45 | // - - Setters 46 | 47 | bool Switch_Class::Set_Pointer(lv_obj_t* LVGL_Object_Pointer) 48 | { 49 | if (Get_Pointer() != NULL) 50 | { 51 | return false; 52 | } 53 | Object_Type Object(LVGL_Object_Pointer); 54 | if (!Object.Check_Class( &lv_switch_class)) 55 | { 56 | return false; 57 | } 58 | this->LVGL_Object_Pointer = LVGL_Object_Pointer; 59 | return true; 60 | } -------------------------------------------------------------------------------- /lib/Xila/src/Keyboard/Drivers/Keyboard_None.cpp: -------------------------------------------------------------------------------- 1 | /// @file Keyboard_None.cpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief 4 | /// @version 0.1.0 5 | /// @date 04-03-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | 9 | #ifdef Xila_Keyboard_Hardware_None 10 | 11 | #include "Keyboard/Keyboard.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | using namespace Xila_Namespace::Keyboard_Types; 15 | 16 | Keyboard_Class::Keyboard_Class() 17 | { 18 | } 19 | 20 | void Keyboard_Class::Begin() 21 | { 22 | } 23 | 24 | unsigned char Keyboard_Class::Read() 25 | { 26 | return '\0'; 27 | } 28 | 29 | uint8_t Keyboard_Class::Available() 30 | { 31 | return false; 32 | } 33 | 34 | uint8_t Keyboard_Class::Read_Raw() 35 | { 36 | return '\0'; 37 | } 38 | 39 | void Keyboard_Class::Clear() 40 | { 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /lib/Xila/src/Keyboard/Drivers/Keyboard_PS2.cpp: -------------------------------------------------------------------------------- 1 | /// @file Keyboard_PS2.cpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief 4 | /// @version 0.1.0 5 | /// @date 24-01-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | 9 | #ifdef Xila_Keyboard_Hardware_PS2 10 | 11 | #include "Keyboard/Keyboard.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | using namespace Xila_Namespace::Keyboard_Types; 15 | 16 | #include 17 | 18 | PS2Keyboard PS2_Keyboard(); 19 | 20 | Keyboard_Class::Keyboard_Class() 21 | : Layout(Layout_Type::American), 22 | Data_Pin(Default_Keyboard_Data_Pin), 23 | Clock_Pin(Default_Keyboard_Clock_Pin) 24 | { 25 | } 26 | 27 | void Keyboard_Class::Begin() 28 | { 29 | switch (Layout) 30 | { 31 | case Layout_Type::American: 32 | PS2Keyboard::begin(Data_Pin, Clock_Pin, PS2Keymap_US); 33 | break; 34 | case Layout_Type::German: 35 | PS2Keyboard::begin(Data_Pin, Clock_Pin, PS2Keymap_German); 36 | break; 37 | case Layout_Type::French: 38 | PS2Keyboard::begin(Data_Pin, Clock_Pin, PS2Keymap_French); 39 | break; 40 | case Layout_Type::Spanish: 41 | PS2Keyboard::begin(Data_Pin, Clock_Pin, PS2Keymap_Spanish); 42 | break; 43 | case Layout_Type::Italian: 44 | PS2Keyboard::begin(Data_Pin, Clock_Pin, PS2Keymap_Italian); 45 | break; 46 | case Layout_Type::English: 47 | PS2Keyboard::begin(Data_Pin, Clock_Pin, PS2Keymap_UK); 48 | break; 49 | } 50 | } 51 | 52 | unsigned char Keyboard_Class::Read() 53 | { 54 | return PS2Keyboard::read(); 55 | } 56 | 57 | uint8_t Keyboard_Class::Available() 58 | { 59 | return PS2Keyboard::available(); 60 | } 61 | 62 | uint8_t Keyboard_Class::Read_Raw() 63 | { 64 | return PS2Keyboard::readScanCode(); 65 | } 66 | 67 | void Keyboard_Class::Clear() 68 | { 69 | PS2Keyboard::clear(); 70 | } 71 | 72 | #endif -------------------------------------------------------------------------------- /lib/Xila/src/Log/Log.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Log.cpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 13-03-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #include "Log/Log.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | 15 | Log_Type Xila_Namespace::Log; 16 | 17 | Log_Class::Log_Class() : Semaphore_Handle(NULL) 18 | { 19 | xSemaphoreHandle Semaphore_Handle = xSemaphoreCreateMutexStatic(&Semaphore_Buffer); 20 | if (Semaphore_Handle == NULL) 21 | { 22 | Print_Static("Failed to create log semaphore !\r\n"); 23 | } 24 | 25 | //if (Semaphore.Create(Semaphore_Class::Type_Type::Mutex) != Result_Type::Success) 26 | //{ 27 | // Print_Static("Failed to create log semaphore !\r\n"); 28 | //} 29 | 30 | Print_Static("Semaphore created.\r\n"); 31 | } -------------------------------------------------------------------------------- /lib/Xila/src/Memory/Memory.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Memory.cpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 20-07-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #include "Memory/Memory.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | 15 | Memory_Type Xila_Namespace::Memory; 16 | 17 | Size_Type Xila_Namespace::Memory_Class::Get_Free_Heap() 18 | { 19 | return ESP.getFreeHeap(); 20 | } 21 | 22 | Size_Type Xila_Namespace::Memory_Class::Get_Heap_Size() 23 | { 24 | return ESP.getHeapSize(); 25 | } 26 | 27 | Size_Type Xila_Namespace::Memory_Class::Get_Minimum_Free_Heap() 28 | { 29 | return ESP.getMinFreeHeap(); 30 | } 31 | 32 | Size_Type Xila_Namespace::Memory_Class::Get_Maximum_Allocated_Heap() 33 | { 34 | return ESP.getMaxAllocHeap(); 35 | } 36 | 37 | Size_Type Xila_Namespace::Memory_Class::Get_PSRAM_Size() 38 | { 39 | return ESP.getPsramSize(); 40 | } 41 | 42 | Size_Type Xila_Namespace::Memory_Class::Get_Free_PSRAM() 43 | { 44 | return ESP.getFreePsram(); 45 | } 46 | 47 | Size_Type Xila_Namespace::Memory_Class::Get_Minimum_Free_PSRAM() 48 | { 49 | return ESP.getMinFreePsram(); 50 | } 51 | 52 | Size_Type Xila_Namespace::Memory_Class::Get_Maximum_Allocated_PSRAM() 53 | { 54 | return ESP.getMaxAllocPsram(); 55 | } -------------------------------------------------------------------------------- /lib/Xila/src/Module/Auto_Semaphore.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Auto_Semaphore.cpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 07-03-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #include "Module/Semaphore.hpp" 12 | #include "Log/Log.hpp" 13 | 14 | using namespace Xila_Namespace; 15 | 16 | Auto_Semaphore_Class::Auto_Semaphore_Class(Semaphore_Type& Semaphore, uint32_t Timeout) : Semaphore_Handle(Semaphore.Semaphore_Handle) 17 | { 18 | xSemaphoreTakeRecursive(Semaphore_Handle, Timeout); 19 | } 20 | 21 | Auto_Semaphore_Class::Auto_Semaphore_Class(const Auto_Semaphore_Type &Auto_Semaphore) : //Semaphore(Auto_Semaphore.Semaphore) 22 | Semaphore_Handle(Auto_Semaphore.Semaphore_Handle) 23 | { 24 | xSemaphoreTakeRecursive(Semaphore_Handle, portMAX_DELAY); 25 | // Do take the semaphore since it's supposed to be already taken since an Auto_Semaphore_Class is invoked. 26 | } 27 | 28 | 29 | Auto_Semaphore_Class::~Auto_Semaphore_Class() 30 | { 31 | xSemaphoreGiveRecursive(Semaphore_Handle); 32 | } -------------------------------------------------------------------------------- /lib/Xila/src/Module/Base_Types.cpp: -------------------------------------------------------------------------------- 1 | /// @file Base_Types.cpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief 4 | /// @version 0.1.0 5 | /// @date 21-03-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | 9 | #include "Module/Base_Types.hpp" 10 | 11 | using namespace Xila_Namespace; 12 | 13 | void* Null = NULL; -------------------------------------------------------------------------------- /lib/Xila/src/Module/Module.cpp: -------------------------------------------------------------------------------- 1 | /// @file Task.cpp 2 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 3 | /// @brief 4 | /// @version 0.1.0 5 | /// @date 19-07-2022 6 | /// 7 | /// @copyright Copyright (c) 2022 8 | 9 | // - Includes 10 | 11 | #include "Module/Module.hpp" 12 | #include "Log/Log.hpp" 13 | 14 | // - Namespaces 15 | using namespace Xila_Namespace; 16 | 17 | // - Methods 18 | 19 | Module_Class::Module_Class(Size_Type Queue_Size) : Instruction_Queue_Handle(NULL) 20 | { 21 | if (Queue_Size != 0) 22 | { 23 | Instruction_Queue_Handle = xQueueCreate(Queue_Size, sizeof(Instruction_Type)); 24 | if (Instruction_Queue_Handle == NULL) 25 | { 26 | Log_Error("Module", "Failed to create instruction queue ! Deleting module..."); 27 | delete this; 28 | } 29 | } 30 | 31 | } 32 | 33 | Module_Class::~Module_Class() 34 | { 35 | vQueueDelete(Instruction_Queue_Handle); 36 | } 37 | 38 | Result_Type Module_Class::Send_Instruction(const Instruction_Type &Instruction) 39 | { 40 | if (xQueueSendToBack(Instruction_Queue_Handle, (void *)&Instruction, 0) != pdTRUE) 41 | { 42 | return Result_Type::Error; 43 | } 44 | return Result_Type::Success; 45 | } 46 | 47 | 48 | Size_Type Module_Class::Instruction_Available() 49 | { 50 | return uxQueueMessagesWaiting(Instruction_Queue_Handle); 51 | } 52 | 53 | Instruction_Type Module_Class::Get_Instruction() 54 | { 55 | static Instruction_Type Current_Instruction; 56 | if (xQueueReceive(Instruction_Queue_Handle, &Current_Instruction, 0) != pdTRUE) 57 | { 58 | Current_Instruction.Set_Sender(NULL); 59 | Current_Instruction.Set_Receiver(NULL); 60 | 61 | } 62 | return Current_Instruction; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /lib/Xila/src/Module/Registry.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Registry.cpp 3 | /// @author Alix ANNERAUD (alix@anneraud.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 05-03-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #include "Module/Registry.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | 15 | bool Xila_Namespace::convertToJson(const char*String, JsonVariant variant) 16 | { 17 | return variant.set((const char*)String); 18 | } -------------------------------------------------------------------------------- /lib/Xila/src/Module/Time.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Time.cpp 3 | /// @author Alix ANNERAUD (alix@anneraud.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 22-02-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #include "Module/Time.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | 15 | Time_Class::Time_Class() : Hours(0), Minutes(0), Seconds(0), Milliseconds(0) 16 | { 17 | } 18 | 19 | Time_Class::Time_Class(uint8_t Hours, uint8_t Minutes, uint8_t Seconds, uint16_t Milliseconds) : Hours(Hours), Minutes(Minutes), Seconds(Seconds), Milliseconds(Milliseconds) 20 | { 21 | } 22 | 23 | void Time_Class::Set(uint8_t Hours, uint8_t Minutes, uint8_t Seconds, uint16_t Milliseconds) 24 | { 25 | Set_Hours(Hours); 26 | Set_Minutes(Minutes); 27 | Set_Seconds(Seconds); 28 | Set_Milliseconds(Milliseconds); 29 | } 30 | 31 | void Time_Class::Set_Hours(uint8_t Hours) 32 | { 33 | this->Hours = Hours; 34 | } 35 | 36 | void Time_Class::Set_Minutes(uint8_t Minutes) 37 | { 38 | this->Minutes = Minutes; 39 | } 40 | 41 | void Time_Class::Set_Seconds(uint8_t Seconds) 42 | { 43 | this->Seconds = Seconds; 44 | } 45 | 46 | void Time_Class::Set_Milliseconds(uint16_t Milliseconds) 47 | { 48 | this->Milliseconds = Milliseconds; 49 | } 50 | 51 | uint8_t Time_Class::Get_Hours() 52 | { 53 | return Hours; 54 | } 55 | 56 | uint8_t Time_Class::Get_Minutes() 57 | { 58 | return Minutes; 59 | } 60 | 61 | uint8_t Time_Class::Get_Seconds() 62 | { 63 | return Seconds; 64 | } 65 | 66 | uint16_t Time_Class::Get_Milliseconds() 67 | { 68 | return Milliseconds; 69 | } 70 | -------------------------------------------------------------------------------- /lib/Xila/src/Pin/Drivers/ESP32.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file ESP32.cpp 3 | /// @author Alix ANNERAUD (alix@anneraud.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 05-03-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #ifdef Xila_Pin_Hardware_ESP32 12 | 13 | #include "Pin/Pin.hpp" 14 | 15 | using namespace Xila_Namespace; 16 | using namespace Xila_Namespace::Pin_Types; 17 | 18 | /// 19 | /// @brief Set voltage reference pin for for ADC measurements. 20 | /// 21 | /// @param Pin Involved GPIO. 22 | void Xila_Namespace::Pin_Class::Set_Voltage_Reference_Pin(uint8_t Pin) 23 | { 24 | analogSetVRefPin(Pin); 25 | } 26 | 27 | #endif -------------------------------------------------------------------------------- /lib/Xila/src/Pin/Drivers/ESP32_S3.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file ESP32_S3.cpp 3 | /// @author Alix ANNERAUD (alix@anneraud.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 05-03-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #ifdef Xila_Pin_Hardware_ESP32_S3 12 | 13 | #include "Pin/Pin.hpp" 14 | 15 | using namespace Xila_Namespace; 16 | using namespace Xila_Namespace::Pin_Types; 17 | 18 | /// 19 | /// @brief Set voltage reference pin for for ADC measurements. 20 | /// 21 | /// @param Pin Involved GPIO. 22 | void Xila_Namespace::Pin_Class::Set_Voltage_Reference_Pin(uint8_t Pin) 23 | { 24 | //analogSetVRefPin(Pin); 25 | } 26 | 27 | 28 | #endif -------------------------------------------------------------------------------- /lib/Xila/src/Power/Drivers/Regular_Battery.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Regular_Battery.cpp 3 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 13-11-2022 7 | /// 8 | /// @copyright Copyright (c) 2022 9 | /// 10 | 11 | #include "Power/Power.hpp" 12 | 13 | #include "Battery_Library.hpp" 14 | 15 | #if defined(Xila_Power_Battery_Default_Sensing_Pin) && defined(Xila_Power_Battery_Default_Minimum_Voltage) && defined(Xila_Power_Battery_Default_Maximum_Voltage) && defined(Xila_Power_Battery_Default_Conversion_Factor) 16 | Battery_Class Battery(Xila_Power_Battery_Default_Sensing_Pin, Xila_Power_Battery_Default_Minimum_Voltage, Xila_Power_Battery_Default_Maximum_Voltage, Xila_Power_Battery_Default_Conversion_Factor); 17 | #endif 18 | 19 | using namespace Xila_Namespace; 20 | 21 | uint8_t Power_Class::Get_Battery_Charge_Level() 22 | { 23 | #ifdef Xila_Power_Battery_Default_Sensing_Pin 24 | return Battery.Get_Charge_Level(); 25 | #else 26 | return 100; 27 | #endif 28 | } 29 | 30 | uint16_t Power_Class::Get_Battery_Voltage() 31 | { 32 | #ifdef Xila_Power_Battery_Default_Sensing_Pin 33 | return Battery.Get_Voltage(); 34 | #else 35 | return 0; 36 | #endif 37 | } 38 | -------------------------------------------------------------------------------- /lib/Xila/src/Software/Software_Handle.cpp: -------------------------------------------------------------------------------- 1 | /// @file Software_Handle.cpp 2 | /// @author Alix ANNERAUD (alix.anneraud@outlook.fr) 3 | /// @brief 4 | /// @version 0.1 5 | /// @date 11-07-2021 6 | /// 7 | /// @copyright Copyright (c) 2021 8 | 9 | #include "Software/Software_Handle.hpp" 10 | #include "Log/Log.hpp" 11 | 12 | using namespace Xila_Namespace; 13 | using namespace Softwares_Types; 14 | 15 | std::list Software_Handle_Class::List; 16 | 17 | Software_Handle_Class::Software_Handle_Class(const char* Name) 18 | : Name(Name) 19 | { 20 | } 21 | 22 | Software_Handle_Class::~Software_Handle_Class() 23 | { 24 | } 25 | 26 | String_Type& Software_Handle_Class::Get_Name(String_Type& Name) const 27 | { 28 | Name = this->Name; 29 | return Name; 30 | } 31 | 32 | void Software_Handle_Class::Create_Instance(const Accounts_Types::User_Type* Owner_User) const 33 | { 34 | // 35 | } -------------------------------------------------------------------------------- /lib/Xila/src/System/Informations.cpp: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file Informations.cpp 3 | /// @author Alix ANNERAUD (alix@anneraud.fr) 4 | /// @brief 5 | /// @version 0.1.0 6 | /// @date 04-03-2023 7 | /// 8 | /// @copyright Copyright (c) 2023 9 | /// 10 | 11 | #include "System/System.hpp" 12 | 13 | using namespace Xila_Namespace; 14 | 15 | // - Methods 16 | 17 | // - - Getters 18 | 19 | /// @brief Return number of chip cores. 20 | /// 21 | /// @return uint32_t Chip cores. 22 | uint32_t System_Class::Get_Chip_Cores() 23 | { 24 | return ESP.getChipCores(); 25 | } 26 | 27 | /// @brief Return chip revision. 28 | /// 29 | /// @return uint8_t Chip revision. 30 | uint8_t System_Class::Get_Chip_Revision() 31 | { 32 | return ESP.getChipRevision(); 33 | } 34 | 35 | /// 36 | /// @brief Return chip model. 37 | /// 38 | /// @return const char* Chip model. 39 | const char *System_Class::Get_Chip_Model() 40 | { 41 | return ESP.getChipModel(); 42 | } 43 | 44 | /// @brief Return CPU frequency. 45 | /// 46 | /// @return uint32_t CPU frequency in MHz. 47 | uint32_t System_Class::Get_CPU_Frequency() 48 | { 49 | return getCpuFrequencyMhz(); 50 | } 51 | 52 | /// @brief Return eFuse MAC. 53 | /// 54 | /// @return uint64_t eFuse MAC. 55 | uint64_t System_Class::Get_eFuse_MAC() 56 | { 57 | return ESP.getEfuseMac(); 58 | } 59 | 60 | /// @brief Return device name. 61 | /// 62 | /// @return const char* Device name. 63 | String_Type& System_Class::Get_Device_Name(String_Class &Device_Name) 64 | { 65 | Device_Name = this->Device_Name; 66 | return Device_Name; 67 | } 68 | 69 | // - - Setters 70 | 71 | /// @brief 72 | /// @param Device_Name 73 | void System_Class::Set_Device_Name(const char* Device_Name) 74 | { 75 | this->Device_Name = Device_Name; 76 | } -------------------------------------------------------------------------------- /lib/Xila/src/System/Shutdown.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xila-Project/Old_core/4a8fc6a3a11cefc460a450c76e6231681c53be6a/lib/Xila/src/System/Shutdown.cpp -------------------------------------------------------------------------------- /lib/Xila/src/System/Start.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xila-Project/Old_core/4a8fc6a3a11cefc460a450c76e6231681c53be6a/lib/Xila/src/System/Start.cpp -------------------------------------------------------------------------------- /lib/Xila/versions_registry.xrf: -------------------------------------------------------------------------------- 1 | { 2 | "Versions_Registry": [ 3 | { 4 | "Version": "0.1.0", 5 | "Date": "20-04-2021", 6 | "Url": "https://codeload.github.com/AlixANNERAUD/Xila/tar.gz/refs/tags/0.1.0", 7 | "Softwares": [ 8 | "Calculator", 9 | "Clock", 10 | "Internet Browser", 11 | "Music Player", 12 | "Oscilloscope", 13 | "Paint", 14 | "Periodic", 15 | "Piano", 16 | "Pong", 17 | "Simon", 18 | "Text Editor", 19 | "Tiny Basic" 20 | ] 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /lib/berry/.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: configure 13 | run: sudo apt-get install libreadline-dev lcov 14 | - name: build & test 15 | run: make test 16 | -------------------------------------------------------------------------------- /lib/berry/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | /berry 39 | *.bec 40 | 41 | # Debug files 42 | *.dSYM/ 43 | *.su 44 | *.idb 45 | *.pdb 46 | .gdb_history 47 | 48 | # Kernel Module Compile Results 49 | *.mod* 50 | *.cmd 51 | .tmp_versions/ 52 | modules.order 53 | Module.symvers 54 | Mkfile.old 55 | dkms.conf 56 | 57 | # Test files 58 | *.gcda 59 | *.gcno 60 | *.info 61 | test_report/ 62 | 63 | # Ctags 64 | tags 65 | 66 | # other 67 | *.out.* 68 | *.user 69 | .vscode 70 | .DS_Store 71 | temp/ 72 | .idea 73 | __pycache__ 74 | .cproject 75 | .project 76 | .settings/ 77 | docs/build/html/ 78 | docs/_doxygen/xml/ 79 | -------------------------------------------------------------------------------- /lib/berry/Generate.sh: -------------------------------------------------------------------------------- 1 | rm ./generate -rf 2 | mkdir ./generate 3 | 4 | 5 | 6 | tools/coc/coc -o generate default src -c default/berry_conf.h 7 | 8 | -------------------------------------------------------------------------------- /lib/berry/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-2020 Guan Wenliang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/berry/berry-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xila-Project/Old_core/4a8fc6a3a11cefc460a450c76e6231681c53be6a/lib/berry/berry-logo.png -------------------------------------------------------------------------------- /lib/berry/docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /lib/berry/docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.https://www.sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /lib/berry/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | breathe>=4.11.1 2 | restructuredtext-lint>=1.1.3 3 | Sphinx>=1.8.1 4 | sphinx-intl>=0.9.11 5 | sphinx-rtd-theme>=0.4.2 6 | myst_parser>=0.18.1 7 | hawkmoth>=0.11.0 8 | mkdocs>=1.4.1 9 | sphinx-typo3-theme>=4.7.9 10 | -------------------------------------------------------------------------------- /lib/berry/docs/source/api.rst: -------------------------------------------------------------------------------- 1 | API documentation 2 | ================= 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :caption: Contents: 7 | 8 | .. autodoxygenfile:: berry.h 9 | :project: berry 10 | -------------------------------------------------------------------------------- /lib/berry/docs/source/en/Home.rst: -------------------------------------------------------------------------------- 1 | Welcome to the berry wiki! 2 | ========================== 3 | 4 | .. toctree:: 5 | :hidden: 6 | 7 | The Berry Script Language Reference Manual 8 | FFI-Example 9 | Roadmap 10 | Memory Requirements 11 | 12 | -------------------------------------------------------------------------------- /lib/berry/docs/source/en/Memory-Requirements.rst: -------------------------------------------------------------------------------- 1 | Memory Requirements 2 | =================== 3 | 4 | RAM required 5 | ------------ 6 | 7 | - extreme: 4 KB 8 | - low: 8 KB 9 | - recommended: ≥16 KB 10 | 11 | ROM/Flash required 12 | ------------------ 13 | 14 | - extreme: 64 KB 15 | - low: 128 KB 16 | - recommended: ≥256 KB 17 | 18 | Explanation 19 | ----------- 20 | 21 | - **extreme**: The memory capacity required in the minimum 22 | configuration. Lower than this value means that it is almost 23 | impossible to run Berry. 24 | - **low**: The minimum memory required for the complete Berry 25 | interpreter includes some user and third-party code. 26 | - **recommended**: In addition to the complete Berry interpreter, there 27 | are many users and third-party code. 28 | -------------------------------------------------------------------------------- /lib/berry/docs/source/es/Home.rst: -------------------------------------------------------------------------------- 1 | Bienvenido a la wiki de Berry! 2 | ============================== 3 | 4 | .. toctree:: 5 | :hidden: 6 | 7 | Manual de referencia del lenguaje Berry Script 8 | FFI-Ejemplo 9 | Hoja de ruta 10 | Requerimientos de Memoria 11 | -------------------------------------------------------------------------------- /lib/berry/docs/source/es/Requerimientos-de-Memoria.rst: -------------------------------------------------------------------------------- 1 | .. raw:: html 2 | 3 | 4 | 5 | Requerimientos de Memoria 6 | ========================= 7 | 8 | RAM requerida 9 | ------------- 10 | 11 | - extrema: 4 KB 12 | - baja: 8 KB 13 | - recomendada: ≥16 KB 14 | 15 | ROM/Flash requerida 16 | ------------------- 17 | 18 | - extrema: 64 KB 19 | - baja: 128 KB 20 | - recomendada: ≥256 KB 21 | 22 | Explicación 23 | ----------- 24 | 25 | - **extrema**: La capacidad de memoria requerida en la configuración 26 | mínima. Un valor inferior a este significa que es casi imposible 27 | ejecutar Berry. 28 | - **baja**: la memoria mínima requerida para que el intérprete completo 29 | de Berry incluya algunos códigos de usuario y de terceros. 30 | - **recomendado**: además del intérprete completo de Berry, se sportan 31 | muchos usuarios y código de terceros. 32 | -------------------------------------------------------------------------------- /lib/berry/examples/anon_func.be: -------------------------------------------------------------------------------- 1 | # anonymous function and closure 2 | def count(x) 3 | var arr = [] 4 | for i : 0 .. x 5 | arr.push( 6 | def (n) # loop variable cannot be used directly as free variable 7 | return def () 8 | return n * n 9 | end 10 | end (i) # define and call anonymous function 11 | ) 12 | end 13 | return arr 14 | end 15 | 16 | for xx : count(6) 17 | print(xx()) # 0, 1, 4 ... n * n 18 | end 19 | 20 | return count 21 | -------------------------------------------------------------------------------- /lib/berry/examples/bigloop.be: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | c = time.clock() 4 | do 5 | i = 0 6 | while i < 100000000 7 | i += 1 8 | end 9 | end 10 | print('while iteration 100000000 times', time.clock() - c, 's') 11 | 12 | c = time.clock() 13 | for i : 1 .. 100000000 14 | end 15 | print('for iteration 100000000 times', time.clock() - c, 's') 16 | -------------------------------------------------------------------------------- /lib/berry/examples/bintree.be: -------------------------------------------------------------------------------- 1 | # Reference from https://github.com/BerryMathDevelopmentTeam/BerryMath/blob/master/testscript/BinaryTree.bm 2 | 3 | class node 4 | var v, l, r 5 | def init(v, l, r) 6 | self.v = v 7 | self.l = l 8 | self.r = r 9 | end 10 | def insert(v) 11 | if v < self.v 12 | if self.l 13 | self.l.insert(v) 14 | else 15 | self.l = node(v) 16 | end 17 | else 18 | if self.r 19 | self.r.insert(v) 20 | else 21 | self.r = node (v) 22 | end 23 | end 24 | end 25 | def sort(l) 26 | if (self.l) self.l.sort(l) end 27 | l.push(self.v) 28 | if (self.r) self.r.sort(l) end 29 | end 30 | end 31 | 32 | class btree 33 | var root 34 | def insert(v) 35 | if self.root 36 | self.root.insert(v) 37 | else 38 | self.root = node(v) 39 | end 40 | end 41 | def sort() 42 | var l = [] 43 | if self.root 44 | self.root.sort(l) 45 | end 46 | return l 47 | end 48 | end 49 | 50 | var tree = btree() 51 | tree.insert(-100) 52 | tree.insert(5); 53 | tree.insert(3); 54 | tree.insert(9); 55 | tree.insert(10); 56 | tree.insert(10000000); 57 | tree.insert(1); 58 | tree.insert(-1); 59 | tree.insert(-10); 60 | print(tree.sort()); 61 | -------------------------------------------------------------------------------- /lib/berry/examples/calcpi.be: -------------------------------------------------------------------------------- 1 | def cpi(n) 2 | i = 2 3 | pi = 3 4 | while i <= n 5 | term = 4.0 / (i * (i + 1) * (i + 2)) 6 | if i % 4 7 | pi = pi + term 8 | else 9 | pi = pi - term 10 | end 11 | i = i + 2 12 | end 13 | return pi 14 | end 15 | 16 | print("pi =", cpi(100)) 17 | -------------------------------------------------------------------------------- /lib/berry/examples/exception.be: -------------------------------------------------------------------------------- 1 | import debug 2 | 3 | def test_func() 4 | try 5 | compile('def +() end')() 6 | except .. as e, v 7 | print('catch execption:', str(e) + ' >>>\n ' + str(v)) 8 | debug.traceback() 9 | end 10 | end 11 | 12 | test_func() 13 | -------------------------------------------------------------------------------- /lib/berry/examples/fib_rec.be: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | def fib(x) 4 | if x <= 2 5 | return 1 6 | end 7 | return fib(x - 1) + fib(x - 2) 8 | end 9 | 10 | c = time.clock() 11 | print("fib:", fib(38)) # minimum stack size: 78!! 12 | print("time:", time.clock() - c, 's') 13 | -------------------------------------------------------------------------------- /lib/berry/examples/guess_number.be: -------------------------------------------------------------------------------- 1 | import time 2 | import math 3 | 4 | math.srand(time.time()) 5 | res = math.rand() % 100 6 | max_test = 7 7 | test = -1 8 | idx = 1 9 | print('Guess a number between 0 and 99. You have', max_test, 'chances.') 10 | while test != res && idx <= max_test 11 | test = number(input(str(idx) + ': enter the number you guessed: ')) 12 | if type(test) != 'int' 13 | print('This is not an integer. Continue!') 14 | continue 15 | elif test > res 16 | print('This number is too large.') 17 | elif test < res 18 | print('This number is too small.') 19 | end 20 | idx = idx + 1 21 | end 22 | if test == res 23 | print('You win!') 24 | else 25 | print('You failed, the correct answer is', res) 26 | end 27 | -------------------------------------------------------------------------------- /lib/berry/examples/json.be: -------------------------------------------------------------------------------- 1 | import json 2 | print(json.load('{"key": "value"}')) 3 | print(json.dump({'test key': nil})) 4 | print(json.dump({'key1': nil, 45: true}, 'format')) 5 | -------------------------------------------------------------------------------- /lib/berry/examples/lambda.be: -------------------------------------------------------------------------------- 1 | # simple lambda example 2 | print((/a b c-> a * b + c)(2, 3, 4)) 3 | 4 | # Y-Combinator and factorial functions 5 | Y = /f-> (/x-> f(/n-> x(x)(n)))(/x-> f(/n-> x(x)(n))) 6 | F = /f-> /x-> x ? f(x - 1) * x : 1 7 | fact = Y(F) 8 | print('fact(10) == ' .. fact(10)) 9 | -------------------------------------------------------------------------------- /lib/berry/examples/listdir.be: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def scandir(path) 4 | print('path: ' + path) 5 | for name : os.listdir(path) 6 | var fullname = os.path.join(path, name) 7 | if os.path.isfile(fullname) 8 | print('file: ' + fullname) 9 | else 10 | print('path: ' + fullname) 11 | scandir(fullname) 12 | end 13 | end 14 | end 15 | 16 | scandir('.') 17 | -------------------------------------------------------------------------------- /lib/berry/examples/qsort.be: -------------------------------------------------------------------------------- 1 | def qsort(data) 2 | # do once sort 3 | def once(left, right) 4 | var pivot = data[left] # use the 0th value as the pivot 5 | while left < right # check if sort is complete 6 | # put the value less than the pivot to the left 7 | while left < right && data[right] >= pivot 8 | right -= 1 # skip values greater than pivot 9 | end 10 | data[left] = data[right] 11 | # put the value greater than the pivot on the right 12 | while left < right && data[left] <= pivot 13 | left += 1 # skip values less than pivot 14 | end 15 | data[right] = data[left] 16 | end 17 | # now we have the index of the pivot, store it 18 | data[left] = pivot 19 | return left # return the index of the pivot 20 | end 21 | # recursive quick sort algorithm 22 | def _sort(left, right) 23 | if left < right # executed when the array is not empty 24 | var index = once(left, right) # get index of pivot for divide and conquer 25 | _sort(left, index - 1) # sort the data on the left 26 | _sort(index + 1, right) # sort the data on the right 27 | end 28 | end 29 | # start quick sort 30 | _sort(0, data.size() - 1) 31 | return data 32 | end 33 | 34 | import time, math 35 | math.srand(time.time()) # sse system time as a random seed 36 | data = [] 37 | # put 20 random numbers into the array 38 | for i : 1 .. 20 39 | data.push(math.rand() % 100) 40 | end 41 | # sort and print 42 | print(qsort(data)) 43 | -------------------------------------------------------------------------------- /lib/berry/examples/repl.be: -------------------------------------------------------------------------------- 1 | do 2 | def ismult(msg) 3 | import string 4 | return string.split(msg, -5)[1] == '\'EOS\'' 5 | end 6 | 7 | def multline(src, msg) 8 | if !ismult(msg) 9 | print('syntax_error: ' + msg) 10 | return 11 | end 12 | while true 13 | try 14 | src += '\n' + input('>> ') 15 | return compile(src) 16 | except 'syntax_error' as e, m 17 | if !ismult(m) 18 | print('syntax_error: ' + m) 19 | return 20 | end 21 | end 22 | end 23 | end 24 | 25 | def parse() 26 | var fun, src = input('> ') 27 | try 28 | fun = compile('return (' + src + ')') 29 | except 'syntax_error' as e, m 30 | try 31 | fun = compile(src) 32 | except 'syntax_error' as e, m 33 | fun = multline(src, m) 34 | end 35 | end 36 | return fun 37 | end 38 | 39 | def run(fun) 40 | try 41 | var res = fun() 42 | if res print(res) end 43 | except .. as e, m 44 | import debug 45 | print(e .. ': ' .. m) 46 | debug.traceback() 47 | end 48 | end 49 | 50 | def repl() 51 | while true 52 | var fun = parse() 53 | if fun != nil 54 | run(fun) 55 | end 56 | end 57 | end 58 | 59 | print("Berry Berry REPL!") 60 | repl() 61 | end 62 | -------------------------------------------------------------------------------- /lib/berry/examples/string.be: -------------------------------------------------------------------------------- 1 | s = "This is a long string test. 0123456789 abcdefg ABCDEFG" 2 | print(s) 3 | 4 | a = .5 5 | print(a) 6 | 7 | import string as s 8 | 9 | print(s.hex(0x45678ABCD, 16)) 10 | 11 | def bin(x, num) 12 | assert(type(x) == 'int', 'the type of \'x\' must be integer') 13 | # test the 'x' bits 14 | var bits = 1 15 | for i : 0 .. 62 16 | if x & (1 << 63 - i) 17 | bits = 64 - i 18 | break 19 | end 20 | end 21 | if type(num) == 'int' && num > 0 && num <= 64 22 | bits = bits < num ? num : bits 23 | end 24 | var result = '' 25 | bits -= 1 26 | for i : 0 .. bits 27 | result += x & (1 << (bits - i)) ? '1' : '0' 28 | end 29 | return result 30 | end 31 | 32 | print(bin(33)) 33 | -------------------------------------------------------------------------------- /lib/berry/examples/strmod.be: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | print(string.format('%.3d', 12)) 4 | print(string.format('%.3f', 12)) 5 | print(string.format('%20.7f', 14.5)) 6 | print(string.format('-- %-40s ---', 'this is a string format test')) 7 | print(string.format('-- %40s ---', 'this is a string format test')) 8 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Area_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Area_Type_map) { 4 | { be_const_key(Move, 3), be_const_ctype_func(Berry_Area_Class_Move_06C52118_A19B_4550_99D6_E2E693FD7B63) }, 5 | { be_const_key(Set_Height, -1), be_const_ctype_func(Berry_Area_Class_Set_Height_BF3B29D5_0BAB_4B73_99A4_3F71E31DB28D) }, 6 | { be_const_key(deinit, 8), be_const_ctype_func(Berry_Area_Class_Deinitialize_A05F0065_688C_4FE4_948A_0827E6F4E6DA) }, 7 | { be_const_key(Align, -1), be_const_ctype_func(Berry_Area_Class_Align_7B700901_671E_4672_A1B9_F841AA24E1F5) }, 8 | { be_const_key(Set_Width, -1), be_const_ctype_func(Berry_Area_Class_Set_Width_7217134E_F28F_4BF7_846B_D48313E86F20) }, 9 | { be_const_key(Get_Height, 7), be_const_ctype_func(Berry_Area_Class_Get_Height_6B40A2A7_E3F0_4BAE_AB6D_64F2DD6336F3) }, 10 | { be_const_key(Get_Width, -1), be_const_ctype_func(Berry_Area_Class_Get_Width_3E919A7E_FDB4_4CD7_80F9_C73EB39184DB) }, 11 | { be_const_key(Increase, 9), be_const_ctype_func(Berry_Area_Class_Increase_18FF6AD3_8DF6_4D69_A0EF_33A5F5107DA4) }, 12 | { be_const_key(_p, -1), be_const_var(0) }, 13 | { be_const_key(Get_Size, -1), be_const_ctype_func(Berry_Area_Class_Get_Size_FA2A7BBC_5299_4B09_8711_332335C5754A) }, 14 | }; 15 | 16 | static be_define_const_map( 17 | Berry_Area_Type_map, 18 | 10 19 | ); 20 | 21 | BE_EXPORT_VARIABLE be_define_const_class( 22 | Berry_Area_Type, 23 | 1, 24 | NULL, 25 | Area_Type 26 | ); 27 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Button_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Button_Type_map) { 4 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Button_Class_Deinitialize_59B3DDD4_B5F3_4B8D_95DA_F75EDD56620C) }, 5 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Button_Class_Create_FC1F1362_50F8_46F1_A28B_C465D39FC7FA) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | { be_const_key(init, -1), be_const_ctype_func(Berry_Button_Class_Initialize_CCA89751_D7EA_4DCD_B82B_15979217417F) }, 8 | }; 9 | 10 | static be_define_const_map( 11 | Berry_Button_Type_map, 12 | 4 13 | ); 14 | 15 | BE_EXPORT_VARIABLE be_define_const_class( 16 | Berry_Button_Type, 17 | 1, 18 | (bclass *)&Berry_Object_Type, 19 | Button_Type 20 | ); 21 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Checkbox_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Checkbox_Type_map) { 4 | { be_const_key(init, 1), be_const_ctype_func(Berry_Checkbox_Class_Initialize_FF452BD3_086C_47A5_9D9E_4AA8EE6641D5) }, 5 | { be_const_key(Set_Text, -1), be_const_ctype_func(Berry_Checkbox_Class_Set_Text_1262EAED_03BB_4BCF_AA5F_4151DCBCF3C1) }, 6 | { be_const_key(Create, 0), be_const_ctype_func(Berry_Checkbox_Class_Create_5341556C_AE53_433A_AD72_103D43007876) }, 7 | { be_const_key(Get_Text, -1), be_const_ctype_func(Berry_Checkbox_Class_Get_Text_402B01F3_C437_4B81_8DC2_F01ED60A599F) }, 8 | { be_const_key(Set_Text_Static, -1), be_const_ctype_func(Berry_Checkbox_Class_Set_Text_Static_2EC8480F_C61B_47D4_8A86_4A401C1A5505) }, 9 | { be_const_key(deinit, 2), be_const_ctype_func(Berry_Checkbox_Class_Deinitialize_4251986B_E64C_4790_9C66_5844AB3D737B) }, 10 | { be_const_key(_p, -1), be_const_var(0) }, 11 | }; 12 | 13 | static be_define_const_map( 14 | Berry_Checkbox_Type_map, 15 | 7 16 | ); 17 | 18 | BE_EXPORT_VARIABLE be_define_const_class( 19 | Berry_Checkbox_Type, 20 | 1, 21 | (bclass *)&Berry_Object_Type, 22 | Checkbox_Type 23 | ); 24 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Color_Dialog_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Color_Dialog_Type_map) { 4 | { be_const_key(Get_Color, -1), be_const_ctype_func(Berry_Color_Dialog_Class_Get_Color_37631A7D_DCFF_4449_94AE_7EA423C6F466) }, 5 | { be_const_key(Set_Color, -1), be_const_ctype_func(Berry_Color_Dialog_Class_Set_Color_D4485A68_E304_4841_9A4A_1965BCB4801B) }, 6 | { be_const_key(deinit, 3), be_const_ctype_func(Berry_Color_Dialog_Class_Deinitialize_BEE4E46C_CC92_4144_9341_F47767A9AAAA) }, 7 | { be_const_key(_p, -1), be_const_var(0) }, 8 | { be_const_key(Create, 0), be_const_ctype_func(Berry_Color_Dialog_Class_Create_89C21F8A_2F45_4E62_8856_76C3CE179DCD) }, 9 | }; 10 | 11 | static be_define_const_map( 12 | Berry_Color_Dialog_Type_map, 13 | 5 14 | ); 15 | 16 | BE_EXPORT_VARIABLE be_define_const_class( 17 | Berry_Color_Dialog_Type, 18 | 1, 19 | (bclass *)&Berry_Dialog_Type, 20 | Color_Dialog_Type 21 | ); 22 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Color_Filter_Descriptor_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Color_Filter_Descriptor_Type_map) { 4 | { be_const_key(_p, 1), be_const_var(0) }, 5 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Color_Filter_Descriptor_Class_Deinitialize_35A06B9E_B6EB_4071_8CF3_E7152B2F04F2) }, 6 | }; 7 | 8 | static be_define_const_map( 9 | Berry_Color_Filter_Descriptor_Type_map, 10 | 2 11 | ); 12 | 13 | BE_EXPORT_VARIABLE be_define_const_class( 14 | Berry_Color_Filter_Descriptor_Type, 15 | 1, 16 | NULL, 17 | Color_Filter_Descriptor_Type 18 | ); 19 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Color_Wheel_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Color_Wheel_Type_map) { 4 | { be_const_key(Get_Color, -1), be_const_ctype_func(Berry_Color_Wheel_Class_Get_Color_CBCFD5E4_C1BC_4728_AEB7_B21176ED5925) }, 5 | { be_const_key(Set_Color, -1), be_const_ctype_func(Berry_Color_Wheel_Class_Set_Color_98BC290B_411A_4733_B7D1_FE477223EC95) }, 6 | { be_const_key(deinit, 8), be_const_ctype_func(Berry_Color_Wheel_Class_Deinitialize_5B0FE8C1_C2DB_4F93_891F_A2AEF562A350) }, 7 | { be_const_key(Set_Mode, -1), be_const_ctype_func(Berry_Color_Wheel_Class_Set_Mode_11958EBF_D676_4D49_9FF3_ADD0B6C6AB4C) }, 8 | { be_const_key(Get_Mode_Fixed, -1), be_const_ctype_func(Berry_Color_Wheel_Class_Get_Mode_Fixed_DCD800B4_93A4_4204_92FD_A71C1977BC0F) }, 9 | { be_const_key(init, -1), be_const_ctype_func(Berry_Color_Wheel_Class_Initialize_699F83E7_BAD2_4967_AECB_91F07CCD1E53) }, 10 | { be_const_key(Set_Mode_Fixed, -1), be_const_ctype_func(Berry_Color_Wheel_Class_Set_Mode_Fixed_745C6BDB_9068_4187_8FB7_12B1C87DB025) }, 11 | { be_const_key(Get_Mode, -1), be_const_ctype_func(Berry_Color_Wheel_Class_Get_Mode_9D8C950B_AFEB_4208_80EF_28139D95AB5E) }, 12 | { be_const_key(_p, -1), be_const_var(0) }, 13 | { be_const_key(Create, 0), be_const_ctype_func(Berry_Color_Wheel_Class_Create_E643953F_F29C_4AA3_A01E_840587410EC3) }, 14 | }; 15 | 16 | static be_define_const_map( 17 | Berry_Color_Wheel_Type_map, 18 | 10 19 | ); 20 | 21 | BE_EXPORT_VARIABLE be_define_const_class( 22 | Berry_Color_Wheel_Type, 23 | 1, 24 | (bclass *)&Berry_Object_Type, 25 | Color_Wheel_Type 26 | ); 27 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Decoder_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Decoder_Type_map) { 4 | { be_const_key(Get_Configuration, -1), be_const_ctype_func(Berry_Decoder_Class_Get_Configuration_9BF7B632_80E2_4C09_AFAD_ECB7400A9BC5) }, 5 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Decoder_Class_Deinitialize_A2D69403_A8A9_4D86_9669_3AE11156D477) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | }; 8 | 9 | static be_define_const_map( 10 | Berry_Decoder_Type_map, 11 | 3 12 | ); 13 | 14 | BE_EXPORT_VARIABLE be_define_const_class( 15 | Berry_Decoder_Type, 16 | 1, 17 | NULL, 18 | Decoder_Type 19 | ); 20 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Dialog_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Dialog_Type_map) { 4 | { be_const_key(Is_Overlay, -1), be_const_ctype_func(Berry_Dialog_Class_Is_Overlay_0420DB67_3B27_44CB_82C8_90D2450C53AB) }, 5 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Dialog_Class_Create_79D00185_8EDB_4EFE_B958_97F69BCB9096) }, 6 | { be_const_key(_p, 5), be_const_var(0) }, 7 | { be_const_key(init, 1), be_const_ctype_func(Berry_Dialog_Class_Initialize_AA627FA1_196C_424F_9C9C_F686FA67236B) }, 8 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Dialog_Class_Deinitialize_0269C884_D187_4B43_A256_25D2DF551D14) }, 9 | { be_const_key(Set_Overlay, -1), be_const_ctype_func(Berry_Dialog_Class_Set_Overlay_42299C73_D72B_4DDC_AA9B_5ECC551126B4) }, 10 | }; 11 | 12 | static be_define_const_map( 13 | Berry_Dialog_Type_map, 14 | 6 15 | ); 16 | 17 | BE_EXPORT_VARIABLE be_define_const_class( 18 | Berry_Dialog_Type, 19 | 1, 20 | (bclass *)&Berry_Window_Type, 21 | Dialog_Type 22 | ); 23 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Hash_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Hash_Type_map) { 4 | { be_const_key(_p, 1), be_const_var(0) }, 5 | { be_const_key(Is_Valid, 2), be_const_ctype_func(Berry_Hash_Class_Is_Valid_09EB699D_6C54_489D_8609_08F439B4CDC2) }, 6 | { be_const_key(Delete, -1), be_const_ctype_func(Berry_Hash_Class_Delete_9ED8FBD2_5EFC_469A_9EEC_96CDE7A7C7E6) }, 7 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Hash_Class_Create_B569D486_8E32_4723_908B_067C847EDE52) }, 8 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Hash_Class_Deinitialize_921D91CD_9A0E_49C6_B6CA_576E287D666A) }, 9 | { be_const_key(Get_Type, -1), be_const_ctype_func(Berry_Hash_Class_Get_Type_DEDDB584_C1D3_43DE_B82A_46FF27521213) }, 10 | { be_const_key(init, 7), be_const_ctype_func(Berry_Hash_Class_Initialize_69E03B26_743B_4D38_8A00_1B9762AAE465) }, 11 | { be_const_key(Get_Size, -1), be_const_ctype_func(Berry_Hash_Class_Get_Size_E05F204B_49D9_4EBB_A7EB_0DAA48C837AD) }, 12 | { be_const_key(Add, 0), be_const_ctype_func(Berry_Hash_Class_Add_042BA89C_7476_48ED_88A3_D7F826B1876A) }, 13 | }; 14 | 15 | static be_define_const_map( 16 | Berry_Hash_Type_map, 17 | 9 18 | ); 19 | 20 | BE_EXPORT_VARIABLE be_define_const_class( 21 | Berry_Hash_Type, 22 | 1, 23 | NULL, 24 | Hash_Type 25 | ); 26 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_I2S_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_I2S_Type_map) { 4 | { be_const_key(init, -1), be_const_ctype_func(Berry_I2S_Class_Initialize_0C462471_FA61_4B68_B5E9_A978C6D2AEB2) }, 5 | { be_const_key(Begin, -1), be_const_ctype_func(Berry_I2S_Class_Begin_E20F1EFD_6987_48D1_AB40_97332140DADB) }, 6 | { be_const_key(deinit, 4), be_const_ctype_func(Berry_I2S_Class_Deinitialize_66959ECF_9E24_427F_ABDD_8299F1FED6F2) }, 7 | { be_const_key(Get_Default_Configuration, 1), be_const_ctype_func(Berry_I2S_Class_Get_Default_Configuration_71B166CB_2C30_4588_9DCD_B7590C094594) }, 8 | { be_const_key(_p, -1), be_const_var(0) }, 9 | }; 10 | 11 | static be_define_const_map( 12 | Berry_I2S_Type_map, 13 | 5 14 | ); 15 | 16 | BE_EXPORT_VARIABLE be_define_const_class( 17 | Berry_I2S_Type, 18 | 1, 19 | NULL, 20 | I2S_Type 21 | ); 22 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_IP_Address_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_IP_Address_Type_map) { 4 | { be_const_key(init, -1), be_const_ctype_func(Berry_IP_Address_Class_Initialize_EA495F1B_E003_4913_8391_9DDBD11FEC6A) }, 5 | { be_const_key(_p, -1), be_const_var(0) }, 6 | { be_const_key(Is_IP_v4, -1), be_const_ctype_func(Berry_IP_Address_Class_Is_IP_v4_0B94DB72_BE0E_42B5_9CBD_533386CEC2BC) }, 7 | { be_const_key(To, 0), be_const_ctype_func(Berry_IP_Address_Class_To_21485721_A70C_44B3_A330_CB7C543D4DD4) }, 8 | { be_const_key(_X3D_X3D, -1), be_const_ctype_func(Berry_IP_Address_Class_Operator_7E33A206_3A8F_4762_B48C_0310DD88B350) }, 9 | { be_const_key(deinit, 3), be_const_ctype_func(Berry_IP_Address_Class_Deinitialize_273B492A_82B9_41A1_9F58_BF5DC0F0765B) }, 10 | { be_const_key(Set_IP_Version, 1), be_const_ctype_func(Berry_IP_Address_Class_Set_IP_Version_CAA36ECA_1513_482B_9A78_4881C02C0BE0) }, 11 | }; 12 | 13 | static be_define_const_map( 14 | Berry_IP_Address_Type_map, 15 | 7 16 | ); 17 | 18 | BE_EXPORT_VARIABLE be_define_const_class( 19 | Berry_IP_Address_Type, 20 | 1, 21 | NULL, 22 | IP_Address_Type 23 | ); 24 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Keyboard_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Keyboard_Type_map) { 4 | { be_const_key(Remove_Text_Area, -1), be_const_ctype_func(Berry_Keyboard_Class_Remove_Text_Area_E675B593_BC38_4CF3_BC2F_7DB692DCCAE7) }, 5 | { be_const_key(Set_Text_Area, -1), be_const_ctype_func(Berry_Keyboard_Class_Set_Text_Area_2B350D2C_20E8_47EF_B357_250411657B51) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | { be_const_key(init, 5), be_const_ctype_func(Berry_Keyboard_Class_Initialize_4EA404FA_AFC0_4211_BFB0_1CEAF41D6B13) }, 8 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Keyboard_Class_Deinitialize_49EC46E8_4CCE_490C_9F55_C0F284C64297) }, 9 | { be_const_key(Set_Pop_Overs, -1), be_const_ctype_func(Berry_Keyboard_Class_Set_Pop_Overs_290CC1BD_589E_4A32_BEE2_F33E6CB76E21) }, 10 | { be_const_key(Get_Button_Text, -1), be_const_ctype_func(Berry_Keyboard_Class_Get_Button_Text_9FA633BF_75EA_47B5_80B8_0A9C4F96E93E) }, 11 | { be_const_key(Get_Mode, -1), be_const_ctype_func(Berry_Keyboard_Class_Get_Mode_81BAFFF1_F9BB_4C77_86BE_D8F0ED9141B1) }, 12 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Keyboard_Class_Create_F7177129_E7E9_4763_9F3F_B495E1CC7A7B) }, 13 | { be_const_key(Get_Text_Area, 8), be_const_ctype_func(Berry_Keyboard_Class_Get_Text_Area_52FB14EE_2FC6_447D_8F66_9512675416DD) }, 14 | { be_const_key(Get_Selected_Button, -1), be_const_ctype_func(Berry_Keyboard_Class_Get_Selected_Button_C2D540BA_D5F8_47E6_BA00_BEACF7768417) }, 15 | { be_const_key(Set_Mode, 0), be_const_ctype_func(Berry_Keyboard_Class_Set_Mode_B4CF387E_CCC2_4686_8733_2D008020AEC2) }, 16 | }; 17 | 18 | static be_define_const_map( 19 | Berry_Keyboard_Type_map, 20 | 12 21 | ); 22 | 23 | BE_EXPORT_VARIABLE be_define_const_class( 24 | Berry_Keyboard_Type, 25 | 1, 26 | (bclass *)&Berry_Object_Type, 27 | Keyboard_Type 28 | ); 29 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Line_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Line_Type_map) { 4 | { be_const_key(Create, 5), be_const_ctype_func(Berry_Line_Class_Create_AD18236E_509F_4676_A70D_F19E5D472827) }, 5 | { be_const_key(Get_Y_Inversion, -1), be_const_ctype_func(Berry_Line_Class_Get_Y_Inversion_64613940_E1FD_4AF2_8D96_AF548C8568C2) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | { be_const_key(Set_Y_Inversion, 0), be_const_ctype_func(Berry_Line_Class_Set_Y_Inversion_2016ED34_0052_44DF_BB68_95D4B03A817B) }, 8 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Line_Class_Deinitialize_0A04EFAB_55B7_4CFA_A309_302CB88E18EC) }, 9 | { be_const_key(init, -1), be_const_ctype_func(Berry_Line_Class_Initialize_42EE213E_AAD8_4569_9F1B_4A5657B41969) }, 10 | }; 11 | 12 | static be_define_const_map( 13 | Berry_Line_Type_map, 14 | 6 15 | ); 16 | 17 | BE_EXPORT_VARIABLE be_define_const_class( 18 | Berry_Line_Type, 19 | 1, 20 | (bclass *)&Berry_Object_Type, 21 | Line_Type 22 | ); 23 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_List_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_List_Type_map) { 4 | { be_const_key(Add_Text, -1), be_const_ctype_func(Berry_List_Class_Add_Text_DB15094C_90E8_4327_91C5_B567FE4991F0) }, 5 | { be_const_key(Create, 3), be_const_ctype_func(Berry_List_Class_Create_BD1753B0_8049_43E2_B106_6EFD36BB4BC9) }, 6 | { be_const_key(Add_Button, -1), be_const_ctype_func(Berry_List_Class_Add_Button_C8446DD0_0E85_41E2_879A_3F7ACE3819EF) }, 7 | { be_const_key(init, -1), be_const_ctype_func(Berry_List_Class_Initialize_74B38C73_BDCE_4A68_B2AB_E4D9CBDD3B09) }, 8 | { be_const_key(Get_Button_Text, 2), be_const_ctype_func(Berry_List_Class_Get_Button_Text_4D4ECCC8_B4CD_4634_8473_87146D088350) }, 9 | { be_const_key(deinit, 1), be_const_ctype_func(Berry_List_Class_Deinitialize_7E860049_FEFE_4D53_9D8A_1203449714C9) }, 10 | { be_const_key(_p, 0), be_const_var(0) }, 11 | }; 12 | 13 | static be_define_const_map( 14 | Berry_List_Type_map, 15 | 7 16 | ); 17 | 18 | BE_EXPORT_VARIABLE be_define_const_class( 19 | Berry_List_Type, 20 | 1, 21 | (bclass *)&Berry_Object_Type, 22 | List_Type 23 | ); 24 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Message_Dialog_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Message_Dialog_Type_map) { 4 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Message_Dialog_Class_Create_EDCE196E_99EC_46C7_AFA3_B5E1906ACC51) }, 5 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Message_Dialog_Class_Deinitialize_E0EBE6CD_B694_44F6_98F9_8FC56EF293E2) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | }; 8 | 9 | static be_define_const_map( 10 | Berry_Message_Dialog_Type_map, 11 | 3 12 | ); 13 | 14 | BE_EXPORT_VARIABLE be_define_const_class( 15 | Berry_Message_Dialog_Type, 16 | 1, 17 | (bclass *)&Berry_Dialog_Type, 18 | Message_Dialog_Type 19 | ); 20 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Point_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Point_Type_map) { 4 | { be_const_key(Get_X_, 6), be_const_ctype_func(Berry_Point_Class_Get_X_3F3B7E24_2EAA_4E0B_BE23_7EB577652146) }, 5 | { be_const_key(Set, -1), be_const_ctype_func(Berry_Point_Class_Set_A2A8F67F_30CD_4A3A_A9F7_5107859609B7) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | { be_const_key(init, 5), be_const_ctype_func(Berry_Point_Class_Initialize_9046DD73_5A9B_476C_B036_CA04FFC3F8C4) }, 8 | { be_const_key(Set_X_, -1), be_const_ctype_func(Berry_Point_Class_Set_X_9A04EC14_E299_4FF5_A249_F9388ACD8933) }, 9 | { be_const_key(Get_Y, 1), be_const_ctype_func(Berry_Point_Class_Get_Y_17D25BD7_B303_4255_A314_573EFD89C78E) }, 10 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Point_Class_Deinitialize_326ED9E3_84EF_46DE_B7AB_4A298C981DED) }, 11 | { be_const_key(Set_Y, -1), be_const_ctype_func(Berry_Point_Class_Set_Y_380D1C96_822B_40AB_BEF5_DFED06263053) }, 12 | }; 13 | 14 | static be_define_const_map( 15 | Berry_Point_Type_map, 16 | 8 17 | ); 18 | 19 | BE_EXPORT_VARIABLE be_define_const_class( 20 | Berry_Point_Type, 21 | 1, 22 | NULL, 23 | Point_Type 24 | ); 25 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Progress_Dialog_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Progress_Dialog_Type_map) { 4 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Progress_Dialog_Class_Create_FAD3C613_29C8_43B7_A901_066DA20619A2) }, 5 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Progress_Dialog_Class_Deinitialize_1F1440B7_61A9_4DE0_81E3_D1E580A5DA47) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | }; 8 | 9 | static be_define_const_map( 10 | Berry_Progress_Dialog_Type_map, 11 | 3 12 | ); 13 | 14 | BE_EXPORT_VARIABLE be_define_const_class( 15 | Berry_Progress_Dialog_Type, 16 | 1, 17 | (bclass *)&Berry_Dialog_Type, 18 | Progress_Dialog_Type 19 | ); 20 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_QRCode_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_QRCode_Type_map) { 4 | { be_const_key(init, -1), be_const_ctype_func(Berry_QRCode_Class_Initialize_F359CA24_1353_4F4E_8366_DC1FE175333E) }, 5 | { be_const_key(_p, -1), be_const_var(0) }, 6 | { be_const_key(deinit, 3), be_const_ctype_func(Berry_QRCode_Class_Deinitialize_9BE98AC0_D236_4557_86E5_3F584779DA22) }, 7 | { be_const_key(Update, 1), be_const_ctype_func(Berry_QRCode_Class_Update_2EAD79C2_D6F8_441F_BBF0_1141EFB5575A) }, 8 | { be_const_key(Create, -1), be_const_ctype_func(Berry_QRCode_Class_Create_907242A9_F9DF_4FBF_AEAE_A05529D69DED) }, 9 | }; 10 | 11 | static be_define_const_map( 12 | Berry_QRCode_Type_map, 13 | 5 14 | ); 15 | 16 | BE_EXPORT_VARIABLE be_define_const_class( 17 | Berry_QRCode_Type, 18 | 1, 19 | (bclass *)&Berry_Object_Type, 20 | QRCode_Type 21 | ); 22 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Roller_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Roller_Type_map) { 4 | { be_const_key(Get_Selected_String, 3), be_const_ctype_func(Berry_Roller_Class_Get_Selected_String_EC5651E3_C427_4300_95C7_EB744E8E2732) }, 5 | { be_const_key(Get_Options, 7), be_const_ctype_func(Berry_Roller_Class_Get_Options_D7A9A026_45FD_446E_9947_BC31147B4B16) }, 6 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Roller_Class_Deinitialize_79EDC691_0B76_41A1_B16D_723F94999195) }, 7 | { be_const_key(Get_Selected, -1), be_const_ctype_func(Berry_Roller_Class_Get_Selected_3325D7B0_DF20_4DD0_BBE8_DA722C4625A5) }, 8 | { be_const_key(Create, 5), be_const_ctype_func(Berry_Roller_Class_Create_7B0755FF_9C66_4549_9954_F1F1D70B5B45) }, 9 | { be_const_key(Set_Selected, -1), be_const_ctype_func(Berry_Roller_Class_Set_Selected_C398ED15_7620_4CEE_87E5_F265D56D6E95) }, 10 | { be_const_key(Set_Visible_Row_Count, -1), be_const_ctype_func(Berry_Roller_Class_Set_Visible_Row_Count_3C3F0EB1_A80F_4E6B_AC20_0D44E78E7A71) }, 11 | { be_const_key(_p, 10), be_const_var(0) }, 12 | { be_const_key(Get_Option_Count, 4), be_const_ctype_func(Berry_Roller_Class_Get_Option_Count_BC1B47DB_ABD7_4EB4_B9CA_0DCA4F6EFD0A) }, 13 | { be_const_key(init, -1), be_const_ctype_func(Berry_Roller_Class_Initialize_EC0DA026_DD0D_4157_B360_51E605FEC7C9) }, 14 | { be_const_key(Set_Options, -1), be_const_ctype_func(Berry_Roller_Class_Set_Options_FF2290FA_02D1_4149_965B_0209834EE75D) }, 15 | }; 16 | 17 | static be_define_const_map( 18 | Berry_Roller_Type_map, 19 | 11 20 | ); 21 | 22 | BE_EXPORT_VARIABLE be_define_const_class( 23 | Berry_Roller_Type, 24 | 1, 25 | (bclass *)&Berry_Object_Type, 26 | Roller_Type 27 | ); 28 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Screen_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Screen_Type_map) { 4 | { be_const_key(Get_User_Screen, 7), be_const_ctype_func(Berry_Screen_Class_Get_User_Screen_20211610_56E6_4B16_90E9_C43E9FC4A47A) }, 5 | { be_const_key(Load, -1), be_const_ctype_func(Berry_Screen_Class_Load_0F5F04DE_C957_4550_96CD_2931D853B398) }, 6 | { be_const_key(Delete, 4), be_const_ctype_func(Berry_Screen_Class_Delete_7F2D8410_B1C2_4AD8_A413_12890FD3529C) }, 7 | { be_const_key(init, -1), be_const_ctype_func(Berry_Screen_Class_Initialize_1BD31F6D_0D9B_4AFF_A00B_8CEC8581FED0) }, 8 | { be_const_key(Get_Active, 6), be_const_ctype_func(Berry_Screen_Class_Get_Active_24E53D74_EE65_4409_81D7_34892D0231CF) }, 9 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Screen_Class_Create_61EA4FBF_3F5C_43A9_B91D_6DD5FDAF0943) }, 10 | { be_const_key(_p, -1), be_const_var(0) }, 11 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Screen_Class_Deinitialize_62A415C5_9356_49C1_8717_8BDCBF36AF86) }, 12 | }; 13 | 14 | static be_define_const_map( 15 | Berry_Screen_Type_map, 16 | 8 17 | ); 18 | 19 | BE_EXPORT_VARIABLE be_define_const_class( 20 | Berry_Screen_Type, 21 | 1, 22 | (bclass *)&Berry_Object_Type, 23 | Screen_Type 24 | ); 25 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Software_Handle_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Software_Handle_Type_map) { 4 | { be_const_key(Get_Name, 1), be_const_ctype_func(Berry_Software_Handle_Class_Get_Name_CACE01A7_3CC1_49D6_8F94_EA627E78D49B) }, 5 | { be_const_key(init, -1), be_const_ctype_func(Berry_Software_Handle_Class_Initialize_BCF1AE68_93CA_48DD_9EF9_D8F4385BF925) }, 6 | { be_const_key(deinit, 4), be_const_ctype_func(Berry_Software_Handle_Class_Deinitialize_561BE87A_3F75_4AEB_A337_EEB0038A3CAE) }, 7 | { be_const_key(Create_Instance, -1), be_const_ctype_func(Berry_Software_Handle_Class_Create_Instance_8C28BBF6_F7D3_4A3F_B3FE_27E170F681BF) }, 8 | { be_const_key(_p, -1), be_const_var(0) }, 9 | }; 10 | 11 | static be_define_const_map( 12 | Berry_Software_Handle_Type_map, 13 | 5 14 | ); 15 | 16 | BE_EXPORT_VARIABLE be_define_const_class( 17 | Berry_Software_Handle_Type, 18 | 1, 19 | NULL, 20 | Software_Handle_Type 21 | ); 22 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Software_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Software_Type_map) { 4 | { be_const_key(Get_Handle, 1), be_const_ctype_func(Berry_Software_Class_Get_Handle_259C5AB3_0284_4EFC_814E_B788F858A6C4) }, 5 | { be_const_key(Get_Owner_User, -1), be_const_ctype_func(Berry_Software_Class_Get_Owner_User_62A61706_23EA_45A6_B9A4_A7A4B7640F0D) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | }; 8 | 9 | static be_define_const_map( 10 | Berry_Software_Type_map, 11 | 3 12 | ); 13 | 14 | BE_EXPORT_VARIABLE be_define_const_class( 15 | Berry_Software_Type, 16 | 1, 17 | NULL, 18 | Software_Type 19 | ); 20 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Stream_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Stream_Type_map) { 4 | { be_const_key(Begin, -1), be_const_ctype_func(Berry_Stream_Class_Begin_8842A979_8572_4D2E_B0EB_E07B9EEC9136) }, 5 | { be_const_key(_p, -1), be_const_var(0) }, 6 | { be_const_key(Set_Notify_Audio_Change, 1), be_const_ctype_func(Berry_Stream_Class_Set_Notify_Audio_Change_03278073_AEFC_4878_8C09_5A9406EE8860) }, 7 | { be_const_key(Set_Configuration, 0), be_const_ctype_func(Berry_Stream_Class_Set_Configuration_7216C9A1_A4B5_469D_8C31_7E27906888C6) }, 8 | { be_const_key(End, -1), be_const_ctype_func(Berry_Stream_Class_End_6FDDDC20_6DAB_4202_B728_1752FF27F706) }, 9 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Stream_Class_Deinitialize_1BFD0FC7_7303_45EE_8F2B_BF2B16CDD1F8) }, 10 | { be_const_key(Get_Configuration, 2), be_const_ctype_func(Berry_Stream_Class_Get_Configuration_BE4D344F_D8D9_4728_AE12_95DBE178310A) }, 11 | }; 12 | 13 | static be_define_const_map( 14 | Berry_Stream_Type_map, 15 | 7 16 | ); 17 | 18 | BE_EXPORT_VARIABLE be_define_const_class( 19 | Berry_Stream_Type, 20 | 1, 21 | NULL, 22 | Stream_Type 23 | ); 24 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Switch_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Switch_Type_map) { 4 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Switch_Class_Deinitialize_95043993_475E_48D9_8D20_926DAA221118) }, 5 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Switch_Class_Create_522B0698_F4CA_4A79_856C_2C249B50EFFC) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | { be_const_key(init, -1), be_const_ctype_func(Berry_Switch_Class_Initialize_68C7BD98_BF4C_4AEB_9CE9_B9652A99C909) }, 8 | }; 9 | 10 | static be_define_const_map( 11 | Berry_Switch_Type_map, 12 | 4 13 | ); 14 | 15 | BE_EXPORT_VARIABLE be_define_const_class( 16 | Berry_Switch_Type, 17 | 1, 18 | (bclass *)&Berry_Object_Type, 19 | Switch_Type 20 | ); 21 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Tabs_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Tabs_Type_map) { 4 | { be_const_key(Set_Active_Tab, 1), be_const_ctype_func(Berry_Tabs_Class_Set_Active_Tab_E7F3A7D8_E434_4699_B4A8_EEE3765EE60F) }, 5 | { be_const_key(deinit, 8), be_const_ctype_func(Berry_Tabs_Class_Deinitialize_4E26EAD4_7AEF_482A_BA13_52FFA0F496EA) }, 6 | { be_const_key(Add_Tab, 0), be_const_ctype_func(Berry_Tabs_Class_Add_Tab_C5756AEA_BBDB_45C7_8DD6_7D9A5058212B) }, 7 | { be_const_key(Create, -1), be_const_ctype_func(Berry_Tabs_Class_Create_A7E557B5_F5C9_47E6_93DE_E29B85579463) }, 8 | { be_const_key(Get_Tab_Active, -1), be_const_ctype_func(Berry_Tabs_Class_Get_Tab_Active_A1C76EDC_B783_4FCB_9526_033EBACDDC81) }, 9 | { be_const_key(Rename_Tab, 6), be_const_ctype_func(Berry_Tabs_Class_Rename_Tab_DDFC647C_89BB_40EB_B8FD_35019039D2FC) }, 10 | { be_const_key(init, -1), be_const_ctype_func(Berry_Tabs_Class_Initialize_15E9913C_1C9A_44AC_9581_6BDABBBD011E) }, 11 | { be_const_key(Get_Tab_Buttons, -1), be_const_ctype_func(Berry_Tabs_Class_Get_Tab_Buttons_9F6CF274_6063_4EF4_BCEF_E88A4F494F91) }, 12 | { be_const_key(_p, -1), be_const_var(0) }, 13 | { be_const_key(Get_Content, 3), be_const_ctype_func(Berry_Tabs_Class_Get_Content_0A595C8A_D2C5_4F9A_AEB8_8DA0A0E99454) }, 14 | }; 15 | 16 | static be_define_const_map( 17 | Berry_Tabs_Type_map, 18 | 10 19 | ); 20 | 21 | BE_EXPORT_VARIABLE be_define_const_class( 22 | Berry_Tabs_Type, 23 | 1, 24 | (bclass *)&Berry_Object_Type, 25 | Tabs_Type 26 | ); 27 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Volume_Configuration_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Volume_Configuration_Type_map) { 4 | { be_const_key(Get_Volume, -1), be_const_ctype_func(Berry_Volume_Configuration_Class_Get_Volume_F587BFB4_0D2B_40C6_867E_C727DDC7412B) }, 5 | { be_const_key(Get_Allow_Boost, -1), be_const_ctype_func(Berry_Volume_Configuration_Class_Get_Allow_Boost_02D3EC19_D757_4EC7_A5D3_0B27FDE4224C) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | { be_const_key(init, -1), be_const_ctype_func(Berry_Volume_Configuration_Class_Initialize_E6FF75B0_8C8F_4BF3_AFDC_8BBC5C751066) }, 8 | { be_const_key(Set_Allow_Boost, 3), be_const_ctype_func(Berry_Volume_Configuration_Class_Set_Allow_Boost_AC7CE45B_D827_4CC7_B4F2_6F5DE7E0485D) }, 9 | { be_const_key(deinit, 4), be_const_ctype_func(Berry_Volume_Configuration_Class_Deinitialize_D67172BD_1BA9_4115_B91E_394DEADA59A3) }, 10 | { be_const_key(Set_Volume, 2), be_const_ctype_func(Berry_Volume_Configuration_Class_Set_Volume_23CDE307_55C2_492C_9A10_61EFE6FC766B) }, 11 | }; 12 | 13 | static be_define_const_map( 14 | Berry_Volume_Configuration_Type_map, 15 | 7 16 | ); 17 | 18 | BE_EXPORT_VARIABLE be_define_const_class( 19 | Berry_Volume_Configuration_Type, 20 | 1, 21 | NULL, 22 | Volume_Configuration_Type 23 | ); 24 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_Volume_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_Volume_Type_map) { 4 | { be_const_key(Get_Volume, -1), be_const_ctype_func(Berry_Volume_Class_Get_Volume_2587964A_4D8E_46DC_A1F1_E362E5A31690) }, 5 | { be_const_key(Begin, -1), be_const_ctype_func(Berry_Volume_Class_Begin_A24AD730_3ADB_43E7_9771_D3B52CA8BB55) }, 6 | { be_const_key(Set_Volume, -1), be_const_ctype_func(Berry_Volume_Class_Set_Volume_ECAF170C_E91B_4061_BF75_AF10A5DD250B) }, 7 | { be_const_key(Get_Default_Configuration, 1), be_const_ctype_func(Berry_Volume_Class_Get_Default_Configuration_D41DA7CB_0FAB_408E_9AB7_D5CAE5723653) }, 8 | { be_const_key(init, -1), be_const_ctype_func(Berry_Volume_Class_Initialize_4F39A22B_4494_4358_9D13_0AAF0901C14A) }, 9 | { be_const_key(deinit, 4), be_const_ctype_func(Berry_Volume_Class_Deinitialize_BF4E88A0_02C1_4833_892B_AA4838E550B2) }, 10 | { be_const_key(_p, 2), be_const_var(0) }, 11 | }; 12 | 13 | static be_define_const_map( 14 | Berry_Volume_Type_map, 15 | 7 16 | ); 17 | 18 | BE_EXPORT_VARIABLE be_define_const_class( 19 | Berry_Volume_Type, 20 | 1, 21 | NULL, 22 | Volume_Type 23 | ); 24 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Berry_WAV_Decoder_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(Berry_WAV_Decoder_Type_map) { 4 | { be_const_key(init, -1), be_const_ctype_func(Berry_WAV_Decoder_Class_Initialize_99656F40_EEA4_4D46_8B83_DC3321BBA65A) }, 5 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_WAV_Decoder_Class_Deinitialize_53482198_DC2B_4277_9F4D_AA77B0A92756) }, 6 | { be_const_key(_p, -1), be_const_var(0) }, 7 | }; 8 | 9 | static be_define_const_map( 10 | Berry_WAV_Decoder_Type_map, 11 | 3 12 | ); 13 | 14 | BE_EXPORT_VARIABLE be_define_const_class( 15 | Berry_WAV_Decoder_Type, 16 | 1, 17 | NULL, 18 | WAV_Decoder_Type 19 | ); 20 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Clipboard.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libClipboard_map) { 4 | { be_const_key(Start, -1), be_const_ctype_func(Berry_Clipboard_Class_Start_773AA169_DC1F_4B25_A9FA_73C8BA7A6649) }, 5 | { be_const_key(Clear, -1), be_const_ctype_func(Berry_Clipboard_Class_Clear_AC0FC3F1_B73C_4260_B51B_D5F478483721) }, 6 | { be_const_key(Copy, -1), be_const_ctype_func(Berry_Clipboard_Class_Copy_0E89CBC2_D31C_4189_88A1_6A941550B35E) }, 7 | { be_const_key(Get_Pointer, 0), be_const_ctype_func(Berry_Clipboard_Class_Get_Pointer) }, 8 | { be_const_key(Paste, 1), be_const_ctype_func(Berry_Clipboard_Class_Paste_EB4EA7FE_7A02_42CE_B3CC_6947C6E65EA1) }, 9 | { be_const_key(Stop, -1), be_const_ctype_func(Berry_Clipboard_Class_Stop_C2B853D1_AA04_4898_9E35_B23D7B3AD1D5) }, 10 | }; 11 | 12 | static be_define_const_map( 13 | m_libClipboard_map, 14 | 6 15 | ); 16 | 17 | static be_define_const_module( 18 | m_libClipboard, 19 | "Clipboard" 20 | ); 21 | 22 | BE_EXPORT_VARIABLE be_define_const_native_module(Clipboard); 23 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_Memory.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libMemory_map) { 4 | { be_const_key(Get_Free_PSRAM, -1), be_const_ctype_func(Berry_Memory_Class_Get_Free_PSRAM_807478E4_DEC7_439A_950C_45302696CBEC) }, 5 | { be_const_key(Get_Heap_Size, -1), be_const_ctype_func(Berry_Memory_Class_Get_Heap_Size_7E9598D7_C4B2_40FC_8730_7F7E02E65DE3) }, 6 | { be_const_key(Get_Free_Heap, 5), be_const_ctype_func(Berry_Memory_Class_Get_Free_Heap_33798E50_B521_4A9F_9252_995D243DC0A1) }, 7 | { be_const_key(Get_Pointer, -1), be_const_ctype_func(Berry_Memory_Class_Get_Pointer) }, 8 | { be_const_key(Get_PSRAM_Size, -1), be_const_ctype_func(Berry_Memory_Class_Get_PSRAM_Size_38E84635_0490_404B_880C_DB64EB03AE5E) }, 9 | { be_const_key(Get_Minimum_Free_Heap, -1), be_const_ctype_func(Berry_Memory_Class_Get_Minimum_Free_Heap_0E05C2DA_BB91_4435_9F18_19E387972A7F) }, 10 | { be_const_key(Get_Minimum_Free_PSRAM, -1), be_const_ctype_func(Berry_Memory_Class_Get_Minimum_Free_PSRAM_768947DE_4F67_4FCF_8A32_362F55A138C2) }, 11 | { be_const_key(Get_Maximum_Allocated_PSRAM, 2), be_const_ctype_func(Berry_Memory_Class_Get_Maximum_Allocated_PSRAM_06F58CB9_B736_4694_BB92_FA4E2684AD82) }, 12 | { be_const_key(Get_Maximum_Allocated_Heap, -1), be_const_ctype_func(Berry_Memory_Class_Get_Maximum_Allocated_Heap_AEA6A511_5619_4A63_9F9B_BB598FF8B786) }, 13 | }; 14 | 15 | static be_define_const_map( 16 | m_libMemory_map, 17 | 9 18 | ); 19 | 20 | static be_define_const_module( 21 | m_libMemory, 22 | "Memory" 23 | ); 24 | 25 | BE_EXPORT_VARIABLE be_define_const_native_module(Memory); 26 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_This.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libThis_map) { 4 | { be_const_key(Get_Instruction, -1), be_const_ctype_func(Berry_This_Get_Instruction) }, 5 | { be_const_key(Get_Window, 5), be_const_ctype_func(Berry_This_Get_Window) }, 6 | { be_const_key(Delay_Microseconds, -1), be_const_ctype_func(Berry_This_Delay_Microseconds) }, 7 | { be_const_key(Instruction_Available, -1), be_const_ctype_func(Berry_This_Instruction_Available) }, 8 | { be_const_key(Delay, 1), be_const_ctype_func(Berry_This_Delay) }, 9 | { be_const_key(Get_This, -1), be_const_ctype_func(Berry_This_Get_This) }, 10 | }; 11 | 12 | static be_define_const_map( 13 | m_libThis_map, 14 | 6 15 | ); 16 | 17 | static be_define_const_module( 18 | m_libThis, 19 | "This" 20 | ); 21 | 22 | BE_EXPORT_VARIABLE be_define_const_native_module(This); 23 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_be_class_Berry_Date_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(be_class_Berry_Date_Type_map) { 4 | { be_const_key(Set_Month, 4), be_const_ctype_func(Berry_Date_Type_Set_Month) }, 5 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Date_Type_Deinitialize) }, 6 | { be_const_key(Get_Day, 0), be_const_ctype_func(Berry_Date_Type_Get_Day) }, 7 | { be_const_key(Set, -1), be_const_ctype_func(Berry_Date_Type_Set) }, 8 | { be_const_key(_p, 1), be_const_var(0) }, 9 | { be_const_key(init, -1), be_const_ctype_func(Berry_Date_Type_Initialize) }, 10 | { be_const_key(Set_Day, -1), be_const_ctype_func(Berry_Date_Type_Set_Day) }, 11 | { be_const_key(Set_Year, -1), be_const_ctype_func(Berry_Date_Type_Set_Year) }, 12 | { be_const_key(Get_Month, -1), be_const_ctype_func(Berry_Date_Type_Get_Month) }, 13 | { be_const_key(Get_Year, 7), be_const_ctype_func(Berry_Date_Type_Get_Year) }, 14 | }; 15 | 16 | static be_define_const_map( 17 | be_class_Berry_Date_Type_map, 18 | 10 19 | ); 20 | 21 | BE_EXPORT_VARIABLE be_define_const_class( 22 | be_class_Berry_Date_Type, 23 | 1, 24 | NULL, 25 | Date_Type 26 | ); 27 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_be_class_Berry_Instruction_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(be_class_Berry_Instruction_Type_map) { 4 | { be_const_key(Get_Sender, -1), be_const_ctype_func(Berry_Instruction_Class_Get_Sender) }, 5 | { be_const_key(_p, 5), be_const_var(0) }, 6 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Instruction_Class_Deinitialize) }, 7 | { be_const_key(Graphics_Get_Current_Target, 10), be_const_ctype_func(Berry_Instruction_Class_Graphics_Get_Current_Target) }, 8 | { be_const_key(Softwares_Get_Code, 8), be_const_ctype_func(Berry_Instruction_Class_Softwares_Get_Code) }, 9 | { be_const_key(Set_Receiver, -1), be_const_ctype_func(Berry_Instruction_Class_Set_Receiver) }, 10 | { be_const_key(Get_Receiver, -1), be_const_ctype_func(Berry_Instruction_Class_Get_Receiver) }, 11 | { be_const_key(Graphics_Get_Target, -1), be_const_ctype_func(Berry_Instruction_Class_Graphics_Get_Target) }, 12 | { be_const_key(Set_Sender, -1), be_const_ctype_func(Berry_Instruction_Class_Set_Sender) }, 13 | { be_const_key(init, 7), be_const_ctype_func(Berry_Instruction_Class_Initialize) }, 14 | { be_const_key(Graphics_Get_Code, -1), be_const_ctype_func(Berry_Instruction_Class_Graphics_Get_Code) }, 15 | }; 16 | 17 | static be_define_const_map( 18 | be_class_Berry_Instruction_Type_map, 19 | 11 20 | ); 21 | 22 | BE_EXPORT_VARIABLE be_define_const_class( 23 | be_class_Berry_Instruction_Type, 24 | 1, 25 | NULL, 26 | Instruction_Type 27 | ); 28 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_be_class_Berry_Module_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(be_class_Berry_Module_Type_map) { 4 | { be_const_key(init, 3), be_const_ctype_func(Berry_Module_Type_Initialize) }, 5 | { be_const_key(_X21_X3D, -1), be_const_ctype_func(Berry_Module_Type_Not_Equal) }, 6 | { be_const_key(deinit, 4), be_const_ctype_func(Berry_Module_Type_Deinitialize) }, 7 | { be_const_key(_X3D_X3D, -1), be_const_ctype_func(Berry_Module_Type_Equal) }, 8 | { be_const_key(_p, -1), be_const_var(0) }, 9 | }; 10 | 11 | static be_define_const_map( 12 | be_class_Berry_Module_Type_map, 13 | 5 14 | ); 15 | 16 | BE_EXPORT_VARIABLE be_define_const_class( 17 | be_class_Berry_Module_Type, 18 | 1, 19 | NULL, 20 | Module_Type 21 | ); 22 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_be_class_Berry_Time_Type.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(be_class_Berry_Time_Type_map) { 4 | { be_const_key(Get_Hours, -1), be_const_ctype_func(Berry_Time_Type_Get_Hours) }, 5 | { be_const_key(_p, -1), be_const_var(0) }, 6 | { be_const_key(deinit, -1), be_const_ctype_func(Berry_Time_Type_Deinitialize) }, 7 | { be_const_key(Set_Seconds, -1), be_const_ctype_func(Berry_Time_Type_Set_Seconds) }, 8 | { be_const_key(Get_Milliseconds, -1), be_const_ctype_func(Berry_Time_Type_Get_Milliseconds) }, 9 | { be_const_key(Get_Seconds, 4), be_const_ctype_func(Berry_Time_Type_Get_Seconds) }, 10 | { be_const_key(Set_Minutes, -1), be_const_ctype_func(Berry_Time_Type_Set_Minutes) }, 11 | { be_const_key(Get_Minutes, -1), be_const_ctype_func(Berry_Time_Type_Get_Minutes) }, 12 | { be_const_key(Set_Milliseconds, 0), be_const_ctype_func(Berry_Time_Type_Set_Milliseconds) }, 13 | { be_const_key(init, -1), be_const_ctype_func(Berry_Time_Type_Initialize) }, 14 | { be_const_key(Set_Hours, -1), be_const_ctype_func(Berry_Time_Type_Set_Hours) }, 15 | }; 16 | 17 | static be_define_const_map( 18 | be_class_Berry_Time_Type_map, 19 | 11 20 | ); 21 | 22 | BE_EXPORT_VARIABLE be_define_const_class( 23 | be_class_Berry_Time_Type, 24 | 1, 25 | NULL, 26 | Time_Type 27 | ); 28 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_be_class_list.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(be_class_list_map) { 4 | { be_const_key(_X2B, -1), be_const_func(m_merge) }, 5 | { be_const_key(init, -1), be_const_func(m_init) }, 6 | { be_const_key(_X2E_X2E, 11), be_const_func(m_connect) }, 7 | { be_const_key(tostring, 2), be_const_func(m_tostring) }, 8 | { be_const_key(pop, 6), be_const_func(m_pop) }, 9 | { be_const_key(insert, -1), be_const_func(m_insert) }, 10 | { be_const_key(size, -1), be_const_func(m_size) }, 11 | { be_const_key(remove, 12), be_const_func(m_remove) }, 12 | { be_const_key(find, -1), be_const_func(m_find) }, 13 | { be_const_key(push, 1), be_const_func(m_push) }, 14 | { be_const_key(item, 5), be_const_func(m_item) }, 15 | { be_const_key(concat, -1), be_const_func(m_concat) }, 16 | { be_const_key(_X2Ep, -1), be_const_var(0) }, 17 | { be_const_key(iter, -1), be_const_func(m_iter) }, 18 | { be_const_key(copy, -1), be_const_func(m_copy) }, 19 | { be_const_key(reverse, 13), be_const_func(m_reverse) }, 20 | { be_const_key(keys, -1), be_const_func(m_keys) }, 21 | { be_const_key(resize, 16), be_const_func(m_resize) }, 22 | { be_const_key(setitem, -1), be_const_func(m_setitem) }, 23 | { be_const_key(_X21_X3D, 7), be_const_func(m_nequal) }, 24 | { be_const_key(clear, -1), be_const_func(m_clear) }, 25 | { be_const_key(_X3D_X3D, -1), be_const_func(m_equal) }, 26 | }; 27 | 28 | static be_define_const_map( 29 | be_class_list_map, 30 | 22 31 | ); 32 | 33 | BE_EXPORT_VARIABLE be_define_const_class( 34 | be_class_list, 35 | 1, 36 | NULL, 37 | list 38 | ); 39 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_be_class_map.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(be_class_map_map) { 4 | { be_const_key(size, -1), be_const_func(m_size) }, 5 | { be_const_key(tostring, -1), be_const_func(m_tostring) }, 6 | { be_const_key(insert, -1), be_const_func(m_insert) }, 7 | { be_const_key(init, -1), be_const_func(m_init) }, 8 | { be_const_key(contains, -1), be_const_func(m_contains) }, 9 | { be_const_key(keys, -1), be_const_func(m_keys) }, 10 | { be_const_key(_X2Ep, -1), be_const_var(0) }, 11 | { be_const_key(iter, 6), be_const_func(m_iter) }, 12 | { be_const_key(setitem, 2), be_const_func(m_setitem) }, 13 | { be_const_key(remove, -1), be_const_func(m_remove) }, 14 | { be_const_key(item, 11), be_const_func(m_item) }, 15 | { be_const_key(find, -1), be_const_func(m_find) }, 16 | }; 17 | 18 | static be_define_const_map( 19 | be_class_map_map, 20 | 12 21 | ); 22 | 23 | BE_EXPORT_VARIABLE be_define_const_class( 24 | be_class_map, 25 | 1, 26 | NULL, 27 | map 28 | ); 29 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_be_class_range.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(be_class_range_map) { 4 | { be_const_key(setrange, -1), be_const_func(m_setrange) }, 5 | { be_const_key(iter, -1), be_const_func(m_iter) }, 6 | { be_const_key(lower, -1), be_const_func(m_lower) }, 7 | { be_const_key(init, 4), be_const_func(m_init) }, 8 | { be_const_key(__upper__, -1), be_const_var(0) }, 9 | { be_const_key(tostring, -1), be_const_func(m_tostring) }, 10 | { be_const_key(__lower__, -1), be_const_var(1) }, 11 | { be_const_key(upper, 1), be_const_func(m_upper) }, 12 | }; 13 | 14 | static be_define_const_map( 15 | be_class_range_map, 16 | 8 17 | ); 18 | 19 | BE_EXPORT_VARIABLE be_define_const_class( 20 | be_class_range, 21 | 2, 22 | NULL, 23 | range 24 | ); 25 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_cb.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libcb_map) { 4 | { be_const_key(make_cb, -1), be_const_func(be_cb_make_cb) }, 5 | { be_const_key(list_handlers, 3), be_const_func(be_cb_list_handlers) }, 6 | { be_const_key(get_cb_list, -1), be_const_func(be_cb_get_cb_list) }, 7 | { be_const_key(gen_cb, -1), be_const_func(be_cb_gen_cb) }, 8 | { be_const_key(add_handler, -1), be_const_func(be_cb_add_handler) }, 9 | }; 10 | 11 | static be_define_const_map( 12 | m_libcb_map, 13 | 5 14 | ); 15 | 16 | static be_define_const_module( 17 | m_libcb, 18 | "cb" 19 | ); 20 | 21 | BE_EXPORT_VARIABLE be_define_const_native_module(cb); 22 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_debug.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libdebug_map) { 4 | { be_const_key(attrdump, 3), be_const_func(m_attrdump) }, 5 | { be_const_key(upvname, -1), be_const_func(m_upvname) }, 6 | { be_const_key(codedump, -1), be_const_func(m_codedump) }, 7 | { be_const_key(counters, -1), be_const_func(m_counters) }, 8 | { be_const_key(top, -1), be_const_func(m_top) }, 9 | { be_const_key(varname, 7), be_const_func(m_varname) }, 10 | { be_const_key(calldepth, -1), be_const_func(m_calldepth) }, 11 | { be_const_key(traceback, -1), be_const_func(m_traceback) }, 12 | }; 13 | 14 | static be_define_const_map( 15 | m_libdebug_map, 16 | 8 17 | ); 18 | 19 | static be_define_const_module( 20 | m_libdebug, 21 | "debug" 22 | ); 23 | 24 | BE_EXPORT_VARIABLE be_define_const_native_module(debug); 25 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_gc.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libgc_map) { 4 | { be_const_key(allocated, -1), be_const_func(m_allocated) }, 5 | { be_const_key(collect, -1), be_const_func(m_collect) }, 6 | }; 7 | 8 | static be_define_const_map( 9 | m_libgc_map, 10 | 2 11 | ); 12 | 13 | static be_define_const_module( 14 | m_libgc, 15 | "gc" 16 | ); 17 | 18 | BE_EXPORT_VARIABLE be_define_const_native_module(gc); 19 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_global.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libglobal_map) { 4 | { be_const_key(contains, -1), be_const_func(m_contains) }, 5 | { be_const_key(setmember, -1), be_const_func(m_setglobal) }, 6 | { be_const_key(_X28_X29, -1), be_const_func(m_globals) }, 7 | { be_const_key(member, -1), be_const_func(m_findglobal) }, 8 | }; 9 | 10 | static be_define_const_map( 11 | m_libglobal_map, 12 | 4 13 | ); 14 | 15 | static be_define_const_module( 16 | m_libglobal, 17 | "global" 18 | ); 19 | 20 | BE_EXPORT_VARIABLE be_define_const_native_module(global); 21 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_introspect.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libintrospect_map) { 4 | { be_const_key(module, 1), be_const_func(m_getmodule) }, 5 | { be_const_key(toptr, -1), be_const_func(m_toptr) }, 6 | { be_const_key(setmodule, -1), be_const_func(m_setmodule) }, 7 | { be_const_key(get, -1), be_const_func(m_findmember) }, 8 | { be_const_key(fromptr, 3), be_const_func(m_fromptr) }, 9 | { be_const_key(name, 4), be_const_func(m_name) }, 10 | { be_const_key(members, -1), be_const_func(m_attrlist) }, 11 | { be_const_key(ismethod, 8), be_const_func(m_ismethod) }, 12 | { be_const_key(set, -1), be_const_func(m_setmember) }, 13 | }; 14 | 15 | static be_define_const_map( 16 | m_libintrospect_map, 17 | 9 18 | ); 19 | 20 | static be_define_const_module( 21 | m_libintrospect, 22 | "introspect" 23 | ); 24 | 25 | BE_EXPORT_VARIABLE be_define_const_native_module(introspect); 26 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_json.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libjson_map) { 4 | { be_const_key(dump, -1), be_const_func(m_json_dump) }, 5 | { be_const_key(load, 0), be_const_func(m_json_load) }, 6 | }; 7 | 8 | static be_define_const_map( 9 | m_libjson_map, 10 | 2 11 | ); 12 | 13 | static be_define_const_module( 14 | m_libjson, 15 | "json" 16 | ); 17 | 18 | BE_EXPORT_VARIABLE be_define_const_native_module(json); 19 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_math.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libmath_map) { 4 | { be_const_key(asin, 7), be_const_func(m_asin) }, 5 | { be_const_key(isnan, -1), be_const_func(m_isnan) }, 6 | { be_const_key(sinh, 22), be_const_func(m_sinh) }, 7 | { be_const_key(cos, -1), be_const_func(m_cos) }, 8 | { be_const_key(rand, -1), be_const_func(m_rand) }, 9 | { be_const_key(deg, -1), be_const_func(m_deg) }, 10 | { be_const_key(log10, 16), be_const_func(m_log10) }, 11 | { be_const_key(acos, -1), be_const_func(m_acos) }, 12 | { be_const_key(cosh, -1), be_const_func(m_cosh) }, 13 | { be_const_key(tanh, 21), be_const_func(m_tanh) }, 14 | { be_const_key(rad, 11), be_const_func(m_rad) }, 15 | { be_const_key(abs, -1), be_const_func(m_abs) }, 16 | { be_const_key(atan2, -1), be_const_func(m_atan2) }, 17 | { be_const_key(tan, 19), be_const_func(m_tan) }, 18 | { be_const_key(ceil, 15), be_const_func(m_ceil) }, 19 | { be_const_key(nan, -1), be_const_real(NAN) }, 20 | { be_const_key(imin, -1), be_const_int(M_IMIN) }, 21 | { be_const_key(pow, -1), be_const_func(m_pow) }, 22 | { be_const_key(atan, -1), be_const_func(m_atan) }, 23 | { be_const_key(imax, 25), be_const_int(M_IMAX) }, 24 | { be_const_key(exp, 17), be_const_func(m_exp) }, 25 | { be_const_key(log, 1), be_const_func(m_log) }, 26 | { be_const_key(sqrt, -1), be_const_func(m_sqrt) }, 27 | { be_const_key(srand, -1), be_const_func(m_srand) }, 28 | { be_const_key(floor, -1), be_const_func(m_floor) }, 29 | { be_const_key(sin, -1), be_const_func(m_sin) }, 30 | { be_const_key(pi, 8), be_const_real(M_PI) }, 31 | }; 32 | 33 | static be_define_const_map( 34 | m_libmath_map, 35 | 27 36 | ); 37 | 38 | static be_define_const_module( 39 | m_libmath, 40 | "math" 41 | ); 42 | 43 | BE_EXPORT_VARIABLE be_define_const_native_module(math); 44 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_os.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libos_map) { 4 | { be_const_key(listdir, 1), be_const_func(m_listdir) }, 5 | { be_const_key(mkdir, -1), be_const_func(m_mkdir) }, 6 | { be_const_key(chdir, -1), be_const_func(m_chdir) }, 7 | { be_const_key(exit, 2), be_const_func(m_exit) }, 8 | { be_const_key(system, -1), be_const_func(m_system) }, 9 | { be_const_key(remove, 3), be_const_func(m_remove) }, 10 | { be_const_key(path, -1), be_const_module(m_libpath) }, 11 | { be_const_key(getcwd, -1), be_const_func(m_getcwd) }, 12 | }; 13 | 14 | static be_define_const_map( 15 | m_libos_map, 16 | 8 17 | ); 18 | 19 | static be_define_const_module( 20 | m_libos, 21 | "os" 22 | ); 23 | 24 | BE_EXPORT_VARIABLE be_define_const_native_module(os); 25 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_os_path.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libpath_map) { 4 | { be_const_key(isdir, -1), be_const_func(m_path_isdir) }, 5 | { be_const_key(join, 2), be_const_func(m_path_join) }, 6 | { be_const_key(exists, -1), be_const_func(m_path_exists) }, 7 | { be_const_key(split, -1), be_const_func(m_path_split) }, 8 | { be_const_key(splitext, -1), be_const_func(m_path_splitext) }, 9 | { be_const_key(isfile, -1), be_const_func(m_path_isfile) }, 10 | }; 11 | 12 | static be_define_const_map( 13 | m_libpath_map, 14 | 6 15 | ); 16 | 17 | static be_define_const_module( 18 | m_libpath, 19 | "path" 20 | ); 21 | 22 | BE_EXPORT_VARIABLE be_define_const_native_module(path); 23 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_solidify.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libsolidify_map) { 4 | { be_const_key(dump, -1), be_const_func(m_dump) }, 5 | }; 6 | 7 | static be_define_const_map( 8 | m_libsolidify_map, 9 | 1 10 | ); 11 | 12 | static be_define_const_module( 13 | m_libsolidify, 14 | "solidify" 15 | ); 16 | 17 | BE_EXPORT_VARIABLE be_define_const_native_module(solidify); 18 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_strict.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libstrict_map) { 4 | { be_const_key(init, -1), be_const_func(m_init) }, 5 | }; 6 | 7 | static be_define_const_map( 8 | m_libstrict_map, 9 | 1 10 | ); 11 | 12 | static be_define_const_module( 13 | m_libstrict, 14 | "strict" 15 | ); 16 | 17 | BE_EXPORT_VARIABLE be_define_const_native_module(strict); 18 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_string.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libstring_map) { 4 | { be_const_key(count, 4), be_const_func(str_count) }, 5 | { be_const_key(byte, 6), be_const_func(str_byte) }, 6 | { be_const_key(format, 8), be_const_func(str_format) }, 7 | { be_const_key(split, -1), be_const_func(str_split) }, 8 | { be_const_key(toupper, -1), be_const_func(str_toupper) }, 9 | { be_const_key(char, -1), be_const_func(str_char) }, 10 | { be_const_key(tr, -1), be_const_func(str_tr) }, 11 | { be_const_key(replace, 1), be_const_func(str_replace) }, 12 | { be_const_key(hex, 11), be_const_func(str_i2hex) }, 13 | { be_const_key(tolower, 5), be_const_func(str_tolower) }, 14 | { be_const_key(find, -1), be_const_func(str_find) }, 15 | { be_const_key(escape, -1), be_const_func(str_escape) }, 16 | }; 17 | 18 | static be_define_const_map( 19 | m_libstring_map, 20 | 12 21 | ); 22 | 23 | static be_define_const_module( 24 | m_libstring, 25 | "string" 26 | ); 27 | 28 | BE_EXPORT_VARIABLE be_define_const_native_module(string); 29 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_sys.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libsys_map) { 4 | { be_const_key(path, -1), be_const_func(m_path) }, 5 | }; 6 | 7 | static be_define_const_map( 8 | m_libsys_map, 9 | 1 10 | ); 11 | 12 | static be_define_const_module( 13 | m_libsys, 14 | "sys" 15 | ); 16 | 17 | BE_EXPORT_VARIABLE be_define_const_native_module(sys); 18 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_time.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libtime_map) { 4 | { be_const_key(dump, 1), be_const_func(m_dump) }, 5 | { be_const_key(clock, -1), be_const_func(m_clock) }, 6 | { be_const_key(time, 0), be_const_func(m_time) }, 7 | }; 8 | 9 | static be_define_const_map( 10 | m_libtime_map, 11 | 3 12 | ); 13 | 14 | static be_define_const_module( 15 | m_libtime, 16 | "time" 17 | ); 18 | 19 | BE_EXPORT_VARIABLE be_define_const_native_module(time); 20 | -------------------------------------------------------------------------------- /lib/berry/generate/be_fixed_undefined.h: -------------------------------------------------------------------------------- 1 | #include "be_constobj.h" 2 | 3 | static be_define_const_map_slots(m_libundefined_map) { 4 | { be_const_key(_X2Ep, -1), be_const_nil() }, 5 | }; 6 | 7 | static be_define_const_map( 8 | m_libundefined_map, 9 | 1 10 | ); 11 | 12 | static be_define_const_module( 13 | m_libundefined, 14 | "undefined" 15 | ); 16 | 17 | BE_EXPORT_VARIABLE be_define_const_native_module(undefined); 18 | -------------------------------------------------------------------------------- /lib/berry/src/be_bytecode.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef __BE_BYTECODE_H 9 | #define __BE_BYTECODE_H 10 | 11 | #include "be_object.h" 12 | 13 | void be_bytecode_save(bvm *vm, const char *filename, bproto *proto); 14 | bclosure* be_bytecode_load(bvm *vm, const char *filename); 15 | bbool be_bytecode_check(const char *path); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /lib/berry/src/be_debug.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_DEBUG_H 9 | #define BE_DEBUG_H 10 | 11 | #include "be_object.h" 12 | 13 | struct bhookblock { 14 | void *data; 15 | bntvhook hook; 16 | }; 17 | 18 | void be_dumpclosure(bclosure *cl); 19 | void be_tracestack(bvm *vm); 20 | void be_callhook(bvm *vm, int mask); 21 | bbool be_debug_varname(bvm *vm, int level, int index); 22 | bbool be_debug_upvname(bvm *vm, int level, int index); 23 | 24 | #if BE_USE_DEBUG_MODULE 25 | void be_print_inst(binstruction ins, int pc, void* fout); 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lib/berry/src/be_func.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_FUNC_H 9 | #define BE_FUNC_H 10 | 11 | #include "be_object.h" 12 | 13 | #define be_newntvclos(vm, cf) \ 14 | be_newntvclosure(vm, cf, 0) 15 | 16 | #define be_ntvclos_upval(cc, n) \ 17 | (((bupval**)((size_t)cc + sizeof(bntvclos)))[n]) 18 | 19 | void be_initupvals(bvm *vm, bclosure *cl); 20 | void be_upvals_close(bvm *vm, bvalue *level); 21 | void be_release_upvalues(bvm *vm, bclosure *cl); 22 | bproto* be_newproto(bvm *vm); 23 | bclosure* be_newclosure(bvm *vm, int nupval); 24 | bntvclos* be_newntvclosure(bvm *vm, bntvfunc cf, int nupvals); 25 | bstring* be_func_varname(bproto *proto, int index, int pc); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /lib/berry/src/be_gclib.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #include "be_object.h" 9 | #include "be_gc.h" 10 | 11 | #if BE_USE_GC_MODULE 12 | 13 | static int m_allocated(bvm *vm) 14 | { 15 | size_t count = be_gc_memcount(vm); 16 | if (count < 0x80000000) { 17 | be_pushint(vm, (bint)count); 18 | } else { 19 | be_pushreal(vm, (breal)count); 20 | } 21 | be_return(vm); 22 | } 23 | 24 | static int m_collect(bvm *vm) 25 | { 26 | be_gc_collect(vm); 27 | be_return_nil(vm); 28 | } 29 | 30 | #if !BE_USE_PRECOMPILED_OBJECT 31 | be_native_module_attr_table(gc){ 32 | be_native_module_function("allocated", m_allocated), 33 | be_native_module_function("collect", m_collect) 34 | }; 35 | 36 | be_define_native_module(gc, NULL); 37 | #else 38 | /* @const_object_info_begin 39 | module gc (scope: global, depend: BE_USE_GC_MODULE) { 40 | allocated, func(m_allocated) 41 | collect, func(m_collect) 42 | } 43 | @const_object_info_end */ 44 | #include "../generate/be_fixed_gc.h" 45 | #endif 46 | 47 | #endif /* BE_USE_SYS_MODULE */ 48 | -------------------------------------------------------------------------------- /lib/berry/src/be_libs.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #include "be_libs.h" 9 | 10 | extern void be_load_baselib(bvm *vm); 11 | extern void be_load_baselib_next(bvm *vm); 12 | extern void be_load_listlib(bvm *vm); 13 | extern void be_load_maplib(bvm *vm); 14 | extern void be_load_rangelib(bvm *vm); 15 | extern void be_load_filelib(bvm *vm); 16 | extern void be_load_byteslib(bvm *vm); 17 | 18 | void be_loadlibs(bvm *vm) 19 | { 20 | be_load_baselib(vm); 21 | #if !BE_USE_PRECOMPILED_OBJECT 22 | be_load_listlib(vm); 23 | be_load_maplib(vm); 24 | be_load_rangelib(vm); 25 | be_load_filelib(vm); 26 | be_load_byteslib(vm); 27 | be_load_baselib_next(vm); 28 | #endif 29 | } 30 | -------------------------------------------------------------------------------- /lib/berry/src/be_libs.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_LIBS_H 9 | #define BE_LIBS_H 10 | 11 | #include "berry.h" 12 | 13 | void be_loadlibs(bvm *vm); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /lib/berry/src/be_list.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_LIST_H 9 | #define BE_LIST_H 10 | 11 | #include "be_object.h" 12 | 13 | struct blist { 14 | bcommon_header; 15 | bgcobject *gray; /* for gc gray list */ 16 | int count, capacity; 17 | bvalue *data; 18 | }; 19 | 20 | #define be_list_data(list) ((list)->data) 21 | #define be_list_count(list) ((list)->count) 22 | #define be_list_at(list, index) ((list)->data + index) 23 | #define be_list_end(list) ((list)->data + (list)->count) 24 | 25 | blist* be_list_new(bvm *vm); 26 | void be_list_delete(bvm *vm, blist *list); 27 | blist* be_list_copy(bvm *vm, blist *original); 28 | bvalue* be_list_index(blist *list, int index); 29 | bvalue* be_list_push(bvm *vm, blist *list, bvalue *value); 30 | bvalue* be_list_insert(bvm *vm, blist *list, int index, bvalue *value); 31 | int be_list_remove(bvm *vm, blist *list, int index); 32 | void be_list_resize(bvm *vm, blist *list, int count); 33 | void be_list_merge(bvm *vm, blist *list, const blist *other); 34 | void be_list_reverse(blist *list); 35 | void be_list_pool_init(bvm *vm, blist *list); 36 | int be_list_pool_alloc(bvm *vm, blist *list, bvalue *src); 37 | void be_list_pool_free(blist *list, int id); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/berry/src/be_mem.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_MEM_H 9 | #define BE_MEM_H 10 | 11 | #include "berry.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #define be_malloc(vm, size) be_realloc((vm), NULL, 0, (size)) 18 | #define be_free(vm, ptr, size) be_realloc((vm), (ptr), (size), 0) 19 | 20 | BERRY_API void* be_os_malloc(size_t size); 21 | BERRY_API void be_os_free(void *ptr); 22 | BERRY_API void* be_os_realloc(void *ptr, size_t size); 23 | BERRY_API void* be_realloc(bvm *vm, void *ptr, size_t old_size, size_t new_size); 24 | BERRY_API void be_gc_memory_pools(bvm *vm); 25 | BERRY_API void be_gc_free_memory_pools(bvm *vm); 26 | BERRY_API void be_gc_init_memory_pools(bvm *vm); 27 | BERRY_API void be_gc_memory_pools_info(bvm *vm, size_t* slots_used, size_t* slots_allocated); 28 | 29 | /* The following moves a portion of memory to constraint regions with 32-bits read/write acess */ 30 | /* Effective only if `BE_USE_MEM_ALIGNED` is set to `1`*/ 31 | BERRY_API void* be_move_to_aligned(bvm *vm, void *ptr, size_t size); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /lib/berry/src/be_module.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_MODULE_H 9 | #define BE_MODULE_H 10 | 11 | #include "be_object.h" 12 | 13 | #define BE_MODULE_NAME 1 14 | 15 | typedef struct bmodule { 16 | bcommon_header; 17 | bmap *table; 18 | union infodata { 19 | const bntvmodule_t *native; 20 | const char *name; 21 | const bstring *sname; 22 | #ifdef __cplusplus 23 | BE_CONSTEXPR infodata(const char *name) : name(name) {} 24 | #endif 25 | } info; 26 | bgcobject *gray; /* for gc gray list */ 27 | #ifdef __cplusplus 28 | BE_CONSTEXPR bmodule(bmap *tab, const char *name) : 29 | next(0), type(BE_MODULE), marked(GC_CONST), 30 | table(tab), info(infodata(name)), gray(0) {} 31 | #endif 32 | } bmodule; 33 | 34 | bmodule* be_module_new(bvm *vm); 35 | void be_module_delete(bvm *vm, bmodule *module); 36 | int be_module_load(bvm *vm, bstring *path); 37 | void be_cache_module(bvm *vm, bstring *name); 38 | int be_module_attr(bvm *vm, bmodule *module, bstring *attr, bvalue *dst); 39 | bbool be_module_setmember(bvm *vm, bmodule *module, bstring *attr, bvalue *src); 40 | const char* be_module_name(bmodule *module); 41 | bbool be_module_setname(bmodule *module, bstring *name); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/berry/src/be_repl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_REPL_H 9 | #define BE_REPL_H 10 | 11 | #include "berry.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | typedef char* (*breadline)(const char *prompt); 18 | typedef void (*bfreeline)(char *ptr); 19 | 20 | BERRY_API int be_repl(bvm *vm, breadline getline, bfreeline freeline); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /lib/berry/src/be_strictlib.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2021 Guan Wenliang & Stephan Hadinger 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #include "be_object.h" 9 | #include "be_module.h" 10 | #include "be_string.h" 11 | #include "be_vector.h" 12 | #include "be_class.h" 13 | #include "be_debug.h" 14 | #include "be_map.h" 15 | #include "be_vm.h" 16 | 17 | #if BE_USE_STRICT_MODULE 18 | 19 | static int m_init(bvm *vm) 20 | { 21 | comp_set_strict(vm); /* enable compiler strict mode */ 22 | be_return_nil(vm); 23 | } 24 | 25 | #if !BE_USE_PRECOMPILED_OBJECT 26 | be_native_module_attr_table(strict) { 27 | be_native_module_function("init", m_init), 28 | }; 29 | 30 | be_define_native_module(strict, NULL); 31 | #else 32 | /* @const_object_info_begin 33 | module strict (scope: strict, depend: BE_USE_STRICT_MODULE) { 34 | init, func(m_init) 35 | } 36 | @const_object_info_end */ 37 | #include "../generate/be_fixed_strict.h" 38 | #endif 39 | 40 | #endif /* BE_USE_STRICT_MODULE */ 41 | -------------------------------------------------------------------------------- /lib/berry/src/be_string.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_STRING_H 9 | #define BE_STRING_H 10 | 11 | #include "be_object.h" 12 | 13 | #define SHORT_STR_MAX_LEN 64 14 | 15 | typedef struct { 16 | bstring_header; 17 | #if BE_USE_STR_HASH_CACHE 18 | uint32_t hash; 19 | #endif 20 | /* char s[]; */ 21 | } bsstring; 22 | 23 | typedef struct { 24 | bstring str; 25 | int llen; 26 | /* char s[]; */ 27 | } blstring; 28 | 29 | typedef struct { 30 | bstring_header; 31 | uint32_t hash; 32 | const char *s; 33 | } bcstring; 34 | 35 | #define str_len(_s) \ 36 | ((_s)->slen == 255 ? cast(blstring*, _s)->llen : (_s)->slen) 37 | 38 | #define str(_s) be_str2cstr(_s) 39 | #define str_extra(_s) ((_s)->extra) 40 | #define str_literal(_vm, _s) be_newstrn((_vm), (_s), sizeof(_s) - 1) 41 | 42 | #if BE_USE_PRECOMPILED_OBJECT 43 | #include "../generate/be_const_strtab.h" 44 | #endif 45 | 46 | void be_string_init(bvm *vm); 47 | void be_string_deleteall(bvm *vm); 48 | int be_eqstr(bstring *s1, bstring *s2); 49 | bstring* be_newstr(bvm *vm, const char *str); 50 | bstring* be_newstrn(bvm *vm, const char *str, size_t len); 51 | bstring* be_newlongstr(bvm *vm, const char *str, size_t len); 52 | void be_gcstrtab(bvm *vm); 53 | uint32_t be_strhash(const bstring *s); 54 | const char* be_str2cstr(const bstring *s); 55 | void be_str_setextra(bstring *s, int extra); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lib/berry/src/be_strlib.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_STRLIB_H 9 | #define BE_STRLIB_H 10 | 11 | #include "be_object.h" 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | bstring* be_strcat(bvm *vm, bstring *s1, bstring *s2); 19 | int be_strcmp(bstring *s1, bstring *s2); 20 | bstring* be_num2str(bvm *vm, bvalue *v); 21 | void be_val2str(bvm *vm, int index); 22 | int be_char2hex(int c); 23 | size_t be_strlcpy(char *dst, const char *src, size_t size); 24 | const char* be_splitpath(const char *path); 25 | const char* be_splitname(const char *path); 26 | const char* be_pushvfstr(bvm *vm, const char *format, va_list arg); 27 | bstring* be_strindex(bvm *vm, bstring *str, bvalue *idx); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/berry/src/be_sys.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_SYS_H 9 | #define BE_SYS_H 10 | 11 | #include 12 | 13 | /* directory information for directory traversal */ 14 | typedef struct { 15 | void *dir; 16 | void *file; 17 | const char *name; 18 | } bdirinfo; 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | void* be_fopen(const char *filename, const char *modes); 25 | int be_fclose(void *hfile); 26 | size_t be_fwrite(void *hfile, const void *buffer, size_t length); 27 | size_t be_fread(void *hfile, void *buffer, size_t length); 28 | char* be_fgets(void *hfile, void *buffer, int size); 29 | int be_fseek(void *hfile, long offset); 30 | long int be_ftell(void *hfile); 31 | long int be_fflush(void *hfile); 32 | size_t be_fsize(void *hfile); 33 | int be_isdir(const char *path); 34 | int be_isfile(const char *path); 35 | int be_isexist(const char *path); 36 | char* be_getcwd(char *buf, size_t size); 37 | int be_chdir(const char *path); 38 | int be_mkdir(const char *path); 39 | int be_unlink(const char *filename); 40 | int be_dirfirst(bdirinfo *info, const char *path); 41 | int be_dirnext(bdirinfo *info); 42 | int be_dirclose(bdirinfo *info); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /lib/berry/src/be_syslib.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #include "be_object.h" 9 | 10 | #if BE_USE_SYS_MODULE 11 | 12 | static int m_path(bvm *vm) 13 | { 14 | be_getbuiltin(vm, "list"); 15 | be_module_path(vm); 16 | be_call(vm, 1); 17 | be_pop(vm, 1); 18 | be_return(vm); 19 | } 20 | 21 | #if !BE_USE_PRECOMPILED_OBJECT 22 | be_native_module_attr_table(sys){ 23 | be_native_module_function("path", m_path) 24 | }; 25 | 26 | be_define_native_module(sys, NULL); 27 | #else 28 | /* @const_object_info_begin 29 | module sys (scope: global, depend: BE_USE_SYS_MODULE) { 30 | path, func(m_path) 31 | } 32 | @const_object_info_end */ 33 | #include "../generate/be_fixed_sys.h" 34 | #endif 35 | 36 | #endif /* BE_USE_SYS_MODULE */ 37 | -------------------------------------------------------------------------------- /lib/berry/src/be_undefinedlib.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang, Stephan Hadinger 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #include "be_object.h" 9 | #include "be_module.h" 10 | #include "be_string.h" 11 | #include "be_vector.h" 12 | #include "be_class.h" 13 | #include "be_debug.h" 14 | #include "be_map.h" 15 | #include "be_vm.h" 16 | #include "be_exec.h" 17 | #include "be_gc.h" 18 | #include 19 | 20 | 21 | #if !BE_USE_PRECOMPILED_OBJECT 22 | be_native_module_attr_table(undefined) { 23 | be_native_module_nil(".p"), /* not needed but can't be empty */ 24 | }; 25 | 26 | be_define_native_module(undefined, NULL); 27 | #else 28 | /* @const_object_info_begin 29 | module undefined (scope: global) { 30 | .p, nil() 31 | } 32 | @const_object_info_end */ 33 | #include "../generate/be_fixed_undefined.h" 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/berry/src/be_var.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | ** Copyright (c) 2018-2020 Guan Wenliang 3 | ** This file is part of the Berry default interpreter. 4 | ** skiars@qq.com, https://github.com/Skiars/berry 5 | ** See Copyright Notice in the LICENSE file or at 6 | ** https://github.com/Skiars/berry/blob/master/LICENSE 7 | ********************************************************************/ 8 | #ifndef BE_VAR_H 9 | #define BE_VAR_H 10 | 11 | #include "be_object.h" 12 | 13 | #define be_global_count(vm) \ 14 | be_vector_count(&(vm)->gbldesc.global.vlist) 15 | 16 | #define be_builtin_count(vm) \ 17 | be_vector_count(&(vm)->gbldesc.builtin.vlist) 18 | 19 | void be_globalvar_init(bvm *vm); 20 | void be_globalvar_deinit(bvm *vm); 21 | int be_global_find(bvm *vm, bstring *name); 22 | int be_global_new(bvm *vm, bstring *name); 23 | bvalue* be_global_var(bvm *vm, int index); 24 | void be_global_release_space(bvm *vm); 25 | int be_builtin_find(bvm *vm, bstring *name); 26 | bstring* be_builtin_name(bvm *vm, int index); 27 | int be_builtin_new(bvm *vm, bstring *name); 28 | void be_bulitin_release_space(bvm *vm); 29 | void be_const_builtin_set(bvm *vm, const bmap *map, const bvector *vec); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /lib/berry/testall.be: -------------------------------------------------------------------------------- 1 | #! ./berry 2 | import os 3 | 4 | os.system('lcov', '-q -c -i -d . -o init.info') 5 | 6 | var exec = './berry' 7 | var path = 'tests' 8 | var testcases = os.listdir(path) 9 | var total = 0, failed = 0 10 | 11 | for i : testcases 12 | if os.path.splitext(i)[1] == '.be' 13 | print('\033[0;36mrun testcase: ' + i + '\033[0m') 14 | var ret = os.system(exec, os.path.join(path, i)) 15 | if ret != 0 16 | print('\033[0;31mreturn code:', ret, '\033[0m') 17 | failed += 1 18 | end 19 | total += 1 20 | end 21 | end 22 | 23 | print('\033[0;32mtest results: ' + 24 | str(total) + ' total, ' + str(failed) + ' failed' + 25 | (failed ? '' : ' (all tests passed)') + 26 | '.\033[0m') 27 | 28 | if failed != 0 29 | os.exit(-1) 30 | end 31 | 32 | var cmds = [ 33 | 'lcov -q -c -d ./ -o cover.info', 34 | 'lcov -q -a init.info -a cover.info -o total.info', 35 | 'lcov --remove total.info */usr/include/* -o final.info', 36 | 'genhtml -q -o test_report --legend --title "lcov" --prefix=./ final.info', 37 | 'rm -f init.info cover.info total.info final.info' 38 | ] 39 | 40 | for cmd : cmds 41 | if os.system(cmd) 42 | os.exit(-1) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/berry/tests/assignment.be: -------------------------------------------------------------------------------- 1 | class Test 2 | var a 3 | end 4 | 5 | # continuous assignment of global suffix expressions 6 | o = Test() 7 | o.a = 100 8 | assert(o.a == 100) 9 | o.a += 10 10 | assert(o.a == 110) 11 | 12 | p = Test() 13 | p.a = Test() 14 | p.a.a = 50 15 | assert(p.a.a == 50) 16 | p.a.a += 10 17 | assert(p.a.a == 60) 18 | 19 | # continuous assignment of local suffix expressions 20 | def test_func() 21 | var o = Test() 22 | o.a = 100 23 | assert(o.a == 100) 24 | o.a += 10 25 | assert(o.a == 110) 26 | 27 | var p = Test() 28 | p.a = Test() 29 | p.a.a = 50 30 | assert(p.a.a == 50) 31 | p.a.a += 10 32 | assert(p.a.a == 60) 33 | end 34 | test_func() 35 | -------------------------------------------------------------------------------- /lib/berry/tests/bitwise.be: -------------------------------------------------------------------------------- 1 | # and, or, xor 2 | a = 11 3 | assert(a & 0xFE == 10) 4 | assert(a | 32 == 43) 5 | assert(a ^ 33 == 42) 6 | 7 | # same with literal 8 | assert(11 & 0xFE == 10) 9 | assert(11 | 32 == 43) 10 | assert(11 ^ 33 == 42) 11 | 12 | # flip 13 | assert(~a == -12) 14 | assert(~11 == -12) 15 | -------------------------------------------------------------------------------- /lib/berry/tests/bool.be: -------------------------------------------------------------------------------- 1 | # test cases for boolean expressions 2 | 3 | assert(1 != false && 1 != true) 4 | assert(0 != false && 0 != true) 5 | assert(!!1 == true) 6 | assert(!!0 == false) 7 | 8 | a = true 9 | b = false 10 | assert(!!list == true) 11 | assert(a && b == false) 12 | assert(!(a && b)) 13 | def test(a, b) 14 | while !(a && b) 15 | assert(false) 16 | end 17 | end 18 | test(true, true) 19 | 20 | # bug in unary 21 | def f(i) 22 | var j = !i # bug if i is erroneously modified 23 | return i 24 | end 25 | assert(f(1) == 1) 26 | 27 | #- addind bool() function -# 28 | assert(bool() == false) 29 | assert(bool(0) == false) 30 | assert(bool(0.0) == false) 31 | assert(bool(false) == false) 32 | assert(bool(nil) == false) 33 | 34 | assert(bool(-1) == true) 35 | assert(bool(3.5) == true) 36 | assert(bool('') == false) # changed behavior 37 | assert(bool('a') == true) 38 | assert(bool(list) == true) 39 | assert(bool(list()) == true) 40 | 41 | import introspect 42 | assert(bool(introspect.toptr(0x1000)) == true) 43 | assert(bool(introspect.toptr(0)) == false) 44 | -------------------------------------------------------------------------------- /lib/berry/tests/bytes_b64.be: -------------------------------------------------------------------------------- 1 | #- base64 encode -# 2 | b=bytes() 3 | assert(b.tob64() == '') 4 | b=bytes('00') 5 | assert(b.tob64() == 'AA==') 6 | b=bytes('1122334455') 7 | assert(b.tob64() == 'ESIzRFU=') 8 | 9 | #- base64 decode -# 10 | b=bytes().fromb64('') 11 | assert(str(b) == str(bytes(''))) 12 | b=bytes().fromb64('AA==') 13 | assert(str(b) == str(bytes('00'))) 14 | b=bytes().fromb64('ESIzRFU=') 15 | assert(str(b) == str(bytes('1122334455'))) 16 | -------------------------------------------------------------------------------- /lib/berry/tests/checkspace.be: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def strfind(st, char) 4 | var len = size(st) 5 | for i : 0 .. len - 1 6 | if st[i] == char 7 | return true 8 | end 9 | end 10 | return false 11 | end 12 | 13 | def checkfile(path) 14 | var subname = os.path.splitext(path)[1] 15 | if (subname == '.c' || subname == '.h' || 16 | subname == '.cpp' || subname == '.be' || subname == '.json') 17 | var f = open(path) 18 | assert(!strfind(f.read(), '\t'), 'file \'' + path + '\' has tab character') 19 | f.close() 20 | end 21 | end 22 | 23 | def findpath(path) 24 | var ls = os.listdir(path) 25 | for name : ls 26 | var fullname = os.path.join(path, name) 27 | if os.path.isfile(fullname) 28 | checkfile(fullname) 29 | elif fullname != '.' && fullname != '..' 30 | findpath(fullname) 31 | end 32 | end 33 | end 34 | 35 | findpath('.') 36 | -------------------------------------------------------------------------------- /lib/berry/tests/class.be: -------------------------------------------------------------------------------- 1 | class Test 2 | var maximum 3 | def init(maximum) 4 | self.maximum = maximum 5 | end 6 | def iter() # method closure upvalues test 7 | var i = -1, maximum = self.maximum 8 | return def () 9 | i += 1 10 | if i > maximum 11 | raise 'stop_iteration' 12 | end 13 | return i 14 | end 15 | end 16 | end 17 | 18 | var sum = 0 19 | for i : Test(10) 20 | sum += i 21 | end 22 | assert(sum == 55, 'iteraion sum is ' + str(sum) + ' (expected 55).') 23 | 24 | #- test case for class instanciated from module member #103 -# 25 | 26 | m = module() 27 | g_i = 0 #- detect side effect from init() -# 28 | class C def init() g_i += 1 end end 29 | m.C = C 30 | 31 | #- normal invocation -# 32 | assert(type(C()) == 'instance') 33 | assert(g_i == 1) 34 | 35 | #- invoke from module member -# 36 | assert(type(m.C()) == 'instance') 37 | assert(g_i == 2) 38 | 39 | class C2 var C1 def init(c) self.C1 = c end end 40 | m.C2 = C2 41 | c2 = m.C2(m.C) 42 | 43 | assert(c2.C1 == C) 44 | 45 | c3 = m.C2(m.C()) 46 | assert(type(c3.C1) == 'instance') 47 | assert(classname(c3.C1) == 'C') 48 | 49 | #- an instance member can be a class and called directly -# 50 | class Test_class 51 | var c 52 | def init() 53 | self.c = map 54 | end 55 | end 56 | c4 = Test_class() 57 | assert(type(c4.c) == 'class') 58 | c5 = c4.c() 59 | assert(type(c5) == 'instance') 60 | assert(classname(c5) == 'map') -------------------------------------------------------------------------------- /lib/berry/tests/closure.be: -------------------------------------------------------------------------------- 1 | #- test for issue #105 -# 2 | 3 | l=[] 4 | def tick() 5 | var start=100 6 | for i : 1..3 7 | l.push(def () return [i, start] end) 8 | end 9 | end 10 | tick() 11 | assert(l[0]() == [1, 100]) 12 | assert(l[1]() == [2, 100]) 13 | assert(l[2]() == [3, 100]) 14 | -------------------------------------------------------------------------------- /lib/berry/tests/compiler.be: -------------------------------------------------------------------------------- 1 | #- test for issue #117 -# 2 | 3 | class A var a end 4 | a=A() 5 | a.a = ["foo", "bar"] 6 | 7 | s = nil 8 | def fs(m) s = m end 9 | 10 | class B 11 | var b, i 12 | def nok() 13 | fs(self.b.a[self.i]) # wrong behavior 14 | end 15 | def ok() 16 | var i = self.i 17 | fs(self.b.a[i]) # works correctly 18 | end 19 | end 20 | b=B() 21 | b.i=0 22 | b.b=a 23 | 24 | b.nok() 25 | assert(s == "foo") 26 | 27 | b.ok() 28 | assert(s == "foo") 29 | -------------------------------------------------------------------------------- /lib/berry/tests/compound.be: -------------------------------------------------------------------------------- 1 | # test bug in compound statements 2 | 3 | a = 0 4 | assert(a == 0) 5 | a += 1 6 | assert(a == 1) 7 | a += 10/2 8 | assert(a == 6) 9 | 10 | class A var a def init() self.a = 1 end def f(x) self.a+=x/2 end def g(x) self.a = self.a + x/2 end end 11 | 12 | a = A() 13 | assert(a.a == 1) 14 | a.f(10) 15 | assert(a.a == 6) 16 | b=A() 17 | assert(b.a == 1) 18 | b.g(10) 19 | assert(b.a == 6) 20 | 21 | # bug in compound assignments 22 | class A var a,b end 23 | c=A() 24 | c.a = {"x": 1, "y": 2} 25 | c.b = "x" 26 | assert(c.a[c.b] == 1) 27 | c.a[c.b] += 2 # this is where the bug happens 28 | assert(c.a[c.b] == 3) 29 | -------------------------------------------------------------------------------- /lib/berry/tests/cond_expr.be: -------------------------------------------------------------------------------- 1 | assert("" != 0 ? true : false) 2 | assert(false || !(true ? false : true) && true) 3 | var t1 = 8, t2 = false 4 | if t1 ? 7 + t1 : t2 5 | var a = 'good' 6 | assert((a == 'good' ? a + '!' : a) == 'good!') 7 | assert((a == 'good?' ? a + '!' : a) != 'good!') 8 | else 9 | assert('condition expression test failed') 10 | end 11 | -------------------------------------------------------------------------------- /lib/berry/tests/debug.be: -------------------------------------------------------------------------------- 1 | import debug 2 | 3 | class A end 4 | debug.attrdump(A) #- should not crash -# -------------------------------------------------------------------------------- /lib/berry/tests/exceptions.be: -------------------------------------------------------------------------------- 1 | 2 | try 3 | for k: 0..1 assert({'a':1}.contains('b'), 'failure') end 4 | except .. as e,m 5 | assert(e == "assert_failed") 6 | assert(m == "failure") 7 | end 8 | -------------------------------------------------------------------------------- /lib/berry/tests/for.be: -------------------------------------------------------------------------------- 1 | var global 2 | 3 | global = 0 4 | for i : 0 .. 10 5 | global += i 6 | end 7 | assert(global == 55) 8 | 9 | global = 0 10 | for i : 0 .. 20 11 | if i > 10 12 | break 13 | end 14 | global += i 15 | end 16 | assert(global == 55) 17 | 18 | global = 0 19 | for i : 0 .. 20 20 | if i > 10 21 | continue 22 | end 23 | global += i 24 | end 25 | assert(global == 55) 26 | 27 | assert(def () 28 | for i : 0 .. 20 29 | if i > 10 30 | return i 31 | end 32 | end 33 | end() == 11) 34 | 35 | # test for "stop_iteration" exception as recurrence 36 | def for_rec(depth) 37 | for i : 0 .. 10 38 | if i == 4 && depth < 200 39 | for_rec(depth + 1) 40 | end 41 | end 42 | end 43 | 44 | for_rec(0) 45 | -------------------------------------------------------------------------------- /lib/berry/tests/function.be: -------------------------------------------------------------------------------- 1 | # CLOSE opcode test 2 | var gbl 3 | def func1() 4 | var a = 'func1_a' 5 | def func2() 6 | return a 7 | end 8 | gbl = func2 9 | return 400000 + 500 10 | end 11 | assert(func1() == 400500) 12 | assert(gbl() == 'func1_a') 13 | -------------------------------------------------------------------------------- /lib/berry/tests/global.be: -------------------------------------------------------------------------------- 1 | #- test module global -# 2 | 3 | def assert_syntax_error(code) 4 | try 5 | var f = compile(code) 6 | assert(false, 'unexpected execution flow') 7 | except .. as e, m 8 | assert(e == 'syntax_error') 9 | end 10 | end 11 | def findinlist(l, e) 12 | for i: 0..size(l)-1 13 | if l[i] == e return i end 14 | end 15 | return nil 16 | end 17 | 18 | #- set the scene -# 19 | global_a = 1 20 | global_b = "bb" 21 | assert(global_a == 1) 22 | assert(global_b == "bb") 23 | 24 | assert_syntax_error("c") #- compilation fails because c does not exist -# 25 | 26 | import global 27 | 28 | assert(global.global_a == 1) 29 | assert(global.global_b == "bb") 30 | 31 | global.global_c = 3 32 | #- now compilation against 'c' global -# 33 | f = compile("return global_c") 34 | assert(f() == 3) 35 | 36 | #- check that access to non-existent global returns nil (new behavior) -# 37 | assert(global.d == nil) 38 | 39 | #- check the glbal list -# 40 | assert(findinlist(global(), 'global_a') != nil) 41 | assert(findinlist(global(), 'global_b') != nil) 42 | assert(findinlist(global(), 'global_c') != nil) 43 | assert(findinlist(global(), 'global_d') == nil) -------------------------------------------------------------------------------- /lib/berry/tests/int.be: -------------------------------------------------------------------------------- 1 | #- toint() converts any instance to int -# 2 | class Test_int 3 | def toint() 4 | return 42 5 | end 6 | end 7 | t=Test_int() 8 | assert(int(t) == 42) 9 | 10 | #- int can parse hex strings -# 11 | assert(int("0x00") == 0) 12 | assert(int("0X1") == 1) 13 | assert(int("0x000000F") == 15) 14 | assert(int("0x1000") == 0x1000) 15 | -------------------------------------------------------------------------------- /lib/berry/tests/introspect.be: -------------------------------------------------------------------------------- 1 | #- introspect -# 2 | import introspect 3 | 4 | #- test for modules -# 5 | m = module("m") 6 | m.a = 1 7 | m.b = def () return "foo" end 8 | 9 | assert(introspect.members(m) == ['a', 'b']) 10 | assert(introspect.get(m, 'a') == 1) 11 | assert(type(introspect.get(m, 'b')) == 'function') 12 | 13 | introspect.set(m, 'a', 2) 14 | assert(m.a == 2) 15 | 16 | #- test for instance -# 17 | class A var a,b static c=1,d=2 def f() end end 18 | a=A() 19 | 20 | assert(introspect.members(A) == ['a', 'f', 'b', 'c', 'd']) #- class members -# 21 | assert(introspect.members(a) == ['a', 'f', 'b', 'c', 'd']) #- instance members -# 22 | 23 | assert(introspect.get(a, 'c') == 1) 24 | assert(introspect.get(a, 'd') == 2) 25 | assert(introspect.get(a, 'a') == nil) 26 | 27 | introspect.set(a, 'a', 3) 28 | assert(a.a == 3) 29 | 30 | #- load module dynamically -# 31 | import introspect 32 | m = introspect.module("math") # load module `math`, assign to `m` and don't create a global variable 33 | assert(type(m.pi) == 'real') 34 | 35 | #- name -# 36 | import string 37 | assert(introspect.name(string) == 'string') 38 | assert(introspect.name(print) == nil) # native C function don't have a registered name 39 | assert(introspect.name("foo") == nil) 40 | class A def a() end static def b() end static var c end 41 | assert(introspect.name(A) == 'A') 42 | assert(introspect.name(A.a) == 'a') 43 | assert(introspect.name(A.b) == 'b') 44 | assert(introspect.name(A.c) == nil) 45 | -------------------------------------------------------------------------------- /lib/berry/tests/introspect_ismethod.be: -------------------------------------------------------------------------------- 1 | # test for introspect.ismethod 2 | import introspect 3 | 4 | # ismethod should return nil for any non-Berry closure 5 | assert(introspect.ismethod() == nil) 6 | assert(introspect.ismethod(true) == nil) 7 | assert(introspect.ismethod("a") == nil) 8 | assert(introspect.ismethod([]) == nil) 9 | assert(introspect.ismethod({}) == nil) 10 | assert(introspect.ismethod(introspect) == nil) # module 11 | assert(introspect.ismethod(introspect.ismethod) == nil) # native method 12 | 13 | def h() end 14 | 15 | class A 16 | def f() end 17 | static def g() end 18 | var h 19 | end 20 | a=A() 21 | a.h = h 22 | 23 | assert(introspect.ismethod(h) == false) 24 | assert(introspect.ismethod(A.f) == true) 25 | assert(introspect.ismethod(A.g) == false) 26 | 27 | assert(introspect.ismethod(a.f) == true) 28 | assert(introspect.ismethod(a.g) == false) 29 | assert(introspect.ismethod(a.h) == false) 30 | -------------------------------------------------------------------------------- /lib/berry/tests/json_advanced.be: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | 4 | 5 | 6 | def assert_load_failed(text) 7 | assert(json.load(text) == nil) 8 | end 9 | 10 | var input_file = open("tests/json_test_cases.json", "r") 11 | var test_cases = json.load(input_file.read()) 12 | 13 | # check positive cases 14 | var has_failed_positives = false 15 | for case_name : test_cases["positive"].keys() 16 | var case = test_cases["positive"][case_name] 17 | var val = json.load(case) 18 | if val == nil && case != "null" 19 | print("Failed to load case: " + case_name) 20 | has_failed_positives = true 21 | end 22 | end 23 | 24 | if has_failed_positives 25 | assert(false) 26 | end 27 | 28 | # check negative cases 29 | 30 | var has_failed_negatives = false 31 | for case_name : test_cases["negative"].keys() 32 | var case = test_cases["negative"][case_name] 33 | 34 | var val = json.load(case) 35 | if val != nil 36 | print("Failed to fail case: " + case_name + ", got: " + json.dump(val)) 37 | has_failed_negatives = true 38 | end 39 | end 40 | 41 | if has_failed_negatives 42 | # assert(false) 43 | end 44 | 45 | # check "any" cases, only for crashes 46 | 47 | for case_name : test_cases["any"].keys() 48 | var case = test_cases["any"][case_name] 49 | var val = json.load(case) 50 | end 51 | 52 | -------------------------------------------------------------------------------- /lib/berry/tests/json_test_stack_size.be: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | # this test must be in a separate file, so that the stack is not expanded yet by other tests 4 | 5 | arr = "{" 6 | for i : 0..1000 7 | arr += '"k' + str(i) + '": "v' + str(i) + '",' 8 | end 9 | arr += "}" 10 | 11 | json.load(arr) 12 | -------------------------------------------------------------------------------- /lib/berry/tests/lexer.be: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def check(a, b) 4 | assert(math.abs(a - b) < 1e-6) 5 | end 6 | 7 | def test_source(src, msg) 8 | try 9 | compile(src) 10 | assert(false, 'unexpected execution flow') 11 | except .. as e, m 12 | assert(e == 'syntax_error') 13 | assert(m == 'string:1: ' + msg) 14 | end 15 | end 16 | 17 | #---- 18 | this is a 19 | mult-line comment 20 | ----# 21 | 22 | compile('x = 5; 0..x') 23 | assert('\x5a' == 'Z') 24 | assert('\132' == 'Z') 25 | assert('\a\b\f\n\r\t\v\\\'\"\?' == '\x07\x08\x0c\x0a\x0d\x09\x0b\x5c\x27\x22\x3f') 26 | assert(.45 == 0.45) 27 | assert(0X10 == 16) 28 | assert(0x10 == 16) 29 | assert(0X1A == 26) 30 | assert(0x1a == 26) 31 | check(45., 45) 32 | check(45.e-1, 4.5) 33 | check(45.E-1, 4.5) 34 | check(45.1e-1, 4.51) 35 | check(45.1e2, 4510) 36 | check(45.e2, 4500) 37 | check(45.e+2, 4500) 38 | 39 | test_source('x = 5; 0...x;', 'unexpected symbol near \'.\'') 40 | test_source('x = 5; 0...x;', 'unexpected symbol near \'.\'') 41 | test_source('0xg', 'invalid hexadecimal number') 42 | test_source('"\\x5g"', 'invalid hexadecimal number') 43 | test_source('0x5g', 'malformed number') 44 | test_source('"\\779"', 'invalid octal number') 45 | test_source('"\n', 'unfinished string') 46 | 47 | var malformed_numbers = [ 48 | '45f', 49 | '45.f', 50 | '45.ef', 51 | '45.e-f', 52 | '45.e-1f', 53 | '45.e-1.', 54 | '45.5.', 55 | '0x45.', 56 | '0x45j' 57 | ] 58 | 59 | for i : malformed_numbers 60 | test_source(i, 'malformed number') 61 | end 62 | -------------------------------------------------------------------------------- /lib/berry/tests/lexergc.be: -------------------------------------------------------------------------------- 1 | #- check the gc bug fixed in #110 -# 2 | #- Berry must be compiled with `#define BE_USE_DEBUG_GC 1` -# 3 | #- for the initial bug to happen -# 4 | 5 | code = "()" #- this code triggers a lexer exception -# 6 | 7 | try 8 | compile(code) 9 | assert(false) #- this should never be reached -# 10 | except .. as e, m 11 | assert(m == "string:1: unexpected symbol near ')'") 12 | end -------------------------------------------------------------------------------- /lib/berry/tests/map.be: -------------------------------------------------------------------------------- 1 | m = { 'a':1, 'b':3.5, 'c': "foo", 0:1} 2 | 3 | assert(type(m) == 'instance') 4 | assert(classname(m) == 'map') 5 | 6 | # accessor 7 | assert(m['a'] == 1) 8 | assert(m['b'] == 3.5) 9 | assert(m['c'] == 'foo') 10 | assert(m[0] == 1) 11 | 12 | # find 13 | assert(m.find('a') == 1) 14 | assert(m.find('z') == nil) 15 | assert(m.find('z', 4) == 4) 16 | 17 | # contains 18 | assert(m.contains('a')) 19 | assert(m.contains(0)) 20 | assert(!m.contains('z')) 21 | assert(!m.contains()) 22 | 23 | # set 24 | m['y'] = -1 25 | assert(m['y'] == -1) 26 | 27 | # remove 28 | m={1:2} 29 | m.remove(2) 30 | assert(str(m) == '{1: 2}') 31 | m.remove(1) 32 | assert(str(m) == '{}') 33 | 34 | # allow booleans to be used as keys 35 | m={true:10, false:20} 36 | assert(m.contains(true)) 37 | assert(m.contains(false)) 38 | assert(m[true] == 10) 39 | assert(m[false] == 20) 40 | -------------------------------------------------------------------------------- /lib/berry/tests/math.be: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | #- nan -# 4 | n = math.nan 5 | assert(str(n) == 'nan') 6 | assert(math.isnan(n)) 7 | assert(math.isnan(n+n)) 8 | assert(math.isnan(n+1)) 9 | assert(math.isnan(n*0)) 10 | 11 | assert(!math.isnan(0)) 12 | assert(!math.isnan(1.5)) 13 | 14 | assert(n != n) #- nan is never identical to itself -# 15 | -------------------------------------------------------------------------------- /lib/berry/tests/member_indirect.be: -------------------------------------------------------------------------------- 1 | #- new syntax for indirect members -# 2 | 3 | #- module accessor -# 4 | s_pi = 'pi' 5 | 6 | import math 7 | assert(math.('pi') == math.pi) 8 | assert(math.(s_pi) == math.pi) 9 | 10 | #- module writer -# 11 | m = module("m") 12 | 13 | m.('aa') = 1 14 | m.('a' + 'b') = 2 15 | s_ac = 'ac' 16 | m.(s_ac) = 3 17 | assert(m.aa == 1) 18 | assert(m.ab == 2) 19 | assert(m.ac == 3) 20 | assert(m.('a'+'a') == 1) 21 | 22 | #- class accessor -# 23 | class A1 24 | static a = 1, b = 2 25 | static s = "foo" 26 | def f() return 0 end 27 | end 28 | assert(A1.a == 1) 29 | assert(A1.b == 2) 30 | assert(A1.s == "foo") 31 | assert(type(A1.f) == 'function') 32 | 33 | #- instance accessor -# 34 | class A2 35 | var a, b 36 | static s_a = 'a' 37 | def init(a,b) 38 | self.(self.('s_a')) = a 39 | self.('b') = b 40 | end 41 | def f(x) 42 | return x+1 43 | end 44 | def g(a,b) 45 | return A2(a,b) 46 | end 47 | end 48 | a = A2(1,2) 49 | 50 | #- reading members -# 51 | assert(a.a == 1) 52 | assert(a.b == 2) 53 | assert(a.(A2.s_a) == 1) 54 | assert(a.('b') == 2) 55 | 56 | #- writing members -# 57 | a.('a') = 10 58 | a.('bb'[0]) = 11 59 | assert(a.a == 10) 60 | assert(a.b == 11) 61 | 62 | #- calling methods -# 63 | assert(a.f(1) == 2) 64 | assert(a.('f')(2) == 3) 65 | 66 | #- mulit-level -# 67 | assert(a.('g')(3,4).('a') == 3) 68 | a.('a') = a.g(3,4) 69 | assert(a.a.b == 4) 70 | assert(a.('a').b == 4) 71 | assert(a.('a').('b') == 4) 72 | assert(a.a.('b') == 4) 73 | 74 | a.('a').('b') += 1 75 | assert(a.a.b == 5) 76 | -------------------------------------------------------------------------------- /lib/berry/tests/module.be: -------------------------------------------------------------------------------- 1 | # test for monkey patching of modules 2 | 3 | import string 4 | import introspect 5 | 6 | var string_orig = string 7 | 8 | introspect.setmodule("string", 42) 9 | import string 10 | assert(string == 42) 11 | 12 | # set back original value 13 | introspect.setmodule("string", string_orig) 14 | import string 15 | assert(type(string) == 'module') 16 | assert(str(string) == '') 17 | 18 | # 19 | # demo, how to monkey patch string with a new function `foo()` returning `bar` 20 | # 21 | import string 22 | import introspect 23 | var string_orig = string # keep a copy of the original string module 24 | var string_alt = module('string') # create a new module 25 | 26 | # function `super()` is a closure to capture the original value of string 27 | string_alt.super = def() 28 | return string_orig 29 | end 30 | 31 | # function `member()` is a clousre to capture the original value of string module 32 | string_alt.member = def(k) 33 | import introspect 34 | return introspect.get(string_orig, k, true) 35 | end 36 | 37 | string_alt.foo = def() return 'bar' end 38 | 39 | # replace the entry for module "string", from now on each `import string` will use `string_alt` 40 | introspect.setmodule("string", string_alt) 41 | import string 42 | 43 | # test the new string module 44 | assert(string.tolower('abCD') == 'abcd') 45 | assert(string.foo() == 'bar') 46 | -------------------------------------------------------------------------------- /lib/berry/tests/os.be: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # os.path.join test 4 | assert(os.path.join('') == '') 5 | assert(os.path.join('abc', 'de') == 'abc/de') 6 | assert(os.path.join('abc', '/de') == '/de') 7 | assert(os.path.join('a', 'de') == 'a/de') 8 | assert(os.path.join('abc/', 'de') == 'abc/de') 9 | assert(os.path.join('abc', 'de', '') == 'abc/de/') 10 | assert(os.path.join('abc', '', '', 'de') == 'abc/de') 11 | assert(os.path.join('abc', '/de', 'fghij') == '/de/fghij') 12 | assert(os.path.join('abc', 'xyz', '/de', 'fghij') == '/de/fghij') 13 | 14 | # os.path.split test 15 | def split(st, lst) 16 | var res = os.path.split(st) 17 | assert(res[0] == lst[0] && res[1] == lst[1], 18 | 'unexpected results: ' .. res .. ', reference value: ' .. lst) 19 | end 20 | 21 | split('/', ['/', '']) 22 | split('//', ['//', '']) 23 | split('///', ['///', '']) 24 | split('a/', ['a', '']) 25 | split('a//', ['a', '']) 26 | split('a/b/c', ['a/b', 'c']) 27 | split('a/b/', ['a/b', '']) 28 | split('a//b//', ['a//b', '']) 29 | split('a/../b', ['a/..', 'b']) 30 | split('abcd////ef/////', ['abcd////ef', '']) 31 | split('abcd////ef', ['abcd', 'ef']) 32 | 33 | # os.path.splitext test 34 | def splitext(st, lst) 35 | var res = os.path.splitext(st) 36 | assert(res[0] == lst[0] && res[1] == lst[1], 37 | 'unexpected results: ' .. res .. ', reference value: ' .. lst) 38 | end 39 | 40 | splitext('a.b', ['a', '.b']) 41 | splitext('a..b', ['a.', '.b']) 42 | splitext('/a..b', ['/a.', '.b']) 43 | splitext('/.b', ['/.b', '']) 44 | splitext('/..b', ['/..b', '']) 45 | splitext('..b', ['..b', '']) 46 | splitext('...b', ['...b', '']) 47 | splitext('.b', ['.b', '']) 48 | splitext('ac..b', ['ac.', '.b']) 49 | splitext('ac.b', ['ac', '.b']) 50 | splitext('ac/.b', ['ac/.b', '']) 51 | splitext('ac/..b', ['ac/..b', '']) 52 | -------------------------------------------------------------------------------- /lib/berry/tests/overload.be: -------------------------------------------------------------------------------- 1 | class test 2 | def init() 3 | self._a = 123 4 | end 5 | def +() 6 | return self._a 7 | end 8 | def ()() 9 | return self._a 10 | end 11 | var _a 12 | end 13 | 14 | print(test() + test()) 15 | -------------------------------------------------------------------------------- /lib/berry/tests/reference.be: -------------------------------------------------------------------------------- 1 | # try to exercise bug in reference 2 | 3 | class failable 4 | var fail # if 'true', tostring() raises an exception 5 | 6 | def tostring() 7 | if self.fail 8 | raise "internal_error", "FAIL" 9 | return "FAIL" 10 | else 11 | return "SUCCESS" 12 | end 13 | end 14 | end 15 | f = failable() 16 | 17 | l1 = [1, 2, f] 18 | l2 = ["foo", l1] 19 | l1.push(l1) 20 | 21 | assert(str(l2) == "['foo', [1, 2, SUCCESS, [...]]]") 22 | assert(str(l1) == "[1, 2, SUCCESS, [...]]") 23 | 24 | f.fail = true 25 | try 26 | print(str(l1)) 27 | except .. 28 | end 29 | 30 | f.fail = false 31 | assert(str(l1) == "[1, 2, SUCCESS, [...]]") # FAILS 32 | -------------------------------------------------------------------------------- /lib/berry/tests/relop.be: -------------------------------------------------------------------------------- 1 | def assert_true(status) 2 | assert(status == true, 'assert(true) failed!') 3 | end 4 | 5 | def assert_false(status) 6 | assert(status == false, 'assert(false) failed!') 7 | end 8 | 9 | assert_true(0 == 0) 10 | assert_false(0 != 0) 11 | assert_true(0 != 1) 12 | assert_false(0 == 1) 13 | 14 | 15 | assert_true(0.0 == 0) 16 | assert_false(0.0 != 0) 17 | assert_true(0.0 != 1.0) 18 | assert_false(0.0 == 1.0) 19 | 20 | assert_true(nil == nil) 21 | assert_false(nil != nil) 22 | assert_true(true != nil) 23 | assert_false(true == nil) 24 | assert_true(nil != false) 25 | assert_false(nil == false) 26 | 27 | assert_true(list == list) 28 | assert_false(list == map) 29 | 30 | assert_true([] == []) 31 | assert_true([true] == [true]) 32 | assert_true([[]] == [[]]) 33 | assert_false([[]] != [[]]) 34 | assert_false([0] == []) 35 | assert_false([] != []) 36 | assert_true([] != nil) 37 | assert_false([] == nil) 38 | 39 | assert_true({} != nil) 40 | assert_false({} == nil) 41 | -------------------------------------------------------------------------------- /lib/berry/tests/subobject.be: -------------------------------------------------------------------------------- 1 | class mylist : classof([]) end 2 | 3 | assert(issubclass(mylist, list) == true) 4 | assert(issubclass(mylist, []) == true) 5 | assert(issubclass(mylist(), list) == false) 6 | assert(issubclass(mylist(), []) == false) 7 | 8 | assert(isinstance(mylist, list) == false) 9 | assert(isinstance(mylist, []) == false) 10 | assert(isinstance(mylist(), list) == true) 11 | assert(isinstance(mylist(), []) == true) 12 | 13 | assert(issubclass(list, list) == true) 14 | assert(issubclass(list, []) == true) 15 | assert(issubclass(list(), list) == false) 16 | assert(issubclass(list(), []) == false) 17 | 18 | assert(isinstance(list, list) == false) 19 | assert(isinstance(list, []) == false) 20 | assert(isinstance(list(), list) == true) 21 | assert(isinstance(list(), []) == true) 22 | 23 | assert(issubclass(list, list) == true) 24 | assert(issubclass(list, []) == true) 25 | assert(issubclass(list(), list) == false) 26 | assert(issubclass(list(), []) == false) 27 | 28 | assert(issubclass(list, mylist) == false) 29 | assert(isinstance([], mylist) == false) 30 | -------------------------------------------------------------------------------- /lib/berry/tests/suffix.be: -------------------------------------------------------------------------------- 1 | var keys = [ 'key1', 'key2', 'key3', 'key4' ] 2 | var pairs = { 3 | keys[0]: 'value1', 4 | keys[1]: 'value2', 5 | keys[2]: 'value3', 6 | keys[3]: 'value4' 7 | } 8 | 9 | for i : 0 .. keys.size() - 1 10 | assert(pairs[keys[i]] == 'value' .. i + 1) 11 | end 12 | 13 | #- test cases related to #101 -# 14 | class C var l end 15 | c=C() 16 | c.l=[0,1,2] 17 | 18 | def t_101_nok_1() return c.l[0..1] end 19 | def t_101_ok_1() var l2 = c.l return l2[0..1] end 20 | 21 | t_i = 0 22 | def t_101_nok_2() return c.l[t_i] end 23 | def t_101_ok_2() return c.l[0] end 24 | 25 | assert(t_101_nok_1() == [0, 1]) 26 | assert(t_101_ok_1() == [0, 1]) 27 | assert(t_101_nok_2() == 0) 28 | assert(t_101_ok_2() == 0) 29 | -------------------------------------------------------------------------------- /lib/berry/tests/super_leveled.be: -------------------------------------------------------------------------------- 1 | #- test for leveled use of super() -# 2 | 3 | #- setup -# 4 | class A def r() return 'a' end def f() return self.r() end end 5 | class B:A def r() return 'b' end def f() return super(self,A).f() + 'b' end end 6 | class C:B def r() return 'c' end def f() return super(self,B).f() + 'c' end end 7 | a=A() 8 | b=B() 9 | c=C() 10 | 11 | #- regular behavior -# 12 | assert(classname(a) == 'A') 13 | assert(classname(b) == 'B') 14 | assert(classname(c) == 'C') 15 | assert(a.r() == 'a') 16 | assert(b.r() == 'b') 17 | assert(c.r() == 'c') 18 | assert(a.f() == 'a') 19 | 20 | #- standard use of super() -# 21 | assert(super(a) == nil) 22 | assert(super(A) == nil) 23 | assert(classname(super(B)) == 'A') 24 | assert(classname(super(C)) == 'B') 25 | assert(classname(super(super(C))) == 'A') 26 | assert(super(super(super(C))) == nil) 27 | 28 | #- super() levele -# 29 | assert(super(a,A) == nil) 30 | assert(super(b,B) == nil) 31 | assert(super(c,C) == nil) 32 | assert(classname(super(c,B)) == 'B') 33 | assert(classname(super(c,A)) == 'A') 34 | assert(super(c,map) == nil) #- not a parent class -# 35 | 36 | #- wrapping it all -# 37 | assert(a.f() == 'a') 38 | assert(b.f() == 'bb') 39 | 40 | #- the last one is tricky: 41 | c.f() -> calls f() in class B -> calls f() in class A -> calls r() of overall class hence C 42 | -# 43 | assert(c.f() == 'cbc') -------------------------------------------------------------------------------- /lib/berry/tests/vararg.be: -------------------------------------------------------------------------------- 1 | #- vararg -# 2 | def f(a,*b) return b end 3 | 4 | assert(f() == []) 5 | assert(f(1) == []) 6 | assert(f(1,2) == [2]) 7 | assert(f(1,2,3) == [2, 3]) 8 | 9 | def g(*a) return a end 10 | 11 | assert(g() == []) 12 | assert(g("foo") == ["foo"]) 13 | assert(g("foo", nil) == ["foo", nil]) 14 | assert(g("foo", nil, 2) == ["foo", nil, 2]) 15 | -------------------------------------------------------------------------------- /lib/berry/tests/virtual_methods.be: -------------------------------------------------------------------------------- 1 | #- basic initialization -# 2 | 3 | def assert_attribute_error(f) 4 | try 5 | f() 6 | assert(false, 'unexpected execution flow') 7 | except .. as e, m 8 | assert(e == 'attribute_error') 9 | end 10 | end 11 | 12 | class T1 13 | var a, b 14 | def init() 15 | self.a = 1 16 | self.b = 2 17 | end 18 | def f() return true end 19 | def g() return false end 20 | end 21 | t = T1() 22 | 23 | #- warm up -# 24 | assert(t.a == 1) 25 | assert(t.b == 2) 26 | assert(t.f() == true) 27 | assert(t.g() == false) 28 | 29 | #- test normal errors when method does not exist -# 30 | assert_attribute_error(/-> t.h()) 31 | assert_attribute_error(/-> t.c) 32 | 33 | class T2 : T1 34 | def member(n) 35 | import undefined 36 | if (n == 'f1') return / n -> n end 37 | if (n == 'f2') return /-> 4 end 38 | if (n == 'a1') return 10 end 39 | if (n == 'h') return undefined end 40 | end 41 | end 42 | t2 = T2() 43 | 44 | #- test non-regression -# 45 | assert(t2.a == 1) 46 | assert(t2.b == 2) 47 | assert(t2.f() == true) 48 | assert(t2.g() == false) 49 | assert_attribute_error(/-> t2.h()) 50 | 51 | #- try virtual methods -# 52 | assert(t2.f1() == t2) 53 | assert(t2.f2() == 4) 54 | assert(t2.a1 == 10) 55 | assert(t2.foo == nil) 56 | 57 | #- module -# 58 | m = module("m") 59 | 60 | m.a = 1 61 | assert(m.a == 1) 62 | assert_attribute_error(/-> m.b) 63 | 64 | m.member = def(n) 65 | import undefined 66 | if n == "b" return 2 end 67 | if n == "c" return undefined end 68 | end 69 | 70 | assert(m.b == 2) 71 | assert_attribute_error(/-> m.c) 72 | assert(m.d == nil) #- returns nil if no response -# 73 | -------------------------------------------------------------------------------- /lib/berry/tests/virtual_methods2.be: -------------------------------------------------------------------------------- 1 | #- virtual attributes -# 2 | 3 | def assert_attribute_error(f) 4 | try 5 | f() 6 | assert(false, 'unexpected execution flow') 7 | except .. as e, m 8 | assert(e == 'attribute_error') 9 | end 10 | end 11 | 12 | class Ta 13 | var a, b, virtual_c 14 | def init() 15 | self.a = 1 16 | self.b = 2 17 | self.virtual_c = 3 18 | end 19 | def member(n) 20 | if n == 'c' return self.virtual_c end 21 | return nil 22 | end 23 | def setmember(n, v) 24 | if n == 'c' self.virtual_c = v return true end 25 | return false 26 | end 27 | end 28 | ta = Ta() 29 | 30 | assert(ta.a == 1) 31 | assert(ta.b == 2) 32 | assert(ta.c == 3) 33 | ta.a = 10 34 | assert(ta.a == 10) 35 | assert(ta.c == 3) 36 | ta.c = 30 37 | assert(ta.c == 30) 38 | assert(ta.virtual_c == 30) 39 | assert_attribute_error(def() ta.d = 0 end) 40 | -------------------------------------------------------------------------------- /lib/berry/tools/coc/coc_string.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def hashcode(s): 4 | """Compute hash for a string, in uint32_t""" 5 | hash = 2166136261 6 | for c in s.encode('utf8'): 7 | hash = ((hash ^ c) * 16777619) & 0xFFFFFFFF 8 | return hash 9 | 10 | def escape_operator_v1(s): 11 | tab = { 12 | # "void": "", 13 | "..": "opt_connect", 14 | "+": "opt_add", "-": "opt_sub", 15 | "*": "opt_mul", "/": "opt_div", 16 | "%": "opt_mod", "&": "opt_and", 17 | "^": "opt_xor", "|": "opt_or", 18 | "<": "opt_lt", ">": "opt_gt", 19 | "<=": "opt_le", ">=": "opt_ge", 20 | "==": "opt_eq", "!=": "opt_neq", 21 | "<<": "opt_shl", ">>": "opt_shr", 22 | "-*": "opt_neg", "~": "opt_flip", 23 | "()": "opt_call", 24 | } 25 | if s in tab: return tab[s] 26 | s2 = "" 27 | for c in s: 28 | if c == '.': s2 += 'dot_' 29 | else: s2 += c 30 | return s2 31 | 32 | def escape_operator(s): 33 | s = re.sub('_X', '_X_', s) # replace any esape sequence '_X' with '_XX' 34 | s = re.sub('[^a-zA-Z0-9_]', lambda m: "_X{0:02X}".format(ord(m.group())), s) 35 | return s 36 | 37 | def unescape_operator(s): 38 | s = re.sub('_X[0-9A-F][0-9A-F]', lambda m: chr(int(m.group()[2:], 16)), s) 39 | s = re.sub('_X_', '_X', s) 40 | return s 41 | -------------------------------------------------------------------------------- /lib/berry/tools/coc/coc_string_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from coc_string import * 3 | 4 | class Test_coc_string(unittest.TestCase): 5 | 6 | def test_hash(self): 7 | self.assertEqual(hashcode("add"), 993596020) 8 | self.assertEqual(hashcode("real"), 3604983901) 9 | 10 | def test_escape(self): 11 | self.assertEqual(escape_operator("foo"), "foo") 12 | self.assertEqual(escape_operator(".."), "_opt_connect") 13 | self.assertEqual(escape_operator("foo.bar"), "foo_dot_bar") 14 | self.assertEqual(escape_operator("foo._bar"), "foo_dot___bar") 15 | self.assertEqual(escape_operator("foo. bar"), "foo_dot__20bar") 16 | 17 | if __name__ == '__main__': 18 | unittest.main() -------------------------------------------------------------------------------- /lib/berry/tools/coc/macro_table.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def int_safe(v): 4 | try: return int(v, 0) 5 | except: return 0 6 | 7 | class macro_table: 8 | pat = re.compile("(?:\\n|$)\\s*#define\\s+(\\w+)[ \\t]+(\\w*)", re.MULTILINE) 9 | pat_query = re.compile("(!?)(\\w+)") 10 | 11 | def __init__(self): 12 | self.map = {} 13 | 14 | # def readfile(self, filename): 15 | # with open(filename) as f: 16 | # return f.read() 17 | 18 | def parse_value(self, s): 19 | if len(s) == 0: return 1 # defined a macro name but no content, considered true 20 | if not s[0].isnumeric(): return 1 21 | return int_safe(s) 22 | 23 | def scan_file(self, filename): 24 | str = "" 25 | with open(filename) as f: 26 | str = f.read() 27 | r = macro_table.pat.findall(str) 28 | for it in r: 29 | # print(f"> it0:{it[0]} it1:{it[1]}") 30 | self.map[it[0]] = self.parse_value(it[1]) 31 | 32 | def query(self, s): 33 | r = macro_table.pat_query.search(s) 34 | value = False 35 | if r: 36 | bang = r[1] 37 | name = r[2] 38 | # print(f">query: bang={bang} name={name} value={self.map.get(name)}") 39 | if name in self.map: 40 | value = int(self.map[name]) != 0 41 | if bang == "!": 42 | value = not value 43 | # print(f">query: {s}:{value}") 44 | return value 45 | 46 | if __name__ == '__main__': 47 | # from hash_map import * 48 | pat = re.compile("(?:\\n|$)\\s*#define\\s+(\\w+)[ \\t]+(\\w+)", re.MULTILINE) 49 | s = "aaa\n#define A 1 // a \n #define B 2\n#define C \n#define D 0 \n #define E 11 \na" 50 | -------------------------------------------------------------------------------- /lib/berry/tools/grammar/const_obj.ebnf: -------------------------------------------------------------------------------- 1 | block = type name ['(' {attributes} ')'] '{' {data_fields} '}'; 2 | type = 'map' | 'class' | 'module' | 'vartab'; 3 | 4 | attributes = name ':' name [',']; 5 | data_fields = data_name ',' data_value [':' depend_macro] '\n'; 6 | 7 | (* regular expression *) 8 | name = [_a-zA-Z]\w*; 9 | data_name = [\._a-zA-Z]\w*; 10 | data_value = [\w\()]+; 11 | depend_macro = [_a-zA-Z]\w*; 12 | -------------------------------------------------------------------------------- /lib/berry/tools/grammar/json.ebnf: -------------------------------------------------------------------------------- 1 | json = value; 2 | value = object | array | 3 | string | number | 'true' | 'false' | 'null'; 4 | object = '{' [ string ':' value ] { ',' string ':' value } '}'; 5 | array = '[' [json] { ',' json } ']'; 6 | -------------------------------------------------------------------------------- /lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Embedded Script 6 | none 7 | berry,Embedded Script,__ext_.berry 8 | Languages 9 | Public 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 | -------------------------------------------------------------------------------- /lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to the "none" extension will be documented in this file. 3 | 4 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 5 | 6 | ## [Unreleased] 7 | - Initial release -------------------------------------------------------------------------------- /lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xila-Project/Old_core/4a8fc6a3a11cefc460a450c76e6231681c53be6a/lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/README.md -------------------------------------------------------------------------------- /lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/berry-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "#", 5 | "blockComment": [ "#-", "-#" ] 6 | }, 7 | // symbols used as brackets 8 | "brackets": [ 9 | ["[", "]"], 10 | ["(", ")"], 11 | ["{", "}"] 12 | ], 13 | // symbols that are auto closed when typing 14 | "autoClosingPairs": [ 15 | ["[", "]"], 16 | ["(", ")"], 17 | ["{", "}"], 18 | ["\"", "\""], 19 | ["'", "'"] 20 | ], 21 | // symbols that that can be used to surround a selection 22 | "surroundingPairs": [ 23 | ["[", "]"], 24 | ["(", ")"], 25 | ["\"", "\""], 26 | ["'", "'"] 27 | ], 28 | "indentationRules": { 29 | "increaseIndentPattern": "(^((\\s*(class|while|for|if|elif|else|try|except))|(.*\\bdef))\\b((?!\\b(end)\\b).)*)$", 30 | "decreaseIndentPattern": "^\\s*((\\b(elif|else|except|end)\\b)|(\\)))" 31 | } 32 | } -------------------------------------------------------------------------------- /lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/berry-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xila-Project/Old_core/4a8fc6a3a11cefc460a450c76e6231681c53be6a/lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/berry-icon.png -------------------------------------------------------------------------------- /lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "berry", 3 | "displayName": "Berry Script Language", 4 | "description": "A small embedded script language.", 5 | "version": "0.1.0", 6 | "icon": "berry-icon.png", 7 | "publisher": "skiars", 8 | "engines": { 9 | "vscode": "^1.15.1" 10 | }, 11 | "categories": [ 12 | "Programming Languages" 13 | ], 14 | "contributes": { 15 | "languages": [ 16 | { 17 | "id": "berry", 18 | "aliases": [ 19 | "Berry", 20 | "berry" 21 | ], 22 | "extensions": [ 23 | ".be" 24 | ], 25 | "configuration": "./berry-configuration.json" 26 | }, 27 | { 28 | "id": "berry-bytecode", 29 | "aliases": [ 30 | "Berry Bytecode", 31 | "berry bytecode" 32 | ], 33 | "extensions": [ 34 | "berry.bytecode" 35 | ] 36 | } 37 | ], 38 | "grammars": [ 39 | { 40 | "language": "berry", 41 | "scopeName": "source.berry", 42 | "path": "./syntaxes/berry.json" 43 | }, 44 | { 45 | "language": "berry-bytecode", 46 | "scopeName": "source.berry.bytecode", 47 | "path": "./syntaxes/bytecode.json" 48 | } 49 | ] 50 | }, 51 | "__metadata": null 52 | } -------------------------------------------------------------------------------- /lib/berry/tools/plugins/vscode/skiars.berry-0.1.0/syntaxes/bytecode.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", 3 | "name": "Berry", 4 | "patterns": [ 5 | { 6 | "include": "#comments" 7 | }, 8 | { 9 | "include": "#keywords" 10 | }, 11 | { 12 | "include": "#number" 13 | }, 14 | { 15 | "include": "#operator" 16 | }, 17 | { 18 | "include": "#entity" 19 | } 20 | ], 21 | "repository": { 22 | "comments": { 23 | "name": "comment.line.berry.bytecode", 24 | "begin": "\\--", 25 | "end": "\\n", 26 | "patterns": [{}] 27 | }, 28 | "keywords": { 29 | "patterns": [{ 30 | "name": "keyword.berry.bytecode", 31 | "match": "or" 32 | }] 33 | }, 34 | "number": { 35 | "patterns": [{ 36 | "name": "constant.numeric.berry.bytecode", 37 | "match": "\\b((0x)?[0-9]+)\\b" 38 | }] 39 | }, 40 | "operator": { 41 | "patterns": [ 42 | { 43 | "name": "keyword.operator.berry.bytecode", 44 | "match": "\\(|\\)|:|\\[|\\]|\\||->" 45 | } 46 | ] 47 | }, 48 | "entity": { 49 | "patterns": [ 50 | { 51 | "name": "entity.name.function.berry", 52 | "match": "^\\s*\\w+(?=\\s*(:|->))" 53 | } 54 | ] 55 | } 56 | }, 57 | "scopeName": "source.berry.bytecode" 58 | } -------------------------------------------------------------------------------- /lib/berry_mapping/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Stephan Hadinger, Guan Wenliang 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /lib/berry_mapping/src/be_raisef.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************************************\ 2 | * Extended version of be_raise() 3 | \*********************************************************************************************/ 4 | 5 | #include "be_mapping.h" 6 | #include "be_exec.h" 7 | #include 8 | #include 9 | #include 10 | 11 | // variant of be_raise with string format 12 | void be_raisef(bvm *vm, const char *except, const char *msg, ...) { 13 | // To save stack space support logging for max text length of 128 characters 14 | char log_data[128]; 15 | 16 | va_list arg; 17 | va_start(arg, msg); 18 | uint32_t len = vsnprintf(log_data, sizeof(log_data)-3, msg, arg); 19 | va_end(arg); 20 | if (len+3 > sizeof(log_data)) { strcat(log_data, "..."); } // Actual data is more 21 | be_raise(vm, except, log_data); 22 | } 23 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Xila.hpp" 2 | 3 | #include "Shell.hpp" 4 | #include "Preferences.hpp" 5 | #include "File_Manager.hpp" 6 | #include "Berry.hpp" 7 | 8 | using namespace Xila; 9 | 10 | void setup() 11 | { 12 | Softwares.Register_Handle(Shell_Class::Handle); 13 | Softwares.Register_Handle(Preferences_Class::Handle); 14 | Softwares.Register_Handle(File_Manager_Class::Handle); 15 | 16 | System.Start(); 17 | 18 | Berry_Class::Load_Softwares_Handles(); 19 | } 20 | 21 | void loop() 22 | { 23 | vTaskDelete(NULL); 24 | } 25 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /test/Rational/test_Rational.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Mathematics/Rational.hpp" 4 | 5 | #include 6 | 7 | using namespace Xila_Namespace; 8 | using namespace Xila_Namespace::Mathematics_Types; 9 | 10 | namespace Xila_Namespace 11 | { 12 | class Unit_Test_Class 13 | { 14 | public: 15 | void Constructor() 16 | { 17 | { 18 | Rational_Class Rational(1, 2); 19 | TEST_ASSERT_EQUAL(1, Rational.Get_Numerator()); 20 | TEST_ASSERT_EQUAL(2, Rational.Get_Denominator()); 21 | } 22 | 23 | } 24 | 25 | } Unit_Test; 26 | } 27 | 28 | void setup() 29 | { 30 | UNITY_BEGIN(); 31 | 32 | UNITY_TEST_ASSERT_EQUAL_FLOAT(1.0, 1.0, 0, "Test 1"); 33 | 34 | UNITY_END(); 35 | } 36 | 37 | void loop() 38 | { 39 | } -------------------------------------------------------------------------------- /test/test_String/Unit_Test_String.hpp: -------------------------------------------------------------------------------- 1 | /// @file test_String.hpp 2 | /// @author Alix ANNERAUD (alix@anneraud.fr) 3 | /// @brief String unit test header file. 4 | /// @version 0.1.0 5 | /// @date 05-04-2023 6 | /// 7 | /// @copyright Copyright (c) 2023 8 | 9 | #ifndef Unit_Test_String_Hpp_Included 10 | #define Unit_Test_String_Hpp_Included 11 | 12 | #include "Module/String.hpp" 13 | 14 | #include "unity.h" 15 | 16 | namespace Xila_Namespace 17 | { 18 | typedef class Unit_Test_Class 19 | { 20 | // - Methods 21 | 22 | void Constructors(); 23 | void Capacity(); 24 | 25 | void Operators(); 26 | void Concatenation(); 27 | 28 | public: 29 | void Run(); 30 | } Unit_Test_Type; 31 | } 32 | 33 | #endif // Unit_Test_String_Hpp_Included 34 | 35 | -------------------------------------------------------------------------------- /test/test_String/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Unit_Test_String.hpp" 2 | 3 | using namespace Xila_Namespace; 4 | 5 | void setup() 6 | { 7 | Unit_Test_Class Unit_Test; 8 | Unit_Test.Run(); 9 | } 10 | 11 | void loop() 12 | { 13 | } --------------------------------------------------------------------------------