Skip to content

Commit

Permalink
Workaround for ifort bug.
Browse files Browse the repository at this point in the history
ifort didn't like doing the getNamedItemValue_len pure
function. It turned out the only place that was called
was from getAttribute, so it was easy enough to inline
the relevant function, which makes ifort happy again.
  • Loading branch information
Toby White committed Jun 27, 2008
1 parent 66ec7cc commit 46176e4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 234 deletions.
153 changes: 27 additions & 126 deletions dom/m_dom_dom.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5036,64 +5036,6 @@ function getNamedItem(map, name, ex)result(np)
end function getNamedItem


pure function getNamedItem_Value_len(map, p, name) result(n)
type(NamedNodeMap), intent(in) :: map
logical, intent(in) :: p
character(len=*), intent(in) :: name
integer :: n

integer :: i

n = 0
if (p) then
do i = 1, map%length
if (str_vs(map%nodes(i)%this%nodeName)==name) then
! This has to be NodeValue, not TextContent since it should be 0 for entity/notation
n = getNodeValue_len(map%nodes(i)%this, .true.)
exit
endif
enddo
endif

end function getNamedItem_Value_len


function getNamedItem_Value(map, name, ex)result(c)
type(DOMException), intent(out), optional :: ex
type(NamedNodeMap), pointer :: map
character(len=*), intent(in) :: name
#ifdef RESTRICTED_ASSOCIATED_BUG
character(len=getNamedItem_Value_len(map, .true., name)) :: c
#else
character(len=getNamedItem_Value_len(map, associated(map), name)) :: c
#endif

integer :: i

if (.not.associated(map)) then
if (getFoX_checks().or.FoX_MAP_IS_NULL<200) then
call throw_exception(FoX_MAP_IS_NULL, "getNamedItem_Value", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif

endif

c = ""
do i = 1, map%length
if (str_vs(map%nodes(i)%this%nodeName)==name) then
! This has to be NodeValue, not TextContent since it should be 0 for entity/notation
c = getNodeValue(map%nodes(i)%this)
return
endif
enddo

end function getNamedItem_Value


function setNamedItem(map, arg, ex)result(np)
type(DOMException), intent(out), optional :: ex
type(NamedNodeMap), pointer :: map
Expand Down Expand Up @@ -5397,71 +5339,6 @@ function getNamedItemNS(map, namespaceURI, localName, ex)result(np)
end function getNamedItemNS


pure function getNamedItemNS_Value_len(map, p, namespaceURI, localName) result(n)
type(NamedNodeMap), intent(in) :: map
logical, intent(in) :: p
character(len=*), intent(in) :: namespaceURI
character(len=*), intent(in) :: localName
integer :: n

integer :: i

n = 0
if (.not.p) return
if (map%ownerElement%nodeType/=ELEMENT_NODE) return
! Since entities & notations cant have NS.

do i = 1, map%length
if (str_vs(map%nodes(i)%this%elExtras%namespaceURI)==namespaceURI &
.and. str_vs(map%nodes(i)%this%elExtras%localName)==localName) then
n = getNodeValue_len(map%nodes(i)%this, .true.)
exit
endif
enddo

end function getNamedItemNS_Value_len


function getNamedItemNS_Value(map, namespaceURI, localName, ex)result(c)
type(DOMException), intent(out), optional :: ex
type(NamedNodeMap), pointer :: map
character(len=*), intent(in) :: namespaceURI
character(len=*), intent(in) :: localName
#ifdef RESTRICTED_ASSOCIATED_BUG
character(len=getNamedItemNS_Value_len(map, .true., namespaceURI, localName)) :: c
#else
character(len=getNamedItemNS_Value_len(map, associated(map), namespaceURI, localName)) :: c
#endif

integer :: i
type(Node), pointer :: np

if (.not.associated(map)) then
if (getFoX_checks().or.FoX_MAP_IS_NULL<200) then
call throw_exception(FoX_MAP_IS_NULL, "getNamedItemNS_Value", ex)
if (present(ex)) then
if (inException(ex)) then
return
endif
endif
endif

endif

c = ""
if (map%ownerElement%nodeType/=ELEMENT_NODE) return
do i = 0, getLength(map) - 1
np => item(map, i)
if (getNamespaceURI(np)==namespaceURI &
.and. getLocalName(np)==localName) then
c = getNodeValue(np)
return
endif
enddo

end function getNamedItemNS_Value


function setNamedItemNS(map, arg, ex)result(np)
type(DOMException), intent(out), optional :: ex
type(NamedNodeMap), pointer :: map
Expand Down Expand Up @@ -9339,6 +9216,8 @@ function getAttribute(arg, name, ex)result(c)
character(len=getAttribute_len(arg, associated(arg), name)) :: c
#endif

integer :: i

if (.not.associated(arg)) then
if (getFoX_checks().or.FoX_NODE_IS_NULL<200) then
call throw_exception(FoX_NODE_IS_NULL, "getAttribute", ex)
Expand All @@ -9363,7 +9242,16 @@ function getAttribute(arg, name, ex)result(c)

endif

c = getNamedItem_Value(getAttributes(arg), name)
if (len(c)>0) then
do i = 1, arg%elExtras%attributes%length
if (str_vs(arg%elExtras%attributes%nodes(i)%this%nodeName)==name) then
c = getTextContent(arg%elExtras%attributes%nodes(i)%this)
exit
endif
enddo
else
c = ""
endif

end function getAttribute

Expand Down Expand Up @@ -9726,6 +9614,8 @@ function getAttributeNS(arg, namespaceURI, localName, ex)result(c)
character(len=getAttributesNS_len(arg, associated(arg), localname, namespaceURI)) :: c
#endif

integer :: i

if (.not.associated(arg)) then
if (getFoX_checks().or.FoX_NODE_IS_NULL<200) then
call throw_exception(FoX_NODE_IS_NULL, "getAttributeNS", ex)
Expand All @@ -9750,8 +9640,19 @@ function getAttributeNS(arg, namespaceURI, localName, ex)result(c)

endif

c = getNamedItemNS_Value(getAttributes(arg), namespaceURI, localName)

if (len(c)>0) then
do i = 1, arg%elExtras%attributes%length
if ((str_vs(arg%elExtras%attributes%nodes(i)%this%elExtras%localName)==localname &
.and. str_vs(arg%elExtras%attributes%nodes(i)%this%elExtras%namespaceURI)==namespaceURI) &
.or. (namespaceURI=="".and.str_vs(arg%elExtras%attributes%nodes(i)%this%nodeName)==localname)) then
c = getTextContent(arg%elExtras%attributes%nodes(i)%this)
exit
endif
enddo
else
c = ""
endif

end function getAttributeNS


Expand Down
30 changes: 27 additions & 3 deletions dom/m_dom_element.m4
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ TOHW_m_dom_get(DOMString, tagName, np%nodeName, (ELEMENT_NODE))
character(len=getAttribute_len(arg, associated(arg), name)) :: c
#endif

integer :: i

if (.not.associated(arg)) then
TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)
endif
Expand All @@ -63,7 +65,16 @@ TOHW_m_dom_get(DOMString, tagName, np%nodeName, (ELEMENT_NODE))
TOHW_m_dom_throw_error(FoX_INVALID_NODE)
endif

c = getNamedItem_Value(getAttributes(arg), name)
if (len(c)>0) then
do i = 1, arg%elExtras%attributes%length
if (str_vs(arg%elExtras%attributes%nodes(i)%this%nodeName)==name) then
c = getTextContent(arg%elExtras%attributes%nodes(i)%this)
exit
endif
enddo
else
c = ""
endif

end function getAttribute

Expand Down Expand Up @@ -268,6 +279,8 @@ TOHW_m_dom_get(DOMString, tagName, np%nodeName, (ELEMENT_NODE))
character(len=getAttributesNS_len(arg, associated(arg), localname, namespaceURI)) :: c
#endif

integer :: i

if (.not.associated(arg)) then
TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)
endif
Expand All @@ -276,8 +289,19 @@ TOHW_m_dom_get(DOMString, tagName, np%nodeName, (ELEMENT_NODE))
TOHW_m_dom_throw_error(FoX_INVALID_NODE)
endif

c = getNamedItemNS_Value(getAttributes(arg), namespaceURI, localName)

if (len(c)>0) then
do i = 1, arg%elExtras%attributes%length
if ((str_vs(arg%elExtras%attributes%nodes(i)%this%elExtras%localName)==localname &
.and. str_vs(arg%elExtras%attributes%nodes(i)%this%elExtras%namespaceURI)==namespaceURI) &
.or. (namespaceURI=="".and.str_vs(arg%elExtras%attributes%nodes(i)%this%nodeName)==localname)) then
c = getTextContent(arg%elExtras%attributes%nodes(i)%this)
exit
endif
enddo
else
c = ""
endif

end function getAttributeNS


Expand Down
105 changes: 0 additions & 105 deletions dom/m_dom_namednodemap.m4
Original file line number Diff line number Diff line change
Expand Up @@ -49,55 +49,6 @@ TOHW_m_dom_contents(`
end function getNamedItem


pure function getNamedItem_Value_len(map, p, name) result(n)
type(NamedNodeMap), intent(in) :: map
logical, intent(in) :: p
character(len=*), intent(in) :: name
integer :: n

integer :: i

n = 0
if (p) then
do i = 1, map%length
if (str_vs(map%nodes(i)%this%nodeName)==name) then
! This has to be NodeValue, not TextContent since it should be 0 for entity/notation
n = getNodeValue_len(map%nodes(i)%this, .true.)
exit
endif
enddo
endif

end function getNamedItem_Value_len


TOHW_function(getNamedItem_Value, (map, name), c)
type(NamedNodeMap), pointer :: map
character(len=*), intent(in) :: name
#ifdef RESTRICTED_ASSOCIATED_BUG
character(len=getNamedItem_Value_len(map, .true., name)) :: c
#else
character(len=getNamedItem_Value_len(map, associated(map), name)) :: c
#endif

integer :: i

if (.not.associated(map)) then
TOHW_m_dom_throw_error(FoX_MAP_IS_NULL)
endif

c = ""
do i = 1, map%length
if (str_vs(map%nodes(i)%this%nodeName)==name) then
! This has to be NodeValue, not TextContent since it should be 0 for entity/notation
c = getNodeValue(map%nodes(i)%this)
return
endif
enddo

end function getNamedItem_Value


TOHW_function(setNamedItem, (map, arg), np)
type(NamedNodeMap), pointer :: map
type(Node), pointer :: arg
Expand Down Expand Up @@ -300,62 +251,6 @@ TOHW_m_dom_contents(`
end function getNamedItemNS


pure function getNamedItemNS_Value_len(map, p, namespaceURI, localName) result(n)
type(NamedNodeMap), intent(in) :: map
logical, intent(in) :: p
character(len=*), intent(in) :: namespaceURI
character(len=*), intent(in) :: localName
integer :: n

integer :: i

n = 0
if (.not.p) return
if (map%ownerElement%nodeType/=ELEMENT_NODE) return
! Since entities & notations cant have NS.

do i = 1, map%length
if (str_vs(map%nodes(i)%this%elExtras%namespaceURI)==namespaceURI &
.and. str_vs(map%nodes(i)%this%elExtras%localName)==localName) then
n = getNodeValue_len(map%nodes(i)%this, .true.)
exit
endif
enddo

end function getNamedItemNS_Value_len


TOHW_function(getNamedItemNS_Value, (map, namespaceURI, localName), c)
type(NamedNodeMap), pointer :: map
character(len=*), intent(in) :: namespaceURI
character(len=*), intent(in) :: localName
#ifdef RESTRICTED_ASSOCIATED_BUG
character(len=getNamedItemNS_Value_len(map, .true., namespaceURI, localName)) :: c
#else
character(len=getNamedItemNS_Value_len(map, associated(map), namespaceURI, localName)) :: c
#endif

integer :: i
type(Node), pointer :: np

if (.not.associated(map)) then
TOHW_m_dom_throw_error(FoX_MAP_IS_NULL)
endif

c = ""
if (map%ownerElement%nodeType/=ELEMENT_NODE) return
do i = 0, getLength(map) - 1
np => item(map, i)
if (getNamespaceURI(np)==namespaceURI &
.and. getLocalName(np)==localName) then
c = getNodeValue(np)
return
endif
enddo

end function getNamedItemNS_Value


TOHW_function(setNamedItemNS, (map, arg), np)
type(NamedNodeMap), pointer :: map
type(Node), pointer :: arg
Expand Down

0 comments on commit 46176e4

Please sign in to comment.