[limb-svn] r5800 - in 3.x/trunk/limb/js: js_tests/cases shared shared/Limb

svn at limb-project.com svn at limb-project.com
Fri May 4 14:16:28 MSD 2007


Author: pachanga
Date: 2007-05-04 14:16:28 +0400 (Fri, 04 May 2007)
New Revision: 5800
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5800

Removed:
   3.x/trunk/limb/js/shared/Limb/Classkit.js
   3.x/trunk/limb/js/shared/Limb/Exception.js
   3.x/trunk/limb/js/shared/Limb/Object.js
Modified:
   3.x/trunk/limb/js/js_tests/cases/classkit_test.html
   3.x/trunk/limb/js/js_tests/cases/exception_test.html
   3.x/trunk/limb/js/js_tests/cases/object_test.html
   3.x/trunk/limb/js/shared/Limb.js
   3.x/trunk/limb/js/shared/Limb/window.js
Log:
-- Classkit.js, Exception.js, Object.js merged into Limb.js

Modified: 3.x/trunk/limb/js/js_tests/cases/classkit_test.html
===================================================================
--- 3.x/trunk/limb/js/js_tests/cases/classkit_test.html	2007-05-04 09:35:51 UTC (rev 5799)
+++ 3.x/trunk/limb/js/js_tests/cases/classkit_test.html	2007-05-04 10:16:28 UTC (rev 5800)
@@ -8,9 +8,6 @@
   <script src="../lib/unittest.js" type="text/javascript"></script>
 
   <script src="../../shared/Limb.js" type="text/javascript"></script>
-  <script src="../../shared/Limb/Exception.js" type="text/javascript"></script>
-  <script src="../../shared/Limb/Classkit.js" type="text/javascript"></script>
-  <script src="../../shared/Limb/Object.js" type="text/javascript"></script>
 
   <link rel="stylesheet" href="../test.css" type="text/css" />
 </head>

Modified: 3.x/trunk/limb/js/js_tests/cases/exception_test.html
===================================================================
--- 3.x/trunk/limb/js/js_tests/cases/exception_test.html	2007-05-04 09:35:51 UTC (rev 5799)
+++ 3.x/trunk/limb/js/js_tests/cases/exception_test.html	2007-05-04 10:16:28 UTC (rev 5800)
@@ -8,8 +8,6 @@
   <script src="../lib/unittest.js" type="text/javascript"></script>
 
   <script src="../../shared/Limb.js" type="text/javascript"></script>
-  <script src="../../shared/Limb/Classkit.js" type="text/javascript"></script>
-  <script src="../../shared/Limb/Exception.js" type="text/javascript"></script>
   <script src="../../shared/Limb/Browser.js" type="text/javascript"></script>
   <link rel="stylesheet" href="../test.css" type="text/css" />
 </head>

Modified: 3.x/trunk/limb/js/js_tests/cases/object_test.html
===================================================================
--- 3.x/trunk/limb/js/js_tests/cases/object_test.html	2007-05-04 09:35:51 UTC (rev 5799)
+++ 3.x/trunk/limb/js/js_tests/cases/object_test.html	2007-05-04 10:16:28 UTC (rev 5800)
@@ -8,9 +8,6 @@
   <script src="../lib/unittest.js" type="text/javascript"></script>
 
   <script src="../../shared/Limb.js" type="text/javascript"></script>
-  <script src="../../shared/Limb/Exception.js" type="text/javascript"></script>
-  <script src="../../shared/Limb/Classkit.js" type="text/javascript"></script>
-  <script src="../../shared/Limb/Object.js" type="text/javascript"></script>
   <script src="../../shared/Limb/Browser.js" type="text/javascript"></script>
   <link rel="stylesheet" href="../test.css" type="text/css" />
 </head>

Deleted: 3.x/trunk/limb/js/shared/Limb/Classkit.js
===================================================================
--- 3.x/trunk/limb/js/shared/Limb/Classkit.js	2007-05-04 09:35:51 UTC (rev 5799)
+++ 3.x/trunk/limb/js/shared/Limb/Classkit.js	2007-05-04 10:16:28 UTC (rev 5800)
@@ -1,176 +0,0 @@
-/**
- * Limb Web Application Framework
- *
- * @link http://limb-project.com
- *
- * @copyright  Copyright &copy; 2004-2007 BIT
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- * @version    $Id$
- * @package    js
- */
-
-Limb.namespace('Limb.Classkit');
-
-Limb.require('Limb.Object');
-Limb.require('Limb.Exception');
-
-Limb.Classkit.createClass = function(body)
-{
-  var new_class = function()
-  {
-    if(Limb.is_function(this['parent']))
-      this.parent = Limb.Classkit.makeParentProxy(this, this.parent);
-
-    this.__construct.apply(this, arguments);
-  }
-
-  new_class.toString = Limb.Classkit.classToString;
-
-  Limb.Classkit.inherit(new_class, Limb.Object, body);
-
-  return new_class;
-}
-
-Limb.Classkit.createInterface = function(body)
-{
-  var new_interface = function()
-  {
-    throw new Limb.Exception('InterfaceException', 'Can not create instance of interface');
-  }
-
-  new_interface.toString = Limb.Classkit.interfaceToString;
-
-  Limb.Classkit.extendInterface(new_interface, body || null);
-
-  return new_interface;
-}
-
-Limb.Classkit.clone = function(target, source)
-{
-  for(var i in source)
-  {
-    if(Limb.is_object(source[i]) || i == 'NAME')
-      continue;
-
-    target[i] = source[i];
-  }
-}
-
-Limb.Classkit.makeParentProxy = function(child_class, parent_class)
-{
-  var proxy = new Object();
-  proxy['NAME'] = parent.NAME;
-
-  var parent_instance = new parent_class();
-
-  for(var method in parent_instance)
-  {
-    if(!Limb.is_function(parent_instance[method]))
-      continue;
-
-    proxy[method] = Limb.Classkit.parentMethodWrapper(child_class, parent_instance, method);
-  }
-
-  return proxy;
-}
-
-Limb.Classkit.inherit = function(child_class, parent_class, child_body)
-{
-  Limb.Classkit.clone(child_class, parent_class);
-  Limb.Classkit.clone(child_class.prototype, parent_class.prototype);
-
-  if(Limb.is_function(parent_class))
-    child_class.prototype.parent = parent_class;
-
-  if(Limb.isset(child_body))
-    Limb.Classkit.extendClass(child_class, child_body);
-}
-
-Limb.Classkit.implement = function(class_ref, interface_ref, class_body)
-{
-  if(Limb.isset(class_body))
-    Limb.Classkit.extendClass(class_ref, class_body);
-
-  Limb.Classkit.checkInterfaceImplementation(class_ref, interface_ref);
-}
-
-Limb.Classkit.extendClass = function(class_ref, class_body)
-{
-  Limb.Classkit.clone(class_ref.prototype, class_body);
-
-  if(Limb.is_object(class_body['static']))
-    Limb.Classkit.clone(class_ref, class_body['static']);
-}
-
-Limb.Classkit.checkInterfaceImplementation = function(child_class, interface_ref)
-{
-  for(var method in interface_ref)
-  {
-    if(!Limb.is_function(interface_ref[method]))
-      continue;
-
-    if(!Limb.is_function(child_class.prototype[method]) && !Limb.is_function(child_class[method]))
-      throw new Limb.Exception('InterfaceException', "Method '" + method + "' not implemented");
-  }
-}
-
-Limb.Classkit.extendInterface = function(interface_ref, body)
-{
-  if(!Limb.is_object(body))
-    return;
-
-  for(var method in body)
-  {
-    if(!Limb.is_function(body[method]))
-      continue;
-
-    interface_ref[method] = Limb.Classkit.interfaceMethodPrototype;
-  }
-}
-
-Limb.Classkit.parentMethodWrapper = function(child_class_ref, parent_class_ref, method)
-{
-  return function()
-  {
-    return parent_class_ref[method].apply(child_class_ref, arguments);
-  }
-}
-
-Limb.Classkit.interfaceMethodPrototype = function()
-{
-  throw new Limb.Exception('InterfaceException', 'Interface methods can not be called');
-}
-
-Limb.Classkit.classToString = function()
-{
-  return '[ class ' + this.prototype.NAME + ' ]';
-}
-
-Limb.Classkit.interfaceToString = function()
-{
-  return '[ interface ' + this.NAME + ' ]';
-}
-
-Limb.Class = function(class_name, body)
-{
-  var class_ref = Limb.Classkit.createClass(body || null);
-  class_ref.prototype.NAME = class_name;
-  class_ref.prototype.static = class_ref;
-
-  Limb.define(class_name, class_ref);
-
-  return class_ref;
-}
-
-Limb.Interface = function(interface_name, body)
-{
-  var interface_ref = Limb.Classkit.createInterface(body || null);
-  interface_ref.NAME = interface_name;
-  interface_ref.is_interface = true;
-
-  Limb.define(interface_name, interface_ref);
-
-  return interface_ref;
-
-}
-

Deleted: 3.x/trunk/limb/js/shared/Limb/Exception.js
===================================================================
--- 3.x/trunk/limb/js/shared/Limb/Exception.js	2007-05-04 09:35:51 UTC (rev 5799)
+++ 3.x/trunk/limb/js/shared/Limb/Exception.js	2007-05-04 10:16:28 UTC (rev 5800)
@@ -1,74 +0,0 @@
-/**
- * Limb Web Application Framework
- *
- * @link http://limb-project.com
- *
- * @copyright  Copyright &copy; 2004-2007 BIT
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- * @version    $Id$
- * @package    js
- */
-
-Limb.namespace('Limb.Exception');
-
-Limb.Exception = function()
-{
-  if(arguments.length == 1 && Limb.is_object(arguments[0]))
-  {
-    this.type = arguments[0].type || 'LimbException';
-    this.message = arguments[0].message;
-    this.stack = arguments[0].stack || 'Stack is not available';
-    this.file_name = arguments[0].fileName || 'File name is not available';
-    this.line_number = arguments[0].lineNumber || 'Line number is not available';
-  }
-  else
-  {
-    this.type = arguments[0] || 'LimbException';
-    this.message = arguments[1] || 'Unknown error';
-    if(typeof(arguments[2]) == 'object')
-    {
-      this.stack = arguments[2].stack || e.stack;
-      this.file_name = arguments[2].fileName || e.fileName;
-      this.line_number = arguments[2].lineNumber || e.lineNumber;
-    }
-    else
-    {
-      this.stack = 'Stack is not available';
-      this.file_name = 'File name is not available';
-      this.line_number = 'Line number is not available';
-    }
-  }
-}
-
-Limb.Exception.prototype =
-{
-  getMessage: function()
-  {
-    return this.message;
-  },
-
-  getType: function()
-  {
-    return this.type;
-  },
-
-  getStack: function()
-  {
-    return this.stack;
-  },
-
-  getFileName: function()
-  {
-    return this.file_name;
-  },
-
-  getLineNumber: function()
-  {
-    return this.line_number;
-  },
-
-  toString: function()
-  {
-    return '[ exception ' + this.type + ' ]';
-  }
-}

Deleted: 3.x/trunk/limb/js/shared/Limb/Object.js
===================================================================
--- 3.x/trunk/limb/js/shared/Limb/Object.js	2007-05-04 09:35:51 UTC (rev 5799)
+++ 3.x/trunk/limb/js/shared/Limb/Object.js	2007-05-04 10:16:28 UTC (rev 5800)
@@ -1,45 +0,0 @@
-/**
- * Limb Web Application Framework
- *
- * @link http://limb-project.com
- *
- * @copyright  Copyright &copy; 2004-2007 BIT
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- * @version    $Id$
- * @package    js
- */
-
-Limb.namespace('Limb.Object');
-
-Limb.require('Limb.Classkit');
-
-Limb.Object.inherits = function(class_name, body)
-{
-  var parent_class = Limb.namespace(class_name);
-  if(!parent_class)
-    return this;
-
-  Limb.Classkit.inherit(this, parent_class, body);
-
-  return this;
-}
-
-Limb.Object.implements = function(interface_name, body)
-{
-  var interface_ref = Limb.namespace(interface_name);
-  if(!interface_ref)
-    return this;
-
-  Limb.Classkit.implement(this, interface_ref, body);
-
-  return this;
-}
-
-Limb.Object.prototype = {
-  __construct: function() {},
-
-  toString: function()
-  {
-    return '[ object ' + this.NAME + ' ]';
-  }
-}

Modified: 3.x/trunk/limb/js/shared/Limb/window.js
===================================================================
--- 3.x/trunk/limb/js/shared/Limb/window.js	2007-05-04 09:35:51 UTC (rev 5799)
+++ 3.x/trunk/limb/js/shared/Limb/window.js	2007-05-04 10:16:28 UTC (rev 5800)
@@ -212,7 +212,7 @@
 
     for(var name in this.params)
     {
-      if(Limb.is_function(this.params[name]))
+      if(Limb.isFunction(this.params[name]))
         continue;
 
       result += name + '=' + this.params[name] + ',';

Modified: 3.x/trunk/limb/js/shared/Limb.js
===================================================================
--- 3.x/trunk/limb/js/shared/Limb.js	2007-05-04 09:35:51 UTC (rev 5799)
+++ 3.x/trunk/limb/js/shared/Limb.js	2007-05-04 10:16:28 UTC (rev 5800)
@@ -17,6 +17,86 @@
   return this.replace(r,'');
 }
 
+if(!Function.prototype.bind)
+{
+  Function.prototype.bind = function(object)
+  {
+    var __method = this;
+    return function() {__method.apply( object, arguments );};
+  };
+}
+
+if(!Function.prototype.bindAsEventListener)
+{
+  Function.prototype.bindAsEventListener = function(object)
+  {
+    var __method = this;
+    return function(event) {__method.call(object, event || window.event);};
+  };
+}
+
+Limb.Exception = function()
+{
+  if(arguments.length == 1 && Limb.isObject(arguments[0]))
+  {
+    this.type = arguments[0].type || 'LimbException';
+    this.message = arguments[0].message;
+    this.stack = arguments[0].stack || 'Stack is not available';
+    this.file_name = arguments[0].fileName || 'File name is not available';
+    this.line_number = arguments[0].lineNumber || 'Line number is not available';
+  }
+  else
+  {
+    this.type = arguments[0] || 'LimbException';
+    this.message = arguments[1] || 'Unknown error';
+    if(typeof(arguments[2]) == 'object')
+    {
+      this.stack = arguments[2].stack || e.stack;
+      this.file_name = arguments[2].fileName || e.fileName;
+      this.line_number = arguments[2].lineNumber || e.lineNumber;
+    }
+    else
+    {
+      this.stack = 'Stack is not available';
+      this.file_name = 'File name is not available';
+      this.line_number = 'Line number is not available';
+    }
+  }
+}
+
+Limb.Exception.prototype =
+{
+  getMessage: function()
+  {
+    return this.message;
+  },
+
+  getType: function()
+  {
+    return this.type;
+  },
+
+  getStack: function()
+  {
+    return this.stack;
+  },
+
+  getFileName: function()
+  {
+    return this.file_name;
+  },
+
+  getLineNumber: function()
+  {
+    return this.line_number;
+  },
+
+  toString: function()
+  {
+    return '[ exception ' + this.type + ' ]';
+  }
+}
+
 Limb.define = function(name, value)
 {
   var parts = name.split('.');
@@ -54,12 +134,207 @@
   return typeof(variable) != 'undefined' && variable != null;
 }
 
-Limb.is_object = function(variable)
+Limb.isObject = function(variable)
 {
   return typeof(variable) == 'object';
 }
 
-Limb.is_function = function(variable)
+Limb.isFunction = function(variable)
 {
   return typeof(variable) == 'function';
 }
+
+Limb.namespace('Limb.Classkit');
+
+Limb.Classkit.createClass = function(body)
+{
+  var new_class = function()
+  {
+    if(Limb.isFunction(this['parent']))
+      this.parent = Limb.Classkit.makeParentProxy(this, this.parent);
+
+    this.__construct.apply(this, arguments);
+  }
+
+  new_class.toString = Limb.Classkit.classToString;
+
+  Limb.Classkit.inherit(new_class, Limb.Object, body);
+
+  return new_class;
+}
+
+Limb.Classkit.createInterface = function(body)
+{
+  var new_interface = function()
+  {
+    throw new Limb.Exception('InterfaceException', 'Can not create instance of interface');
+  }
+
+  new_interface.toString = Limb.Classkit.interfaceToString;
+
+  Limb.Classkit.extendInterface(new_interface, body || null);
+
+  return new_interface;
+}
+
+Limb.Classkit.clone = function(target, source)
+{
+  for(var i in source)
+  {
+    if(Limb.isObject(source[i]) || i == 'NAME')
+      continue;
+
+    target[i] = source[i];
+  }
+}
+
+Limb.Classkit.makeParentProxy = function(child_class, parent_class)
+{
+  var proxy = new Object();
+  proxy['NAME'] = parent.NAME;
+
+  var parent_instance = new parent_class();
+
+  for(var method in parent_instance)
+  {
+    if(!Limb.isFunction(parent_instance[method]))
+      continue;
+
+    proxy[method] = Limb.Classkit.parentMethodWrapper(child_class, parent_instance, method);
+  }
+
+  return proxy;
+}
+
+Limb.Classkit.inherit = function(child_class, parent_class, child_body)
+{
+  Limb.Classkit.clone(child_class, parent_class);
+  Limb.Classkit.clone(child_class.prototype, parent_class.prototype);
+
+  if(Limb.isFunction(parent_class))
+    child_class.prototype.parent = parent_class;
+
+  if(Limb.isset(child_body))
+    Limb.Classkit.extendClass(child_class, child_body);
+}
+
+Limb.Classkit.implement = function(class_ref, interface_ref, class_body)
+{
+  if(Limb.isset(class_body))
+    Limb.Classkit.extendClass(class_ref, class_body);
+
+  Limb.Classkit.checkInterfaceImplementation(class_ref, interface_ref);
+}
+
+Limb.Classkit.extendClass = function(class_ref, class_body)
+{
+  Limb.Classkit.clone(class_ref.prototype, class_body);
+
+  if(Limb.isObject(class_body['static']))
+    Limb.Classkit.clone(class_ref, class_body['static']);
+}
+
+Limb.Classkit.checkInterfaceImplementation = function(child_class, interface_ref)
+{
+  for(var method in interface_ref)
+  {
+    if(!Limb.isFunction(interface_ref[method]))
+      continue;
+
+    if(!Limb.isFunction(child_class.prototype[method]) && !Limb.isFunction(child_class[method]))
+      throw new Limb.Exception('InterfaceException', "Method '" + method + "' not implemented");
+  }
+}
+
+Limb.Classkit.extendInterface = function(interface_ref, body)
+{
+  if(!Limb.isObject(body))
+    return;
+
+  for(var method in body)
+  {
+    if(!Limb.isFunction(body[method]))
+      continue;
+
+    interface_ref[method] = Limb.Classkit.interfaceMethodPrototype;
+  }
+}
+
+Limb.Classkit.parentMethodWrapper = function(child_class_ref, parent_class_ref, method)
+{
+  return function()
+  {
+    return parent_class_ref[method].apply(child_class_ref, arguments);
+  }
+}
+
+Limb.Classkit.interfaceMethodPrototype = function()
+{
+  throw new Limb.Exception('InterfaceException', 'Interface methods can not be called');
+}
+
+Limb.Classkit.classToString = function()
+{
+  return '[ class ' + this.prototype.NAME + ' ]';
+}
+
+Limb.Classkit.interfaceToString = function()
+{
+  return '[ interface ' + this.NAME + ' ]';
+}
+
+Limb.Class = function(class_name, body)
+{
+  var class_ref = Limb.Classkit.createClass(body || null);
+  class_ref.prototype.NAME = class_name;
+  class_ref.prototype.static = class_ref;
+
+  Limb.define(class_name, class_ref);
+
+  return class_ref;
+}
+
+Limb.Interface = function(interface_name, body)
+{
+  var interface_ref = Limb.Classkit.createInterface(body || null);
+  interface_ref.NAME = interface_name;
+  interface_ref.is_interface = true;
+
+  Limb.define(interface_name, interface_ref);
+
+  return interface_ref;
+}
+
+Limb.namespace('Limb.Object');
+
+Limb.Object.inherits = function(class_name, body)
+{
+  var parent_class = Limb.namespace(class_name);
+  if(!parent_class)
+    return this;
+
+  Limb.Classkit.inherit(this, parent_class, body);
+
+  return this;
+}
+
+Limb.Object.implements = function(interface_name, body)
+{
+  var interface_ref = Limb.namespace(interface_name);
+  if(!interface_ref)
+    return this;
+
+  Limb.Classkit.implement(this, interface_ref, body);
+
+  return this;
+}
+
+Limb.Object.prototype = {
+  __construct: function() {},
+
+  toString: function()
+  {
+    return '[ object ' + this.NAME + ' ]';
+  }
+}
+



More information about the limb-svn mailing list