Add initial filds to the builder
This commit is contained in:
parent
c2c95ea130
commit
57bb9ba17c
4
examples/empty_omp.omp
Normal file
4
examples/empty_omp.omp
Normal file
@ -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))
|
183
examples/simple_bpc.omp
Normal file
183
examples/simple_bpc.omp
Normal file
@ -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
|
||||
)
|
||||
)
|
9
pkg/types/omp/bpc.go
Normal file
9
pkg/types/omp/bpc.go
Normal file
@ -0,0 +1,9 @@
|
||||
package omp
|
||||
|
||||
type BPC struct {
|
||||
|
||||
}
|
||||
|
||||
func (s BPC) Init() {
|
||||
|
||||
}
|
20
pkg/types/omp/header.go
Normal file
20
pkg/types/omp/header.go
Normal file
@ -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)
|
||||
}
|
21
pkg/types/omp/header_test.go
Normal file
21
pkg/types/omp/header_test.go
Normal file
@ -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)
|
||||
}
|
||||
|
||||
}
|
37
pkg/types/omp/omp.go
Normal file
37
pkg/types/omp/omp.go
Normal file
@ -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))")
|
||||
}
|
23
pkg/types/omp/omp_test.go
Normal file
23
pkg/types/omp/omp_test.go
Normal file
@ -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)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user