-
Notifications
You must be signed in to change notification settings - Fork 0
chore: setting up skeleton and adapting ci for go #2
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| .idea | ||
| cmake-build-* | ||
| **/build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| [submodule "3rd/googletest"] | ||
| path = 3rd/googletest | ||
| url = git@github.com:google/googletest.git | ||
| [submodule "spec"] | ||
| path = spec | ||
| url = git@github.com:CollaborativeStateMachines/Spec.git | ||
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| .PHONY: test build clean run | ||
|
|
||
| test: | ||
| go test ./... | ||
|
|
||
| build: | ||
| @mkdir -p build/casem | ||
| go build -o build/casem/casem ./cmd/casem.go | ||
|
|
||
| clean: | ||
| rm -rf build | ||
|
|
||
| run: test build | ||
| ./build/casem/casem |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Casem | ||
|
|
||
| ## Project Strucutre | ||
|
|
||
| ```bash | ||
| Casem/ | ||
| ├── ATTRIBUTION.md | ||
| ├── cmd | ||
| │ └── casem.go # Application Entry Point | ||
| ├── CONTRIBUTING.md | ||
| ├── CONTRIBUTORS | ||
| ├── csm # Public CSM Package: Defines API to implement CSM via Go | ||
| ├── go.mod | ||
| ├── internal # Internal Application Logic | ||
| ├── LICENSE | ||
| ├── Makefile | ||
| ├── README.md | ||
| └── spec # Language Specification | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package main | ||
|
|
||
| import "fmt" | ||
|
|
||
| func main() { | ||
| fmt.Println("Hello Casem") | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package csm | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "strings" | ||
| ) | ||
|
|
||
| type ContextVariable interface { | ||
| String() string | ||
| } | ||
|
|
||
| type typedVariable[T any] struct { | ||
| name string | ||
| value T | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably have to adapt this later. |
||
| } | ||
|
|
||
| func NewContextVariable[T any](name string, value T) (ContextVariable, error) { | ||
| if strings.TrimSpace(name) == "" { | ||
| return nil, errors.New("name cannot be blank") | ||
| } | ||
| return &typedVariable[T]{ | ||
| name: name, | ||
| value: value, | ||
| }, nil | ||
| } | ||
|
|
||
| func (cv *typedVariable[T]) String() string { | ||
| if cv == nil { | ||
| return "<nil>" | ||
| } | ||
| return fmt.Sprintf("ContextVariable(name=%q, value=%+v)", cv.name, cv.value) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package csm | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestNewContextVariable(t *testing.T) { | ||
| _, err := NewContextVariable("a", 1) | ||
| if err != nil { | ||
| t.Errorf("Expected no error but received: %v", err) | ||
| } | ||
| _, err = NewContextVariable("", 1) | ||
| if err == nil { | ||
| t.Errorf("Expected error but received: %v", err) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package csm | ||
|
|
||
| import "fmt" | ||
|
|
||
| type EventChannel int | ||
|
|
||
| const ( | ||
| Internal EventChannel = iota | ||
| External | ||
| Peripheral | ||
| ) | ||
|
|
||
| type Event struct { | ||
| Topic string | ||
| Channel EventChannel | ||
| Data []ContextVariable | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because event serialization may become messy here. |
||
| Target string | ||
| Source string | ||
| } | ||
|
|
||
| type ConditionalEvent struct { | ||
| Event | ||
| Provided Expression | ||
| } | ||
|
|
||
| func (c EventChannel) String() string { | ||
| switch c { | ||
| case Internal: | ||
| return "Internal" | ||
| case External: | ||
| return "External" | ||
| case Peripheral: | ||
| return "Peripheral" | ||
| default: | ||
| return fmt.Sprintf("UnknownChannel(%d)", c) | ||
| } | ||
| } | ||
|
|
||
| func (e Event) String() string { | ||
| return fmt.Sprintf("Event(topic=%q, channel=%s, target=%q, source=%q)", | ||
| e.Topic, e.Channel, e.Target, e.Source) | ||
| } | ||
|
|
||
| func (e ConditionalEvent) String() string { | ||
| return fmt.Sprintf("ConditionalEvent(provided=%q, event=%+v)", e.Provided, e.Event) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package csm | ||
|
|
||
| import "fmt" | ||
|
|
||
| type Expression string | ||
|
|
||
| func (e Expression) String() string { | ||
| return fmt.Sprintf("expression=%v", string(e)) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module github.com/CollaborativeStateMachines/Casem | ||
|
|
||
| go 1.26.5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| package util |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
Please pin to a commit hash.