You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`--rust-types-custom-str-impl`: Used to specify a comma-separated list of type names that should not have string conversion code generated as it will be provided by custom implementations provided by the developer using the generated code.
19
+
If you're building a new code generator, the preferred way to provide a code
20
+
generator to xdrgen is to use it as a library. See below for examples for how
21
+
to do so.
49
22
50
23
## Usage as a library
51
24
@@ -57,36 +30,57 @@ gem 'xdrgen'
57
30
58
31
And then execute:
59
32
60
-
$ bundle
33
+
```
34
+
$ bundle
35
+
```
61
36
62
37
Example usage:
63
38
64
39
```ruby
65
40
require'xdrgen'
66
41
67
-
# create a compilation object, specifying your options
42
+
classGenerator < Xdrgen::Generators::Base
43
+
defgenerate
44
+
out =@output.open("#{@namespace}.rs")
45
+
# Use @top to access the top of the AST.
46
+
# Use @options to access any options passed via the compile.
47
+
# Use out.puts to write code.
48
+
end
49
+
end
68
50
69
-
c =Xdrgen::Compilation.new(
51
+
Xdrgen::Compilation.new(
70
52
["MyProgram.x"],
71
53
output_dir:"src/generated",
72
-
language::ruby,
54
+
generator:Generator,
73
55
namespace:"MyProgram::XDR",
74
-
options: {
75
-
rust_types_custom_str_impl: [],
76
-
rust_types_custom_jsonschema_impl: [],
77
-
},
78
-
)
56
+
options: { }, # any option your generator needs
57
+
).compile
58
+
```
79
59
80
-
# then run compile
60
+
## Usage as a binary (legacy)
81
61
82
-
c.compile
62
+
Xdrgen is a rubygem, compatible with ruby 2.1 or higher
0 commit comments