Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matsumotory/mruby-userdata
When shared mrb_state, you can share userdata objects between one Ruby code and another is shared mrb_state.
https://github.com/matsumotory/mruby-userdata
Last synced: about 2 months ago
JSON representation
When shared mrb_state, you can share userdata objects between one Ruby code and another is shared mrb_state.
- Host: GitHub
- URL: https://github.com/matsumotory/mruby-userdata
- Owner: matsumotory
- Created: 2013-07-29T05:09:47.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-09-25T06:03:00.000Z (over 1 year ago)
- Last Synced: 2024-10-18T18:17:12.093Z (3 months ago)
- Language: C
- Size: 8.79 KB
- Stars: 12
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-mruby - mruby-userdata - When shared mrb_state, you can share userdata objects between one Ruby code and the other. (Data Structures)
README
# Userdata class for mruby
When shared mrb_state, you can share userdata objects between one Ruby code and the other.## install by mrbgems
- add conf.gem line to `build_config.rb`
```ruby
MRuby::Build.new do |conf|# ... (snip) ...
conf.gem :git => 'https://github.com/matsumoto-r/mruby-userdata.git'
end
```## How to use
- One ruby code A```ruby
u = Userdata.new
u.hoge = {:hoge => 1}
```- The other ruby code B is shared mrb_state with ruby code A
```ruby
u = Userdata.new
hash = u.hoge
hash[:fuga] = 2
u.hoge = hash
p u.hoge # => {:hoge => 1, :fuga =>2}
```- use userdata key
```ruby
mirb - Embeddable Interactive Ruby Shell
This is a very early version, please test and report errors.
Thanks :)
> u = Userdata.new
=> #
> u.hoge
=> nil
> u.hoge = 1
=> 1
> u.hoge
=> 1
> q = Userdata.new
=> #
> q.hoge
=> 1
> q.hoge = q.hoge + 1
=> 2
> u.hoge
=> 2
> s = Userdata.new "my_key"
=> #
> s.hoge
=> nil
> s.hoge = 1
=> 1
> u.hoge
=> 2
> q.hoge
=> 2
```# License
under the MIT License:* http://www.opensource.org/licenses/mit-license.php