Skip to content

Commit 0e6dbe4

Browse files
authored
Remove references of asBool (#2022)
1 parent 70e003b commit 0e6dbe4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

package/cpp/api/JsiSkParagraphStyle.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace RNSkia {
2424
namespace jsi = facebook::jsi;
2525

2626
namespace para = skia::textlayout;
27+
2728
/**
2829
Implementation of the ParagraphStyle object in JSI
2930
*/
@@ -60,7 +61,7 @@ class JsiSkParagraphStyle {
6061

6162
if (object.hasProperty(runtime, "disableHinting")) {
6263
auto propValue = object.getProperty(runtime, "disableHinting");
63-
if (propValue.asBool()) {
64+
if (asBool(runtime, propValue)) {
6465
retVal.turnHintingOff();
6566
}
6667
}
@@ -83,7 +84,7 @@ class JsiSkParagraphStyle {
8384
}
8485
if (object.hasProperty(runtime, "replaceTabCharacters")) {
8586
auto propValue = object.getProperty(runtime, "replaceTabCharacters");
86-
retVal.setReplaceTabCharacters(propValue.asBool());
87+
retVal.setReplaceTabCharacters(asBool(runtime, propValue));
8788
}
8889
if (object.hasProperty(runtime, "textAlign")) {
8990
auto propValue = object.getProperty(runtime, "textAlign");

package/cpp/api/JsiSkStrutStyle.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ namespace jsi = facebook::jsi;
2020

2121
namespace para = skia::textlayout;
2222

23+
bool asBool(jsi::Runtime &runtime, const jsi::Value &value) {
24+
if (!value.isBool()) {
25+
throw jsi::JSError(runtime, "Expected boolean value");
26+
}
27+
return value.getBool();
28+
}
29+
2330
/**
2431
Implementation of the TextStyle object in JSI for the paragraph builder
2532
*/
@@ -47,7 +54,7 @@ class JsiSkStrutStyle {
4754

4855
if (object.hasProperty(runtime, "strutEnabled")) {
4956
auto propValue = object.getProperty(runtime, "strutEnabled");
50-
retVal.setStrutEnabled(propValue.asBool());
57+
retVal.setStrutEnabled(asBool(runtime, propValue));
5158
}
5259
if (object.hasProperty(runtime, "fontFamilies")) {
5360
auto propValue = object.getProperty(runtime, "fontFamilies")
@@ -78,15 +85,15 @@ class JsiSkStrutStyle {
7885
}
7986
if (object.hasProperty(runtime, "halfLeading")) {
8087
auto propValue = object.getProperty(runtime, "halfLeading");
81-
retVal.setHalfLeading(propValue.asBool());
88+
retVal.setHalfLeading(asBool(runtime, propValue));
8289
}
8390
if (object.hasProperty(runtime, "leading")) {
8491
auto propValue = object.getProperty(runtime, "leading");
8592
retVal.setLeading(propValue.asNumber());
8693
}
8794
if (object.hasProperty(runtime, "forceStrutHeight")) {
8895
auto propValue = object.getProperty(runtime, "forceStrutHeight");
89-
retVal.setForceStrutHeight(propValue.asBool());
96+
retVal.setForceStrutHeight(asBool(runtime, propValue));
9097
}
9198

9299
return retVal;

0 commit comments

Comments
 (0)