Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add to JS backend conversion between JavaScript objects and associati…

…on lists.
  • Loading branch information...
commit 78831debd954ca5fdcb0b8d5a7781bc89f295beb 1 parent 815cf3d
@feeley authored
Showing with 24 additions and 3 deletions.
  1. +22 −1 gsc/_t-univ.scm
  2. +2 −2 include/stamp.h
View
23 gsc/_t-univ.scm
@@ -2961,7 +2961,13 @@ function Gambit_js2scm(obj) {
if (obj instanceof Array) {
return obj.map(Gambit_js2scm);
} else {
- throw "Gambit_js2scm error";
+ var alist = null;
+ for (var key in obj) {
+ alist = new Gambit_Pair(new Gambit_Pair(Gambit_js2scm(key),
+ Gambit_js2scm(obj[key])),
+ alist);
+ }
+ return alist;
}
} else {
throw "Gambit_js2scm error";
@@ -2986,6 +2992,20 @@ function Gambit_scm2js(obj) {
return obj.toString();
} else if (obj instanceof Gambit_Flonum) {
return obj.val;
+ } else if (obj instanceof Gambit_Pair) {
+ var jsobj = {};
+ var i = 0;
+ while (obj instanceof Gambit_Pair) {
+ var elem = obj.car;
+ if (elem instanceof Gambit_Pair) {
+ jsobj[Gambit_scm2js(elem.car)] = Gambit_scm2js(elem.cdr);
+ } else {
+ jsobj[i] = Gambit_scm2js(elem);
+ }
+ ++i;
+ obj = obj.cdr;
+ }
+ return jsobj;
} else {
throw "Gambit_scm2js error";
}
@@ -3080,6 +3100,7 @@ EOF
(need-feature 'strtocodes)
(need-feature 'String)
(need-feature 'Flonum)
+ (need-feature 'Pair)
(need-feature 'ffi)
(for-each need-feature
View
4 include/stamp.h
@@ -2,5 +2,5 @@
* Time stamp of last source code repository commit.
*/
-#define ___STAMP_YMD 20140218
-#define ___STAMP_HMS 152752
+#define ___STAMP_YMD 20140219
+#define ___STAMP_HMS 43208
Please sign in to comment.
Something went wrong with that request. Please try again.