From 623ba863fae227c8e0163704ede1da3abac81f8a Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Wed, 29 Jul 2020 13:30:07 -0700 Subject: [PATCH] Updating to format version 3. --- assets/dependency_test.riv | Bin 414 -> 324 bytes assets/juice.riv | Bin 14314 -> 9147 bytes assets/shapetest.riv | Bin 440 -> 297 bytes assets/two_artboards.riv | Bin 495 -> 311 bytes dev/core_generator/lib/src/comment.dart | 2 +- dev/core_generator/lib/src/field_type.dart | 1 + .../lib/src/field_types/initialize.dart | 1 + .../lib/src/field_types/uint_field_type.dart | 13 +++ dev/defs/animation/keyed_object.json | 2 +- dev/defs/animation/keyframe.json | 2 +- .../animation/keyframe_draw_order_value.json | 4 +- dev/defs/component.json | 2 +- dev/defs/drawable.json | 7 +- dev/defs/shapes/rectangle.json | 1 + dev/update_defs.sh | 14 +++ rive/include/core/binary_reader.hpp | 3 +- .../core/field_types/core_uint_type.hpp | 13 +++ rive/include/core/reader.h | 97 ++++++++++++++++-- rive/include/file.hpp | 4 +- .../generated/animation/animation_base.hpp | 5 +- .../animation/cubic_interpolator_base.hpp | 5 +- .../generated/animation/keyed_object_base.hpp | 9 +- .../animation/keyed_property_base.hpp | 5 +- .../generated/animation/keyframe_base.hpp | 8 +- .../animation/keyframe_color_base.hpp | 5 +- .../animation/keyframe_double_base.hpp | 5 +- .../animation/keyframe_draw_order_base.hpp | 5 +- .../keyframe_draw_order_value_base.hpp | 11 +- .../animation/linear_animation_base.hpp | 5 +- rive/include/generated/artboard_base.hpp | 5 +- rive/include/generated/backboard_base.hpp | 5 +- rive/include/generated/component_base.hpp | 9 +- .../generated/container_component_base.hpp | 5 +- rive/include/generated/core_registry.hpp | 77 ++++++++------ rive/include/generated/drawable_base.hpp | 28 ++--- rive/include/generated/node_base.hpp | 5 +- .../shapes/cubic_asymmetric_vertex_base.hpp | 5 +- .../shapes/cubic_detached_vertex_base.hpp | 5 +- .../shapes/cubic_mirrored_vertex_base.hpp | 5 +- .../generated/shapes/cubic_vertex_base.hpp | 5 +- .../include/generated/shapes/ellipse_base.hpp | 5 +- .../generated/shapes/paint/fill_base.hpp | 5 +- .../shapes/paint/gradient_stop_base.hpp | 5 +- .../shapes/paint/linear_gradient_base.hpp | 5 +- .../shapes/paint/radial_gradient_base.hpp | 5 +- .../shapes/paint/shape_paint_base.hpp | 5 +- .../shapes/paint/solid_color_base.hpp | 5 +- .../generated/shapes/paint/stroke_base.hpp | 5 +- .../generated/shapes/parametric_path_base.hpp | 5 +- rive/include/generated/shapes/path_base.hpp | 5 +- .../generated/shapes/path_composer_base.hpp | 5 +- .../generated/shapes/path_vertex_base.hpp | 5 +- .../generated/shapes/points_path_base.hpp | 5 +- .../generated/shapes/rectangle_base.hpp | 7 +- rive/include/generated/shapes/shape_base.hpp | 5 +- .../generated/shapes/straight_vertex_base.hpp | 5 +- .../generated/shapes/triangle_base.hpp | 5 +- rive/src/core/binary_reader.cpp | 23 +++-- rive/src/core/field_types/core_color_type.cpp | 2 +- .../src/core/field_types/core_double_type.cpp | 2 +- .../src/core/field_types/core_string_type.cpp | 2 +- rive/src/core/field_types/core_uint_type.cpp | 9 ++ rive/src/file.cpp | 19 ++-- rive/test/file_test.cpp | 4 +- 64 files changed, 323 insertions(+), 208 deletions(-) create mode 100644 dev/core_generator/lib/src/field_types/uint_field_type.dart create mode 100755 dev/update_defs.sh create mode 100644 rive/include/core/field_types/core_uint_type.hpp create mode 100644 rive/src/core/field_types/core_uint_type.cpp diff --git a/assets/dependency_test.riv b/assets/dependency_test.riv index 8bf8e6eb4068df75f571754adb82345029069466..8ce10ca49fef747ea08328e625702cfea75b42f5 100644 GIT binary patch literal 324 zcmYjMu}Z^G6g{tfSNqcBQKe{gF$kGN^tm|aML{=-w9cUoRT@$$>E2O?g7^h~f`1^y z*>7-ib98cvFR>NxaJU@KJ?Gr;ymwm1`;5s=urRkNYmNCiItHhzoHvmDRtm6|Ld~^c| zdtak%$VKhSM*r6C@Wy2}8INLDkvPEJi@#J=&n;AKZt18$8cxR3bU*;xIkviKc9SLX Hz*WExu9!tl literal 414 zcmWIY40B~-xZl9YC(gjg&B(&ylvA3@&ca|c%bA0P;dhubCkq3MkrNjSLy)#JHwyz0 z@PJ7Mb{4*%)Z~)Hy!4z@g@DA83|2;VUKWO5olbl#40*jy{9t7QK(fJJ5KIbzNfDqL zPG?b|8eV4x5f(0|#N_PsqWsdl6jnwCO-4oyMg|5URz@yW*8hz+e({6YOscFKA07G0 z&%ngO=)}s%3AE;o63ChfUmS5+15)eE%E$^-TX5D9sCL67oK9k3X5obU1)?V>{4h|D zf#D%s=8G{hh%+)XZ~}b|vdR(Yc%W5JL!E)zcyw`FB?8m{^(CXcIag?2NoGk-YKnrP V1*456qm30fjI0?M?0~_*000lmLh1kj diff --git a/assets/juice.riv b/assets/juice.riv index b6c8287fd085afb810a499c8196438c44016dc48..67096d7263bb55e3c9539d93a2644b88584b77b5 100644 GIT binary patch literal 9147 zcmai334Bvk*1xaKE3}Z1Vkx=#N@<}*Rsll`4v^%%v|&@MT@oEpD9{ZHt!=TWC_yM9 zlub~eAXa1%K|fUJCoUxmohc5?2*~bI5ETUd3JNac*g5CE`;ymyGyHy~@8o~(xo1D; zrPB)Y0c&ITI|BxL^if|t0YI#*s>rVvw+s4~ z!^eGwxRt4n_>QEj_=1qy_Ujo7xlJ6~=d}%k+CVA2$+PEP2lcFOlyYyhj_~H~wf1(n z`Yrs}=6|u+=|Kg)S%4Sfkt*x3w=%Oo&OJ+?jEhwxK zHvzwWg4M9{VzvzOby;Zn`vM3y>f+VQvJ0kF<2lIej5`UQaRIqn(tnr6I46wRjeC%5=%=i8@2Kvs5< zz;lE8FmL>^3L8OfjSjboR`rBp!FXnX@>~qhQQ|v-slM<|nKqwV4ie-$ZGWXA8R@;Ow+j3hNE|&qKRrK)!$(ub+kJesf#XnykK%gNl|f?=oR!y1DE;@ zErYN6jM-^dtg(BSCfee=ka%&v(BFJ6LrUJAveeeAdBPZ}_o5HVF`d^4sY@0=)<$}Z zPNg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zeeKZ}+!*KE7h8vNL2K%ek&3Cql39z6o$_;y4mq!oB{%5nM1BI&VU0q@8q}7)O66xI z^|`rYs7n{?(n1DFs$t55l@tVwD|$)FvzEFn_sl!K_@Z-nvx80wGyEDP=aPQ>*-^X6 z`gZ#rbIG#Zz5B`*j=7Yc>bfFW;??GohFP0ST5e4vP`D-E>b05QdEwIPwPVQ+%`kR- z^rCw|Z*@#D>TW?2uT~okvsN1|w?-R<8yQTY#rTaK5+83fh=3q8B@cn)kedt)ke#$(MI7$UW(evRdrhZ zRh|E7Hr|y2%d0wd%DeTj;U6sA8V_lBwK{2-wK{3JH99HWQp)H(G~mKrm&YdtF<+?K zY^WCb)v0+>%TPU};nixRVb*G+<<@AUa3hKKOP43!nlg<&7LX;Cm|D*D&!4nVi|N1$ zo!uBQxZl9YCeFaf!^pzpms+miSX7dfpIDT_&cJZOnS+7B!(MBuS8Zp!SpdA=-f~dx&-s7B;ucoE!y1m};OxkY!FGAT2P}o(>SzVCMi` P0yobdrsCv&hzbS(ta?8g literal 440 zcmWIY40B~-xZl9YCeFaf!^pzpms+miSX7dfpIDT_&ceWO!kGg|dN^}}NiL9x6E~1# zVBi6h3?eLCPKn9c=|%aac`2-n44RCL8jK7KLadC8s;nCy9r?)*VsompetB{6H$Q^_ z3y*6~PG&)IszN|wNd_w;8!rpPqh=>QFv$-#QvgUd*b9P5Auy@H$jHFP%E%%CmX`#n zJru$rq3aUzTanWtl*L#`&?yWo7Y=4KFte~jtpPd-XoCs2Gth<`e;skzAjZfb&dAKb z33L$5CZMZ;HUR<5rl0$vHbHIvX%DqcgoVv5GbcyE5U3mKe>B%Rg@8>$)z9ew)elt+ R^c0$f_NW?u?uTk%004IBQS$%* diff --git a/assets/two_artboards.riv b/assets/two_artboards.riv index 17556040f67b9f101a783b0d61cd564453361b14..fc707c05440ae561445efc0c1eee4bd28d06cb65 100644 GIT binary patch literal 311 zcmWIY40B~>xZl9YEzZEi!N|hwpO?zs@coT5M}y&ZXHEu=XHHxU*S0uuGXMb(h+q(5 z;c`k$&Q34NFU?C~Wnd6uWmGjZH2e=_ursi*@VMsWWEK>sDg-2!WU#XGG9<-1@qq{t zhNQbrq9B5SnS~vyij{$vpV ju{fU@;(Sh4HlV{e;f8>m7WNyc|KDPe(-6*LV_*OPP~$|~ literal 495 zcmWIY40B~-xZl9YEzZEi!N|hwpO?zc((wI_GY3n9;dWSVc~L0OwLX($}i1JVP#~{WMtG}WMB|tWn@%k-T3IpPks=aU6u9Ai;KVc8CY0& zTyt_V3yM<}0uoCySQ%M)Ss0RHo%p~cKiEtGAlYCq2quNVqzF*Y?< mJmJR-3qPR4*?_+0gj)vjci3-`J^vQtvMBrmhUybJ*MB3yC+ diff --git a/dev/core_generator/lib/src/comment.dart b/dev/core_generator/lib/src/comment.dart index beea40e8..761139e8 100644 --- a/dev/core_generator/lib/src/comment.dart +++ b/dev/core_generator/lib/src/comment.dart @@ -10,7 +10,7 @@ String comment(String s, {int indent = 0}) { _indentRegexp[indent] = reg = _makeWrappingRegExp(80 - 4 - 2 * indent); } - return "// " + + return "/// " + s .replaceAllMapped(reg, (Match m) => "${m[1]}${m[2]}\n") .trim() diff --git a/dev/core_generator/lib/src/field_type.dart b/dev/core_generator/lib/src/field_type.dart index 086edd21..f52accac 100644 --- a/dev/core_generator/lib/src/field_type.dart +++ b/dev/core_generator/lib/src/field_type.dart @@ -3,6 +3,7 @@ export 'package:core_generator/src/field_types/double_field_type.dart'; export 'package:core_generator/src/field_types/int_field_type.dart'; export 'package:core_generator/src/field_types/string_field_type.dart'; export 'package:core_generator/src/field_types/color_field_type.dart'; +export 'package:core_generator/src/field_types/uint_field_type.dart'; Map _types = {}; diff --git a/dev/core_generator/lib/src/field_types/initialize.dart b/dev/core_generator/lib/src/field_types/initialize.dart index 6c357931..8f5e5a6c 100644 --- a/dev/core_generator/lib/src/field_types/initialize.dart +++ b/dev/core_generator/lib/src/field_types/initialize.dart @@ -8,6 +8,7 @@ void initializeFields() { fields = [ StringFieldType(), IntFieldType(), + UintFieldType(), DoubleFieldType(), BoolFieldType(), ColorFieldType(), diff --git a/dev/core_generator/lib/src/field_types/uint_field_type.dart b/dev/core_generator/lib/src/field_types/uint_field_type.dart new file mode 100644 index 00000000..8de3a3d6 --- /dev/null +++ b/dev/core_generator/lib/src/field_types/uint_field_type.dart @@ -0,0 +1,13 @@ +import '../field_type.dart'; + +class UintFieldType extends FieldType { + UintFieldType() + : super( + 'uint', + 'CoreUintType', + cppName: 'int', + ); + + @override + String get defaultValue => '0'; +} diff --git a/dev/defs/animation/keyed_object.json b/dev/defs/animation/keyed_object.json index c69a1966..631fba48 100644 --- a/dev/defs/animation/keyed_object.json +++ b/dev/defs/animation/keyed_object.json @@ -7,7 +7,7 @@ "properties": { "objectId": { "type": "Id", - "typeRuntime": "int", + "typeRuntime": "uint", "key": { "int": 51, "string": "objectid" diff --git a/dev/defs/animation/keyframe.json b/dev/defs/animation/keyframe.json index 08c7c845..9dce4306 100644 --- a/dev/defs/animation/keyframe.json +++ b/dev/defs/animation/keyframe.json @@ -33,7 +33,7 @@ }, "interpolatorId": { "type": "Id", - "typeRuntime": "int", + "typeRuntime": "uint", "key": { "int": 69, "string": "interpolatorid" diff --git a/dev/defs/animation/keyframe_draw_order_value.json b/dev/defs/animation/keyframe_draw_order_value.json index 7d0a8c93..d8bc0fe8 100644 --- a/dev/defs/animation/keyframe_draw_order_value.json +++ b/dev/defs/animation/keyframe_draw_order_value.json @@ -16,7 +16,7 @@ }, "drawableId": { "type": "Id", - "typeRuntime": "int", + "typeRuntime": "uint", "key": { "int": 77, "string": "drawableid" @@ -25,7 +25,7 @@ }, "value": { "type": "FractionalIndex", - "typeRuntime": "int", + "typeRuntime": "uint", "key": { "int": 78, "string": "value" diff --git a/dev/defs/component.json b/dev/defs/component.json index 6e553885..d48e1f76 100644 --- a/dev/defs/component.json +++ b/dev/defs/component.json @@ -25,7 +25,7 @@ }, "parentId": { "type": "Id", - "typeRuntime": "int", + "typeRuntime": "uint", "key": { "int": 5, "string": "parentId" diff --git a/dev/defs/drawable.json b/dev/defs/drawable.json index 80fec211..5c2de1f3 100644 --- a/dev/defs/drawable.json +++ b/dev/defs/drawable.json @@ -9,17 +9,18 @@ "properties": { "drawOrder": { "type": "FractionalIndex", - "typeRuntime": "int", + "typeRuntime": "uint", "key": { "int": 22, "string": "drawOrder" } }, - "blendMode": { + "blendModeValue": { "type": "int", + "initialValue": "3", "key": { "int": 23, - "string": "blendMode" + "string": "blendModeValue" } } } diff --git a/dev/defs/shapes/rectangle.json b/dev/defs/shapes/rectangle.json index bdd043b4..d771905f 100644 --- a/dev/defs/shapes/rectangle.json +++ b/dev/defs/shapes/rectangle.json @@ -8,6 +8,7 @@ "properties": { "cornerRadius": { "type": "double", + "initialValue": "0", "key": { "int": 31, "string": "cornerRadius" diff --git a/dev/update_defs.sh b/dev/update_defs.sh new file mode 100755 index 00000000..e8d86c35 --- /dev/null +++ b/dev/update_defs.sh @@ -0,0 +1,14 @@ +#!/bin/bash +rm -fR .clone_defs 2> /dev/null +mkdir .clone_defs +cd .clone_defs +git init +git remote add origin -f git@github.com:rive-app/rive.git +git config core.sparseCheckout true +echo '/dev/defs/*' > .git/info/sparse-checkout +git pull origin master + +rm -fR ../defs +mv dev/defs ../ +cd .. +rm -fR .clone_defs \ No newline at end of file diff --git a/rive/include/core/binary_reader.hpp b/rive/include/core/binary_reader.hpp index 74475770..cdb3853d 100644 --- a/rive/include/core/binary_reader.hpp +++ b/rive/include/core/binary_reader.hpp @@ -24,10 +24,11 @@ namespace rive uint64_t readVarUint(); int64_t readVarInt(); - std::string readString(bool explicitLength = false); + std::string readString(); double readFloat64(); float readFloat32(); uint8_t readByte(); + uint32_t readUint(); BinaryReader read(size_t length); }; } // namespace rive diff --git a/rive/include/core/field_types/core_uint_type.hpp b/rive/include/core/field_types/core_uint_type.hpp new file mode 100644 index 00000000..ba03614b --- /dev/null +++ b/rive/include/core/field_types/core_uint_type.hpp @@ -0,0 +1,13 @@ +#ifndef _RIVE_CORE_UINT_TYPE_HPP_ +#define _RIVE_CORE_UINT_TYPE_HPP_ + +namespace rive +{ + class BinaryReader; + class CoreUintType + { + public: + static unsigned int deserialize(BinaryReader& reader); + }; +} // namespace rive +#endif \ No newline at end of file diff --git a/rive/include/core/reader.h b/rive/include/core/reader.h index 6dc4e4ad..bdf375a6 100644 --- a/rive/include/core/reader.h +++ b/rive/include/core/reader.h @@ -1,11 +1,23 @@ #include #include +static bool is_big_endian(void) +{ + union + { + uint32_t i; + char c[4]; + } bint = {0x01020304}; + + return bint.c[0] == 1; +} + /* Decode an unsigned int LEB128 at buf into r, returning the nr of bytes read. */ -inline size_t decode_uint_leb(const uint8_t *buf, const uint8_t *buf_end, uint64_t *r) +inline size_t +decode_uint_leb(const uint8_t* buf, const uint8_t* buf_end, uint64_t* r) { - const uint8_t *p = buf; + const uint8_t* p = buf; uint8_t shift = 0; uint64_t result = 0; uint8_t byte; @@ -13,7 +25,9 @@ inline size_t decode_uint_leb(const uint8_t *buf, const uint8_t *buf_end, uint64 do { if (p >= buf_end) + { return 0; + } byte = *p++; result |= ((uint64_t)(byte & 0x7f)) << shift; shift += 7; @@ -24,9 +38,10 @@ inline size_t decode_uint_leb(const uint8_t *buf, const uint8_t *buf_end, uint64 /* Decode a signed int LEB128 at buf into r, returning the nr of bytes read. */ -inline size_t decode_int_leb(const uint8_t *buf, const uint8_t *buf_end, int64_t *r) +inline size_t +decode_int_leb(const uint8_t* buf, const uint8_t* buf_end, int64_t* r) { - const uint8_t *p = buf; + const uint8_t* p = buf; uint8_t shift = 0; int64_t result = 0; uint8_t byte; @@ -34,7 +49,9 @@ inline size_t decode_int_leb(const uint8_t *buf, const uint8_t *buf_end, int64_t do { if (p >= buf_end) + { return 0; + } byte = *p++; result |= ((uint64_t)(byte & 0x7f)) << shift; @@ -49,12 +66,17 @@ inline size_t decode_int_leb(const uint8_t *buf, const uint8_t *buf_end, int64_t /* Decodes a string */ -inline size_t decode_string(uint8_t str_len, const uint8_t *buf, const uint8_t *buf_end, char *char_buf) +inline size_t decode_string(uint8_t str_len, + const uint8_t* buf, + const uint8_t* buf_end, + char* char_buf) { // Return zero bytes read on buffer overflow if (buf_end - buf < str_len) + { return 0; - const uint8_t *p = buf; + } + const uint8_t* p = buf; for (int i = 0; i < str_len; i++) { char_buf[i] = *p++; @@ -66,33 +88,86 @@ inline size_t decode_string(uint8_t str_len, const uint8_t *buf, const uint8_t * /* Decodes a double (8 bytes) */ -inline size_t decode_double(const uint8_t *buf, const uint8_t *buf_end, double *r) +inline size_t +decode_double(const uint8_t* buf, const uint8_t* buf_end, double* r) { // Return zero bytes read on buffer overflow if (buf_end - buf < sizeof(double)) + { return 0; - memcpy(r, buf, sizeof(double)); + } + if (is_big_endian()) + { + uint8_t inverted[8] = {buf[7], + buf[6], + buf[5], + buf[4], + buf[3], + buf[2], + buf[1], + buf[0]}; + memcpy(r, inverted, sizeof(double)); + } + else + { + memcpy(r, buf, sizeof(double)); + } return sizeof(double); } /* Decodes a float (4 bytes) */ -inline size_t decode_float(const uint8_t *buf, const uint8_t *buf_end, float *r) +inline size_t decode_float(const uint8_t* buf, const uint8_t* buf_end, float* r) { // Return zero bytes read on buffer overflow if (buf_end - buf < sizeof(float)) + { return 0; - memcpy(r, buf, sizeof(float)); + } + if (is_big_endian()) + { + uint8_t inverted[4] = {buf[3], buf[2], buf[1], buf[0]}; + memcpy(r, inverted, sizeof(float)); + } + else + { + memcpy(r, buf, sizeof(float)); + } return sizeof(float); } /* Decodes a single byte */ -inline size_t decode_uint_8(const uint8_t *buf, const uint8_t *buf_end, uint8_t *r) +inline size_t +decode_uint_8(const uint8_t* buf, const uint8_t* buf_end, uint8_t* r) { // Return zero bytes read on buffer overflow if (buf_end - buf < sizeof(uint8_t)) + { return 0; + } memcpy(r, buf, sizeof(uint8_t)); return sizeof(uint8_t); +} + +/* Decodes a 32 bit unsigned integer. + */ +inline size_t +decode_uint_32(const uint8_t* buf, const uint8_t* buf_end, uint32_t* r) +{ + // Return zero bytes read on buffer overflow + if (buf_end - buf < sizeof(uint32_t)) + { + return 0; + } + if (is_big_endian()) + { + uint8_t inverted[4] = {buf[3], buf[2], buf[1], buf[0]}; + memcpy(r, inverted, sizeof(uint32_t)); + } + else + { + memcpy(r, buf, sizeof(uint32_t)); + } + return sizeof(uint32_t); } \ No newline at end of file diff --git a/rive/include/file.hpp b/rive/include/file.hpp index 520d7cbe..d6952b12 100644 --- a/rive/include/file.hpp +++ b/rive/include/file.hpp @@ -32,7 +32,7 @@ namespace rive { public: /// Major version number supported by the runtime. - static const int majorVersion = 2; + static const int majorVersion = 3; /// Minor version number supported by the runtime. static const int minorVersion = 0; @@ -47,7 +47,7 @@ namespace rive public: ~File(); - + /// /// Imports a Rive file from a binary buffer. /// @param reader a pointer to a binary reader attached to the file. diff --git a/rive/include/generated/animation/animation_base.hpp b/rive/include/generated/animation/animation_base.hpp index 31313cdf..32850bd5 100644 --- a/rive/include/generated/animation/animation_base.hpp +++ b/rive/include/generated/animation/animation_base.hpp @@ -13,9 +13,8 @@ namespace rive public: static const int typeKey = 27; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/animation/cubic_interpolator_base.hpp b/rive/include/generated/animation/cubic_interpolator_base.hpp index e2fb1345..e0ce3eb6 100644 --- a/rive/include/generated/animation/cubic_interpolator_base.hpp +++ b/rive/include/generated/animation/cubic_interpolator_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 28; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/animation/keyed_object_base.hpp b/rive/include/generated/animation/keyed_object_base.hpp index 9c4ab30b..b6143f06 100644 --- a/rive/include/generated/animation/keyed_object_base.hpp +++ b/rive/include/generated/animation/keyed_object_base.hpp @@ -1,7 +1,7 @@ #ifndef _RIVE_KEYED_OBJECT_BASE_HPP_ #define _RIVE_KEYED_OBJECT_BASE_HPP_ #include "core.hpp" -#include "core/field_types/core_int_type.hpp" +#include "core/field_types/core_uint_type.hpp" namespace rive { class KeyedObjectBase : public Core @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 25; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) @@ -49,7 +48,7 @@ namespace rive switch (propertyKey) { case objectIdPropertyKey: - m_ObjectId = CoreIntType::deserialize(reader); + m_ObjectId = CoreUintType::deserialize(reader); return true; } return false; diff --git a/rive/include/generated/animation/keyed_property_base.hpp b/rive/include/generated/animation/keyed_property_base.hpp index 1778e338..076c38c2 100644 --- a/rive/include/generated/animation/keyed_property_base.hpp +++ b/rive/include/generated/animation/keyed_property_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 26; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/animation/keyframe_base.hpp b/rive/include/generated/animation/keyframe_base.hpp index d9c537be..25359348 100644 --- a/rive/include/generated/animation/keyframe_base.hpp +++ b/rive/include/generated/animation/keyframe_base.hpp @@ -2,6 +2,7 @@ #define _RIVE_KEY_FRAME_BASE_HPP_ #include "core.hpp" #include "core/field_types/core_int_type.hpp" +#include "core/field_types/core_uint_type.hpp" namespace rive { class KeyFrameBase : public Core @@ -12,9 +13,8 @@ namespace rive public: static const int typeKey = 29; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) @@ -81,7 +81,7 @@ namespace rive m_InterpolationType = CoreIntType::deserialize(reader); return true; case interpolatorIdPropertyKey: - m_InterpolatorId = CoreIntType::deserialize(reader); + m_InterpolatorId = CoreUintType::deserialize(reader); return true; } return false; diff --git a/rive/include/generated/animation/keyframe_color_base.hpp b/rive/include/generated/animation/keyframe_color_base.hpp index e1ac419e..afed3475 100644 --- a/rive/include/generated/animation/keyframe_color_base.hpp +++ b/rive/include/generated/animation/keyframe_color_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 37; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/animation/keyframe_double_base.hpp b/rive/include/generated/animation/keyframe_double_base.hpp index 5c138f64..d8e7cfe6 100644 --- a/rive/include/generated/animation/keyframe_double_base.hpp +++ b/rive/include/generated/animation/keyframe_double_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 30; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/animation/keyframe_draw_order_base.hpp b/rive/include/generated/animation/keyframe_draw_order_base.hpp index e897a2ac..10bffbdf 100644 --- a/rive/include/generated/animation/keyframe_draw_order_base.hpp +++ b/rive/include/generated/animation/keyframe_draw_order_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 32; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/animation/keyframe_draw_order_value_base.hpp b/rive/include/generated/animation/keyframe_draw_order_value_base.hpp index 20084b08..0dcf036c 100644 --- a/rive/include/generated/animation/keyframe_draw_order_value_base.hpp +++ b/rive/include/generated/animation/keyframe_draw_order_value_base.hpp @@ -1,7 +1,7 @@ #ifndef _RIVE_KEY_FRAME_DRAW_ORDER_VALUE_BASE_HPP_ #define _RIVE_KEY_FRAME_DRAW_ORDER_VALUE_BASE_HPP_ #include "core.hpp" -#include "core/field_types/core_int_type.hpp" +#include "core/field_types/core_uint_type.hpp" namespace rive { class KeyFrameDrawOrderValueBase : public Core @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 33; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) @@ -62,10 +61,10 @@ namespace rive switch (propertyKey) { case drawableIdPropertyKey: - m_DrawableId = CoreIntType::deserialize(reader); + m_DrawableId = CoreUintType::deserialize(reader); return true; case valuePropertyKey: - m_Value = CoreIntType::deserialize(reader); + m_Value = CoreUintType::deserialize(reader); return true; } return false; diff --git a/rive/include/generated/animation/linear_animation_base.hpp b/rive/include/generated/animation/linear_animation_base.hpp index 4bee6d22..bc0bdbbc 100644 --- a/rive/include/generated/animation/linear_animation_base.hpp +++ b/rive/include/generated/animation/linear_animation_base.hpp @@ -14,9 +14,8 @@ namespace rive public: static const int typeKey = 31; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/artboard_base.hpp b/rive/include/generated/artboard_base.hpp index 88658971..0e014158 100644 --- a/rive/include/generated/artboard_base.hpp +++ b/rive/include/generated/artboard_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 1; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/backboard_base.hpp b/rive/include/generated/backboard_base.hpp index 96c71d40..8e83e534 100644 --- a/rive/include/generated/backboard_base.hpp +++ b/rive/include/generated/backboard_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 23; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/component_base.hpp b/rive/include/generated/component_base.hpp index be53af6f..d64eff66 100644 --- a/rive/include/generated/component_base.hpp +++ b/rive/include/generated/component_base.hpp @@ -1,8 +1,8 @@ #ifndef _RIVE_COMPONENT_BASE_HPP_ #define _RIVE_COMPONENT_BASE_HPP_ #include "core.hpp" -#include "core/field_types/core_int_type.hpp" #include "core/field_types/core_string_type.hpp" +#include "core/field_types/core_uint_type.hpp" #include namespace rive { @@ -14,9 +14,8 @@ namespace rive public: static const int typeKey = 10; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) @@ -67,7 +66,7 @@ namespace rive m_Name = CoreStringType::deserialize(reader); return true; case parentIdPropertyKey: - m_ParentId = CoreIntType::deserialize(reader); + m_ParentId = CoreUintType::deserialize(reader); return true; } return false; diff --git a/rive/include/generated/container_component_base.hpp b/rive/include/generated/container_component_base.hpp index f0d262e8..9087500d 100644 --- a/rive/include/generated/container_component_base.hpp +++ b/rive/include/generated/container_component_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 11; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/core_registry.hpp b/rive/include/generated/core_registry.hpp index 62c190f1..438250a9 100644 --- a/rive/include/generated/core_registry.hpp +++ b/rive/include/generated/core_registry.hpp @@ -105,13 +105,34 @@ namespace rive } return nullptr; } - static void setInt(Core* object, int propertyKey, int value) + static void setUint(Core* object, int propertyKey, int value) { switch (propertyKey) { case KeyedObjectBase::objectIdPropertyKey: object->as()->objectId(value); break; + case KeyFrameBase::interpolatorIdPropertyKey: + object->as()->interpolatorId(value); + break; + case KeyFrameDrawOrderValueBase::drawableIdPropertyKey: + object->as()->drawableId(value); + break; + case KeyFrameDrawOrderValueBase::valuePropertyKey: + object->as()->value(value); + break; + case ComponentBase::parentIdPropertyKey: + object->as()->parentId(value); + break; + case DrawableBase::drawOrderPropertyKey: + object->as()->drawOrder(value); + break; + } + } + static void setInt(Core* object, int propertyKey, int value) + { + switch (propertyKey) + { case KeyedPropertyBase::propertyKeyPropertyKey: object->as()->propertyKey(value); break; @@ -121,9 +142,6 @@ namespace rive case KeyFrameBase::interpolationTypePropertyKey: object->as()->interpolationType(value); break; - case KeyFrameBase::interpolatorIdPropertyKey: - object->as()->interpolatorId(value); - break; case LinearAnimationBase::fpsPropertyKey: object->as()->fps(value); break; @@ -139,15 +157,6 @@ namespace rive case LinearAnimationBase::workEndPropertyKey: object->as()->workEnd(value); break; - case KeyFrameDrawOrderValueBase::drawableIdPropertyKey: - object->as()->drawableId(value); - break; - case KeyFrameDrawOrderValueBase::valuePropertyKey: - object->as()->value(value); - break; - case ComponentBase::parentIdPropertyKey: - object->as()->parentId(value); - break; case StrokeBase::capPropertyKey: object->as()->cap(value); break; @@ -157,11 +166,8 @@ namespace rive case FillBase::fillRulePropertyKey: object->as()->fillRule(value); break; - case DrawableBase::drawOrderPropertyKey: - object->as()->drawOrder(value); - break; - case DrawableBase::blendModePropertyKey: - object->as()->blendMode(value); + case DrawableBase::blendModeValuePropertyKey: + object->as()->blendModeValue(value); break; } } @@ -336,20 +342,36 @@ namespace rive break; } } - static int getInt(Core* object, int propertyKey) + static int getUint(Core* object, int propertyKey) { switch (propertyKey) { case KeyedObjectBase::objectIdPropertyKey: return object->as()->objectId(); + case KeyFrameBase::interpolatorIdPropertyKey: + return object->as()->interpolatorId(); + case KeyFrameDrawOrderValueBase::drawableIdPropertyKey: + return object->as() + ->drawableId(); + case KeyFrameDrawOrderValueBase::valuePropertyKey: + return object->as()->value(); + case ComponentBase::parentIdPropertyKey: + return object->as()->parentId(); + case DrawableBase::drawOrderPropertyKey: + return object->as()->drawOrder(); + } + return 0; + } + static int getInt(Core* object, int propertyKey) + { + switch (propertyKey) + { case KeyedPropertyBase::propertyKeyPropertyKey: return object->as()->propertyKey(); case KeyFrameBase::framePropertyKey: return object->as()->frame(); case KeyFrameBase::interpolationTypePropertyKey: return object->as()->interpolationType(); - case KeyFrameBase::interpolatorIdPropertyKey: - return object->as()->interpolatorId(); case LinearAnimationBase::fpsPropertyKey: return object->as()->fps(); case LinearAnimationBase::durationPropertyKey: @@ -360,23 +382,14 @@ namespace rive return object->as()->workStart(); case LinearAnimationBase::workEndPropertyKey: return object->as()->workEnd(); - case KeyFrameDrawOrderValueBase::drawableIdPropertyKey: - return object->as() - ->drawableId(); - case KeyFrameDrawOrderValueBase::valuePropertyKey: - return object->as()->value(); - case ComponentBase::parentIdPropertyKey: - return object->as()->parentId(); case StrokeBase::capPropertyKey: return object->as()->cap(); case StrokeBase::joinPropertyKey: return object->as()->join(); case FillBase::fillRulePropertyKey: return object->as()->fillRule(); - case DrawableBase::drawOrderPropertyKey: - return object->as()->drawOrder(); - case DrawableBase::blendModePropertyKey: - return object->as()->blendMode(); + case DrawableBase::blendModeValuePropertyKey: + return object->as()->blendModeValue(); } return 0; } diff --git a/rive/include/generated/drawable_base.hpp b/rive/include/generated/drawable_base.hpp index 4086f8f6..6034cb67 100644 --- a/rive/include/generated/drawable_base.hpp +++ b/rive/include/generated/drawable_base.hpp @@ -1,6 +1,7 @@ #ifndef _RIVE_DRAWABLE_BASE_HPP_ #define _RIVE_DRAWABLE_BASE_HPP_ #include "core/field_types/core_int_type.hpp" +#include "core/field_types/core_uint_type.hpp" #include "node.hpp" namespace rive { @@ -12,9 +13,8 @@ namespace rive public: static const int typeKey = 13; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) @@ -32,11 +32,11 @@ namespace rive int coreType() const override { return typeKey; } static const int drawOrderPropertyKey = 22; - static const int blendModePropertyKey = 23; + static const int blendModeValuePropertyKey = 23; private: int m_DrawOrder = 0; - int m_BlendMode = 0; + int m_BlendModeValue = 3; public: inline int drawOrder() const { return m_DrawOrder; } void drawOrder(int value) @@ -49,15 +49,15 @@ namespace rive drawOrderChanged(); } - inline int blendMode() const { return m_BlendMode; } - void blendMode(int value) + inline int blendModeValue() const { return m_BlendModeValue; } + void blendModeValue(int value) { - if (m_BlendMode == value) + if (m_BlendModeValue == value) { return; } - m_BlendMode = value; - blendModeChanged(); + m_BlendModeValue = value; + blendModeValueChanged(); } bool deserialize(int propertyKey, BinaryReader& reader) override @@ -65,10 +65,10 @@ namespace rive switch (propertyKey) { case drawOrderPropertyKey: - m_DrawOrder = CoreIntType::deserialize(reader); + m_DrawOrder = CoreUintType::deserialize(reader); return true; - case blendModePropertyKey: - m_BlendMode = CoreIntType::deserialize(reader); + case blendModeValuePropertyKey: + m_BlendModeValue = CoreIntType::deserialize(reader); return true; } return Node::deserialize(propertyKey, reader); @@ -76,7 +76,7 @@ namespace rive protected: virtual void drawOrderChanged() {} - virtual void blendModeChanged() {} + virtual void blendModeValueChanged() {} }; } // namespace rive diff --git a/rive/include/generated/node_base.hpp b/rive/include/generated/node_base.hpp index 6d7dba1c..038bb3e5 100644 --- a/rive/include/generated/node_base.hpp +++ b/rive/include/generated/node_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 2; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/cubic_asymmetric_vertex_base.hpp b/rive/include/generated/shapes/cubic_asymmetric_vertex_base.hpp index e42b83d4..cefcac53 100644 --- a/rive/include/generated/shapes/cubic_asymmetric_vertex_base.hpp +++ b/rive/include/generated/shapes/cubic_asymmetric_vertex_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 34; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/cubic_detached_vertex_base.hpp b/rive/include/generated/shapes/cubic_detached_vertex_base.hpp index 00d855b0..fc130592 100644 --- a/rive/include/generated/shapes/cubic_detached_vertex_base.hpp +++ b/rive/include/generated/shapes/cubic_detached_vertex_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 6; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/cubic_mirrored_vertex_base.hpp b/rive/include/generated/shapes/cubic_mirrored_vertex_base.hpp index 79ec5efa..495e5331 100644 --- a/rive/include/generated/shapes/cubic_mirrored_vertex_base.hpp +++ b/rive/include/generated/shapes/cubic_mirrored_vertex_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 35; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/cubic_vertex_base.hpp b/rive/include/generated/shapes/cubic_vertex_base.hpp index 8ff56b83..195b695a 100644 --- a/rive/include/generated/shapes/cubic_vertex_base.hpp +++ b/rive/include/generated/shapes/cubic_vertex_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 36; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/ellipse_base.hpp b/rive/include/generated/shapes/ellipse_base.hpp index 5b33e286..1d826c8e 100644 --- a/rive/include/generated/shapes/ellipse_base.hpp +++ b/rive/include/generated/shapes/ellipse_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 4; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/paint/fill_base.hpp b/rive/include/generated/shapes/paint/fill_base.hpp index 860891e9..48a176a3 100644 --- a/rive/include/generated/shapes/paint/fill_base.hpp +++ b/rive/include/generated/shapes/paint/fill_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 20; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/paint/gradient_stop_base.hpp b/rive/include/generated/shapes/paint/gradient_stop_base.hpp index 2872e21e..baeb2041 100644 --- a/rive/include/generated/shapes/paint/gradient_stop_base.hpp +++ b/rive/include/generated/shapes/paint/gradient_stop_base.hpp @@ -13,9 +13,8 @@ namespace rive public: static const int typeKey = 19; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/paint/linear_gradient_base.hpp b/rive/include/generated/shapes/paint/linear_gradient_base.hpp index beac333c..c217207b 100644 --- a/rive/include/generated/shapes/paint/linear_gradient_base.hpp +++ b/rive/include/generated/shapes/paint/linear_gradient_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 22; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/paint/radial_gradient_base.hpp b/rive/include/generated/shapes/paint/radial_gradient_base.hpp index 93721b77..620f2d0b 100644 --- a/rive/include/generated/shapes/paint/radial_gradient_base.hpp +++ b/rive/include/generated/shapes/paint/radial_gradient_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 17; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/paint/shape_paint_base.hpp b/rive/include/generated/shapes/paint/shape_paint_base.hpp index 6f919325..5b491bad 100644 --- a/rive/include/generated/shapes/paint/shape_paint_base.hpp +++ b/rive/include/generated/shapes/paint/shape_paint_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 21; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/paint/solid_color_base.hpp b/rive/include/generated/shapes/paint/solid_color_base.hpp index 695a1f2b..23410677 100644 --- a/rive/include/generated/shapes/paint/solid_color_base.hpp +++ b/rive/include/generated/shapes/paint/solid_color_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 18; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/paint/stroke_base.hpp b/rive/include/generated/shapes/paint/stroke_base.hpp index 5c8df92a..5ebea1bb 100644 --- a/rive/include/generated/shapes/paint/stroke_base.hpp +++ b/rive/include/generated/shapes/paint/stroke_base.hpp @@ -14,9 +14,8 @@ namespace rive public: static const int typeKey = 24; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/parametric_path_base.hpp b/rive/include/generated/shapes/parametric_path_base.hpp index 35984e23..db5a1675 100644 --- a/rive/include/generated/shapes/parametric_path_base.hpp +++ b/rive/include/generated/shapes/parametric_path_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 15; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/path_base.hpp b/rive/include/generated/shapes/path_base.hpp index 42d23f45..4f26cd2d 100644 --- a/rive/include/generated/shapes/path_base.hpp +++ b/rive/include/generated/shapes/path_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 12; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/path_composer_base.hpp b/rive/include/generated/shapes/path_composer_base.hpp index 083c5edd..cf56b7a9 100644 --- a/rive/include/generated/shapes/path_composer_base.hpp +++ b/rive/include/generated/shapes/path_composer_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 9; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/path_vertex_base.hpp b/rive/include/generated/shapes/path_vertex_base.hpp index 38a2154b..3b025c41 100644 --- a/rive/include/generated/shapes/path_vertex_base.hpp +++ b/rive/include/generated/shapes/path_vertex_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 14; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/points_path_base.hpp b/rive/include/generated/shapes/points_path_base.hpp index f1a23371..d2cd329f 100644 --- a/rive/include/generated/shapes/points_path_base.hpp +++ b/rive/include/generated/shapes/points_path_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 16; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/rectangle_base.hpp b/rive/include/generated/shapes/rectangle_base.hpp index 2783ac0c..307d046c 100644 --- a/rive/include/generated/shapes/rectangle_base.hpp +++ b/rive/include/generated/shapes/rectangle_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 7; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) @@ -36,7 +35,7 @@ namespace rive static const int cornerRadiusPropertyKey = 31; private: - float m_CornerRadius = 0.0f; + float m_CornerRadius = 0; public: inline float cornerRadius() const { return m_CornerRadius; } void cornerRadius(float value) diff --git a/rive/include/generated/shapes/shape_base.hpp b/rive/include/generated/shapes/shape_base.hpp index 61503168..4b4c451e 100644 --- a/rive/include/generated/shapes/shape_base.hpp +++ b/rive/include/generated/shapes/shape_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 3; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/straight_vertex_base.hpp b/rive/include/generated/shapes/straight_vertex_base.hpp index f99fcd2e..c55f020a 100644 --- a/rive/include/generated/shapes/straight_vertex_base.hpp +++ b/rive/include/generated/shapes/straight_vertex_base.hpp @@ -12,9 +12,8 @@ namespace rive public: static const int typeKey = 5; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/include/generated/shapes/triangle_base.hpp b/rive/include/generated/shapes/triangle_base.hpp index c5016ed8..898071a1 100644 --- a/rive/include/generated/shapes/triangle_base.hpp +++ b/rive/include/generated/shapes/triangle_base.hpp @@ -11,9 +11,8 @@ namespace rive public: static const int typeKey = 8; - // Helper to quickly determine if a core object extends another without - // RTTI - /// at runtime. + /// Helper to quickly determine if a core object extends another without + /// RTTI at runtime. bool isTypeOf(int typeKey) const override { switch (typeKey) diff --git a/rive/src/core/binary_reader.cpp b/rive/src/core/binary_reader.cpp index d3c53967..9d1e2c52 100644 --- a/rive/src/core/binary_reader.cpp +++ b/rive/src/core/binary_reader.cpp @@ -3,7 +3,11 @@ using namespace rive; -BinaryReader::BinaryReader(uint8_t* bytes, size_t length) : m_Position(bytes), m_End(bytes + length), m_Overflowed(false), m_Length(length) +BinaryReader::BinaryReader(uint8_t* bytes, size_t length) : + m_Position(bytes), + m_End(bytes + length), + m_Overflowed(false), + m_Length(length) { } @@ -43,9 +47,9 @@ int64_t BinaryReader::readVarInt() return value; } -std::string BinaryReader::readString(bool explicitLength) +std::string BinaryReader::readString() { - uint64_t length = explicitLength ? readVarUint() : m_End - m_Position; + uint64_t length = readVarUint(); if (didOverflow()) { return std::string(); @@ -98,14 +102,15 @@ uint8_t BinaryReader::readByte() return *m_Position++; } -BinaryReader BinaryReader::read(size_t length) +uint32_t BinaryReader::readUint() { - if (m_End - m_Position < length) + uint32_t value; + auto readBytes = decode_uint_32(m_Position, m_End, &value); + if (readBytes == 0) { overflow(); - return BinaryReader(m_Position, 0); + return 0; } - auto readerPosition = m_Position; - m_Position += length; - return BinaryReader(readerPosition, length); + m_Position += readBytes; + return value; } \ No newline at end of file diff --git a/rive/src/core/field_types/core_color_type.cpp b/rive/src/core/field_types/core_color_type.cpp index 86a2edc1..eb0b5b7a 100644 --- a/rive/src/core/field_types/core_color_type.cpp +++ b/rive/src/core/field_types/core_color_type.cpp @@ -5,5 +5,5 @@ using namespace rive; int CoreColorType::deserialize(BinaryReader& reader) { - return reader.readVarInt(); + return reader.readUint(); } \ No newline at end of file diff --git a/rive/src/core/field_types/core_double_type.cpp b/rive/src/core/field_types/core_double_type.cpp index 17b71a92..a645d8a5 100644 --- a/rive/src/core/field_types/core_double_type.cpp +++ b/rive/src/core/field_types/core_double_type.cpp @@ -5,5 +5,5 @@ using namespace rive; double CoreDoubleType::deserialize(BinaryReader& reader) { - return reader.lengthInBytes() == 4 ? reader.readFloat32() : reader.readFloat64(); + return reader.readFloat32(); } \ No newline at end of file diff --git a/rive/src/core/field_types/core_string_type.cpp b/rive/src/core/field_types/core_string_type.cpp index d4b8021b..37da03da 100644 --- a/rive/src/core/field_types/core_string_type.cpp +++ b/rive/src/core/field_types/core_string_type.cpp @@ -5,5 +5,5 @@ using namespace rive; std::string CoreStringType::deserialize(BinaryReader& reader) { - return reader.readString(false); + return reader.readString(); } \ No newline at end of file diff --git a/rive/src/core/field_types/core_uint_type.cpp b/rive/src/core/field_types/core_uint_type.cpp new file mode 100644 index 00000000..e9887ddb --- /dev/null +++ b/rive/src/core/field_types/core_uint_type.cpp @@ -0,0 +1,9 @@ +#include "core/field_types/core_uint_type.hpp" +#include "core/binary_reader.hpp" + +using namespace rive; + +unsigned int CoreUintType::deserialize(BinaryReader& reader) +{ + return reader.readVarUint(); +} \ No newline at end of file diff --git a/rive/src/file.cpp b/rive/src/file.cpp index 44270e56..3c50b260 100644 --- a/rive/src/file.cpp +++ b/rive/src/file.cpp @@ -12,6 +12,11 @@ template static T* readRuntimeObject(BinaryReader& reader) auto coreObjectKey = reader.readVarUint(); auto object = CoreRegistry::makeCoreInstance(coreObjectKey); + if (object == nullptr) + { + fprintf(stderr, "Unknown object of type %llu.\n", coreObjectKey); + return nullptr; + } while (true) { auto propertyKey = reader.readVarUint(); @@ -20,20 +25,18 @@ template static T* readRuntimeObject(BinaryReader& reader) // Terminator. https://media.giphy.com/media/7TtvTUMm9mp20/giphy.gif break; } - auto propertyLength = reader.readVarUint(); - auto valueReader = reader.read(propertyLength); - // We can get away with just checking once as our reader is safe to call - // again after overflowing. if (reader.didOverflow()) { delete object; return nullptr; } - if (object != nullptr) + if (!object->deserialize(propertyKey, reader)) { - object->deserialize(propertyKey, valueReader); + fprintf(stderr, "Unknown property of type %llu.\n", propertyKey); + delete object; + return nullptr; } } @@ -93,8 +96,8 @@ ImportResult File::import(BinaryReader& reader, File** importedFile) { fprintf(stderr, "Unsupported version %u expected %u.\n", - majorVersion, - header.majorVersion()); + header.majorVersion(), + majorVersion); return ImportResult::unsupportedVersion; } auto file = new File(); diff --git a/rive/test/file_test.cpp b/rive/test/file_test.cpp index 6e92cef5..f7cbdbf0 100644 --- a/rive/test/file_test.cpp +++ b/rive/test/file_test.cpp @@ -35,7 +35,7 @@ TEST_CASE("file can be read", "[file]") delete[] bytes; } -TEST_CASE("file with animation be read", "[file]") +TEST_CASE("file with animation can be read", "[file]") { FILE* fp = fopen("../../assets/juice.riv", "r"); REQUIRE(fp != nullptr); @@ -116,7 +116,7 @@ TEST_CASE("dependencies are as expected", "[file]") auto nodeB = artboard->find("B"); auto nodeC = artboard->find("C"); auto shape = artboard->find("Rectangle"); - auto path = artboard->find("Rectangle Path"); + auto path = artboard->find("Rectangle Path"); REQUIRE(nodeA != nullptr); REQUIRE(nodeB != nullptr); REQUIRE(nodeC != nullptr);