古灵精怪

以前一直很惊叹解析DOC的quirks模式,居然能在如此多错误的情况下容错,保持健壮。但最近看看Macromedia公司的AS2官方类库,才更为惊叹AS脚本解析器的容错能力;
代码里面一堆堆错误,硬是能够正常跑起来,结果放到Eclipse下,一大堆报错,类库编译都通不过,用FDT+Aswing随便个小东西就得改一大堆的错误才能运行,随便举几个例子:
以下摘抄都是官方公布类库:
Directory:
Documents and SettingsAdministratorLocal SettingsApplication DataMacromediaFlash 8zh_cnConfigurationClasses
例一、类型不匹配
不过ASv1本身就是弱类型的,所以不算太错,但Number-Date真不知运行的时候为啥不会错,因为确实没找到转换函数
mxservicesWSDL.as

if (src != undefined)
{
var start = new Date();
this.wsdl.log.logInfo("Received WSDL document from the remote service", Log.VERBOSE);
this.parseXML(src);
this.loaded = true;
//加入此行,真不知 Math.round(new Date().getMilliseconds())错在哪里T T
var end = new Date();
//106 var parseTime = Math.round(new Date()) - start;
var parseTime = Math.round((end.getMilliseconds()) - start.getMilliseconds());
this.wsdl.log.logInfo("Parsed WSDL XML [" + parseTime + " millis]", Log.VERBOSE);
}

例二、变量名重复定义
例三、缺少结尾分号
mxservicesWebServiceProxy.as

// Shut off the __resolve
this.service.__resolve = function(operationName) {
var callback = new PendingCall();
callback.genSingleConcurrencyFault = function()
{
clearInterval(this.timerID); // only once
//192对应例二 var fault = new SOAPFault("Client.NoSuchMethod",
var innerFault = new SOAPFault("Client.NoSuchMethod", "Couldn't find method '" + operationName + "' in service!");
this.__handleFault(innerFault);
this.onFault(innerFault);
//197对应例三
};
callback["timerID"] = setInterval(function() { callback.genSingleConcurrencyFault(); }, 50); // 5 ms
return callback;
};

例四、相等与赋值乱用
mxservicesWSDL.as

// per WSDL 1.1 spec, if message is not named default to op Name plus suffix by mode:
if (message.name == undefined)
{
if (mode == SOAPConstants.MODE_IN)
{
message.name = operationName + "Request";
}
else
{
//598message.name == operationName + "Response";
message.name = operationName + "Response";
}
}

例五、不知为何
mxservicesNameSpace.as

//18
static var _doc = new XML();
//65不知为何必须使用this来访问static成员,反正少了编不过
var node = this._doc.createTextNode(value);

《古灵精怪》上有1条评论

  1. typedef map<u_int32_t, RTPServer *, less<u_int32_t>,shm_allocator<pair<shm_string, RTPServer *> > > server_addr_map;

    这堆东西在g++ 3.4 & 2.95 下都是很正常滴 =。=

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据