aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/bools.c2
-rw-r--r--stdlib/bools.h2
-rw-r--r--stdlib/integers.c6
-rw-r--r--stdlib/integers.h4
-rw-r--r--stdlib/nums.c4
-rw-r--r--stdlib/nums.h4
-rw-r--r--stdlib/stdlib.c14
7 files changed, 18 insertions, 18 deletions
diff --git a/stdlib/bools.c b/stdlib/bools.c
index bc1a6445..9a2c8cd6 100644
--- a/stdlib/bools.c
+++ b/stdlib/bools.c
@@ -22,7 +22,7 @@ PUREFUNC public Text_t Bool$as_text(const bool *b, bool colorize, const TypeInfo
return *b ? Text("yes") : Text("no");
}
-PUREFUNC public OptionalBool_t Bool$from_text(Text_t text)
+PUREFUNC public OptionalBool_t Bool$parse(Text_t text)
{
if (Text$equal_ignoring_case(text, Text("yes"))
|| Text$equal_ignoring_case(text, Text("on"))
diff --git a/stdlib/bools.h b/stdlib/bools.h
index fbc40f8b..7dec5711 100644
--- a/stdlib/bools.h
+++ b/stdlib/bools.h
@@ -14,7 +14,7 @@
#define no (Bool_t)false
PUREFUNC Text_t Bool$as_text(const bool *b, bool colorize, const TypeInfo_t *type);
-OptionalBool_t Bool$from_text(Text_t text);
+OptionalBool_t Bool$parse(Text_t text);
extern const TypeInfo_t Bool$info;
diff --git a/stdlib/integers.c b/stdlib/integers.c
index 9bde1890..d0cc6617 100644
--- a/stdlib/integers.c
+++ b/stdlib/integers.c
@@ -330,7 +330,7 @@ public Int_t Int$from_str(const char *str) {
return Int$from_mpz(i);
}
-public OptionalInt_t Int$from_text(Text_t text) {
+public OptionalInt_t Int$parse(Text_t text) {
return Int$from_str(Text$as_c_string(text));
}
@@ -411,8 +411,8 @@ public const TypeInfo_t Int$info = {
public to_attr Range_t KindOfInt ## $to(c_type from, c_type to) { \
return (Range_t){Int64_to_Int(from), Int64_to_Int(to), to >= from ? (Int_t){.small=(1<<2)&1} : (Int_t){.small=(1<<2)&1}}; \
} \
- public PUREFUNC Optional ## KindOfInt ## _t KindOfInt ## $from_text(Text_t text) { \
- OptionalInt_t full_int = Int$from_text(text); \
+ public PUREFUNC Optional ## KindOfInt ## _t KindOfInt ## $parse(Text_t text) { \
+ OptionalInt_t full_int = Int$parse(text); \
if (full_int.small == 0) return (Optional ## KindOfInt ## _t){.is_null=true}; \
if (Int$compare_value(full_int, I(min_val)) < 0) { \
return (Optional ## KindOfInt ## _t){.is_null=true}; \
diff --git a/stdlib/integers.h b/stdlib/integers.h
index b441e2be..430a3eac 100644
--- a/stdlib/integers.h
+++ b/stdlib/integers.h
@@ -35,7 +35,7 @@
Text_t type_name ## $octal(c_type i, Int_t digits, bool prefix); \
Array_t type_name ## $bits(c_type x); \
to_attr Range_t type_name ## $to(c_type from, c_type to); \
- PUREFUNC Optional ## type_name ## _t type_name ## $from_text(Text_t text); \
+ PUREFUNC Optional ## type_name ## _t type_name ## $parse(Text_t text); \
MACROLIKE PUREFUNC c_type type_name ## $clamped(c_type x, c_type min, c_type max) { \
return x < min ? min : (x > max ? max : x); \
} \
@@ -103,7 +103,7 @@ Text_t Int$hex(Int_t i, Int_t digits, bool uppercase, bool prefix);
Text_t Int$octal(Int_t i, Int_t digits, bool prefix);
PUREFUNC Range_t Int$to(Int_t from, Int_t to);
OptionalInt_t Int$from_str(const char *str);
-OptionalInt_t Int$from_text(Text_t text);
+OptionalInt_t Int$parse(Text_t text);
Int_t Int$abs(Int_t x);
Int_t Int$power(Int_t base, Int_t exponent);
Int_t Int$sqrt(Int_t i);
diff --git a/stdlib/nums.c b/stdlib/nums.c
index 30973fbc..8a210d7e 100644
--- a/stdlib/nums.c
+++ b/stdlib/nums.c
@@ -61,7 +61,7 @@ public CONSTFUNC double Num$mix(double amount, double x, double y) {
return (1.0-amount)*x + amount*y;
}
-public OptionalNum_t Num$from_text(Text_t text) {
+public OptionalNum_t Num$parse(Text_t text) {
const char *str = Text$as_c_string(text);
char *end = NULL;
double d = strtod(str, &end);
@@ -138,7 +138,7 @@ public CONSTFUNC float Num32$mix(float amount, float x, float y) {
return (1.0f-amount)*x + amount*y;
}
-public OptionalNum32_t Num32$from_text(Text_t text) {
+public OptionalNum32_t Num32$parse(Text_t text) {
const char *str = Text$as_c_string(text);
char *end = NULL;
double d = strtod(str, &end);
diff --git a/stdlib/nums.h b/stdlib/nums.h
index a07a2710..dc7f9ff8 100644
--- a/stdlib/nums.h
+++ b/stdlib/nums.h
@@ -28,7 +28,7 @@ CONSTFUNC bool Num$finite(double n);
CONSTFUNC bool Num$isnan(double n);
double Num$nan(Text_t tag);
CONSTFUNC double Num$mix(double amount, double x, double y);
-OptionalNum_t Num$from_text(Text_t text);
+OptionalNum_t Num$parse(Text_t text);
MACROLIKE CONSTFUNC double Num$clamped(double x, double low, double high) {
return (x <= low) ? low : (x >= high ? high : x);
}
@@ -45,7 +45,7 @@ CONSTFUNC bool Num32$isinf(float n);
CONSTFUNC bool Num32$finite(float n);
CONSTFUNC bool Num32$isnan(float n);
CONSTFUNC float Num32$mix(float amount, float x, float y);
-OptionalNum32_t Num32$from_text(Text_t text);
+OptionalNum32_t Num32$parse(Text_t text);
float Num32$nan(Text_t tag);
MACROLIKE CONSTFUNC float Num32$clamped(float x, float low, float high) {
return (x <= low) ? low : (x >= high ? high : x);
diff --git a/stdlib/stdlib.c b/stdlib/stdlib.c
index f2c6897c..eb285316 100644
--- a/stdlib/stdlib.c
+++ b/stdlib/stdlib.c
@@ -57,37 +57,37 @@ static bool parse_single_arg(const TypeInfo_t *info, char *arg, void *dest)
*(OptionalInt_t*)dest = parsed;
return parsed.small != 0;
} else if (info == &Int64$info) {
- OptionalInt64_t parsed = Int64$from_text(Text$from_str(arg));
+ OptionalInt64_t parsed = Int64$parse(Text$from_str(arg));
if (!parsed.is_null)
*(OptionalInt64_t*)dest = parsed;
return !parsed.is_null;
} else if (info == &Int32$info) {
- OptionalInt32_t parsed = Int32$from_text(Text$from_str(arg));
+ OptionalInt32_t parsed = Int32$parse(Text$from_str(arg));
if (!parsed.is_null)
*(OptionalInt32_t*)dest = parsed;
return !parsed.is_null;
} else if (info == &Int16$info) {
- OptionalInt16_t parsed = Int16$from_text(Text$from_str(arg));
+ OptionalInt16_t parsed = Int16$parse(Text$from_str(arg));
if (!parsed.is_null)
*(OptionalInt16_t*)dest = parsed;
return !parsed.is_null;
} else if (info == &Int8$info) {
- OptionalInt8_t parsed = Int8$from_text(Text$from_str(arg));
+ OptionalInt8_t parsed = Int8$parse(Text$from_str(arg));
if (!parsed.is_null)
*(OptionalInt8_t*)dest = parsed;
return !parsed.is_null;
} else if (info == &Bool$info) {
- OptionalBool_t parsed = Bool$from_text(Text$from_str(arg));
+ OptionalBool_t parsed = Bool$parse(Text$from_str(arg));
if (parsed != NULL_BOOL)
*(OptionalBool_t*)dest = parsed;
return parsed != NULL_BOOL;
} else if (info == &Num$info) {
- OptionalNum_t parsed = Num$from_text(Text$from_str(arg));
+ OptionalNum_t parsed = Num$parse(Text$from_str(arg));
if (!isnan(parsed))
*(OptionalNum_t*)dest = parsed;
return !isnan(parsed);
} else if (info == &Num32$info) {
- OptionalNum32_t parsed = Num32$from_text(Text$from_str(arg));
+ OptionalNum32_t parsed = Num32$parse(Text$from_str(arg));
if (!isnan(parsed))
*(OptionalNum32_t*)dest = parsed;
return !isnan(parsed);