/**
 * This class provides method yarn for weaving into objects.  In this manner, it provides aspect-oriented programming services 
 * for objects and classes in JavaScript. 
 * <br><br>
 * <a href="mailto:ehudsons@andrew.cmu.edu">Ellen Hudson-Snyder</a>, 
 * <a href="mailto:evedar@andrew.cmu.edu">Elvin Vedar</a>,
 * <a href="mailto:cbalz@andrew.cmu.edu">Christopher M. Balz</a>.
 * <br><br>CVS Version Info:<br>
 *  $Id: MethodYarn.js,v 1.3 2005/11/27 16:31:28 cbalz Exp $     
 * <br><br>
 * @object-prop <code>strTargetFunctionName</code> <code>string</code>  The name of the target method on its object.
 * @object-prop <code>funTarget</code> <code>function</code> The target method itself.
 * @object-prop <code>strfunYarn</code> <code>string</code> or <code>function</code> The code, as <code>string</code> or as 
 *                                                                  <code>function</code>, to 
 *                                                                  be woven into a the target method.  If 
 *                                                                  the code is in 
 *                                                                  <code>function</code> form, the top 
 *                                                                  ('function  . . . {') and 
 *                                                                  bottom (including any final 'return') 
 *                                                                  will be removed.  
 * @object-prop <code>pIntCurlyBraceLevels</code> <code>number</code> The number of curly brace levels to insert 
 *                                                               the code after or before.
 */


/**
 * Create a ball of method yarn for an aspect to weave.  An aspect is the central element
 * of a software engineering paradigm, Aspect Oriented Programming, which complements object-oriented
 * software engineering.
 * @param strTargetFunctionName <code>string</code>  The name of the target method on its object.
 * @param funTarget <code>function</code>  The target method itself.
 * @param strfunYarn <code>function</code> OR <code>string</code>   The code, as <code>string</code> or as 
 *                                                                  <code>function</code>, to 
 *                                                                  be woven into a the target method.  If 
 *                                                                  the code is in 
 *                                                                  <code>function</code> form, the top 
 *                                                                  ('function  . . . {') and 
 *                                                                  bottom (including any final 'return') 
 *                                                                  will be removed.
 * @param pIntCurlyBraceLevels <code>number</code>  The number of curly brace levels to insert 
 *                                                  the code after or before.
 */
function MethodYarn(strTargetFunctionName, funTarget, strfunYarn, pIntCurlyBraceLevels ) {
    this.strTargetFunctionName = strTargetFunctionName; 
    this.funTarget = funTarget;
    
    if (typeof strfunYarn != "string") {
        this.strFunYarn = Aspect.chopFunctionTop(strfunYarn)[2].replace(Aspect.RXP_INSERT_AFTER, "");
    } else {        
        this.strFunYarn = strfunYarn;
    }
    if (typeof pIntCurlyBraceLevels != "undefined") {
        this.intCurlyBraceLevels = pIntCurlyBraceLevels;        
    } else {
        this.intCurlyBraceLevels = 1;
    }
}

