Menu

[r744]: / phprpc_3.0 / asp / compat.js  Maximize  Restore  History

Download this file

116 lines (108 with data), 4.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**********************************************************\
| |
| The implementation of PHPRPC Protocol 3.0 |
| |
| compat.js |
| |
| Release 3.0.1 |
| Copyright: by Team-PHPRPC |
| |
| WebSite: http://www.phprpc.org/ |
| http://www.phprpc.net/ |
| http://www.phprpc.com/ |
| http://sourceforge.net/projects/php-rpc/ |
| |
| Authors: Ma Bingyao <andot@ujn.edu.cn> |
| |
| This file may be distributed and/or modified under the |
| terms of the GNU General Public License (GPL) version |
| 2.0 as published by the Free Software Foundation and |
| appearing in the included file LICENSE. |
| |
\**********************************************************/
/* Provides some VBScript helper codes.
*
* Copyright: Ma Bingyao <andot@ujn.edu.cn>
* Version: 3.0
* LastModified: Apr 12, 2010
* This library is free. You can redistribute it and/or modify it under GPL.
*/
function IsDictionary(o) {
return ((o != null) &&
(typeof(o) == "object") &&
(o instanceof ActiveXObject) &&
(typeof(o.Add) == "unknown") &&
(typeof(o.Exists) == "unknown") &&
(typeof(o.Items) == "unknown") &&
(typeof(o.Keys) == "unknown") &&
(typeof(o.Remove) == "unknown") &&
(typeof(o.RemoveAll) == "unknown") &&
(typeof(o.Count) == "number") &&
(typeof(o.Item) == "unknown") &&
(typeof(o.Key) == "unknown"));
}
function IsVBArray(o) {
return ((o != null) &&
(typeof(o) == "unknown") &&
(o.constructor == VBArray) &&
(typeof(o.dimensions) == "function") &&
(typeof(o.getItem) == "function") &&
(typeof(o.lbound) == "function") &&
(typeof(o.toArray) == "function") &&
(typeof(o.ubound) == "function"));
}
function DictionaryToObject(dict) {
var array, i, result;
array = (new VBArray(dict.Keys())).toArray();
result = {};
for (i in array) {
if (IsDictionary(dict(array[i]))) {
result[array[i]] = DictionaryToObject(dict(array[i]));
}
else if (IsVBArray(dict(array[i]))) {
result[array[i]] = VBArrayToJSArray(dict(array[i]));
}
else {
result[array[i]] = dict(array[i]);
}
}
return result;
}
function ObjectToDictionary(object) {
var key, result;
result = new ActiveXObject("Scripting.Dictionary");
for (key in object) {
result.Add(key, object[key]);
}
return result;
}
function VBArrayToJSArray(vbArray) {
function toJSArray(vbarray, dimension, indices) {
var rank = vbarray.dimensions();
if (rank > dimension) {
indices[dimension] = 0;
dimension++;
}
var lb = vbarray.lbound(dimension);
var ub = vbarray.ubound(dimension);
var jsarray = [];
for (var i = lb; i <= ub; i++) {
indices[dimension - 1] = i;
if (rank == dimension) {
jsarray[i] = vbarray.getItem.apply(vbarray, indices);
}
else {
jsarray[i] = toJSArray(vbarray, dimension, indices);
}
}
return jsarray;
}
var vbarray = new VBArray(vbArray);
if (vbarray.dimensions() == 1 && vbarray.lbound() == 0) {
return vbarray.toArray();
}
return toJSArray(vbarray, 0, []);
}
function JSArrayToVBArray(jsarray) {
return ObjectToDictionary(jsarray).Items();
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.