-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils-objects.r
108 lines (90 loc) · 1.99 KB
/
utils-objects.r
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
rebol [
title: "object manipulation"
file: %utils-objects.r
version: 1.0.0
date: 2020-06-04
author: "Maxim Olivier-Adlhoch"
; -- slim - Library Manager --
slim-name: 'utils-objects
slim-version: 1.4.0
slim-prefix: none
]
;--------------------------------------
; unit testing setup
;--------------------------------------
;
; test-enter-slim 'utils-objects
;
;--------------------------------------
slim/register [
;--------------------------
;- literally()
;--------------------------
; purpose:
;
; inputs:
;
; returns:
;
; notes:
;
; to do:
;
; tests:
;--------------------------
literally: funcl [
"returns a block with which you can rebuild an object, fixes lit-word datatype"
object "the object you want the specification for"
/no-func {do not include any functions in the specification.
this is usefull to template objects which have methods,
for which you do not want to duplicate code in ram.
This also allows you to reimport old data while keeping newer methods}
/ignore ignore-list[block!]{do not include the words in this list}
][
blk: third object
forall blk [
item: first blk
if word! = (type? first blk) [
if not (value? item) [
change blk to-lit-word item
]
]
; do we strip functions from the specification?
if no-func [
if function! = (type? first blk) [
blk: back blk
remove/part blk 2
]
]
]
;probe head blk
;probe ignore-list
; ignore list
if ignore [
blk: head blk
while [ not tail? blk ] [
;print "^/---"
item: first blk
;probe item
either find ignore-list to-word item [
;print ["removed"]
remove/part blk 2
;probe blk
; blk: back blk
][
; skip every other value
blk: skip blk 2
]
]
]
;ask""
return head blk
]
]
;------------------------------------
; We are done testing this library.
;------------------------------------
;
; test-exit-slim
;
;------------------------------------