diff --git a/examples/empty_omp.omp b/examples/empty_omp.omp new file mode 100644 index 0000000..ea0067f --- /dev/null +++ b/examples/empty_omp.omp @@ -0,0 +1,4 @@ +; OM File Header - Saved 2022/12/29 14:43:16 +; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16") +; End File Header +(in-package :om)(load-lib-for (quote nil))(setf *om-current-persistent* (om-load-patch1 "Patch" (quote nil) (quote nil) nil 6.19)) diff --git a/examples/simple_bpc.omp b/examples/simple_bpc.omp new file mode 100644 index 0000000..1aa5131 --- /dev/null +++ b/examples/simple_bpc.omp @@ -0,0 +1,183 @@ +( + in-package :om +) + +( + load-lib-for + ( + quote nil + ) +) + +( + setf *om-current-persistent* + ( + om-load-patch1 "Patch 2" + ( + quote + ( + ( + let + ( + ( + box + ( + om-load-editor-box1 "BPC" + ( + quote bpc + ) + ( + quote + ( + ( + om-load-inputfun + ( + quote input-funbox + ) + "object" "self" nil + ) + ( + om-load-inputfun + ( + quote input-funbox + ) + "X coordinates (list)" "x-points" + ( + list 0 100 + ) + ) + ( + om-load-inputfun + ( + quote input-funbox + ) + "Y coordinates (list)" "y-points" + ( + list 0 100 + ) + ) + ( + om-load-inputfun + ( + quote input-funbox + ) + "precision + ( + integer + ) [0 - 10]" "decimals" 0 + ) + ) + ) + ( + om-make-point 151 96 + ) + ( + om-make-point 40 60 + ) + ( + let + ( + ( + newobj + ( + when + ( + find-class + ( + quote bpc + ) + nil + ) + ( + let + ( + ( + newbpf + ( + simple-bpf-from-list + ( + quote + ( + -1 99 70 + ) + ) + ( + quote + ( + 0 100 65 + ) + ) + ( + quote bpc + ) + 0 + ) + ) + ) + ( + setf + ( + bpfcolor newbpf + ) + ( + om-make-color 0 0 0 + ) + ) + ( + set-name newbpf "BPC" + ) + newbpf + ) + ) + ) + ) + ( + when newobj + ) + newobj + ) + "x" nil + ( + pairlis + ( + quote + ( + picture winpos winsize + ) + ) + ( + list nil + ( + om-make-point 0 0 + ) + ( + om-make-point 1900 1006 + ) + ) + ) + nil nil nil nil + ) + ) + ) + ( + when + ( + fboundp + ( + quote set-active + ) + ) + ( + set-active box nil + ) + ) + box + ) + ) + ) + ( + quote nil + ) + nil 6.19 + ) +) \ No newline at end of file diff --git a/main.go b/main.go index 93e3504..ca8e2e5 100644 --- a/main.go +++ b/main.go @@ -113,7 +113,7 @@ func main() { out, err := ioutil.ReadFile("/tmp/goids.yaml") if err != nil { - panic(err) + panic(err) } output := []OutPut{} err = yaml.Unmarshal(out, &output) diff --git a/pkg/types/omp/bpc.go b/pkg/types/omp/bpc.go new file mode 100644 index 0000000..39a8cbd --- /dev/null +++ b/pkg/types/omp/bpc.go @@ -0,0 +1,9 @@ +package omp + +type BPC struct { + +} + +func (s BPC) Init() { + +} \ No newline at end of file diff --git a/pkg/types/omp/header.go b/pkg/types/omp/header.go new file mode 100644 index 0000000..00b08e4 --- /dev/null +++ b/pkg/types/omp/header.go @@ -0,0 +1,20 @@ +package omp + +type Header struct { + Data []byte +} + +func (h *Header) Init() { + h.Data = []byte(`; OM File Header - Saved 2022/12/29 14:43:16 +; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16") +; End File Header +`) +} + +func (h *Header) GetData() []byte { + return h.Data +} + +func (h *Header) DataToString() string { + return string(h.Data) +} diff --git a/pkg/types/omp/header_test.go b/pkg/types/omp/header_test.go new file mode 100644 index 0000000..fdf6a9b --- /dev/null +++ b/pkg/types/omp/header_test.go @@ -0,0 +1,21 @@ +package omp_test + +import ( + "goids/pkg/types/omp" + "testing" +) + +const headerExample = `; OM File Header - Saved 2022/12/29 14:43:16 +; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16") +; End File Header +` + +func TestAbs(t *testing.T) { + header := &omp.Header{} + header.Init() + str := header.DataToString() + if str != headerExample { + t.Errorf("Header is wrong\nwant:\n%s \n\ngot \n%s", headerExample, str) + } + +} diff --git a/pkg/types/omp/omp.go b/pkg/types/omp/omp.go new file mode 100644 index 0000000..1c176a6 --- /dev/null +++ b/pkg/types/omp/omp.go @@ -0,0 +1,37 @@ +package omp + +import "bytes" + +type OMP struct { + Header Header + Data Data +} + +func (s OMP) Build() []byte { + buff := bytes.NewBufferString("") + buff.Write(s.Header.GetData()) + buff.Write(s.Data.GetIntro()) + buff.Write(s.Data.GetLibFor()) + return buff.Bytes() +} + +type Data struct { + Intro []byte + LibFor []byte +} + +func (s *Data) GetIntro() []byte { + return s.Intro +} + +func (s *Data) SetIntro() { + s.Intro = []byte("(in-package :om)") +} + +func (s *Data) GetLibFor() []byte { + return s.LibFor +} + +func (s *Data) SetLibFor() { + s.LibFor = []byte("(load-lib-for (quote nil))") +} diff --git a/pkg/types/omp/omp_test.go b/pkg/types/omp/omp_test.go new file mode 100644 index 0000000..9453daf --- /dev/null +++ b/pkg/types/omp/omp_test.go @@ -0,0 +1,23 @@ +package omp_test + +import ( + "goids/pkg/types/omp" + "testing" +) + +const ompExample = `; OM File Header - Saved 2022/12/29 14:43:16 +; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16") +; End File Header +(in-package :om)(load-lib-for (quote nil))` + +func TestOmpBuilder(t *testing.T) { + header := &omp.OMP{} + header.Data.SetIntro() + header.Data.SetLibFor() + header.Header.Init() + str := string(header.Build()) + if str != ompExample { + t.Errorf("Header is wrong\nwant:\n%s \n\ngot \n%s", ompExample, str) + } + +}