-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for specification overloads #107
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ef683c5
Ignoring GoLand directory
dertseha 5545d4d
first attempt at providing overloads
dertseha 65398df
reading overload information from an XML file
dertseha ffa35d5
added example overloads file
dertseha c90bbed
allowing parameter names to be changed as well
dertseha fc28c39
removed debug printfs
dertseha b2aad41
removed obsolete attributes
dertseha 65d743f
using fixed suffix "WithOffset" for example overloads
dertseha 8dda71e
renamed List member to Overloads
dertseha 6d57b8a
extracted single function getter
dertseha 9664fe7
removed unnecessary Name field from Overload
dertseha e338703
added test for signature parsing
dertseha f28200d
changed type change description for overloads to use c defintions
dertseha 9ba163d
extended readme about overload function
dertseha 8a40325
Updated wording to be more explicit about overloads
dertseha 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 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 |
---|---|---|
|
@@ -32,3 +32,6 @@ wgl | |
# Vim | ||
*.swp | ||
*.swo | ||
|
||
# GoLand | ||
.idea/ |
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,53 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/xml" | ||
"os" | ||
) | ||
|
||
type xmlOverloads struct { | ||
List []xmlOverload `xml:"overload"` | ||
dertseha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
type xmlOverload struct { | ||
Name string `xml:"name,attr"` | ||
OverloadName string `xml:"overloadName,attr"` | ||
|
||
ParameterChanges []xmlParameterChange `xml:"parameterChanges>change"` | ||
} | ||
|
||
type xmlParameterChange struct { | ||
// Index is the zero-based index of the parameter list. | ||
Index int `xml:"index,attr"` | ||
// Name describes a change of the parameter name. | ||
Name *xmlNameChange `xml:"name"` | ||
// Type describes a change of the parameter type. | ||
Type *xmlTypeChange `xml:"type"` | ||
} | ||
|
||
type xmlNameChange struct { | ||
Value string `xml:"value,attr"` | ||
} | ||
|
||
type xmlTypeChange struct { | ||
Name string `xml:"name,attr"` | ||
PointerLevel int `xml:"pointerLevel,attr"` | ||
dertseha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func readOverloadFile(file string) (xmlOverloads, error) { | ||
var overloads xmlOverloads | ||
|
||
_, err := os.Stat(file) | ||
if err != nil { | ||
return overloads, nil | ||
} | ||
|
||
f, err := os.Open(file) | ||
if err != nil { | ||
return overloads, err | ||
} | ||
defer f.Close() | ||
|
||
err = xml.NewDecoder(f).Decode(&overloads) | ||
return overloads, err | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func TestGoType(t *testing.T) { | ||
tt := []struct { | ||
in Type | ||
expected string | ||
}{ | ||
{ | ||
in: Type{ | ||
Name: "uintptr_t", | ||
PointerLevel: 1, | ||
CDefinition: "uintptr_t*", | ||
Cast: "void *", | ||
}, | ||
expected: "*uintptr", | ||
}, | ||
} | ||
|
||
for _, tc := range tt { | ||
tc := tc | ||
t.Run(tc.in.String(), func(t *testing.T) { | ||
goType := tc.in.GoType() | ||
if goType != tc.expected { | ||
t.Errorf("expected <%s>, got <%s>", tc.expected, goType) | ||
} | ||
}) | ||
} | ||
} |
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,26 @@ | ||
<overloads> | ||
<overload name="glDrawElements" overloadName="DrawElementsWithOffset"> | ||
<parameterChanges> | ||
<change index="3"> | ||
<type name="uintptr_t" pointerLevel="0" /> | ||
</change> | ||
</parameterChanges> | ||
</overload> | ||
|
||
<overload name="glVertexAttribPointer" overloadName="VertexAttribPointerWithOffset"> | ||
<parameterChanges> | ||
<change index="5"> | ||
<name value="offset" /> | ||
<type name="uintptr_t" pointerLevel="0" /> | ||
</change> | ||
</parameterChanges> | ||
</overload> | ||
<overload name="glGetVertexAttribPointerv" overloadName="GetVertexAttribPointerWithOffsetv"> | ||
<parameterChanges> | ||
<change index="2"> | ||
<name value="offset" /> | ||
<type name="uintptr_t" pointerLevel="2" /> | ||
</change> | ||
</parameterChanges> | ||
</overload> | ||
</overloads> |
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.
could this value be pulled from the parent struct? similarly for Name?
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.
Name
turned out not to be necessary. As forGoName
, I was not able to figure out an easy way to accessGoName
from the parent from the sub-templateoverloadCall
. Hence I kept this field