add some omp data to serde

This commit is contained in:
Nikolai Rodionov 2023-01-10 21:40:21 +01:00
parent 57bb9ba17c
commit 83debb7459
5 changed files with 193 additions and 3 deletions

172
examples/bpc_sliced.omp Normal file
View File

@ -0,0 +1,172 @@
(
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
)
)

View File

@ -6,4 +6,6 @@ type BPC struct {
func (s BPC) Init() {
}
}
// InitPatch()

View File

@ -4,6 +4,8 @@ type Header struct {
Data []byte
}
//TODO: It must be create dynamically for different kinds of entities (patch, maquette, etc)
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")

View File

@ -1,6 +1,9 @@
package omp
import "bytes"
import (
"bytes"
"fmt"
)
type OMP struct {
Header Header
@ -12,12 +15,14 @@ func (s OMP) Build() []byte {
buff.Write(s.Header.GetData())
buff.Write(s.Data.GetIntro())
buff.Write(s.Data.GetLibFor())
buff.Write(s.Data.GetOMCurrentPersistent())
return buff.Bytes()
}
type Data struct {
Intro []byte
LibFor []byte
CurrentPersistent []byte
}
func (s *Data) GetIntro() []byte {
@ -35,3 +40,11 @@ func (s *Data) GetLibFor() []byte {
func (s *Data) SetLibFor() {
s.LibFor = []byte("(load-lib-for (quote nil))")
}
func (s *Data) SetOMCurrentPersistent(kind string, name string) {
s.CurrentPersistent = []byte(fmt.Sprintf("(setf *om-current-persistent* (%s \"%s\" (quote nil) (quote nil) nil 6.19))", kind, name))
}
func (s *Data) GetOMCurrentPersistent() []byte{
return s.CurrentPersistent
}

View File

@ -8,12 +8,13 @@ import (
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))`
(in-package :om)(load-lib-for (quote nil))(setf *om-current-persistent* (om-load-patch1 "Test Patch" (quote nil) (quote nil) nil 6.19))`
func TestOmpBuilder(t *testing.T) {
header := &omp.OMP{}
header.Data.SetIntro()
header.Data.SetLibFor()
header.Data.SetOMCurrentPersistent("om-load-patch1", "Test Patch")
header.Header.Init()
str := string(header.Build())
if str != ompExample {