abiparser 0.1.0 → 0.1.2
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/abiparser/constructor.rb +7 -0
- data/lib/abiparser/function.rb +14 -2
- data/lib/abiparser/param.rb +25 -9
- data/lib/abiparser/version.rb +1 -1
- data/lib/abiparser.rb +4 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c3444ce73a26479bc5a39156f1c4a4213dc8445e86b5411003335de8d468e6
|
4
|
+
data.tar.gz: 1d600bcd4c0d0f9fa6059cac6d3ec7ae6f9f4f27e94306d2af34d36b67f5d5ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 191678ab0a6577f9ccfd35ddb27827962d323b613b113af5f96e7ca3e99c18483b1ef698ff8053d04cb90ea86cd1f32727ca8b96319e9df291ad86e5d404194d
|
7
|
+
data.tar.gz: 9853905ee95157f03e2fd4d74da4e4432fed384dc7c4ea1ef3aa37b9eb6b59c4390c9adc851a0d04c12d318620eadbc239abbbc2cf68f177dd23bfbb07a22eef
|
@@ -48,13 +48,20 @@ class Constructor
|
|
48
48
|
|
49
49
|
|
50
50
|
attr_reader :inputs
|
51
|
+
## :input_types
|
51
52
|
|
52
53
|
def initialize( inputs: [],
|
53
54
|
payable: false )
|
54
55
|
@inputs = inputs
|
55
56
|
@payable = payable
|
57
|
+
|
58
|
+
## parse inputs into types
|
59
|
+
## note: use "calculated" sig(nature) and NOT the type
|
60
|
+
## (differs for tuples, that is, types with components !!!)
|
61
|
+
## @input_types = @inputs.map {|param| Type.parse( param.sig ) }
|
56
62
|
end
|
57
63
|
|
64
|
+
|
58
65
|
## add - why? why not?
|
59
66
|
## def constant?() false; end
|
60
67
|
## alias_method :readonly?, :constant?
|
data/lib/abiparser/function.rb
CHANGED
@@ -55,9 +55,10 @@ class Function
|
|
55
55
|
|
56
56
|
attr_reader :name,
|
57
57
|
:inputs, :outputs
|
58
|
+
## :input_types, :output_types
|
58
59
|
|
59
60
|
def initialize( name,
|
60
|
-
inputs:
|
61
|
+
inputs: [],
|
61
62
|
outputs: [],
|
62
63
|
payable: false,
|
63
64
|
constant: false,
|
@@ -65,10 +66,21 @@ class Function
|
|
65
66
|
@name = name
|
66
67
|
@inputs = inputs
|
67
68
|
@outputs = outputs
|
68
|
-
|
69
69
|
@payable = payable
|
70
70
|
@constant = constant
|
71
71
|
@pure = pure
|
72
|
+
|
73
|
+
## parse inputs & outputs into types
|
74
|
+
## note: use "calculated" sig(nature) and NOT the type
|
75
|
+
## (differs for tuples, that is, types with components !!!)
|
76
|
+
## @input_types = @inputs.map do |param|
|
77
|
+
## Type.parse( param.sig )
|
78
|
+
## end
|
79
|
+
## @output_types = @outputs.map do |param|
|
80
|
+
## ## pp param
|
81
|
+
## ## puts "sig: #{param.sig}"
|
82
|
+
## Type.parse( param.sig )
|
83
|
+
## end
|
72
84
|
end
|
73
85
|
|
74
86
|
|
data/lib/abiparser/param.rb
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
module ABI
|
2
2
|
class Param
|
3
|
-
attr_reader :type, :name,
|
3
|
+
attr_reader :type, :name,
|
4
|
+
:internal_type,
|
5
|
+
:components
|
4
6
|
|
5
7
|
def self.parse( o )
|
6
8
|
type = o['type']
|
7
9
|
internal_type = o['internalType']
|
8
10
|
name = o['name']
|
11
|
+
components = o['components'] ? o['components'].map { |c| parse( c ) } : nil
|
9
12
|
|
10
13
|
new( type, name,
|
11
|
-
internal_type: internal_type
|
14
|
+
internal_type: internal_type,
|
15
|
+
components: components )
|
12
16
|
end
|
13
17
|
|
14
18
|
### check - find a "better" name for internal_type
|
15
19
|
## use a keyword param - why? why not?
|
16
20
|
def initialize( type, name=nil,
|
17
|
-
|
21
|
+
internal_type: nil,
|
22
|
+
components: nil ) ## note: type goes first!!!
|
18
23
|
@type = type
|
19
24
|
## note: convert empty string "" to nil - why? why not?
|
20
25
|
@name = if name && name.empty?
|
@@ -27,20 +32,31 @@ class Param
|
|
27
32
|
else
|
28
33
|
internal_type
|
29
34
|
end
|
35
|
+
@components = components
|
30
36
|
end
|
31
37
|
|
32
38
|
|
33
39
|
def sig
|
34
|
-
|
35
|
-
|
40
|
+
@sig ||= begin
|
41
|
+
if @components
|
42
|
+
## replace tuple with (type,...)
|
43
|
+
## e.g. tuple[] becomes (type,...)[] etc.
|
44
|
+
tuple = @components.map {|c| c.sig }.join(',')
|
45
|
+
@type.sub( "tuple", "(#{tuple})" )
|
46
|
+
else
|
47
|
+
"#{@type}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
@sig
|
36
51
|
end
|
37
52
|
|
53
|
+
|
38
54
|
def doc
|
39
55
|
buf = ''
|
40
|
-
if @internal_type && @internal_type !=
|
56
|
+
if @internal_type && @internal_type != sig
|
41
57
|
buf << "#{@internal_type} "
|
42
58
|
else
|
43
|
-
buf << "#{
|
59
|
+
buf << "#{sig} "
|
44
60
|
end
|
45
61
|
buf << (@name ? @name : '_')
|
46
62
|
buf
|
@@ -48,10 +64,10 @@ class Param
|
|
48
64
|
|
49
65
|
def decl
|
50
66
|
buf = ''
|
51
|
-
buf << "#{
|
67
|
+
buf << "#{sig} "
|
52
68
|
buf << (@name ? @name : '_')
|
53
69
|
## use inline comment - why? why not?
|
54
|
-
if @internal_type && @internal_type !=
|
70
|
+
if @internal_type && @internal_type != sig
|
55
71
|
buf << " /* #{@internal_type} */"
|
56
72
|
end
|
57
73
|
buf
|
data/lib/abiparser/version.rb
CHANGED
data/lib/abiparser.rb
CHANGED
@@ -37,8 +37,10 @@ end
|
|
37
37
|
|
38
38
|
|
39
39
|
|
40
|
+
|
40
41
|
## our own code
|
41
42
|
require_relative 'abiparser/version' # note: let version always go first
|
43
|
+
|
42
44
|
require_relative 'abiparser/param'
|
43
45
|
require_relative 'abiparser/constructor'
|
44
46
|
require_relative 'abiparser/function'
|
@@ -46,7 +48,7 @@ require_relative 'abiparser/utils'
|
|
46
48
|
require_relative 'abiparser/contract'
|
47
49
|
require_relative 'abiparser/interface'
|
48
50
|
|
49
|
-
require_relative 'abiparser/export/interface
|
51
|
+
require_relative 'abiparser/export/interface'
|
50
52
|
|
51
53
|
|
52
54
|
|
@@ -121,9 +123,6 @@ module ABI
|
|
121
123
|
end # module ABI
|
122
124
|
|
123
125
|
|
124
|
-
## add convenience alternate spellings - why? why not?
|
125
|
-
Abi = ABI
|
126
|
-
|
127
126
|
|
128
|
-
puts
|
127
|
+
puts ABIParser.banner
|
129
128
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abiparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocos
|