Added jsdoc comment based documentation

This commit is contained in:
zumbrunn 2007-02-07 10:27:37 +00:00
parent 383c7b0e9c
commit a7cac41923

View file

@ -6,29 +6,36 @@
* compliance with the License. A copy of the License is available at
* http://adele.helma.org/download/helma/license.txt
*
* Copyright 1998-2006 Helma Software. All Rights Reserved.
* Copyright 1998-2007 Helma Software. All Rights Reserved.
*
* $RCSfile: helma.Aspects.js,v $
* $RCSfile: Aspects.js,v $
* $Author: czv $
* $Revision: 1.9 $
* $Date: 2006/04/18 13:06:58 $
* $Revision: 1.2 $
* $Date: 2006/04/24 07:02:17 $
*/
/**
* Define the global namespace if not existing
*/
if (!global.helma) {
global.helma = {};
}
/**
* library for adding Aspects (by roman porotnikov,
* http://www.jroller.com/page/deep/20030701)
*
* Library for adding Aspects
* <br /><br />
* Provides static methods to wrap existing functions
* inside a javascript closure in order to add additional
* behavior without overriding the existing one.
* <br /><br />
* Based on code by roman porotnikov,
* http://www.jroller.com/page/deep/20030701
* <br /><br />
* Note: Each prototype that uses aspects must implement a method
* onCodeUpdate() to prevent aspects being lost when the prototype
* is re-compiled
*/
helma.Aspects = function() {
return this;
};
@ -44,6 +51,18 @@ helma.Aspects.prototype.toString = function() {
};
/**
* Adds a function to be called before the orginal function.
* <br /><br />
* The return value of the added function needs to provide the
* array of arguments that is passed to the original function.
*
* @param {Object} obj The object of which the original function is a property
* @param {String} fname The property name of the original function
* @param {Function} before The function to be called before the original function
* @returns Function A new function, wrapping the original function
* @type Function
*/
helma.Aspects.prototype.addBefore = function(obj, fname, before) {
var oldFunc = obj[fname];
obj[fname] = function() {
@ -53,6 +72,21 @@ helma.Aspects.prototype.addBefore = function(obj, fname, before) {
};
/**
* Adds a function to be called after an existing function.
* <br /><br />
* The return value of the original function is passed to the
* added function as its first argument. In addition, the added
* function also receives an array of the original arguments,
* the original function and the scope object of the original
* function as additional parameters.
*
* @param {Object} obj as Object, the object of which the original function is a property
* @param {String} fname as String, the property name of the original function
* @param {Function} after as Function, the function to be called after the original function
* @returns Function A new function, wrapping the original function
* @type Function
*/
helma.Aspects.prototype.addAfter = function(obj, fname, after) {
var oldFunc = obj[fname];
obj[fname] = function() {
@ -62,6 +96,20 @@ helma.Aspects.prototype.addAfter = function(obj, fname, after) {
};
/**
* Wraps an additional function around the original function.
* <br /><br />
* The added function receives as its arguments an array of the original
* arguments, the original function and the scope object of the original
* function. The original function is not called directly and needs
* to be invoked by the added function.
*
* @param {Object} obj as Object, the object of which the original function is a property
* @param {String} fname as String, the property name of the original function
* @param {Function} around as Function, the function to be called inside the original function
* @returns Function A new function, wrapping the original function
* @type Function
*/
helma.Aspects.prototype.addAround = function(obj, fname, around) {
var oldFunc = obj[fname];
obj[fname] = function() {