require 'formula' class Dcmtk < Formula homepage 'http://dicom.offis.de/dcmtk.php.en' url 'ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk360/dcmtk-3.6.0.tar.gz' sha1 '469e017cffc56f36e834aa19c8612111f964f757' revision 1 bottle do sha1 "7a5dae3786225a07fc1b615c186a348d762c1a67" => :mavericks sha1 "f2b20d273322b799b4bd79da8dbe21bc293f37ff" => :mountain_lion sha1 "044eeba49ae368d5f8cce753d54dcaa9b8d18fbb" => :lion end option 'with-docs', 'Install development libraries/headers and HTML docs' option 'with-openssl', 'Configure DCMTK with support for OpenSSL' depends_on 'cmake' => :build depends_on "libpng" depends_on 'libtiff' depends_on "doxygen" => :build if build.with? "docs" # This roughly corresponds to thefollowing upstream patch: # # http://git.dcmtk.org/web?p=dcmtk.git;a=commitdiff;h=dbadc0d8f3760f65504406c8b2cb8633f868a258 # # However, this patch can't be applied as-is, since it refers to # some files that don't exist in the 3.6.0 release. # # This patch can be dropped once DCMTK makes a new release, but # since this is a very rare occurrence (the last development preview # release is from mid 2012), it seems justifiable to keep the patch # ourselves for a while. patch :DATA def install ENV.m64 if MacOS.prefer_64_bit? args = std_cmake_args args << '-DDCMTK_WITH_DOXYGEN=YES' if build.with? "docs" args << '-DDCMTK_WITH_OPENSSL=YES' if build.with? "openssl" args << '..' mkdir 'build' do system 'cmake', *args system 'make DOXYGEN' if build.with? "docs" system 'make install' end end end __END__ diff --git a/dcmimgle/include/dcmtk/dcmimgle/dimoflt.h b/dcmimgle/include/dcmtk/dcmimgle/dimoflt.h index a88ab9d..da860fe 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/dimoflt.h +++ b/dcmimgle/include/dcmtk/dcmimgle/dimoflt.h @@ -106,11 +106,11 @@ class DiMonoFlipTemplate if (this->Data != NULL) { if (horz && vert) - flipHorzVert(&pixel, &this->Data); + this->flipHorzVert(&pixel, &this->Data); else if (horz) - flipHorz(&pixel, &this->Data); + this->flipHorz(&pixel, &this->Data); else if (vert) - flipVert(&pixel, &this->Data); + this->flipVert(&pixel, &this->Data); } } } diff --git a/dcmimgle/include/dcmtk/dcmimgle/dimoipxt.h b/dcmimgle/include/dcmtk/dcmimgle/dimoipxt.h index e815e90..51603ea 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/dimoipxt.h +++ b/dcmimgle/include/dcmtk/dcmimgle/dimoipxt.h @@ -76,10 +76,10 @@ class DiMonoInputPixelTemplate else if ((this->Modality != NULL) && this->Modality->hasRescaling()) { rescale(pixel, this->Modality->getRescaleSlope(), this->Modality->getRescaleIntercept()); - determineMinMax(OFstatic_cast(T3, this->Modality->getMinValue()), OFstatic_cast(T3, this->Modality->getMaxValue())); + this->determineMinMax(OFstatic_cast(T3, this->Modality->getMinValue()), OFstatic_cast(T3, this->Modality->getMaxValue())); } else { rescale(pixel); // "copy" or reference pixel data - determineMinMax(OFstatic_cast(T3, this->Modality->getMinValue()), OFstatic_cast(T3, this->Modality->getMaxValue())); + this->determineMinMax(OFstatic_cast(T3, this->Modality->getMinValue()), OFstatic_cast(T3, this->Modality->getMaxValue())); } } } diff --git a/dcmimgle/include/dcmtk/dcmimgle/dimopxt.h b/dcmimgle/include/dcmtk/dcmimgle/dimopxt.h index 641acd2..dc0b439 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/dimopxt.h +++ b/dcmimgle/include/dcmtk/dcmimgle/dimopxt.h @@ -178,7 +178,7 @@ class DiMonoPixelTemplate if ((idx >= 0) && (idx <= 1)) { if ((idx == 1) && (MinValue[1] == 0) && (MaxValue[1] == 0)) - determineMinMax(0, 0, 0x2); // determine on demand + this->determineMinMax(0, 0, 0x2); // determine on demand /* suppl. 33: "A Window Center of 2^n-1 and a Window Width of 2^n selects the range of input values from 0 to 2^n-1." */ diff --git a/dcmimgle/include/dcmtk/dcmimgle/dimorot.h b/dcmimgle/include/dcmtk/dcmimgle/dimorot.h index 4ef277d..19f9a98 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/dimorot.h +++ b/dcmimgle/include/dcmtk/dcmimgle/dimorot.h @@ -105,11 +105,11 @@ class DiMonoRotateTemplate if (this->Data != NULL) { if (degree == 90) - rotateRight(&pixel, &(this->Data)); + this->rotateRight(&pixel, &(this->Data)); else if (degree == 180) - rotateTopDown(&pixel, &(this->Data)); + this->rotateTopDown(&pixel, &(this->Data)); else if (degree == 270) - rotateLeft(&pixel, &(this->Data)); + this->rotateLeft(&pixel, &(this->Data)); } } } diff --git a/dcmimgle/include/dcmtk/dcmimgle/dimosct.h b/dcmimgle/include/dcmtk/dcmimgle/dimosct.h index 60c9abb..9a46187 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/dimosct.h +++ b/dcmimgle/include/dcmtk/dcmimgle/dimosct.h @@ -124,7 +124,7 @@ class DiMonoScaleTemplate { const T value = OFstatic_cast(T, OFstatic_cast(double, DicomImageClass::maxval(bits)) * OFstatic_cast(double, pvalue) / OFstatic_cast(double, DicomImageClass::maxval(WIDTH_OF_PVALUES))); - scaleData(&pixel, &this->Data, interpolate, value); + this->scaleData(&pixel, &this->Data, interpolate, value); } } } diff --git a/dcmimgle/include/dcmtk/dcmimgle/discalet.h b/dcmimgle/include/dcmtk/dcmimgle/discalet.h index 758dde2..912e82a 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/discalet.h +++ b/dcmimgle/include/dcmtk/dcmimgle/discalet.h @@ -206,12 +206,12 @@ class DiScaleTemplate (Left >= OFstatic_cast(signed long, Columns)) || (Top >= OFstatic_cast(signed long, Rows))) { // no image to be displayed DCMIMGLE_DEBUG("clipping area is fully outside the image boundaries"); - fillPixel(dest, value); // ... fill bitmap + this->fillPixel(dest, value); // ... fill bitmap } else if ((this->Src_X == this->Dest_X) && (this->Src_Y == this->Dest_Y)) // no scaling { if ((Left == 0) && (Top == 0) && (Columns == this->Src_X) && (Rows == this->Src_Y)) - copyPixel(src, dest); // copying + this->copyPixel(src, dest); // copying else if ((Left >= 0) && (OFstatic_cast(Uint16, Left + this->Src_X) <= Columns) && (Top >= 0) && (OFstatic_cast(Uint16, Top + this->Src_Y) <= Rows)) clipPixel(src, dest); // clipping @@ -567,7 +567,7 @@ class DiScaleTemplate if ((xtemp == NULL) || (xvalue == NULL)) { DCMIMGLE_ERROR("can't allocate temporary buffers for interpolation scaling"); - clearPixel(dest); + this->clearPixel(dest); } else { for (int j = 0; j < this->Planes; ++j) { @@ -905,7 +905,7 @@ class DiScaleTemplate if (pTemp == NULL) { DCMIMGLE_ERROR("can't allocate temporary buffer for interpolation scaling"); - clearPixel(dest); + this->clearPixel(dest); } else { /* @@ -1029,7 +1029,7 @@ class DiScaleTemplate if (pTemp == NULL) { DCMIMGLE_ERROR("can't allocate temporary buffer for interpolation scaling"); - clearPixel(dest); + this->clearPixel(dest); } else { /* diff --git a/dcmimgle/include/dcmtk/dcmimgle/diflipt.h b/dcmimgle/include/dcmtk/dcmimgle/diflipt.h index 4933fe1..cb8d5e1 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/diflipt.h +++ b/dcmimgle/include/dcmtk/dcmimgle/diflipt.h @@ -129,7 +129,7 @@ class DiFlipTemplate else if (vert) flipVert(src, dest); else - copyPixel(src, dest); + this->copyPixel(src, dest); } } diff --git a/dcmimgle/include/dcmtk/dcmimgle/dirotat.h b/dcmimgle/include/dcmtk/dcmimgle/dirotat.h index edb452e..6ae6bbe 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/dirotat.h +++ b/dcmimgle/include/dcmtk/dcmimgle/dirotat.h @@ -132,7 +132,7 @@ class DiRotateTemplate else if (degree == 270) rotateLeft(src, dest); else - copyPixel(src, dest); + this->copyPixel(src, dest); } diff --git a/dcmimage/include/dcmtk/dcmimage/diargpxt.h b/dcmimage/include/dcmtk/dcmimage/diargpxt.h index 7e3894d..a25c1f7 100644 --- a/dcmimage/include/dcmtk/dcmimage/diargpxt.h +++ b/dcmimage/include/dcmtk/dcmimage/diargpxt.h @@ -91,7 +91,7 @@ class DiARGBPixelTemplate const unsigned long planeSize, const int bits) { // not very much optimized, but no one really uses ARGB !! - if (Init(pixel)) + if (this->Init(pixel)) { register T2 value; const T1 offset = OFstatic_cast(T1, DicomImageClass::maxval(bits - 1)); diff --git a/dcmimage/include/dcmtk/dcmimage/dicmypxt.h b/dcmimage/include/dcmtk/dcmimage/dicmypxt.h index 5357780..4050ec6 100644 --- a/dcmimage/include/dcmtk/dcmimage/dicmypxt.h +++ b/dcmimage/include/dcmtk/dcmimage/dicmypxt.h @@ -87,7 +87,7 @@ class DiCMYKPixelTemplate const unsigned long planeSize, const int bits) { - if (Init(pixel)) + if (this->Init(pixel)) { // use the number of input pixels derived from the length of the 'PixelData' // attribute), but not more than the size of the intermediate buffer diff --git a/dcmimage/include/dcmtk/dcmimage/dicocpt.h b/dcmimage/include/dcmtk/dcmimage/dicocpt.h index 0c06de7..9770770 100644 --- a/dcmimage/include/dcmtk/dcmimage/dicocpt.h +++ b/dcmimage/include/dcmtk/dcmimage/dicocpt.h @@ -86,7 +86,7 @@ class DiColorCopyTemplate inline void copy(const T *pixel[3], const unsigned long offset) { - if (Init(pixel)) + if (this->Init(pixel)) { for (int j = 0; j < 3; j++) OFBitmanipTemplate::copyMem(pixel[j] + offset, this->Data[j], this->getCount()); diff --git a/dcmimage/include/dcmtk/dcmimage/dicoflt.h b/dcmimage/include/dcmtk/dcmimage/dicoflt.h index a5bed81..9c339f6 100644 --- a/dcmimage/include/dcmtk/dcmimage/dicoflt.h +++ b/dcmimage/include/dcmtk/dcmimage/dicoflt.h @@ -98,14 +98,14 @@ class DiColorFlipTemplate const int horz, const int vert) { - if (Init(pixel)) + if (this->Init(pixel)) { if (horz && vert) - flipHorzVert(pixel, this->Data); + this->flipHorzVert(pixel, this->Data); else if (horz) - flipHorz(pixel, this->Data); + this->flipHorz(pixel, this->Data); else if (vert) - flipVert(pixel, this->Data); + this->flipVert(pixel, this->Data); } } }; diff --git a/dcmimage/include/dcmtk/dcmimage/dicorot.h b/dcmimage/include/dcmtk/dcmimage/dicorot.h index 2bcd71e..9169f41 100644 --- a/dcmimage/include/dcmtk/dcmimage/dicorot.h +++ b/dcmimage/include/dcmtk/dcmimage/dicorot.h @@ -98,14 +98,14 @@ class DiColorRotateTemplate inline void rotate(const T *pixel[3], const int degree) { - if (Init(pixel)) + if (this->Init(pixel)) { if (degree == 90) - rotateRight(pixel, this->Data); + this->rotateRight(pixel, this->Data); else if (degree == 180) - rotateTopDown(pixel, this->Data); + this->rotateTopDown(pixel, this->Data); else if (degree == 270) - rotateLeft(pixel, this->Data); + this->rotateLeft(pixel, this->Data); } } }; diff --git a/dcmimage/include/dcmtk/dcmimage/dicosct.h b/dcmimage/include/dcmtk/dcmimage/dicosct.h index 006a829..045b04f 100644 --- a/dcmimage/include/dcmtk/dcmimage/dicosct.h +++ b/dcmimage/include/dcmtk/dcmimage/dicosct.h @@ -107,8 +107,8 @@ class DiColorScaleTemplate inline void scale(const T *pixel[3], const int interpolate) { - if (Init(pixel)) - scaleData(pixel, this->Data, interpolate); + if (this->Init(pixel)) + this->scaleData(pixel, this->Data, interpolate); } }; diff --git a/dcmimage/include/dcmtk/dcmimage/dihsvpxt.h b/dcmimage/include/dcmtk/dcmimage/dihsvpxt.h index 10d8b70..d2c160b 100644 --- a/dcmimage/include/dcmtk/dcmimage/dihsvpxt.h +++ b/dcmimage/include/dcmtk/dcmimage/dihsvpxt.h @@ -87,7 +87,7 @@ class DiHSVPixelTemplate const unsigned long planeSize, const int bits) { - if (Init(pixel)) + if (this->Init(pixel)) { register T2 *r = this->Data[0]; register T2 *g = this->Data[1]; diff --git a/dcmimage/include/dcmtk/dcmimage/dipalpxt.h b/dcmimage/include/dcmtk/dcmimage/dipalpxt.h index 2e5eef7..875dac8 100644 --- a/dcmimage/include/dcmtk/dcmimage/dipalpxt.h +++ b/dcmimage/include/dcmtk/dcmimage/dipalpxt.h @@ -92,7 +92,7 @@ class DiPalettePixelTemplate void convert(const T1 *pixel, DiLookupTable *palette[3]) { // can be optimized if necessary ! - if (Init(pixel)) + if (this->Init(pixel)) { register const T1 *p = pixel; register T2 value = 0; diff --git a/dcmimage/include/dcmtk/dcmimage/dirgbpxt.h b/dcmimage/include/dcmtk/dcmimage/dirgbpxt.h index 85f973d..ff18aaf 100644 --- a/dcmimage/include/dcmtk/dcmimage/dirgbpxt.h +++ b/dcmimage/include/dcmtk/dcmimage/dirgbpxt.h @@ -87,7 +87,7 @@ class DiRGBPixelTemplate const unsigned long planeSize, const int bits) { - if (Init(pixel)) + if (this->Init(pixel)) { // use the number of input pixels derived from the length of the 'PixelData' // attribute), but not more than the size of the intermediate buffer diff --git a/dcmimage/include/d
/**
 * Template provides directions an how to bind to a given element.
 * It contains a list of init functions which need to be called to
 * bind to a new instance of elements. It also provides a list
 * of child paths which contain child templates
 */
function Template(priority) {
  this.paths = [];
  this.children = [];
  this.inits = [];
  this.priority = priority;
  this.newScope = false;
}

Template.prototype = {
  attach: function(element, scope) {
    var inits = {};
    this.collectInits(element, inits, scope);
    forEachSorted(inits, function(queue){
      forEach(queue, function(fn) {fn();});
    });
  },

  collectInits: function(element, inits, scope) {
    var queue = inits[this.priority], childScope = scope;
    if (!queue) {
      inits[this.priority] = queue = [];
    }
    if (this.newScope) {
      childScope = createScope(scope);
      scope.$onEval(childScope.$eval);
      element.data($$scope, childScope);
    }
    forEach(this.inits, function(fn) {
      queue.push(function() {
        childScope.$tryEval(function(){
          return childScope.$service(fn, childScope, element);
        }, element);
      });
    });
    var i,
        childNodes = element[0].childNodes,
        children = this.children,
        paths = this.paths,
        length = paths.length;
    for (i = 0; i < length; i++) {
      children[i].collectInits(jqLite(childNodes[paths[i]]), inits, childScope);
    }
  },


  addInit:function(init) {
    if (init) {
      this.inits.push(init);
    }
  },


  addChild: function(index, template) {
    if (template) {
      this.paths.push(index);
      this.children.push(template);
    }
  },

  empty: function() {
    return this.inits.length === 0 && this.paths.length === 0;
  }
};

///////////////////////////////////
//Compiler
//////////////////////////////////

/**
 * @workInProgress
 * @ngdoc function
 * @name angular.compile
 * @function
 *
 * @description
 * Compiles a piece of HTML string or DOM into a template and produces a template function, which
 * can then be used to link {@link angular.scope scope} and the template together.
 *
 * The compilation is a process of walking the DOM tree and trying to match DOM elements to
 * {@link angular.markup markup}, {@link angular.attrMarkup attrMarkup},
 * {@link angular.widget widgets}, and {@link angular.directive directives}. For each match it
 * executes coresponding markup, attrMarkup, widget or directive template function and collects the
 * instance functions into a single template function which is then returned.
 *
 * The template function can then be used once to produce the view or as it is the case with
 * {@link angular.widget.@ng:repeat repeater} many-times, in which case each call results in a view
 * that is a DOM clone of the original template.
 *
   <pre>
    //copile the entire window.document and give me the scope bound to this template.
    var rootSscope = angular.compile(window.document)();

    //compile a piece of html
    var rootScope2 = angular.compile(''<div ng:click="clicked = true">click me</div>')();

    //compile a piece of html and retain reference to both the dom and scope
    var template = angular.element('<div ng:click="clicked = true">click me</div>'),
        scoope = angular.compile(view)();
    //at this point template was transformed into a view
   </pre>
 *
 *
 * @param {string|DOMElement} element Element or HTML to compile into a template function.
 * @returns {function([scope][, cloneAttachFn])} a template function which is used to bind template
 * (a DOM element/tree) to a scope. Where:
 *
 *   * `scope` - A {@link angular.scope scope} to bind to. If none specified, then a new
 *               root scope is created.
 *   * `cloneAttachFn` - If `cloneAttachFn` is provided, then the link function will clone the
 *               `template` and call the `cloneAttachFn` function allowing the caller to attach the
 *               cloned elements to the DOM document at the approriate place. The `cloneAttachFn` is
 *               called as: <br/> `cloneAttachFn(clonedElement, scope)` where:
 *
 *     * `clonedElement` - is a clone of the original `element` passed into the compiler.
 *     * `scope` - is the current scope with which the linking function is working with.
 *
 * Calling the template function returns the scope to which the element is bound to. It is either
 * the same scope as the one passed into the template function, or if none were provided it's the
 * newly create scope.
 *
 * If you need access to the bound view, there are two ways to do it:
 *
 * - If you are not asking the linking function to clone the template, create the DOM element(s)
 *   before you send them to the compiler and keep this reference around.
 *   <pre>
 *     var view = angular.element('<p>{{total}}</p>'),
 *         scope = angular.compile(view)();
 *   </pre>
 *
 * - if on the other hand, you need the element to be cloned, the view reference from the original
 *   example would not point to the clone, but rather to the original template that was cloned. In
 *   this case, you can access the clone via the cloneAttachFn:
 *   <pre>
 *     var original = angular.element('<p>{{total}}</p>'),
 *         scope = someParentScope.$new(),
 *         clone;
 *
 *     angular.compile(original)(scope, function(clonedElement, scope) {
 *       clone = clonedElement;
 *       //attach the clone to DOM document at the right place
 *     });
 *
 *     //now we have reference to the cloned DOM via `clone`
 *   </pre>
 */
function Compiler(markup, attrMarkup, directives, widgets){
  this.markup = markup;
  this.attrMarkup = attrMarkup;
  this.directives = directives;
  this.widgets = widgets;
}

Compiler.prototype = {
  compile: function(templateElement) {
    templateElement = jqLite(templateElement);
    var index = 0,
        template,
        parent = templateElement.parent();
    if (parent && parent[0]) {
      parent = parent[0];
      for(var i = 0; i < parent.childNodes.length; i++) {
        if (parent.childNodes[i] == templateElement[0]) {
          index = i;
        }
      }
    }
    template = this.templatize(templateElement, index, 0) || new Template();
    return function(scope, cloneConnectFn){
      // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart
      // and sometimes changes the structure of the DOM.
      var element = cloneConnectFn
        ? JQLitePrototype.clone.call(templateElement) // IMPORTANT!!!
        : templateElement;
        scope = scope || createScope();
      element.data($$scope, scope);
      scope.$element = element;
      (cloneConnectFn||noop)(element, scope);
      template.attach(element, scope);
      scope.$eval();
      return scope;
    };
  },


  /**
   * @workInProgress
   * @ngdoc directive
   * @name angular.directive.ng:eval-order
   *
   * @description
   * Normally the view is updated from top to bottom. This usually is
   * not a problem, but under some circumstances the values for data
   * is not available until after the full view is computed. If such
   * values are needed before they are computed the order of
   * evaluation can be change using ng:eval-order
   *
   * @element ANY
   * @param {integer|string=} [priority=0] priority integer, or FIRST, LAST constant
   *
   * @example
   * try changing the invoice and see that the Total will lag in evaluation
   * @example
     <doc:example>
       <doc:source>
        <div>TOTAL: without ng:eval-order {{ items.$sum('total') | currency }}</div>
        <div ng:eval-order='LAST'>TOTAL: with ng:eval-order {{ items.$sum('total') | currency }}</div>
        <table ng:init="items=[{qty:1, cost:9.99, desc:'gadget'}]">
          <tr>
            <td>QTY</td>
            <td>Description</td>
            <td>Cost</td>
            <td>Total</td>
            <td></td>
          </tr>
          <tr ng:repeat="item in items">
            <td><input name="item.qty"/></td>
            <td><input name="item.desc"/></td>
            <td><input name="item.cost"/></td>
            <td>{{item.total = item.qty * item.cost | currency}}</td>
            <td><a href="" ng:click="items.$remove(item)">X</a></td>
          </tr>
          <tr>
            <td colspan="3"><a href="" ng:click="items.$add()">add</a></td>
            <td>{{ items.$sum('total') | currency }}</td>
          </tr>
        </table>
       </doc:source>
       <doc:scenario>
         it('should check ng:format', function(){
           expect(using('.doc-example-live div:first').binding("items.$sum('total')")).toBe('$9.99');
           expect(using('.doc-example-live div:last').binding("items.$sum('total')")).toBe('$9.99');
           input('item.qty').enter('2');
           expect(using('.doc-example-live div:first').binding("items.$sum('total')")).toBe('$9.99');
           expect(using('.doc-example-live div:last').binding("items.$sum('total')")).toBe('$19.98');
         });
       </doc:scenario>
     </doc:example>
   */

  templatize: function(element, elementIndex, priority){
    var self = this,
        widget,
        fn,
        directiveFns = self.directives,
        descend = true,
        directives = true,
        elementName = nodeName_(element),
        elementNamespace = elementName.indexOf(':') > 0 ? lowercase(elementName).replace(':', '-') : '',
        template,
        selfApi = {
          compile: bind(self, self.compile),
          descend: function(value){ if(isDefined(value)) descend = value; return descend;},
          directives: function(value){ if(isDefined(value)) directives = value; return directives;},
          scope: function(value){ if(isDefined(value)) template.newScope = template.newScope || value; return template.newScope;}
        };
    try {
      priority = element.attr('ng:eval-order') || priority || 0;
    } catch (e) {
      // for some reason IE throws error under some weird circumstances. so just assume nothing
      priority = priority || 0;
    }
    element.addClass(elementNamespace);
    if (isString(priority)) {
      priority = PRIORITY[uppercase(priority)] || parseInt(priority, 10);
    }
    template = new Template(priority);
    eachAttribute(element, function(value, name){
      if (!widget) {
        if (widget = self.widgets('@' + name)) {
          element.addClass('ng-attr-widget');
          widget = bind(selfApi, widget, value, element);
        }
      }
    });
    if (!widget) {
      if (widget = self.widgets(elementName)) {
        if (elementNamespace)
          element.addClass('ng-widget');
        widget = bind(selfApi, widget, element);
      }
    }
    if (widget) {
      descend = false;
      directives = false;
      var parent = element.parent();
      template.addInit(widget.call(selfApi, element));
      if (parent && parent[0]) {
        element = jqLite(parent[0].childNodes[elementIndex]);
      }
    }
    if (descend){
      // process markup for text nodes only
      for(var i=0, child=element[0].childNodes;
          i<child.length; i++) {
        if (isTextNode(child[i])) {
          forEach(self.markup, function(markup){
            if (i<child.length) {
              var textNode = jqLite(child[i]);
              markup.call(selfApi, textNode.text(), textNode, element);
            }
          });
        }
      }
    }

    if (directives) {
      // Process attributes/directives
      eachAttribute(element, function(value, name){
        forEach(self.attrMarkup, function(markup){
          markup.call(selfApi, value, name, element);
        });
      });
      eachAttribute(element, function(value, name){
        fn = directiveFns[name];
        if (fn) {
          element.addClass('ng-directive');
          template.addInit((directiveFns[name]).call(selfApi, value, element));
        }
      });
    }
    // Process non text child nodes
    if (descend) {
      eachNode(element, function(child, i){
        template.addChild(i, self.templatize(child, i, priority));
      });
    }
    return template.empty() ? null : template;
  }
};

function eachNode(element, fn){
  var i, chldNodes = element[0].childNodes || [], chld;
  for (i = 0; i < chldNodes.length; i++) {
    if(!isTextNode(chld = chldNodes[i])) {
      fn(jqLite(chld), i);
    }
  }
}

function eachAttribute(element, fn){
  var i, attrs = element[0].attributes || [], chld, attr, name, value, attrValue = {};
  for (i = 0; i < attrs.length; i++) {
    attr = attrs[i];
    name = attr.name;
    value = attr.value;
    if (msie && name == 'href') {
      value = decodeURIComponent(element[0].getAttribute(name, 2));
    }
    attrValue[name] = value;
  }
  forEachSorted(attrValue, fn);
}