Skip to content

Commit f9f19f3

Browse files
committed
replace _cstr by _lit for litral C strings; ref #3300
1 parent 3d9aa46 commit f9f19f3

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

include/mruby.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_
430430
*
431431
* mrb_value
432432
* mrb_example_method(mrb_state *mrb){
433-
* return mrb_str_new_cstr(mrb, "example");
433+
* return mrb_str_new_lit(mrb, "example");
434434
* }
435435
*
436436
* void
@@ -473,7 +473,7 @@ MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*);
473473
*
474474
* mrb_value
475475
* mrb_example_method(mrb_state *mrb){
476-
* return mrb_str_new_cstr(mrb, "example");
476+
* return mrb_str_new_lit(mrb, "example");
477477
* }
478478
*
479479
* void
@@ -696,7 +696,7 @@ MRB_API mrb_value mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char
696696
*
697697
* example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
698698
* mrb_define_method(mrb, example_class, "example_method", exampleMethod, MRB_ARGS_NONE());
699-
* mid = mrb_intern_str(mrb, mrb_str_new_cstr(mrb, "example_method" ));
699+
* mid = mrb_intern_str(mrb, mrb_str_new_lit(mrb, "example_method" ));
700700
* obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => 1(true in Ruby world)
701701
*
702702
* // If mrb_obj_respond_to returns 1 then puts "True"
@@ -884,7 +884,7 @@ MRB_API mrb_value mrb_funcall(mrb_state*, mrb_value, const char*, mrb_int,...);
884884
* mrb_state *mrb = mrb_open();
885885
*
886886
* if (!mrb) { }
887-
* mrb_sym m_sym = mrb_intern_cstr(mrb, "method_name"); // Symbol for method.
887+
* mrb_sym m_sym = mrb_intern_lit(mrb, "method_name"); // Symbol for method.
888888
*
889889
* FILE *fp = fopen("test.rb","r");
890890
* mrb_value obj = mrb_load_file(mrb,fp);
@@ -912,7 +912,7 @@ MRB_API mrb_value mrb_funcall_with_block(mrb_state*, mrb_value, mrb_sym, mrb_int
912912
* :pizza # => :pizza
913913
*
914914
* // C style:
915-
* mrb_sym m_sym = mrb_intern_cstr(mrb, "pizza"); // => :pizza
915+
* mrb_sym m_sym = mrb_intern_lit(mrb, "pizza"); // => :pizza
916916
* @param [mrb_state*] mrb_state* The current mruby state.
917917
* @param [const char*] const char* The name of the method.
918918
* @return [mrb_sym] mrb_sym A symbol.

include/mruby/string.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ MRB_API void mrb_str_modify(mrb_state*, struct RString*);
110110
* }
111111
*
112112
* // Creates new Ruby strings.
113-
* str1 = mrb_str_new_cstr(mrb, "abc");
114-
* str2 = mrb_str_new_cstr(mrb, "def");
113+
* str1 = mrb_str_new_lit(mrb, "abc");
114+
* str2 = mrb_str_new_lit(mrb, "def");
115115
*
116116
* // Concatnates str2 to str1.
117117
* mrb_str_concat(mrb, str1, str2);
@@ -158,8 +158,8 @@ MRB_API void mrb_str_concat(mrb_state*, mrb_value, mrb_value);
158158
* }
159159
*
160160
* // Creates two Ruby strings from the passed in C strings.
161-
* a = mrb_str_new_cstr(mrb, "abc");
162-
* b = mrb_str_new_cstr(mrb, "def");
161+
* a = mrb_str_new_lit(mrb, "abc");
162+
* b = mrb_str_new_lit(mrb, "def");
163163
*
164164
* // Prints both C strings.
165165
* mrb_p(mrb, a);
@@ -227,7 +227,7 @@ MRB_API mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj);
227227
* // handle error
228228
* }
229229
* // Creates a new string.
230-
* str = mrb_str_new_cstr(mrb, "Hello, world!");
230+
* str = mrb_str_new_lit(mrb, "Hello, world!");
231231
* // Returns 5 characters of
232232
* mrb_str_resize(mrb, str, 5);
233233
* mrb_p(mrb, str);
@@ -267,7 +267,7 @@ MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
267267
* // handle error
268268
* }
269269
* // Creates new string.
270-
* str1 = mrb_str_new_cstr(mrb, "Hello, world!");
270+
* str1 = mrb_str_new_lit(mrb, "Hello, world!");
271271
* // Returns a sub-string within the range of 0..2
272272
* str2 = mrb_str_substr(mrb, str1, 0, 2);
273273
*

include/mruby/variable.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id)
6666
*
6767
* !!!c
6868
* // C style
69-
* mrb_sym sym = mrb_intern_cstr(mrb, "$value");
69+
* mrb_sym sym = mrb_intern_lit(mrb, "$value");
7070
* mrb_value var = mrb_gv_get(mrb, sym);
7171
*
7272
* @param mrb The mruby state reference
@@ -86,8 +86,8 @@ MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym);
8686
*
8787
* !!!c
8888
* // C style
89-
* mrb_sym sym = mrb_intern_cstr(mrb, "$value");
90-
* mrb_gv_set(mrb, sym, mrb_str_new_cstr("foo"));
89+
* mrb_sym sym = mrb_intern_lit(mrb, "$value");
90+
* mrb_gv_set(mrb, sym, mrb_str_new_lit("foo"));
9191
*
9292
* @param mrb The mruby state reference
9393
* @param sym The name of the global variable
@@ -106,7 +106,7 @@ MRB_API void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
106106
*
107107
* !!!c
108108
* // C style
109-
* mrb_sym sym = mrb_intern_cstr(mrb, "$value");
109+
* mrb_sym sym = mrb_intern_lit(mrb, "$value");
110110
* mrb_gv_remove(mrb, sym);
111111
*
112112
* @param mrb The mruby state reference

0 commit comments

Comments
 (0)