Additional support for arrays of doubles
authorPat Thoyts <patthoyts@users.sourceforge.net>
Thu, 18 Jun 2009 01:53:26 +0000 (02:53 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Thu, 18 Jun 2009 01:53:26 +0000 (02:53 +0100)
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
src/TclObject.cpp

index 3ef5112615b6451eae1d20065ec726b7f49e887a..39aef5c0ea3658ff84d4d43cfe578a0c806e7de0 100644 (file)
@@ -213,7 +213,19 @@ convertFromSafeArray (
         if (FAILED(hr)) {
             _com_issue_error(hr);
         }
-
+    } else if (elementType == VT_R8) {
+        double *dataPtr = NULL;
+        Tcl_Obj *listObj = Tcl_NewListObj(0, NULL);
+        hr = SafeArrayAccessData(psa, reinterpret_cast<void **>(&dataPtr));
+        if (SUCCEEDED(hr)) {
+           for (long n = lowerBound; SUCCEEDED(hr) && n <= upperBound; ++n, ++dataPtr) {
+               Tcl_Obj *eltObj = Tcl_NewDoubleObj(*dataPtr);
+               Tcl_ListObjAppendElement(interp, listObj, eltObj);
+           }
+           SafeArrayUnaccessData(psa);
+        }
+        if (FAILED(hr)) _com_issue_error(hr);
+       pResult = listObj;
     } else {
         // Create list of Tcl values.
         pResult = Tcl_NewListObj(0, 0);