Hey guys, I was trying to follow the basic example with the String#blank?
so basically just copy pasted it from README into a Rust crate.
Then compiled it (as per https://github.com/d-unseductable/ruru#how-do-i-use-it) and fired up the (pry) console hoping to see the magic.
Unfortunately got this, so scratching my head a little.
> library = Fiddle::dlopen('rust/play/target/release/libplay.dylib')
> Fiddle::Function.new(library['initialize_string'], [], Fiddle::TYPE_VOIDP)
Fiddle::DLError: unknown symbol "initialize_string" from (pry):17:in `[]'
Any pointers please?
> ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
> irb # then:
> RbConfig::CONFIG['configure_args'].include?('--enable-shared')
=> true
> rustc --version
rustc 1.27.0 (3eda71b00 2018-06-19)
> cat Cargo.toml
[package]
name = "play"
version = "0.1.0"
authors = ["<me>"]
[lib]
crate-type = ["dylib"]
[dependencies]
ruru = "0.9.0"
Recompiling the crate seems to have fixed this, so not sure what was going on TBH :innocent:
But now a different error that seems to come from Class::from_existing("String")
Error: [BUG] Segmentation fault at 0x0000000000000438
C stack:
0 libruby.2.5.dylib 0x00000001084ddc87 rb_vm_bugreport + 135
1 libruby.2.5.dylib 0x0000000108362258 rb_bug_context + 472
2 libruby.2.5.dylib 0x0000000108450b31 sigsegv + 81
3 libsystem_platform.dylib 0x00007fff7ac5ef5a _sigtramp + 26
4 libruby.2.4.0.dylib 0x0000000108a57fe1 ruby_xmalloc + 17
5 libruby.2.4.0.dylib 0x0000000108b256fa st_init_table_with_size + 74
6 libruby.2.4.0.dylib 0x0000000108a2f80e rb_enc_init + 110
7 libruby.2.4.0.dylib 0x0000000108a30be5 rb_usascii_encoding + 21
8 libruby.2.4.0.dylib 0x0000000108b4f3c7 rb_intern + 23
9 libplay.dylib 0x00000001087bf1ec _ZN4ruru7binding4util11internal_id17hdb1af469e236d7dcE + 108
10 libplay.dylib 0x00000001087bf149 _ZN4ruru7binding4util12get_constant17ha4887c45800de38aE + 41
==>>>>>> 11 libplay.dylib 0x00000001087c0caf _ZN4ruru5class5class5Class13from_existing17h9fe2a0f2fe1e0735E + 63
12 libplay.dylib 0x00000001087b8e2e initialize_string + 30
13 libffi.dylib 0x00007fff79298f64 ffi_call_unix64 + 76
14 libffi.dylib 0x00007fff7929977c ffi_call + 808
15 fiddle.bundle 0x00000001087af6fb nogvl_ffi_call + 27
16 libruby.2.5.dylib 0x000000010848a762 rb_thread_call_without_gvl + 82
17 fiddle.bundle 0x00000001087af187 function_call + 823
18 libruby.2.5.dylib 0x00000001084d15bb vm_call_cfunc + 283
19 libruby.2.5.dylib 0x00000001084baa04 vm_exec_core + 12196
20 libruby.2.5.dylib 0x00000001084cbe8e vm_exec + 142
21 libruby.2.5.dylib 0x000000010836c0f1 ruby_exec_internal + 177
master
and that seems to work ok though
[dependencies]
ruru = { git = "ssh://github.com/d-unseductable/ruru.git" }
Class::get_nested_class()
method to open up the class so you can define the method.