Skip to content

Commit

Permalink
Merge pull request #45 from 200sc/release/v0.6.0
Browse files Browse the repository at this point in the history
Release/v0.6.0
  • Loading branch information
200sc committed Mar 21, 2024
2 parents e846d30 + a0b9faa commit a7281a0
Show file tree
Hide file tree
Showing 41 changed files with 2,324 additions and 616 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.20"
go-version: "1.21"

- name: Build
run: go build -v ./...
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ Please raise issues for discussion before opening PRs (or ideally before startin
just to save time if its not the direction we want to take the project.

For small changes (anywhere from typos to non-breaking bug fixes) going straight to a PR is fine, but not required.

## Testing

This library is organized so `go test -v` will test tokenization, parsing, code generation, and the validity of the output generated code. Output code is validated via some integrated tests, and by relying on `go test` itself checking that output can be compiled.

If an example file fails tokenization, it can be added to `testTokenizeFiles` to track that failure and prevent regressions. Likewise for parsing, `TestReadFile` notes expected parsing output. Adding a variant that just ensures a file -can- be parsed, not ensuring a particular AST, is a welcome augmentation.

For generated code, add the example file to `generated/base` and add it's name, minus `.bop`, to `genTestFiles`.
2 changes: 1 addition & 1 deletion bebop.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package bebop

// Version is the library version. Should be used by CLI tools when passed a '--version' flag.
const Version = "v0.5.0"
const Version = "v0.6.0"

// A File is a structured representation of a .bop file.
type File struct {
Expand Down
4 changes: 2 additions & 2 deletions gen_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ const (
hintSafeKey = "&safe"

fmtErrReturn = "if err != nil {\n\treturn err\n}"
fmtAddSizeToAt = "tmp := (%ASGN)\nat += tmp.Size()"
fmtAddSizeToAt = "{\n\ttmp := (%ASGN)\n\tat += tmp.Size()\n}\n"
fmtAdd4PlusLenToAt = "at += 4 + len(%ASGN)"
fmtAddSizeToBodyLen = "tmp := (%ASGN)\nbodyLen += tmp.Size()"
fmtAddSizeToBodyLen = "{\n\ttmp := (%ASGN)\n\tbodyLen += tmp.Size()\n}\n"
fmtAdd4PlusLenToBodyLen = "bodyLen += 4 + len(%ASGN)"

fmtMakeType = "(%RECV), err = Make%TYPE(r)\n" + fmtErrReturn
Expand Down
1 change: 1 addition & 0 deletions gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ var genTestFiles = []string{
"documentation",
"enums",
"foo",
"fruit",
"jazz",
"lab",
"map_types",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/200sc/bebop

go 1.20
go 1.21
10 changes: 10 additions & 0 deletions testdata/base/fruit.bop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
struct Fruit {
uint64 ID;
string Name;
}

struct Basket {
Fruit Apples;
Fruit Oranges;
Fruit Mangos;
}
28 changes: 20 additions & 8 deletions testdata/generated-always-pointers/foo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

259 changes: 259 additions & 0 deletions testdata/generated-always-pointers/fruit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a7281a0

Please sign in to comment.