-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option for rust generator for custom str implementations for types (
#177)
- Loading branch information
1 parent
b405294
commit 64612a2
Showing
17 changed files
with
23,603 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
class Xdrgen::Generators::Base | ||
def initialize(top, output, namespace=nil) | ||
def initialize(top, output, namespace=nil, options={}) | ||
@top = top | ||
@output = output | ||
@namespace = namespace | ||
@options = options | ||
end | ||
|
||
def generate | ||
raise NotImplementedError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'spec_helper' | ||
|
||
describe Xdrgen::Generators::Rust do | ||
generator_fixture_paths.each do |path| | ||
it "can generate #{File.basename path}" do | ||
c = generate path, "" | ||
end | ||
|
||
it "can generate #{File.basename path} with custom str impls" do | ||
c = generate path, "_custom_str_impls", { | ||
rust_types_custom_str_impl: [ | ||
"Foo", | ||
"TestArray", | ||
"Color2", | ||
"UnionKey", | ||
"MyUnion", | ||
"HasOptions", | ||
"MyStruct", | ||
"LotsOfMyStructs", | ||
], | ||
} | ||
end | ||
end | ||
|
||
def generate(path, output_sub_path, options = {rust_types_custom_str_impl: []}) | ||
compilation = Xdrgen::Compilation.new( | ||
[path], | ||
output_dir: "#{SPEC_ROOT}/output/generator_spec_rust#{output_sub_path}/#{File.basename path}", | ||
language: "rust", | ||
namespace: "MyXDR", | ||
options: options, | ||
) | ||
compilation.compile | ||
compilation | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.