Permalink
Browse files

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

  • Loading branch information...
matz committed Nov 27, 2016
1 parent 3d9aa46 commit f9f19f34dd8b267895fb61223b194a6ae6bdc89e
Showing with 15 additions and 15 deletions.
  1. +5 −5 include/mruby.h
  2. +6 −6 include/mruby/string.h
  3. +4 −4 include/mruby/variable.h
View
@@ -430,7 +430,7 @@ MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_
*
* mrb_value
* mrb_example_method(mrb_state *mrb){
* return mrb_str_new_cstr(mrb, "example");
* return mrb_str_new_lit(mrb, "example");
* }
*
* void
@@ -473,7 +473,7 @@ MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*);
*
* mrb_value
* mrb_example_method(mrb_state *mrb){
* return mrb_str_new_cstr(mrb, "example");
* return mrb_str_new_lit(mrb, "example");
* }
*
* void
@@ -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);
* 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)
*
* // 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,...);
* mrb_state *mrb = mrb_open();
*
* 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");
* 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
* :pizza # => :pizza
*
* // 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 [const char*] const char* The name of the method.
* @return [mrb_sym] mrb_sym A symbol.
View
@@ -110,8 +110,8 @@ MRB_API void mrb_str_modify(mrb_state*, struct RString*);
* }
*
* // Creates new Ruby strings.
* str1 = mrb_str_new_cstr(mrb, "abc");
* str2 = mrb_str_new_cstr(mrb, "def");
* str1 = mrb_str_new_lit(mrb, "abc");
* str2 = mrb_str_new_lit(mrb, "def");
*
* // Concatnates str2 to str1.
* mrb_str_concat(mrb, str1, str2);
@@ -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.
* a = mrb_str_new_cstr(mrb, "abc");
* b = mrb_str_new_cstr(mrb, "def");
* a = mrb_str_new_lit(mrb, "abc");
* b = mrb_str_new_lit(mrb, "def");
*
* // Prints both C strings.
* mrb_p(mrb, a);
@@ -227,7 +227,7 @@ MRB_API mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj);
* // handle error
* }
* // Creates a new string.
* str = mrb_str_new_cstr(mrb, "Hello, world!");
* str = mrb_str_new_lit(mrb, "Hello, world!");
* // Returns 5 characters of
* mrb_str_resize(mrb, str, 5);
* mrb_p(mrb, str);
@@ -267,7 +267,7 @@ MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
* // handle error
* }
* // 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
* str2 = mrb_str_substr(mrb, str1, 0, 2);
*
View
@@ -66,7 +66,7 @@ MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id)
*
* !!!c
* // 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);
*
* @param mrb The mruby state reference
@@ -86,8 +86,8 @@ MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym);
*
* !!!c
* // C style
* mrb_sym sym = mrb_intern_cstr(mrb, "$value");
* mrb_gv_set(mrb, sym, mrb_str_new_cstr("foo"));
* mrb_sym sym = mrb_intern_lit(mrb, "$value");
* mrb_gv_set(mrb, sym, mrb_str_new_lit("foo"));
*
* @param mrb The mruby state reference
* @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);
*
* !!!c
* // C style
* mrb_sym sym = mrb_intern_cstr(mrb, "$value");
* mrb_sym sym = mrb_intern_lit(mrb, "$value");
* mrb_gv_remove(mrb, sym);
*
* @param mrb The mruby state reference

0 comments on commit f9f19f3

Please sign in to comment.