This repository was archived by the owner on Feb 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Fix Proc argument conversions when passing to binding #78
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
16d404c
split QObject::connect lambda into own Call::Body
HertzDevil aaf2cbf
use CrystalFromCpp to generate #on_X procs
HertzDevil a403961
Call::Result#apply_conversion
HertzDevil ab2db91
Bindgen::Template hierarchy
HertzDevil 3b4605b
specs for templates
HertzDevil 896f652
template for Proc conversion
HertzDevil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,88 @@ | ||
| require "../spec_helper" | ||
|
|
||
| describe "Template" do | ||
| describe ".from_string" do | ||
| it "constructs the no-op template from nil" do | ||
| Bindgen::Template.from_string(nil).should be_a(Bindgen::Template::None) | ||
| end | ||
|
|
||
| it "can construct a simple template from a string" do | ||
| Bindgen::Template.from_string("%x", simple: true).should eq( | ||
| Bindgen::Template::Simple.new("%x")) | ||
| end | ||
|
|
||
| it "can construct a full template from a string" do | ||
| expected = Bindgen::Template::Full.new("%x") | ||
| Bindgen::Template.from_string("%x").should eq(expected) | ||
| Bindgen::Template.from_string("%x", simple: false).should eq(expected) | ||
| end | ||
| end | ||
|
|
||
| describe "#no_op?" do | ||
| it "returns true for the no-op template" do | ||
| Bindgen::Template::None.new.no_op?.should be_true | ||
| end | ||
|
|
||
| it "returns false for any other templates" do | ||
| conversion1 = Bindgen::Template::Simple.new("%x") | ||
| conversion2 = Bindgen::Template::Full.new("%x") | ||
| conversion3 = Bindgen::Template::Seq.new(conversion1, conversion2) | ||
|
|
||
| conversion1.no_op?.should be_false | ||
| conversion2.no_op?.should be_false | ||
| conversion3.no_op?.should be_false | ||
| end | ||
| end | ||
|
|
||
| describe "#followed_by" do | ||
| it "composes two templates" do | ||
| conversion1 = Bindgen::Template::Simple.new("%x") | ||
| conversion2 = Bindgen::Template::Full.new("%x") | ||
| conversion3 = Bindgen::Template::Seq.new(conversion1, conversion2) | ||
|
|
||
| conversion1.followed_by(conversion2).should eq(conversion3) | ||
| end | ||
|
|
||
| it "is #no_op? only when both templates are #no_op?" do | ||
| op = Bindgen::Template::Simple.new("%x") | ||
| no = Bindgen::Template::None.new | ||
|
|
||
| op.followed_by(op).no_op?.should be_false | ||
| op.followed_by(no).no_op?.should be_false | ||
| no.followed_by(op).no_op?.should be_false | ||
| no.followed_by(no).no_op?.should be_true | ||
| end | ||
| end | ||
|
|
||
| describe "None#template" do | ||
| it "returns the code unmodified" do | ||
| Bindgen::Template::None.new.template("123").should eq("123") | ||
| end | ||
| end | ||
|
|
||
| describe "Simple#template" do | ||
| it "substitutes % with the supplied code" do | ||
| Bindgen::Template::Simple.new("a%b%c").template("123").should eq("a123b123c") | ||
| end | ||
|
|
||
| it "substitutes %% with %" do | ||
| Bindgen::Template::Simple.new("%%a%%%b%%%%c").template("123").should eq("%a%123b%%c") | ||
| end | ||
| end | ||
|
|
||
| describe "Full#template" do | ||
| it "follows Util.template rules for template substitution" do | ||
| key, value = ENV.first | ||
| Bindgen::Template::Full.new("%{#{key}}%").template("123").should eq("123#{value}123") | ||
| end | ||
| end | ||
|
|
||
| describe "Seq#template" do | ||
| it "composes two templates" do | ||
| first = Bindgen::Template::Simple.new("%_a") | ||
| second = Bindgen::Template::Simple.new("%_b") | ||
| conversion = Bindgen::Template::Seq.new(first: first, second: second) | ||
| conversion.template("c").should eq("c_a_b") | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mistake, will be fixed.