Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
2a38bf91
Commit
2a38bf91
authored
Nov 18, 2016
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Nov 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3254 from herwinw/doc
Doc
parents
57900d80
18d6994f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
207 additions
and
8 deletions
+207
-8
include/mruby/array.h
include/mruby/array.h
+120
-7
include/mruby/hash.h
include/mruby/hash.h
+87
-1
No files found.
include/mruby/array.h
View file @
2a38bf91
...
...
@@ -54,14 +54,60 @@ MRB_API mrb_value mrb_ary_new_capa(mrb_state*, mrb_int);
* Array.new
*
* @param mrb The mruby state reference.
* @return The initialized array
* @return The initialized array
.
*/
MRB_API
mrb_value
mrb_ary_new
(
mrb_state
*
mrb
);
/*
* Initializes a new array with initial values
*
* Equivalent to:
*
* Array[value1, value2, ...]
*
* @param mrb The mruby state reference.
* @param size The numer of values.
* @param vals The actual values.
* @return The initialized array.
*/
MRB_API
mrb_value
mrb_ary_new_from_values
(
mrb_state
*
mrb
,
mrb_int
size
,
const
mrb_value
*
vals
);
/*
* Initializes a new array with two initial values
*
* Equivalent to:
*
* Array[car, cdr]
*
* @param mrb The mruby state reference.
* @param car The first value.
* @param cdr The second value.
* @return The initialized array.
*/
MRB_API
mrb_value
mrb_assoc_new
(
mrb_state
*
mrb
,
mrb_value
car
,
mrb_value
cdr
);
MRB_API
void
mrb_ary_concat
(
mrb_state
*
,
mrb_value
,
mrb_value
);
MRB_API
mrb_value
mrb_ary_splat
(
mrb_state
*
,
mrb_value
);
/*
* Concatenate two arrays. The target array will be modified
*
* Equivalent to:
* ary.concat(other)
*
* @param mrb The mruby state reference.
* @param self The target array.
* @param other The array that will be concatenated to self.
*/
MRB_API
void
mrb_ary_concat
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
other
);
/*
* Create an array from the input. It tries calling to_a on the
* value. If value does not respond to that, it creates a new
* array with just this value.
*
* @param mrb The mruby state reference.
* @param value The value to change into an array.
* @return An array representation of value.
*/
MRB_API
mrb_value
mrb_ary_splat
(
mrb_state
*
mrb
,
mrb_value
value
);
/*
* Pushes value into array.
...
...
@@ -84,8 +130,8 @@ MRB_API void mrb_ary_push(mrb_state *mrb, mrb_value array, mrb_value value);
* ary.pop
*
* @param mrb The mruby state reference.
* @param ary The array from which the value will be poped.
* @return The poped value.
* @param ary The array from which the value will be pop
p
ed.
* @return The pop
p
ed value.
*/
MRB_API
mrb_value
mrb_ary_pop
(
mrb_state
*
mrb
,
mrb_value
ary
);
...
...
@@ -117,14 +163,81 @@ MRB_API mrb_value mrb_ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n);
*/
MRB_API
void
mrb_ary_set
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
n
,
mrb_value
val
);
MRB_API
void
mrb_ary_replace
(
mrb_state
*
mrb
,
mrb_value
a
,
mrb_value
b
);
/*
* Replace the array with another array
*
* Equivalent to:
*
* ary.replace(other)
*
* @param mrb The mruby state reference
* @param self The target array.
* @param other The array to replace it with.
*/
MRB_API
void
mrb_ary_replace
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
other
);
MRB_API
mrb_value
mrb_check_array_type
(
mrb_state
*
mrb
,
mrb_value
self
);
/*
* Unshift an element into an array
*
* Equivalent to:
*
* ary.unshift(item)
*
* @param mrb The mruby state reference.
* @param self The target array.
* @param item The item to unshift.
*/
MRB_API
mrb_value
mrb_ary_unshift
(
mrb_state
*
mrb
,
mrb_value
self
,
mrb_value
item
);
MRB_API
mrb_value
mrb_ary_entry
(
mrb_value
ary
,
mrb_int
offset
);
/*
* Shifts the first element from the array.
*
* Equivalent to:
*
* ary.shift
*
* @param mrb The mruby state reference.
* @param self The array from which the value will be shifted.
* @return The shifted value.
*/
MRB_API
mrb_value
mrb_ary_shift
(
mrb_state
*
mrb
,
mrb_value
self
);
/*
* Removes all elements from this array
*
* Equivalent to:
*
* ary.clear
*
* @param mrb The mruby state reference.
* @param self The target array.
* @return self
*/
MRB_API
mrb_value
mrb_ary_clear
(
mrb_state
*
mrb
,
mrb_value
self
);
/*
* Join the array elements together in a string
*
* Equivalent to:
*
* ary.join(sep="")
*
* @param mrb The mruby state reference.
* @param ary The target array
* @param sep The separater, can be NULL
*/
MRB_API
mrb_value
mrb_ary_join
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_value
sep
);
MRB_API
mrb_value
mrb_ary_resize
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
len
);
/*
* Update the capacity of the array
*
* @param mrb The mruby state reference.
* @param ary The target array.
* @param new_len The new capacity of the array
*/
MRB_API
mrb_value
mrb_ary_resize
(
mrb_state
*
mrb
,
mrb_value
ary
,
mrb_int
new_len
);
static
inline
mrb_int
mrb_ary_len
(
mrb_state
*
mrb
,
mrb_value
ary
)
...
...
include/mruby/hash.h
View file @
2a38bf91
...
...
@@ -28,40 +28,126 @@ MRB_API mrb_value mrb_hash_new_capa(mrb_state*, int);
/*
* Initializes a new hash.
*
* Equivalent to:
*
* Hash.new
*
* @param mrb The mruby state reference.
* @return The initialized hash.
*/
MRB_API
mrb_value
mrb_hash_new
(
mrb_state
*
mrb
);
/*
* Sets a keys and values to hashes.
*
* Equivalent to:
*
* hash[key] = val
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to set.
* @param val The value to set.
* @return The value.
*/
MRB_API
void
mrb_hash_set
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
,
mrb_value
val
);
/*
* Gets a value from a key.
* Gets a value from a key. If the key is not found, the default of the
* hash is used.
*
* Equivalent to:
*
* hash[key]
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to get.
* @return The found value.
*/
MRB_API
mrb_value
mrb_hash_get
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
);
/*
* Gets a value from a key. If the key is not found, the default parameter is
* used.
*
* Equivalent to:
*
* hash.hash_key?(key) ? hash[key] : def
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to get.
* @param def The default value.
* @return The found value.
*/
MRB_API
mrb_value
mrb_hash_fetch
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
,
mrb_value
def
);
/*
* Deletes hash key and value pair.
*
* Equivalent to:
*
* hash.delete(key)
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to delete.
* @return The deleted value.
*/
MRB_API
mrb_value
mrb_hash_delete_key
(
mrb_state
*
mrb
,
mrb_value
hash
,
mrb_value
key
);
/*
* Gets an array of keys.
*
* Equivalent to:
*
* hash.keys
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @return An array with the keys of the hash.
*/
MRB_API
mrb_value
mrb_hash_keys
(
mrb_state
*
mrb
,
mrb_value
hash
);
MRB_API
mrb_value
mrb_check_hash_type
(
mrb_state
*
mrb
,
mrb_value
hash
);
/*
* Check if the hash is empty
*
* Equivalent to:
*
* hash.empty?
*
* @param mrb The mruby state reference.
* @param self The target hash.
* @return True if the hash is empty, false otherwise.
*/
MRB_API
mrb_value
mrb_hash_empty_p
(
mrb_state
*
mrb
,
mrb_value
self
);
/*
* Gets an array of values.
*
* Equivalent to:
*
* hash.values
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @return An array with the values of the hash.
*/
MRB_API
mrb_value
mrb_hash_values
(
mrb_state
*
mrb
,
mrb_value
hash
);
/*
* Clears the hash.
*
* Equivalent to:
*
* hash.clear
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @return The hash
*/
MRB_API
mrb_value
mrb_hash_clear
(
mrb_state
*
mrb
,
mrb_value
hash
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment