replace _cstr by _lit for litral C strings; ref #3300

parent 3d9aa463
...@@ -430,7 +430,7 @@ MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_ ...@@ -430,7 +430,7 @@ MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_
* *
* mrb_value * mrb_value
* mrb_example_method(mrb_state *mrb){ * mrb_example_method(mrb_state *mrb){
* return mrb_str_new_cstr(mrb, "example"); * return mrb_str_new_lit(mrb, "example");
* } * }
* *
* void * void
...@@ -473,7 +473,7 @@ MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*); ...@@ -473,7 +473,7 @@ MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*);
* *
* mrb_value * mrb_value
* mrb_example_method(mrb_state *mrb){ * mrb_example_method(mrb_state *mrb){
* return mrb_str_new_cstr(mrb, "example"); * return mrb_str_new_lit(mrb, "example");
* } * }
* *
* void * void
...@@ -696,7 +696,7 @@ MRB_API mrb_value mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char ...@@ -696,7 +696,7 @@ MRB_API mrb_value mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char
* *
* example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class); * example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
* mrb_define_method(mrb, example_class, "example_method", exampleMethod, MRB_ARGS_NONE()); * mrb_define_method(mrb, example_class, "example_method", exampleMethod, MRB_ARGS_NONE());
* mid = mrb_intern_str(mrb, mrb_str_new_cstr(mrb, "example_method" )); * mid = mrb_intern_str(mrb, mrb_str_new_lit(mrb, "example_method" ));
* obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => 1(true in Ruby world) * obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => 1(true in Ruby world)
* *
* // If mrb_obj_respond_to returns 1 then puts "True" * // 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,...); ...@@ -884,7 +884,7 @@ MRB_API mrb_value mrb_funcall(mrb_state*, mrb_value, const char*, mrb_int,...);
* mrb_state *mrb = mrb_open(); * mrb_state *mrb = mrb_open();
* *
* if (!mrb) { } * if (!mrb) { }
* mrb_sym m_sym = mrb_intern_cstr(mrb, "method_name"); // Symbol for method. * mrb_sym m_sym = mrb_intern_lit(mrb, "method_name"); // Symbol for method.
* *
* FILE *fp = fopen("test.rb","r"); * FILE *fp = fopen("test.rb","r");
* mrb_value obj = mrb_load_file(mrb,fp); * 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 ...@@ -912,7 +912,7 @@ MRB_API mrb_value mrb_funcall_with_block(mrb_state*, mrb_value, mrb_sym, mrb_int
* :pizza # => :pizza * :pizza # => :pizza
* *
* // C style: * // C style:
* mrb_sym m_sym = mrb_intern_cstr(mrb, "pizza"); // => :pizza * mrb_sym m_sym = mrb_intern_lit(mrb, "pizza"); // => :pizza
* @param [mrb_state*] mrb_state* The current mruby state. * @param [mrb_state*] mrb_state* The current mruby state.
* @param [const char*] const char* The name of the method. * @param [const char*] const char* The name of the method.
* @return [mrb_sym] mrb_sym A symbol. * @return [mrb_sym] mrb_sym A symbol.
......
...@@ -110,8 +110,8 @@ MRB_API void mrb_str_modify(mrb_state*, struct RString*); ...@@ -110,8 +110,8 @@ MRB_API void mrb_str_modify(mrb_state*, struct RString*);
* } * }
* *
* // Creates new Ruby strings. * // Creates new Ruby strings.
* str1 = mrb_str_new_cstr(mrb, "abc"); * str1 = mrb_str_new_lit(mrb, "abc");
* str2 = mrb_str_new_cstr(mrb, "def"); * str2 = mrb_str_new_lit(mrb, "def");
* *
* // Concatnates str2 to str1. * // Concatnates str2 to str1.
* mrb_str_concat(mrb, str1, str2); * mrb_str_concat(mrb, str1, str2);
...@@ -158,8 +158,8 @@ MRB_API void mrb_str_concat(mrb_state*, mrb_value, mrb_value); ...@@ -158,8 +158,8 @@ MRB_API void mrb_str_concat(mrb_state*, mrb_value, mrb_value);
* } * }
* *
* // Creates two Ruby strings from the passed in C strings. * // Creates two Ruby strings from the passed in C strings.
* a = mrb_str_new_cstr(mrb, "abc"); * a = mrb_str_new_lit(mrb, "abc");
* b = mrb_str_new_cstr(mrb, "def"); * b = mrb_str_new_lit(mrb, "def");
* *
* // Prints both C strings. * // Prints both C strings.
* mrb_p(mrb, a); * mrb_p(mrb, a);
...@@ -227,7 +227,7 @@ MRB_API mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj); ...@@ -227,7 +227,7 @@ MRB_API mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj);
* // handle error * // handle error
* } * }
* // Creates a new string. * // Creates a new string.
* str = mrb_str_new_cstr(mrb, "Hello, world!"); * str = mrb_str_new_lit(mrb, "Hello, world!");
* // Returns 5 characters of * // Returns 5 characters of
* mrb_str_resize(mrb, str, 5); * mrb_str_resize(mrb, str, 5);
* mrb_p(mrb, str); * mrb_p(mrb, str);
...@@ -267,7 +267,7 @@ MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len); ...@@ -267,7 +267,7 @@ MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
* // handle error * // handle error
* } * }
* // Creates new string. * // Creates new string.
* str1 = mrb_str_new_cstr(mrb, "Hello, world!"); * str1 = mrb_str_new_lit(mrb, "Hello, world!");
* // Returns a sub-string within the range of 0..2 * // Returns a sub-string within the range of 0..2
* str2 = mrb_str_substr(mrb, str1, 0, 2); * str2 = mrb_str_substr(mrb, str1, 0, 2);
* *
......
...@@ -66,7 +66,7 @@ MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id) ...@@ -66,7 +66,7 @@ MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id)
* *
* !!!c * !!!c
* // C style * // C style
* mrb_sym sym = mrb_intern_cstr(mrb, "$value"); * mrb_sym sym = mrb_intern_lit(mrb, "$value");
* mrb_value var = mrb_gv_get(mrb, sym); * mrb_value var = mrb_gv_get(mrb, sym);
* *
* @param mrb The mruby state reference * @param mrb The mruby state reference
...@@ -86,8 +86,8 @@ MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym); ...@@ -86,8 +86,8 @@ MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym);
* *
* !!!c * !!!c
* // C style * // C style
* mrb_sym sym = mrb_intern_cstr(mrb, "$value"); * mrb_sym sym = mrb_intern_lit(mrb, "$value");
* mrb_gv_set(mrb, sym, mrb_str_new_cstr("foo")); * mrb_gv_set(mrb, sym, mrb_str_new_lit("foo"));
* *
* @param mrb The mruby state reference * @param mrb The mruby state reference
* @param sym The name of the global variable * @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); ...@@ -106,7 +106,7 @@ MRB_API void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
* *
* !!!c * !!!c
* // C style * // C style
* mrb_sym sym = mrb_intern_cstr(mrb, "$value"); * mrb_sym sym = mrb_intern_lit(mrb, "$value");
* mrb_gv_remove(mrb, sym); * mrb_gv_remove(mrb, sym);
* *
* @param mrb The mruby state reference * @param mrb The mruby state reference
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment