serpent 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/ext/serpent/serpent.cpp +21 -1
- data/lib/serpent.rb +18 -0
- data/lib/serpent/version.rb +1 -1
- data/test/serpent_test.rb +10 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e064fffc2cbbd7c57f6a9f8c8b0a4cf326ec73b
|
4
|
+
data.tar.gz: d7403a3c974afdac5933e4c6d960fdc642c9c25e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 676765556e178545eac61b86590d55e9b6885897cbbb959df28b8e6a4c1c376665e164491c256e0ac856049df8c3d1e9fbdb605d8e18875bdd7a68bf296673fa
|
7
|
+
data.tar.gz: e5c93ddca6f6dcd41979f7aa4e0a4e6731292df4665d2b477548d3cdfe63df26517fd38caa8cbb201a5cf17aa1d88be649371ae909e6bac5b916fa113d8d2ffa
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/ext/serpent/serpent.cpp
CHANGED
@@ -7,8 +7,28 @@ std::string serpent_compile(Object self, std::string code) {
|
|
7
7
|
return compile(code);
|
8
8
|
}
|
9
9
|
|
10
|
+
std::string serpent_mk_raw_signature(Object self, std::string input) {
|
11
|
+
return mkSignature(input);
|
12
|
+
}
|
13
|
+
|
14
|
+
std::string serpent_mk_raw_full_signature(Object self, std::string input) {
|
15
|
+
return mkFullSignature(input);
|
16
|
+
}
|
17
|
+
|
18
|
+
std::string serpent_mk_raw_contract_info(Object self, std::string input) {
|
19
|
+
return mkContractInfoDecl(input);
|
20
|
+
}
|
21
|
+
|
22
|
+
unsigned int serpent_get_prefix(Object self, std::string signature) {
|
23
|
+
return getPrefix(signature);
|
24
|
+
}
|
25
|
+
|
10
26
|
extern "C"
|
11
27
|
void Init_serpent() {
|
12
28
|
Module rb_mSerpent = define_module("Serpent")
|
13
|
-
.define_module_function("compile", &serpent_compile)
|
29
|
+
.define_module_function("compile", &serpent_compile)
|
30
|
+
.define_module_function("mk_raw_signature", &serpent_mk_raw_signature)
|
31
|
+
.define_module_function("mk_raw_full_signature", &serpent_mk_raw_full_signature)
|
32
|
+
.define_module_function("mk_raw_contract_info", &serpent_mk_raw_contract_info)
|
33
|
+
.define_module_function("get_prefix", &serpent_get_prefix);
|
14
34
|
}
|
data/lib/serpent.rb
CHANGED
@@ -1,2 +1,20 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
require 'serpent/version'
|
2
4
|
require 'serpent/serpent'
|
5
|
+
|
6
|
+
module Serpent
|
7
|
+
class <<self
|
8
|
+
def mk_signature(s)
|
9
|
+
JSON.parse mk_raw_signature(s)
|
10
|
+
end
|
11
|
+
|
12
|
+
def mk_full_signature(s)
|
13
|
+
JSON.parse mk_raw_full_signature(s)
|
14
|
+
end
|
15
|
+
|
16
|
+
def mk_contract_info(s)
|
17
|
+
JSON.parse mk_raw_contract_info(s)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/serpent/version.rb
CHANGED
data/test/serpent_test.rb
CHANGED
@@ -5,13 +5,19 @@ require 'serpent'
|
|
5
5
|
|
6
6
|
class SerpentTest < Minitest::Test
|
7
7
|
|
8
|
-
|
9
|
-
code = <<-SERPENT
|
8
|
+
CODE = <<EOF
|
10
9
|
def main(a,b):
|
11
10
|
return(a ^ b)
|
12
|
-
|
11
|
+
EOF
|
12
|
+
|
13
|
+
def test_compile
|
14
|
+
assert_equal decode_hex('604a80600b6000396055567c0100000000000000000000000000000000000000000000000000000000600035046397d857aa8114156048576004356040526024356060526060516040510a60805260206080f35b505b6000f3'), Serpent.compile(CODE)
|
15
|
+
end
|
13
16
|
|
14
|
-
|
17
|
+
def test_mk_full_signature
|
18
|
+
sig = Serpent.mk_full_signature(CODE).first
|
19
|
+
assert_equal 'main(int256,int256)', sig['name']
|
20
|
+
assert_equal [{'name' => 'a', 'type' => 'int256'}, {'name' => 'b', 'type' => 'int256'}], sig['inputs']
|
15
21
|
end
|
16
22
|
|
17
23
|
private
|