Skip to content

Commit

Permalink
Add message bytes to string.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Aug 6, 2024
1 parent 5bee774 commit 172538c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,18 @@ ctr_object* ctr_string_length(ctr_object* myself, ctr_argument* argumentList) {
return ctr_build_number_from_float((ctr_number) n);
}

/**
* @def
* [ String ] bytes
*
* @example
* ☞ x ≔ ‘☘☘☘’.
* ✎ write: x bytes, stop.
*/
ctr_object* ctr_string_bytes(ctr_object* myself, ctr_argument* argumentList) {
return ctr_build_number_from_float(myself->value.svalue->vlen);
}

/**
* @def
* [ String ] + [ String ]
Expand Down
2 changes: 2 additions & 0 deletions citrine.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ extern ctr_object* ctr_string_fill_in(ctr_object* myself, ctr_argument* argument
extern ctr_object* ctr_string_copy(ctr_object* myself, ctr_argument* argumentList);
extern ctr_object* ctr_string_to_code(ctr_object* myself, ctr_argument* ctr_argumentList);
extern ctr_object* ctr_string_minus(ctr_object* myself, ctr_argument* ctr_argumentList);
extern ctr_object* ctr_string_bytes(ctr_object* myself, ctr_argument* ctr_argumentList);


/**
* Block Interface
Expand Down
2 changes: 1 addition & 1 deletion tests/test-o-mat/Configuration
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
☞ one way languages ≔ List ← ‘hy’ ; ‘en’.

☞ variations ≔ memory management modes + languages.
☞ number of tests ≔ 368.
☞ number of tests ≔ 369.

☞ base path for tests ≔ ‘../../’.
1 change: 1 addition & 0 deletions world.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ void ctr_initialize_world() {
ctr_internal_create_func(CtrStdString, ctr_build_string_from_cstring( CTR_DICT_CODE ), &ctr_string_to_code );
ctr_internal_create_func(CtrStdString, ctr_build_string_from_cstring( CTR_DICT_TOOBJECT ), &ctr_string_eval );
ctr_internal_create_func(CtrStdString, ctr_build_string_from_cstring( CTR_DICT_MINUS ), &ctr_string_minus );
ctr_internal_create_func(CtrStdString, ctr_build_string_from_cstring( "bytes" ), &ctr_string_bytes );
ctr_internal_object_add_property(CtrStdWorld, ctr_build_string_from_cstring( CTR_DICT_STRING ), CtrStdString, 0 );
CtrStdString->link = CtrStdObject;
CtrStdString->info.sticky = 1;
Expand Down

0 comments on commit 172538c

Please sign in to comment.