summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorcremno <[email protected]>2014-02-12 00:37:47 +0100
committercremno <[email protected]>2014-02-12 00:37:47 +0100
commit7691b649634166bfc769ba58edcbe91aced50828 (patch)
treee097b53199b134766ca13f2e0f651a8e33c444e2 /include
parent27dbcd0f0d6f6144d5d59d215131bdbafda14f46 (diff)
downloadmruby-7691b649634166bfc769ba58edcbe91aced50828.tar.gz
mruby-7691b649634166bfc769ba58edcbe91aced50828.zip
array implementation: several small changes
src/array.c: - make various functions without declaration in the mruby headers static - removed all uncessary int casts and two useless comments mrb_ary_new_from_values: move to similar functions mrb_check_array_type: fix indentation include/mruby/array.h: mrb_shared_array: padding (default "mrbconf.h" on an usual 64-bit system) sizeof(mrb_int)==sizeof(int)==4 && sizeof(mrb_value*)==8 both: mrb_ary_aget: remove declaration in header and make static nobody uses it which is not surprising since it has 1 req arg! mrb_assoc_new: small optimization and move to similar functions mrb_ary_len: re-implement as static inline function (it is used by mrbgems) programmers should directly use RARRAY_LEN instead
Diffstat (limited to 'include')
-rw-r--r--include/mruby/array.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/mruby/array.h b/include/mruby/array.h
index 5a064cb37..5fbf71174 100644
--- a/include/mruby/array.h
+++ b/include/mruby/array.h
@@ -13,8 +13,8 @@ extern "C" {
typedef struct mrb_shared_array {
int refcnt;
- mrb_value *ptr;
mrb_int len;
+ mrb_value *ptr;
} mrb_shared_array;
struct RArray {
@@ -40,23 +40,29 @@ void mrb_ary_decref(mrb_state*, mrb_shared_array*);
mrb_value mrb_ary_new_capa(mrb_state*, mrb_int);
mrb_value mrb_ary_new(mrb_state *mrb);
mrb_value mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals);
+mrb_value mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr);
void mrb_ary_concat(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_ary_splat(mrb_state*, mrb_value);
void mrb_ary_push(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary);
-mrb_value mrb_ary_aget(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n);
void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val);
-mrb_int mrb_ary_len(mrb_state *mrb, mrb_value ary);
void mrb_ary_replace(mrb_state *mrb, mrb_value a, mrb_value b);
mrb_value mrb_check_array_type(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item);
-mrb_value mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr);
mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset);
mrb_value mrb_ary_shift(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_clear(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
+static inline mrb_int
+mrb_ary_len(mrb_state *mrb, mrb_value ary)
+{
+ (void)mrb;
+ mrb_assert(mrb_array_p(ary));
+ return RARRAY_LEN(ary);
+}
+
#if defined(__cplusplus)
} /* extern "C" { */
#endif