You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by sh...@apache.org on 2010/05/24 06:31:27 UTC

svn commit: r947536 - in /axis/axis2/c/core/trunk/axiom: include/axiom_element.h src/om/om_element.c

Author: shankar
Date: Mon May 24 04:31:26 2010
New Revision: 947536

URL: http://svn.apache.org/viewvc?rev=947536&view=rev
Log:
adding axiom_element_declare_namespace_assume_param_ownership method

Modified:
    axis/axis2/c/core/trunk/axiom/include/axiom_element.h
    axis/axis2/c/core/trunk/axiom/src/om/om_element.c

Modified: axis/axis2/c/core/trunk/axiom/include/axiom_element.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_element.h?rev=947536&r1=947535&r2=947536&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_element.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_element.h Mon May 24 04:31:26 2010
@@ -432,6 +432,21 @@ extern "C"
         const axutil_env_t * env,
         axiom_node_t * element_node);
 
+    /**
+	 * This method will declare the namespace without checking whether it is already declared. 
+	 * (This method is only used by codegen. We have to remove this method in future)
+     * @param om_element pointer to om_element
+     * @param env environment MUST not be NULL
+     * @param om_node pointer to this element node
+     * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+     *
+     */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axiom_element_declare_namespace_assume_param_ownership(
+        axiom_element_t * om_element,
+        const axutil_env_t * env,
+        axiom_namespace_t * ns);
+
 #if 0
     /**
      * builds this om_element_node completely, This is only possible
@@ -508,18 +523,6 @@ extern "C"
         const axutil_env_t * env,
         axiom_namespace_t * om_ns);
 
-    /**
-     * @param om_element pointer to om_element
-     * @param env environment MUST not be NULL
-     * @param om_node pointer to this element node
-     * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
-     *
-     */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    axiom_element_declare_namespace_assume_param_ownership(
-        axiom_element_t * om_element,
-        const axutil_env_t * env,
-        axiom_namespace_t * ns);
 
     /**
      * unconditionally set the namespace of the element

Modified: axis/axis2/c/core/trunk/axiom/src/om/om_element.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/om_element.c?rev=947536&r1=947535&r2=947536&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/om_element.c (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/om_element.c Mon May 24 04:31:26 2010
@@ -1565,6 +1565,63 @@ axiom_element_set_is_empty(
     om_element->is_empty = is_empty;
 }
 
+/**
+ * This method will declare the namespace without checking whether it is already declared. 
+ * (This method is only used by codegen. We have to remove this method in future)
+ * @param om_element pointer to om_element
+ * @param env environment MUST not be NULL
+ * @param om_node pointer to this element node
+ * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+ *
+ */
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_element_declare_namespace_assume_param_ownership(
+    axiom_element_t * om_element,
+    const axutil_env_t * env,
+    axiom_namespace_t * ns)
+{
+    axis2_char_t *prefix = NULL;
+
+    if(!ns || !om_element)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "namespace or om_element is NULL");
+        return AXIS2_FAILURE;
+    }
+
+    if(!(om_element->namespaces))
+    {
+        om_element->namespaces = axutil_hash_make(env);
+        if(!(om_element->namespaces))
+        {
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create namespaces hash map");
+            return AXIS2_FAILURE;
+        }
+    }
+	
+    prefix = axiom_namespace_get_prefix(ns, env);
+    if(prefix)
+    {
+        axutil_hash_set(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns);
+    }
+    else
+    {
+        /* create a key with empty string */
+        axis2_char_t *key;
+        key = AXIS2_MALLOC(env->allocator, sizeof(char) * 1);
+        if(!key)
+        {
+            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+                "Insufficient memory to create key to store namespace");
+        }
+        key[0] = '\0';
+        axutil_hash_set(om_element->namespaces, key, AXIS2_HASH_KEY_STRING, ns);
+    }
+    axiom_namespace_increment_ref(ns, env);
+    return AXIS2_SUCCESS;
+}
+
 #if 0
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axiom_element_build(
@@ -1685,50 +1742,6 @@ axiom_element_set_namespace_with_no_find
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axiom_element_declare_namespace_assume_param_ownership(
-    axiom_element_t * om_element,
-    const axutil_env_t * env,
-    axiom_namespace_t * ns)
-{
-    axis2_char_t *prefix = NULL;
-    axis2_char_t *uri = NULL;
-
-    if(!ns || !om_element)
-    {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "namespace or om_element is NULL");
-        return AXIS2_FAILURE;
-    }
-
-    uri = axiom_namespace_get_uri(ns, env);
-    prefix = axiom_namespace_get_prefix(ns, env);
-
-    if(!(om_element->namespaces))
-    {
-        om_element->namespaces = axutil_hash_make(env);
-        if(!(om_element->namespaces))
-        {
-            return AXIS2_FAILURE;
-        }
-    }
-    if(prefix)
-    {
-        axutil_hash_set(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns);
-    }
-    else
-    {
-        axis2_char_t *key = NULL;
-        key = AXIS2_MALLOC(env->allocator, sizeof(char) * 10);
-        memset(key, 0, sizeof(char) * 10);
-        key[0] = '\0';
-        axutil_hash_set(om_element->namespaces, key, AXIS2_HASH_KEY_STRING, ns);
-    }
-    axiom_namespace_increment_ref(ns, env);
-
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axiom_element_set_namespace_assume_param_ownership(
     axiom_element_t * om_element,
     const axutil_env_t * env,