Skip to content

Commit

Permalink
[fix] plugins, opabsl: test for undefineds, small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthuraa committed Aug 22, 2012
1 parent 7b7ab20 commit b5f7556
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/opabsl/jsbsl/bslClientOnly.js
Expand Up @@ -331,7 +331,7 @@ var load_js_files = {}
##args(element)
{
var handler = element.opa_insertion;
if (handler != undefined){
if (typeof handler != 'undefined'){
delete(element.opa_insertion);
while(handler.length > 0) handler.pop()();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/plugins/opabsl/jsbsl/bslClosure.js
Expand Up @@ -83,7 +83,7 @@ global = this;
##args(str)
{
var f = global[str];
return (f != undefined) && f.distant || false
return (typeof f != 'undefined') && f.distant || false
}
function set_distant(str, b)
Expand All @@ -104,7 +104,7 @@ function get_closure_name(closure) {
var tmp;
// opa - see type Closure.info
tmp = closure.info ;
if (tmp != undefined) return tmp.closure_name;
if (typeof tmp != 'undefined') return tmp.closure_name;
// chrome
tmp = closure.name;
Expand All @@ -118,7 +118,7 @@ function get_closure_name(closure) {
##args(closure)
{
var info = closure.info;
if (info != undefined) {
if (typeof info != 'undefined') {
return js_some(info);
} else {
var name = get_closure_name(closure);
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/opabsl/jsbsl/bslDom.js
Expand Up @@ -707,6 +707,7 @@ function bsldom_unbind(dom, handler)

//Export a callback
function export_cb(a){
var undefined;
return a ? function () { a(this) } : undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/opabsl/jsbsl/bslDomSupport.js
Expand Up @@ -17,7 +17,7 @@
##register support_placeholder : -> bool
##args()
{
return document.createElement('input').placeholder !== undefined
return typeof document.createElement('input').placeholder != 'undefined';
}

##register support_notification: -> bool
Expand Down
8 changes: 4 additions & 4 deletions lib/plugins/opabsl/jsbsl/bslValue.js
Expand Up @@ -102,7 +102,7 @@ var xmlizer_tbl = {}
##args(k)
{
var r = to_string_tbl[k];
if(r==undefined) return js_none;
if(typeof r == 'undefined') return js_none;
else return js_some(r);
}

Expand All @@ -116,7 +116,7 @@ var xmlizer_tbl = {}
##args(k)
{
var r = compare_tbl[k];
if(r==undefined) return js_none;
if(typeof r == 'undefined') return js_none;
else return js_some(r);
}

Expand All @@ -130,7 +130,7 @@ var xmlizer_tbl = {}
##args(k)
{
var r = serializer_tbl[k];
if(r==undefined) return js_none;
if(typeof r == 'undefined') return js_none;
else return js_some(r);
}

Expand All @@ -144,7 +144,7 @@ var xmlizer_tbl = {}
##args(k)
{
var r = xmlizer_tbl[k];
if(r==undefined) return js_none;
if(typeof r == 'undefined') return js_none;
else return js_some(r);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/opabsl/jsbsl/jQueryExtends.js
Expand Up @@ -50,7 +50,7 @@ var div = document.createElement( "div" );


// Opa overload replacement
(function($){
(function($, undefined){
var jq_bind = $.fn.bind;
var jq_unbind = $.fn.unbind;
var jq_keydown= $.fn.keydown;
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/opabsl/jsbsl/jsExtends.js
Expand Up @@ -87,6 +87,7 @@ if (!Array.prototype.reduce)
**/
Array.prototype.reduce = function(fun /*, initialValue */)
{
var undefined;
"use strict";

if (this === void 0 || this === null)
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/opabsl/jsbsl/json2.js
Expand Up @@ -417,7 +417,7 @@ if (!this.JSON) {
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
if (typeof v != 'undefined') {
value[k] = v;
} else {
delete value[k];
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/opabsl/nodejsbsl/bslBinary.nodejs
Expand Up @@ -348,8 +348,8 @@ var FLOATMAX32 = 3.402823466e38;
##args(b, start, length)
//function get_binary(b, start, length)
{
if (start === undefined) start = 0;
if (length === undefined) length = b.length;
if (typeof start == 'undefined') start = 0;
if (typeof length == 'undefined') length = b.length;
if (start < 0 || start >= b.length || length < 0) return {contents:new Buffer(0), length:0};
var end = (b.length < start + length) ? b.length : start + length;
var len = end - start;
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/opabsl/nodejsbsl/bslLogger.nodejs
Expand Up @@ -111,7 +111,7 @@ var tty = require('tty');
}

function pc(i) {
if (i === null || i === undefined) return "??";
if (i === null || typeof i == 'undefined') return "??";
var s = (i % 100).toString();
switch (s.length) {
case 0: return "00";
Expand Down
26 changes: 17 additions & 9 deletions lib/plugins/opabsl/nodejsbsl/bslNumber.nodejs
Expand Up @@ -182,7 +182,7 @@ var max_int = Math.pow(2, 53);

/* Debug code
function to_hex_(i) {
if (i === undefined) return "undefind";
if (typeof i == 'undefined') return "undefind";
var s = i.toString(16);
while (s.length < 8) s = "0"+s;
return s;
Expand Down Expand Up @@ -531,7 +531,8 @@ function qr64(N, D) {
var err = "Int64.of_string: number too large for int64";
for (var i = 0; i < s.length; i++) {
var dig = tab[s[i]];
if (dig === undefined || dig >= radix) throw ("Int64.of_string: bad digit "+dig);
if (typeof dig == 'undefined' || dig >= radix)
throw ("Int64.of_string: bad digit "+dig);
x = adde(mule(x, {h:0, l:radix}, err), {h:0, l:dig}, err);
}
return x;
Expand Down Expand Up @@ -884,8 +885,10 @@ function a2s(a) {
}

function s2a(s,start,length) {
start = (start === undefined) ? 0 : start;
end = (length === undefined) ? s.length : (start + length > s.length) ? s.length : start + length;
start = (typeof start == 'undefined') ? 0 : start;
var end =
(typeof length == 'undefined') ? s.length :
(start + length > s.length) ? s.length : start + length;
var a = new Array(end - start - 1);
for (var i = start, j = 0; i < end; i++, j++) { a[j] = uncode(s[i]) };
return a;
Expand All @@ -899,17 +902,22 @@ function clen(c) {
}

function slen(s,start,length) {
var size = 0;
start = (start === undefined) ? 0 : start;
end = (length === undefined) ? s.length : (start + length > s.length) ? s.length : start + length;
var size = 0, i;
start = (typeof start == 'undefined') ? 0 : start;
var end =
(typeof length == 'undefined') ? s.length :
(start + length > s.length) ? s.length : start + length;
for (i = start; i < end; size += clen(s.charCodeAt(i++)));
return size;
}

// This routine flattens out unicode characters, "\uabcd" -> <Buffer ab cd>
function s2bj(s,start,length,b,j) {
start = (start === undefined) ? 0 : start;
end = (length === undefined) ? s.length : (start + length > s.length) ? s.length : start + length;
start = (typeof start == 'undefined') ? 0 : start;
var end =
(typeof length == 'undefined') ? s.length :
(start + length > s.length) ? s.length : start + length;
var i;
for (i = start; i < end; i++) {
var c = s.charCodeAt(i);
if (c >= 0 && c <= 0xff) {
Expand Down
18 changes: 9 additions & 9 deletions lib/plugins/opabsl/nodejsbsl/hashtable.nodejs
Expand Up @@ -10,13 +10,13 @@
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
function Hashtable(hash, equal){
if(hash!=undefined){
if(typeof hash != 'undefined'){
this.hash = hash
} else {
this.hash = function(x){return x}
}

if(equal!=undefined){
if(typeof equal != 'undefined'){
this.equal = equal;
} else {
this.equal = function(x, y){return x==y}
Expand All @@ -36,7 +36,7 @@ Hashtable.prototype.put = function(key, value){
var entries = this.entries;
var h = this.hash(key);
var x = entries[h];
if(x == undefined){
if(typeof x == 'undefined'){
entries[h] = [{key:key, value:value}];
this.size++;
return;
Expand All @@ -57,7 +57,7 @@ Hashtable.prototype.get = function(key){
var entries = this.entries;
var h = this.hash(key);
var x = entries[h];
if(x == undefined){
if(typeof x == 'undefined'){
return;
}
for(var i in x){
Expand All @@ -73,7 +73,7 @@ Hashtable.prototype.remove = function(key){
var entries = this.entries;
var h = this.hash(key);
var x = entries[h];
if(x == undefined){
if(typeof x == 'undefined'){
return;
}
for(var i in x){
Expand All @@ -89,7 +89,7 @@ Hashtable.prototype.remove = function(key){
}

Hashtable.prototype.containsKey = function(key){
return (this.get(key) != undefined);
return (typeof this.get(key) != 'undefined');
}

Hashtable.prototype.values = function(){
Expand All @@ -116,7 +116,7 @@ SimpleTable.prototype.clear = function(){
}
SimpleTable.prototype.put = function(key, value){
var prev = this.entries[key];
if(prev==undefined) this.size++;
if (typeof prev == 'undefined') this.size++;
this.entries[key]=value;
return;
}
Expand All @@ -125,11 +125,11 @@ SimpleTable.prototype.get = function(key){
}
SimpleTable.prototype.remove = function(key){
var x = this.entries[key];
if (x != undefined) this.size--;
if (typeof x != 'undefined') this.size--;
delete this.entries[key];
}
SimpleTable.prototype.containsKey = function(key){
return (this.get(key) != undefined);
return (typeof this.get(key) != 'undefined');
}
SimpleTable.prototype.values = function(){
var ret = new Array(this.size);
Expand Down

0 comments on commit b5f7556

Please sign in to comment.