interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / apps / interplane-forge / collab / coJjson.om

755 lines · 10526 bytes Raw Blame History
1note collab/coJjson.om (ForgePatches): the JSON form of the patch and issue pages (docs/API.md):
2note forge/patches/1 and forge/issues/1 for the lists, forge/patch/1 and forge/issue/1 for one COB. Same
3note loading, validation and statuses as the HTML handlers; every link is the href the HTML page builds.
4note Pool text (titles, descriptions, bodies) is the raw markdown source, written by cojp without the
5note 64 KiB cap of fjt; ill-formed UTF-8 becomes U+FFFD as in fjstr.
6text tcjrep "\\ufffd"
7text tcjsps "forge/patches/1"
8text tcjsis "forge/issues/1"
9text tcjsp "forge/patch/1"
10text tcjsi "forge/issue/1"
11text tcjsts "states"
12text tcjcnt "count"
13text tcjpath "path"
14text tcjtr "truncated"
15text tcjpats "patches"
16text tcjisss "issues"
17text tcjtitl "title"
18text tcjauth "author"
19text tcjupd "updated"
20text tcjrevs "revisions"
21text tcjcoms "comments"
22text tcjverd "verdict"
23text tcjname "name"
24text tcjdid "did"
25text tcjopen "opened"
26text tcjdesc "description"
27text tcjlabs "labels"
28text tcjasg "assignees"
29text tcjbld "forged_commit"
30text tcjmrgs "merges"
31text tcjact "activity"
32text tcjdiff "diff"
33text tcjnum "number"
34text tcjred "redacted"
35text tcjbase "base"
36text tcjhead "head"
37text tcjtime "time"
38text tcjrev "revision"
39text tcjcmt "commit"
40text tcjtype "type"
41text tcjbody "body"
42text tcjraw "raw"
43text tcjreas "reason"
44text tcjtrvw "review"
45text tcjtcom "comment"
46text tcjtmrg "merge"
47global gcjn ulong 1
48note ---- JSON strings from gcpool (UTF-8 checked like fjulen, but on gcpool[i, e))
49fn cojc i ulong e ulong to bool
50if ge i e
51ret false
52end
53c = get gcpool i
54ret and ge c 128 le c 191
55end
56fn coju3 i ulong e ulong c uchar to ulong
57if not cojc add i 1 e
58ret 0
59end
60if not cojc add i 2 e
61ret 0
62end
63d = get gcpool add i 1
64if and eq c 224 lt d 160
65ret 0
66end
67if and eq c 237 gt d 159
68ret 0
69end
70ret 3
71end
72fn coju4 i ulong e ulong c uchar to ulong
73if not cojc add i 1 e
74ret 0
75end
76if not cojc add i 2 e
77ret 0
78end
79if not cojc add i 3 e
80ret 0
81end
82d = get gcpool add i 1
83if and eq c 240 lt d 144
84ret 0
85end
86if and eq c 244 gt d 143
87ret 0
88end
89ret 4
90end
91fn cojul i ulong e ulong to ulong
92c = get gcpool i
93if lt c 128
94ret 1
95end
96if and ge c 194 le c 223
97if cojc add i 1 e
98ret 2
99end
100ret 0
101end
102if and ge c 224 le c 239
103ret coju3 i e c
104end
105if and ge c 240 le c 244
106ret coju4 i e c
107end
108ret 0
109end
110note cojp o n: gcpool[o, o+n) as one JSON string
111fn cojp o ulong n ulong to void
112fputc 34
113e = add o n
114i = o
115while lt i e bound 4194304
116l = cojul i e
117if eq l 0
118fput tcjrep
119i = add i 1
120continue
121end
122if eq l 1
123fjasc get gcpool i
124i = add i 1
125continue
126end
127for k ulong l bound 4
128fputc get gcpool add i k
129end
130i = add i l
131end
132fputc 34
133end
134note cojlst k: the ", "-joined list in gcpool at gcm k/k+1 (labels 3, assignees 5) as an array of strings
135fn cojlst k ulong to void
136fputc 91
137o = get gcm k
138e = add o get gcm add k 1
139s = o
140i = o
141while lt i e bound 4194304
142if eq get gcpool i 44
143if lt add i 1 e
144if eq get gcpool add i 1 32
145cojp s sub i s
146fputc 44
147i = add i 2
148s = i
149continue
150end
151end
152end
153i = add i 1
154end
155if gt e o
156cojp s sub e s
157end
158fputc 93
159end
160note ---- small pieces
161fn cojq to void
162fputc 34
163end
164fn cojnum r ulong to void
165if lt r 64
166fnum add r 1
167ret
168end
169fynull
170end
171fn cojkn t view uchar * to void
172fyk t
173fynull
174end
175note cojsn kd s: the state as a JSON string of its ?state= value; cojsv the bare value
176fn cojsn kd ulong s ulong to void
177cojq
178cojsv kd s
179cojq
180end
181fn cojsv kd ulong s ulong to void
182if eq s 9
183fput tcall
184end
185if eq s 0
186fput tcopen
187end
188if eq s 1
189fput tcdraft
190end
191if eq s 3
192fput tcmerged
193end
194if eq s 2
195if eq kd 1
196fput tcarch
197else
198fput tcclosed
199end
200end
201ret
202end
203note cojaun ow / cojaup ow: open an author object with its name, and close it with its link
204fn cojaun ow bool to void
205fputc 123
206fyk0 tcjname
207if ow
208cojq
209fput tfowner
210cojq
211else
212fynull
213end
214fyk tcjdid
215end
216fn cojaup ow bool to void
217fyk tcjpath
218if ow
219cojq
220fputb
221fput tfowner
222cojq
223else
224fynull
225end
226fputc 125
227end
228note cojcau ci: the author of change ci (coauth): {"name","did","path"}
229fn cojcau ci ulong to void
230ow = coisown ci
231cojaun ow
232fjtb
233for k ulong len tcdidk
234fjtc get tcdidk k
235end
236for k ulong get gccal ci bound 64
237fjtc get gccau add mul ci 64 k
238end
239fjstr
240cojaup ow
241end
242note ---- list pages
243fn cojlist kd ulong to long
244if eq coldata kd false
245ret 500
246end
247put gcm 9 kd
248f = coqstate kd
249if and eq kd 2 or eq f 1 eq f 3
250f = ulong 0
251end
252if eq kd 1
253fyrhead tcjsps
254else
255fyrhead tcjsis
256end
257fyk tcstn
258cojsn kd f
259fyk tcjsts
260cojtabs kd
261fyk tcjtr
262fybool gt get gcun 0 200
263if eq kd 1
264fyk tcjpats
265else
266fyk tcjisss
267end
268cojrows kd f
269fyk tcnwr
270cojq
271fputrl
272if eq kd 1
273fput tcpatp
274else
275fput tcissp
276end
277fput tcnwr
278cojq
279fputc 10
280fyend
281ret 200
282end
283note cojtabs kd: the filter links in HTML order (cotabs)
284fn cojtabs kd ulong to void
285fputc 91
286cojtab kd 0 false
287if eq kd 1
288cojtab kd 1 true
289cojtab kd 3 true
290cojtab kd 2 true
291else
292cojtab kd 2 true
293end
294cojtab kd 9 true
295fputc 93
296end
297fn cojtab kd ulong s ulong c bool to void
298if c
299fputc 44
300end
301fputc 123
302fyk0 tcstn
303cojsn kd s
304fyk tcjcnt
305cotabn kd s
306fyk tcjpath
307cojq
308fputrl
309if eq kd 1
310fput tcpats
311else
312fput tcisss
313end
314fput tcstq
315cojsv kd s
316cojq
317fputc 125
318end
319fn cojrows kd ulong f ulong to void
320fputc 91
321m = ulong 0
322for i ulong get gcsn 0
323if or eq f 9 eq f get gcss i
324if gt m 0
325fputc 44
326end
327fputc 10
328cojrow kd i
329m = add m 1
330end
331end
332fputc 93
333end
334fn cojrow kd ulong i ulong to void
335coidref get gcsr i
336fputc 123
337fyk0 tcid
338cojq
339coidh 40
340cojq
341fyk tcjtitl
342fjtb
343o = get gcst mul i 2
344for k ulong get gcst add mul i 2 1 bound 300
345fjtc get gclp add o k
346end
347fjstr
348fyk tcstn
349cojsn kd get gcss i
350fyk tcjauth
351cojlau i
352cojrow2 kd i
353end
354fn cojrow2 kd ulong i ulong to void
355fyk tcjupd
356fjiso get gcsu i
357if eq kd 1
358fyk tcjrevs
359fnum get gcsc i
360end
361fyk tcjcoms
362fnum get gcsk i
363fyk tcjverd
364n = get gcsvl i
365if eq n 0
366fynull
367else
368fjtb
369for k ulong n bound 128
370fjtc get gcsv add mul i 128 k
371end
372fjstr
373end
374fyk tcjpath
375cojq
376coplink kd
377cojq
378fputc 125
379end
380fn cojlau i ulong to void
381n = get gcsal i
382ow = false
383if eq n len tfnid
384ow = cosaown i
385end
386cojaun ow
387fjtb
388for k ulong len tcdidk
389fjtc get tcdidk k
390end
391for k ulong n bound 64
392fjtc get gcsau add mul i 64 k
393end
394fjstr
395cojaup ow
396end
397note ---- one patch (copatpg)
398fn cojpat to long
399if eq corefs 1 false
400ret 500
401end
402if eq coresolve false
403ret 404
404end
405if eq coload 1 false
406ret 404
407end
408if ne get gcov 0 0
409fincut
410ret 500
411end
412fyrhead tcjsp
413cojhead 1 costate
414fyk tcjdesc
415if eq get gcrn 0 0
416cojq
417cojq
418else
419cojp get gcrd 0 get gcrd 1
420end
421cojmeta
422fyk tcjbld
423if cobldok tcbldc
424cojq
425fput tcbldc
426cojq
427else
428fynull
429end
430fyk tcjrevs
431cojrevs
432fyk tcjmrgs
433cojmrgs
434fyk tcjact
435cojact
436fyk tcjdiff
437cojdiff coqrev
438fputc 10
439fyend
440ret 200
441end
442note cojhead kd s: id, title, state, author, opened, path of the loaded COB
443fn cojhead kd ulong s ulong to void
444fyk tcid
445cojq
446coidh 40
447cojq
448fyk tcjtitl
449cojp get gcm 0 get gcm 1
450fyk tcstn
451cojsn kd s
452fyk tcjauth
453cojcau 0
454fyk tcjopen
455fjiso get gccts 0
456fyk tcjpath
457cojq
458coplink kd
459cojq
460end
461fn cojmeta to void
462fyk tcjlabs
463cojlst 3
464fyk tcjasg
465cojlst 5
466end
467fn cojrevs to void
468fputc 91
469for r ulong get gcrn 0
470if gt r 0
471fputc 44
472end
473fputc 10
474cojrev r
475end
476fputc 93
477end
478fn cojrev r ulong to void
479fputc 123
480fyk0 tcjnum
481fnum add r 1
482fyk tcid
483cojq
484corhex r 40
485cojq
486fyk tcjpath
487cojq
488copatl
489coidh 40
490fput tcrq
491corhex r 40
492fput tcrfrag
493cojq
494fyk tcjred
495fybool eq get gcrx r 1
496cojrev2 r
497end
498fn cojrev2 r ulong to void
499fyk tcjbase
500cojq
501cobhex r 40
502cojq
503fyk tcjhead
504cojq
505cohhex r 40
506cojq
507ci = get gcrt r
508fyk tcjauth
509cojcau ci
510fyk tcjtime
511fjiso get gccts ci
512fyk tcjverd
513cojrv r
514fputc 125
515end
516fn cojrv r ulong to void
517n = get gcrvl r
518if eq n 0
519fynull
520ret
521end
522fjtb
523for k ulong n bound 256
524fjtc get gcrvd add mul r 256 k
525end
526fjstr
527end
528fn cojmrgs to void
529fputc 91
530for m ulong get gcmn 0
531if gt m 0
532fputc 44
533end
534fputc 123
535fyk0 tcjrev
536fnum add get gcmr m 1
537fyk tcjcmt
538cojq
539comhex m 40
540cojq
541ci = get gcmt m
542fyk tcjauth
543cojcau ci
544fyk tcjtime
545fjiso get gccts ci
546fputc 125
547end
548fputc 93
549end
550note ---- activity (copact): every change in order; each item has the same keys
551fn cojact to void
552put gcjn 0 0
553fputc 91
554for ci ulong get gccn 0
555cojactc ci
556end
557fputc 93
558end
559fn cojactc ci ulong to void
560for r ulong get gcrn 0
561if eq get gcrt r ci
562cojarev ci r
563end
564end
565for w ulong get gcwn 0
566if eq get gcwt w ci
567cojarvw ci w
568end
569end
570for q ulong get gcqn 0
571if eq get gcqt q ci
572cojacom ci q
573end
574end
575for m ulong get gcmn 0
576if eq get gcmt m ci
577cojamrg ci m
578end
579end
580end
581note cojah ty ci: open an activity item: type, author, time, and the "revision" key
582fn cojah ty view uchar * ci ulong to void
583n = get gcjn 0
584if gt n 0
585fputc 44
586end
587put gcjn 0 add n 1
588fputc 10
589fputc 123
590fyk0 tcjtype
591cojq
592fput ty
593cojq
594fyk tcjauth
595cojcau ci
596fyk tcjtime
597fjiso get gccts ci
598fyk tcjrev
599end
600fn cojarev ci ulong r ulong to void
601if eq r 0
602cojah tcopen ci
603else
604cojah tcjrev ci
605end
606fnum add r 1
607fyk tcjhead
608cojq
609cohhex r 40
610cojq
611cojkn tcjcmt
612cojkn tcjverd
613cojkn tcjbody
614fyk tcjred
615fybool eq get gcrx r 1
616fputc 125
617end
618fn cojarvw ci ulong w ulong to void
619cojah tcjtrvw ci
620cojnum get gcwr w
621cojkn tcjhead
622cojkn tcjcmt
623fyk tcjverd
624v = get gcwv w
625if eq v 0
626fynull
627else
628cojq
629if eq v 1
630fput tcaccept
631else
632fput tcreject
633end
634cojq
635end
636fyk tcjbody
637cojp get gcws mul w 2 get gcws add mul w 2 1
638fyk tcjred
639fybool false
640fputc 125
641end
642fn cojacom ci ulong q ulong to void
643cojah tcjtcom ci
644cojnum get gcqr q
645cojkn tcjhead
646cojkn tcjcmt
647cojkn tcjverd
648cojbody q
649fputc 125
650end
651note cojbody q: "body" (null when redacted) and "redacted" of comment q
652fn cojbody q ulong to void
653fyk tcjbody
654x = eq get gcqx q 1
655if x
656fynull
657else
658cojp get gcqs mul q 2 get gcqs add mul q 2 1
659end
660fyk tcjred
661fybool x
662end
663fn cojamrg ci ulong m ulong to void
664cojah tcjtmrg ci
665cojnum get gcmr m
666cojkn tcjhead
667fyk tcjcmt
668cojq
669comhex m 40
670cojq
671cojkn tcjverd
672cojkn tcjbody
673fyk tcjred
674fybool false
675fputc 125
676end
677note cojdiff r: the revision whose changes the page shows (coqrev), with the raw diff link; null when none
678fn cojdiff r ulong to void
679if gt r 63
680fynull
681ret
682end
683fputc 123
684fyk0 tcjrev
685fnum add r 1
686fyk tcid
687cojq
688corhex r 40
689cojq
690fyk tcjbase
691cojq
692cobhex r 40
693cojq
694fyk tcjhead
695cojq
696cohhex r 40
697cojq
698fyk tcjraw
699cojq
700copatl
701coidh 40
702fput tcdsuf
703fput tcrq
704corhex r 40
705cojq
706fputc 125
707end
708note ---- one issue (coisspg)
709fn cojiss to long
710if eq corefs 2 false
711ret 500
712end
713if eq coresolve false
714ret 404
715end
716if eq coload 2 false
717ret 404
718end
719if ne get gcov 0 0
720fincut
721ret 500
722end
723fyrhead tcjsi
724cojhead 2 get gcm 2
725fyk tcjreas
726if gt get gcm 8 0
727cojp get gcm 7 get gcm 8
728else
729fynull
730end
731cojmeta
732fyk tcjcoms
733fputc 91
734for q ulong get gcqn 0
735if gt q 0
736fputc 44
737end
738fputc 10
739cojicom q
740end
741fputc 93
742fputc 10
743fyend
744ret 200
745end
746fn cojicom q ulong to void
747ci = get gcqt q
748fputc 123
749fyk0 tcjauth
750cojcau ci
751fyk tcjtime
752fjiso get gccts ci
753cojbody q
754fputc 125
755end