2009/dap/ReSpec.js/js respec.js,1.106,1.107

Update of /sources/public/2009/dap/ReSpec.js/js
In directory hutz:/tmp/cvs-serv7477/js

Modified Files:
	respec.js 
Log Message:
fixing the handling of exception fields

Index: respec.js
===================================================================
RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- respec.js	13 Apr 2010 10:51:51 -0000	1.106
+++ respec.js	13 Apr 2010 11:15:09 -0000	1.107
@@ -1220,12 +1220,72 @@
         for (var i = 0; i < dts.length; i++) {
             var dt = dts[i];
             var dd = dt.nextElementSibling; // we take a simple road
-            var mem = this.interfaceMember(dt, dd);
+            var mem;
+            if (obj.type == "exception") {
+                mem = this.exceptionMember(dt, dd);
+            }
+            else {
+                mem = this.interfaceMember(dt, dd);
+            }
             obj.children.push(mem);
         }
         this.parent = exParent;
     },
     
+    parseConst:    function (mem, str) {
+        // CONST
+        var match = /^\s*const\s+\b([^=]+\??)\s+([^=\s]+)\s*=\s*(.*)$/.exec(str);
+        if (match) {
+            mem.type = "constant";
+            var type = match[1];
+            mem.nullable = false;
+            if (/\?$/.test(type)) {
+                type = type.replace(/\?$/, "");
+                mem.nullable = true;
+            }
+            mem.datatype = type;
+            mem.id = match[2];
+            mem.refId = this._id(mem.id);
+            mem.value = match[3];
+            return true;
+        }
+        return false;
+    },
+    
+    exceptionMember:    function (dt, dd) {
+        var mem = { children: [] };
+        var str = this._norm(dt.textContent);
+        mem.description = sn.documentFragment();
+        sn.copyChildren(dd, mem.description);
+        str = this.parseExtendedAttributes(str, mem);
+    
+        if (this.parseConst(mem, str)) return mem;
+
+        // FIELD
+        var match = /^\s*(.*?)\s+(\S+)\s*$/.exec(str);
+        if (match) {
+            mem.type = "field";
+            var type = match[1];
+            mem.nullable = false;
+            if (/\?$/.test(type)) {
+                type = type.replace(/\?$/, "");
+                mem.nullable = true;
+            }
+            mem.array = false;
+            if (/\[\]$/.test(type)) {
+                type = type.replace(/\[\]$/, "");
+                mem.array = true;
+            }
+            mem.datatype = type;
+            mem.id = match[2];
+            mem.refId = this._id(mem.id);
+            return mem;
+        }
+
+        // NOTHING MATCHED
+        error("Expected interface member, got: " + str);
+    },
+    
     interfaceMember:    function (dt, dd) {
         var mem = { children: [] };
         var str = this._norm(dt.textContent);
@@ -1299,22 +1359,7 @@
             return mem;
         }
             
-        // CONST
-        match = /^\s*const\s+\b([^=]+\??)\s+([^=\s]+)\s*=\s*(.*)$/.exec(str);
-        if (match) {
-            mem.type = "constant";
-            var type = match[1];
-            mem.nullable = false;
-            if (/\?$/.test(type)) {
-                type = type.replace(/\?$/, "");
-                mem.nullable = true;
-            }
-            mem.datatype = type;
-            mem.id = match[2];
-            mem.refId = this._id(mem.id);
-            mem.value = match[3];
-            return mem;
-        }
+        if (this.parseConst(mem, str)) return mem;
             
         // METHOD
         match = /^\s*\b(.*?)\s+\b(\S+)\s*\(\s*(.*)\s*\)\s*$/.exec(str);
@@ -1513,7 +1558,59 @@
             }
             return sn.element("div", { "class": "idlImplementsDesc" }, null, cnt);
         }
-        else if (obj.type == "interface" || obj.type == "exception") {
+
+        else if (obj.type == "exception") {
+            var df = sn.documentFragment();
+            var curLnk = "widl-" + obj.refId + "-";
+            var types = ["field", "constant"];
+            for (var i = 0; i < types.length; i++) {
+                var type = types[i];
+                var things = obj.children.filter(function (it) { return it.type == type });
+                if (things.length == 0) continue;
+                if (!this.noIDLSorting) {
+                    things.sort(function (a, b) {
+                        if (a.id < b.id) return -1;
+                        if (a.id > b.id) return 1;
+                          return 0;
+                    });
+                }
+                
+                var sec = sn.element("section", {}, df);
+                var secTitle = type;
+                secTitle = secTitle.substr(0, 1).toUpperCase() + secTitle.substr(1) + "s";
+                sn.element("h2", {}, sec, secTitle);
+                var dl = sn.element("dl", { "class": type + "s" }, sec);
+                for (var j = 0; j < things.length; j++) {
+                    var it = things[j];
+                    var dt = sn.element("dt", { id: curLnk + it.refId }, dl);
+                    sn.element("code", {}, dt, it.id);
+                    var desc = sn.element("dd", {}, dl, [it.description]);
+                    if (type == "field") {
+                        sn.text(" of type ", dt);
+                        if (it.array) sn.text("array of ", dt);
+                        var span = sn.element("span", { "class": "idlFieldType" }, dt);
+                        var matched = /^sequence<(.+)>$/.exec(it.datatype);
+                        if (matched) {
+                            sn.text("sequence<", span);
+                            sn.element("a", {}, span, matched[1]);
+                            sn.text(">", span);
+                        }
+                        else {
+                            sn.element("a", {}, span, it.datatype);
+                        }
+                        if (it.nullable) sn.text(", nullable", dt);
+                    }
+                    else if (type == "constant") {
+                        sn.text(" of type ", dt);
+                        sn.element("span", { "class": "idlConstType" }, dt, [sn.element("a", {}, null, it.datatype)]);
+                        if (it.nullable) sn.text(", nullable", dt);
+                    }
+                }
+            }
+            return df;
+        }
+
+        else if (obj.type == "interface") {
             var df = sn.documentFragment();
             var curLnk = "widl-" + obj.refId + "-";
             var types = ["attribute", "method", "constant"];

Received on Tuesday, 13 April 2010 11:15:12 UTC