Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* core: object inspection methods may use byte strings within, but u…

…ltimately return UTF-8 strings.
  • Loading branch information...
commit 040383626d7910ec421902dd8f63c257228771f8 1 parent 2d18fee
_why authored
View
5 core/compile.c
@@ -125,7 +125,7 @@ PN potion_proto_string(Potion *P, PN cl, PN self) {
num++;
}
pn_printf(P, out, "; function end\n");
- return out;
+ return PN_STR_B(out);
}
#define PN_REG(f, reg) \
@@ -831,8 +831,7 @@ PN potion_run(Potion *P, PN code) {
#endif
}
-PN potion_eval(Potion *P, const char *str) {
- PN bytes = potion_byte_str(P, str);
+PN potion_eval(Potion *P, PN bytes) {
PN code = potion_parse(P, bytes);
if (PN_TYPE(code) != PN_TSOURCE) return code;
code = potion_send(code, PN_compile, PN_NIL, PN_NIL);
View
2  core/lick.c
@@ -48,7 +48,7 @@ PN potion_lick_string(Potion *P, PN cl, PN self) {
pn_printf(P, out, " ");
potion_bytes_obj_string(P, out, ((struct PNLick *)self)->attr);
}
- return out;
+ return PN_STR_B(out);
}
void potion_lick_init(Potion *P) {
View
8 core/objmodel.c
@@ -34,7 +34,7 @@ PN potion_closure_code(Potion *P, PN cl, PN self) {
PN potion_closure_string(Potion *P, PN cl, PN self, PN len) {
int x = 0;
- PN out = potion_byte_str(P, "Function(");
+ PN out = potion_byte_str(P, "function(");
if (PN_IS_TUPLE(PN_CLOSURE(self)->sig)) {
PN_TUPLE_EACH(PN_CLOSURE(self)->sig, i, v, {
if (PN_IS_STR(v)) {
@@ -44,7 +44,7 @@ PN potion_closure_string(Potion *P, PN cl, PN self, PN len) {
});
}
pn_printf(P, out, ")");
- return out;
+ return PN_STR_B(out);
}
PN potion_type_new(Potion *P, PNType t, PN self) {
@@ -268,11 +268,11 @@ PN potion_ref(Potion *P, PN data) {
}
PN potion_ref_string(Potion *P, PN cl, PN self, PN len) {
- return potion_byte_str(P, "#<ref>");
+ return potion_str(P, "<ref>");
}
PN potion_object_string(Potion *P, PN cl, PN self, PN len) {
- return potion_byte_str(P, "#<object>");
+ return potion_str(P, "<object>");
}
PN potion_object_forward(Potion *P, PN cl, PN self, PN method) {
View
2  core/pn-ast.c
@@ -54,7 +54,7 @@ PN potion_source_string(Potion *P, PN cl, PN self) {
potion_bytes_obj_string(P, out, t->a[i]);
if (i == n - 1 && n > 1) pn_printf(P, out, ")");
}
- return out;
+ return PN_STR_B(out);
}
void potion_source_init(Potion *P) {
View
4 core/potion.c
@@ -233,7 +233,7 @@ int main(int argc, char *argv[]) {
}
Potion *P = potion_create(sp);
- potion_eval(P,
+ potion_eval(P, potion_byte_str(P,
"loop:\n" \
" '>> ' print\n" \
" code = read\n" \
@@ -243,7 +243,7 @@ int main(int argc, char *argv[]) {
" if (obj kind == Error):\n" \
" obj string print." \
" else: ('=> ', obj, \"\\n\") join print.\n" \
- "_ loop");
+ "_ loop"));
potion_destroy(P);
return 0;
}
View
2  core/potion.h
@@ -618,7 +618,7 @@ PN potion_parse(Potion *, PN);
PN potion_vm_proto(Potion *, PN, PN, ...);
PN potion_vm_class(Potion *, PN, PN);
PN potion_vm(Potion *, PN, PN, PN, PN_SIZE, PN * volatile);
-PN potion_eval(Potion *, const char *);
+PN potion_eval(Potion *, PN);
PN potion_run(Potion *, PN);
PN_F potion_jit_proto(Potion *, PN, PN);
View
2  core/string.c
@@ -78,7 +78,7 @@ static PN potion_str_length(Potion *P, PN closure, PN self) {
}
static PN potion_str_eval(Potion *P, PN closure, PN self) {
- return potion_eval(P, PN_STR_PTR(self));
+ return potion_eval(P, self);
}
static PN potion_str_number(Potion *P, PN closure, PN self) {
View
4 core/table.c
@@ -23,7 +23,7 @@ PN potion_table_string(Potion *P, PN cl, PN self) {
potion_bytes_obj_string(P, out, kh_val(PN, t, k));
}
pn_printf(P, out, ")");
- return out;
+ return PN_STR_B(out);
}
PN potion_table_empty(Potion *P) {
@@ -193,7 +193,7 @@ PN potion_tuple_string(Potion *P, PN cl, PN self) {
licks = (licks > 0 && licks == PN_TUPLE_LEN(self));
if (licks) PN_STR_PTR(out)[0] = '[';
pn_printf(P, out, licks ? "]" : ")");
- return out;
+ return PN_STR_B(out);
}
PN potion_tuple_pop(Potion *P, PN cl, PN self, PN key) {
View
2  test/api/potion-test.c
@@ -96,7 +96,7 @@ void potion_test_sig(CuTest *T) {
}
void potion_test_eval(CuTest *T) {
- PN add = potion_eval(P, "(x, y): x + y.");
+ PN add = potion_eval(P, potion_str(P, "(x, y): x + y."));
PN_F addfn = PN_CLOSURE_F(add);
PN num = addfn(P, 0, 0, PN_NUM(3), PN_NUM(5));
CuAssertIntEquals(T, "calling closure as c func failed",
View
2  test/closures/endings.pn
@@ -7,4 +7,4 @@ func2 = (x, y):
_ func2
(func, func2)
-# (Function(x, y), Function(x, y))
+# (function(x, y), function(x, y))
View
2  test/closures/inspect.pn
@@ -1,2 +1,2 @@
(x, y): x + y.
-# Function(x, y)
+# function(x, y)
View
2  test/closures/upvals.pn
@@ -24,4 +24,4 @@ z = ():
z4.
(cl (), cl2 (), cl3 (), cl4 (12), o, z1, z2, z3, z())
-# (Function(), 17, 45, 67, 23, true, 16, (nil, nil), (b=2))
+# (function(), 17, 45, 67, 23, true, 16, (nil, nil), (b=2))
Please sign in to comment.
Something went wrong with that request. Please try again.