malachite 0.0.19 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/malachite/cgo.tmpl +8 -0
- data/lib/malachite/exporter.go.tmpl +8 -5
- data/lib/malachite/file_compiler.rb +5 -4
- data/lib/malachite/function.rb +1 -1
- data/lib/malachite/main.go.tmpl +6 -0
- data/lib/malachite/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 233112bb95e12d25261f6ba2c8694c0634c6be04
|
4
|
+
data.tar.gz: ef2ce7c4b9bd83c50f19c8314e07dcd6e17ed664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2df3015621e0894ee169f4cae21d6dbf7f339a69e2537e6107ef0fe745e833c96ee464685dcd34124958ed2d8b72e81409a04b662f38a52d6bc0e81ccab9a31
|
7
|
+
data.tar.gz: 98799f8b8e9a723ad1f0befff9f110002b1f0f95995d1966e09f7eaaf041b02cebec451c3ab9953034b26219b7e73a8cd45ec58d71aaff53d9f57380f5cb4d6e
|
@@ -1,11 +1,14 @@
|
|
1
1
|
//export callXXXXXX
|
2
|
-
func callXXXXXX(data *C.char)
|
2
|
+
func callXXXXXX(data *C.char) C.VALUE {
|
3
3
|
things := YYYYYY
|
4
4
|
err := Unmarshal(C.GoString(data), &things)
|
5
5
|
if err != nil {
|
6
|
-
|
6
|
+
str := err.Error()
|
7
|
+
cstr := GOSTRING_PTR(str)
|
8
|
+
return C.rb_utf8_str_new(cstr, C.long(len(str)))
|
9
|
+
} else {
|
10
|
+
str := Marshal(HandleXXXXXX(things))
|
11
|
+
cstr := GOSTRING_PTR(str)
|
12
|
+
return C.rb_utf8_str_new(cstr, C.long(len(str)))
|
7
13
|
}
|
8
|
-
marshaled := C.CString(Marshal(HandleXXXXXX(things)))
|
9
|
-
defer C.free(unsafe.Pointer(marshaled))
|
10
|
-
return marshaled
|
11
14
|
}
|
@@ -7,10 +7,7 @@ module Malachite
|
|
7
7
|
def compile
|
8
8
|
File.open(path_to_tmp_file(@file), 'w') do |file|
|
9
9
|
if file_has_handle_function?(@file)
|
10
|
-
file.puts
|
11
|
-
file.puts '// #include <stdlib.h>'
|
12
|
-
file.puts "import \"C\""
|
13
|
-
file.puts "import \"unsafe\""
|
10
|
+
file.puts cgo_tmpl
|
14
11
|
file.puts source_file(@file)
|
15
12
|
file.puts exporter_boilerplate(@file)
|
16
13
|
else
|
@@ -22,6 +19,10 @@ module Malachite
|
|
22
19
|
|
23
20
|
private
|
24
21
|
|
22
|
+
def cgo_tmpl
|
23
|
+
File.read(File.expand_path('../cgo.tmpl', __FILE__))
|
24
|
+
end
|
25
|
+
|
25
26
|
def source_file(f)
|
26
27
|
source = File.read(f)
|
27
28
|
source.gsub(/package main/, '')
|
data/lib/malachite/function.rb
CHANGED
data/lib/malachite/main.go.tmpl
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
package main
|
2
2
|
import "C"
|
3
3
|
import "encoding/json"
|
4
|
+
import "unsafe"
|
4
5
|
|
5
6
|
func main() {}
|
6
7
|
|
@@ -16,3 +17,8 @@ func Marshal(v interface{}) string {
|
|
16
17
|
}
|
17
18
|
return string(b)
|
18
19
|
}
|
20
|
+
|
21
|
+
func GOSTRING_PTR(str string) *C.char {
|
22
|
+
bytes := *(*[]byte)(unsafe.Pointer(&str))
|
23
|
+
return (*C.char)(unsafe.Pointer(&bytes[0]))
|
24
|
+
}
|
data/lib/malachite/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: malachite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Hubert
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
67
|
- lib/malachite.rb
|
68
|
+
- lib/malachite/cgo.tmpl
|
68
69
|
- lib/malachite/client.rb
|
69
70
|
- lib/malachite/compiler.rb
|
70
71
|
- lib/malachite/errors.rb
|