Commit | Line | Data |
---|---|---|
ffc1074f LC |
1 | Bigloo 4.0b removes `xml-attribute-encode', which leads to a build failure |
2 | in Hop. | |
3 | ||
4 | This patch allows Hop to be compiled with Bigloo 4.0b. | |
5 | ||
6 | ||
7 | changeset: 3327:3515f7f1aef2 | |
8 | branch: 2.4.x | |
9 | user: Manuel Serrano <Manuel.Serrano@inria.fr> | |
10 | date: Wed Jul 31 12:41:10 2013 +0200 | |
11 | summary: Fix serialization bug | |
12 | ||
13 | diff -r 7244c4d30ad4 -r 3515f7f1aef2 runtime/js_comp.scm | |
14 | --- a/runtime/js_comp.scm Fri Jul 19 08:28:13 2013 +0200 | |
15 | +++ b/runtime/js_comp.scm Wed Jul 31 12:41:10 2013 +0200 | |
16 | @@ -143,10 +143,17 @@ | |
17 | (display "{ " op) | |
18 | (display-seq fields op | |
19 | (lambda (f op) | |
20 | + (let ((iv (class-field-info f))) | |
21 | (display "'" op) | |
22 | (display (class-field-name f) op) | |
23 | (display "': " op) | |
24 | - (compile ((class-field-accessor f) obj) op))) | |
25 | + (cond | |
26 | + ((and (pair? iv) (memq :client iv)) | |
27 | + => | |
28 | + (lambda (x) | |
29 | + (compile (when (pair? (cdr x)) (cadr x)) op))) | |
30 | + (else | |
31 | + (compile ((class-field-accessor f) obj) op)))))) | |
32 | (display "}" op)) | |
33 | ||
34 | (let ((klass (object-class obj))) | |
35 | diff -r 7244c4d30ad4 -r 3515f7f1aef2 runtime/xml.scm | |
36 | --- a/runtime/xml.scm Fri Jul 19 08:28:13 2013 +0200 | |
37 | +++ b/runtime/xml.scm Wed Jul 31 12:41:10 2013 +0200 | |
38 | @@ -55,6 +55,7 @@ | |
39 | (generic xml-write-attribute ::obj ::obj ::output-port ::xml-backend) | |
40 | (generic xml-write-expression ::obj ::output-port) | |
41 | (xml-write-attributes ::pair-nil ::output-port ::xml-backend) | |
42 | + (xml-attribute-encode obj) | |
43 | ||
44 | (xml->string ::obj ::xml-backend) | |
45 | ||
46 | @@ -613,6 +614,52 @@ | |
47 | (display ">" p)))) | |
48 | ||
49 | ;*---------------------------------------------------------------------*/ | |
50 | +;* xml-attribute-encode ... */ | |
51 | +;*---------------------------------------------------------------------*/ | |
52 | +(define (xml-attribute-encode obj) | |
53 | + (if (not (string? obj)) | |
54 | + obj | |
55 | + (let ((ol (string-length obj))) | |
56 | + (define (count str ol) | |
57 | + (let loop ((i 0) | |
58 | + (j 0)) | |
59 | + (if (=fx i ol) | |
60 | + j | |
61 | + (let ((c (string-ref str i))) | |
62 | + ;; attribute values should escape &#... | |
63 | + (if (or (char=? c #\') (char=? c #\&)) | |
64 | + (loop (+fx i 1) (+fx j 5)) | |
65 | + (loop (+fx i 1) (+fx j 1))))))) | |
66 | + (define (encode str ol nl) | |
67 | + (if (=fx nl ol) | |
68 | + obj | |
69 | + (let ((nstr (make-string nl))) | |
70 | + (let loop ((i 0) | |
71 | + (j 0)) | |
72 | + (if (=fx j nl) | |
73 | + nstr | |
74 | + (let ((c (string-ref str i))) | |
75 | + (case c | |
76 | + ((#\') | |
77 | + (string-set! nstr j #\&) | |
78 | + (string-set! nstr (+fx j 1) #\#) | |
79 | + (string-set! nstr (+fx j 2) #\3) | |
80 | + (string-set! nstr (+fx j 3) #\9) | |
81 | + (string-set! nstr (+fx j 4) #\;) | |
82 | + (loop (+fx i 1) (+fx j 5))) | |
83 | + ((#\&) | |
84 | + (string-set! nstr j #\&) | |
85 | + (string-set! nstr (+fx j 1) #\#) | |
86 | + (string-set! nstr (+fx j 2) #\3) | |
87 | + (string-set! nstr (+fx j 3) #\8) | |
88 | + (string-set! nstr (+fx j 4) #\;) | |
89 | + (loop (+fx i 1) (+fx j 5))) | |
90 | + (else | |
91 | + (string-set! nstr j c) | |
92 | + (loop (+fx i 1) (+fx j 1)))))))))) | |
93 | + (encode obj ol (count obj ol))))) | |
94 | + | |
95 | +;*---------------------------------------------------------------------*/ | |
96 | ;* xml-write-attributes ... */ | |
97 | ;*---------------------------------------------------------------------*/ | |
98 | (define (xml-write-attributes attr p backend) | |
99 | diff -r 7244c4d30ad4 -r 3515f7f1aef2 share/hop-serialize.js | |
100 | --- a/share/hop-serialize.js Fri Jul 19 08:28:13 2013 +0200 | |
101 | +++ b/share/hop-serialize.js Wed Jul 31 12:41:10 2013 +0200 | |
102 | @@ -942,7 +942,7 @@ | |
103 | case 0x2e /* . */: return null; | |
104 | case 0x3c /* < */: return read_cnst(); | |
105 | case 0x22 /* " */: return read_string( s ); | |
106 | - case 0x25 /* " */: return decodeURIComponent( read_string( s ) ); | |
107 | + case 0x25 /* % */: return decodeURIComponent( read_string( s ) ); | |
108 | case 0x55 /* U */: return read_string( s ); | |
109 | case 0x5b /* [ */: return read_vector( read_size( s ) ); | |
110 | case 0x28 /* ( */: return read_list( read_size( s ) ); | |
111 | diff -r 7244c4d30ad4 -r 3515f7f1aef2 src/main.scm | |
112 | --- a/src/main.scm Fri Jul 19 08:28:13 2013 +0200 | |
113 | +++ b/src/main.scm Wed Jul 31 12:41:10 2013 +0200 | |
114 | @@ -59,8 +59,6 @@ | |
115 | (for-each register-srfi! (cons 'hop-server (hop-srfis))) | |
116 | ;; set the library load path | |
117 | (bigloo-library-path-set! (hop-library-path)) | |
118 | - ;; define the Hop macros | |
119 | - (hop-install-expanders!) | |
120 | ;; setup the hop readers | |
121 | (bigloo-load-reader-set! hop-read) | |
122 | (bigloo-load-module-set! |