arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.7k stars 4.72k forks source link

Berry bytes solidification #21558

Closed s-hadinger closed 1 month ago

s-hadinger commented 1 month ago

Description:

Berry is now able to solidify bytes instances, which opens the door for more flash size optimization.

Example:

class DemoBin
    static var b1 = bytes("DEADBEEF")
end

import solidify
solidify.dump(DemoBin)

Output is:

extern const bclass be_class_DemoBin;

/********************************************************************
** Solidified class: DemoBin
********************************************************************/
be_local_class(DemoBin,
    0,
    NULL,
    be_nested_map(1,
    ( (struct bmapnode*) &(const bmapnode[]) {
        { be_const_key(b1, -1), be_const_bytes_instance(DEADBEEF) },
    })),
    (bstring*) &be_const_str_DemoBin
);

As expected, the solidified bytes instance is read-only.

Checklist:

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass