-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnetfarm.lisp
74 lines (59 loc) · 2.11 KB
/
netfarm.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(eval-when (:compile-toplevel :load-toplevel :execute)
;; netfarm won't load if you don't have it on your path since it's
;; not on quicklisp the second quickload is harder to satisfy need
;; to grab a lot more software. The calls to some of the software
;; deadlocks so I've commented out related code.
;; (ql:quickload '(:serapeum :netfarm))
;; (ql:quickload '(:netfarm-client :netfarm-server))
)
(defpackage #:netfarm-playground
(:use :common-lisp :serapeum))
(in-package #:netfarm-playground)
(defclass foo-class ()
((a :initarg :a)
(b :initarg :b)
(c :initarg :c))
(:metaclass netfarm:netfarm-class))
(defmethod print-object ((obj foo-class) stream)
(flet ((bound (x)
(if (slot-boundp obj x) (slot-value obj x) "#<unbound>")))
(pprint-logical-block (stream nil)
(print-unreadable-object (obj stream :type t)
(format stream "~3I~_:a ~W ~_:b ~W ~_:c ~A"
(bound 'a)
(bound 'b)
(bound 'c))))))
(def foo-fields
(c2mop:class-slots (find-class 'foo-class)))
(def object-to-play
(make-instance 'foo-class
:a "This is A"
:b '("This" "is" 2)
:c #(1 2 3 4 5 6)))
(def rendered
(netfarm:render-object object-to-play))
(def parsed-into-data
(netfarm:parse-block rendered))
(def object-back
(netfarm:apply-class (netfarm:parse-block rendered)
(find-class 'foo-class)))
(def bigger-object
(make-instance
'foo-class
:a "Hi there"
:b nil
:c (make-instance 'foo-class
:a nil
:b "How are you?"
:c (make-instance 'foo-class
:a "I'm doing fine"
:b nil
:c nil))))
;; (defvar *system*
;; (make-instance 'netfarm-server:memory-system))
;; (decentralise-system:start-system *system*)
;; (defparameter *client*
;; (decentralise-client:connect-to-system *system*))
;; ;; lets start saving things
;; ;; Times out for me
;; (netfarm-client:save-object *client* bigger-object)