Added: webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_particle.c URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_particle.c?rev=394660&view=auto ============================================================================== --- webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_particle.c (added) +++ webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_particle.c Mon Apr 17 05:15:47 2006 @@ -0,0 +1,232 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_xml_schema_particle.h> + +typedef struct axis2_xml_schema_particle_impl axis2_xml_schema_particle_impl_t; + +/** + * @brief Other Extension Struct Impl + * Axis2 Other Extension + */ +struct axis2_xml_schema_particle_impl +{ + axis2_xml_schema_particle_t particle; + axis2_xml_schema_annotated_t *annotated; + long max_occurs; + axis2_char_t *max_occurs_string; + long min_occurs; + axis2_char_t *min_occurs_string; + axis2_hash_t *methods; + void *inherited; +}; + +#define INTF_TO_IMPL(particle) ((axis2_xml_schema_particle_impl_t *) particle) + +axis2_status_t AXIS2_CALL +axis2_xml_schema_particle_free(void *particle, + axis2_env_t **env); + +axis2_xml_schema_annotated_t *AXIS2_CALL +axis2_xml_schema_particle_get_base_impl(void *particle, + axis2_env_t **env); + +long AXIS2_CALL +axis2_xml_schema_particle_get_max_occurs(void *particle, + axis2_env_t **env); + +axis2_status_t AXIS2_CALL +axis2_xml_schema_particle_set_max_occurs(void *particle, + axis2_env_t **env, + long max_occurs); + +long AXIS2_CALL +axis2_xml_schema_particle_get_min_occurs(void *particle, + axis2_env_t **env); + +axis2_status_t AXIS2_CALL +axis2_xml_schema_particle_set_min_occurs(void *particle, + axis2_env_t **env, + long min_occurs); + +AXIS2_DECLARE(axis2_xml_schema_particle_t *) +axis2_xml_schema_particle_create(axis2_env_t **env) +{ + axis2_xml_schema_particle_impl_t *particle_impl = NULL; + axis2_status_t status = AXIS2_FAILURE; + + particle_impl = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_particle_impl_t)); + + particle_impl->annotated = NULL; + particle_impl->methods = NULL; + particle_impl->particle.ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_particle_ops_t)); + + particle_impl->particle.ops->free = axis2_xml_schema_particle_free; + particle_impl->particle.ops->get_base_impl = + axis2_xml_schema_particle_get_base_impl; + particle_impl->particle.ops->get_max_occurs = + axis2_xml_schema_particle_get_max_occurs; + particle_impl->particle.ops->set_max_occurs = + axis2_xml_schema_particle_set_max_occurs; + particle_impl->particle.ops->get_min_occurs = + axis2_xml_schema_particle_get_min_occurs; + particle_impl->particle.ops->set_min_occurs = + axis2_xml_schema_particle_set_min_occurs; + + particle_impl->methods = axis2_hash_make(env); + if(!particle_impl->methods) + { + AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + axis2_hash_set(particle_impl->methods, "free", AXIS2_HASH_KEY_STRING, + axis2_xml_schema_particle_free); + axis2_hash_set(particle_impl->methods, "get_max_occurs", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_particle_get_max_occurs); + axis2_hash_set(particle_impl->methods, "set_max_occurs", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_particle_set_max_occurs); + axis2_hash_set(particle_impl->methods, "get_min_occurs", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_particle_get_min_occurs); + axis2_hash_set(particle_impl->methods, "set_min_occurs", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_particle_set_min_occurs); + + particle_impl->annotated = axis2_xml_schema_annotated_create(env); + status = axis2_xml_schema_annotated_resolve_methods( + &(particle_impl->particle.base), env, particle_impl->annotated, + particle_impl->methods); + + return &(particle_impl->particle); +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_particle_free(void *particle, + axis2_env_t **env) +{ + axis2_xml_schema_particle_impl_t *particle_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + particle_impl = INTF_TO_IMPL(particle); + + if(particle_impl->methods) + { + axis2_hash_free(particle_impl->methods, env); + particle_impl->methods = NULL; + } + + if(particle_impl->annotated) + { + AXIS2_XML_SCHEMA_OBJ_FREE(particle_impl->annotated, env); + particle_impl->annotated = NULL; + } + + if((&(particle_impl->particle))->ops) + { + AXIS2_FREE((*env)->allocator, (&(particle_impl->particle))->ops); + (&(particle_impl->particle))->ops = NULL; + } + + if(particle_impl) + { + AXIS2_FREE((*env)->allocator, particle_impl); + particle_impl = NULL; + } + return AXIS2_SUCCESS; +} + +axis2_xml_schema_annotated_t *AXIS2_CALL +axis2_xml_schema_particle_get_base_impl(void *particle, + axis2_env_t **env) +{ + axis2_xml_schema_particle_impl_t *particle_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + particle_impl = INTF_TO_IMPL(particle); + + return particle_impl->annotated; +} + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_schema_particle_resolve_methods( + axis2_xml_schema_particle_t *particle, + axis2_env_t **env, + axis2_xml_schema_particle_t *particle_impl, + axis2_hash_t *methods) +{ + axis2_xml_schema_particle_impl_t *particle_impl_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, particle_impl, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, methods, AXIS2_FAILURE); + + particle_impl_l = (axis2_xml_schema_particle_impl_t *) particle_impl; + + particle->ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_particle_ops_t)); + particle->ops->free = axis2_hash_get(methods, "free", + AXIS2_HASH_KEY_STRING); + particle->ops->get_base_impl = + particle_impl_l->particle.ops->get_base_impl; + particle->ops->get_max_occurs = + particle_impl_l->particle.ops->get_max_occurs; + particle->ops->set_max_occurs = + particle_impl_l->particle.ops->set_max_occurs; + particle->ops->get_min_occurs = + particle_impl_l->particle.ops->get_min_occurs; + particle->ops->set_min_occurs = + particle_impl_l->particle.ops->set_min_occurs; + + return axis2_xml_schema_annotated_resolve_methods(&(particle->base), + env, particle_impl_l->annotated, methods); +} + +long AXIS2_CALL +axis2_xml_schema_particle_get_max_occurs(void *particle, + axis2_env_t **env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return INTF_TO_IMPL(particle)->max_occurs; +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_particle_set_max_occurs(void *particle, + axis2_env_t **env, + long max_occurs) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + INTF_TO_IMPL(particle)->max_occurs = max_occurs; + return AXIS2_SUCCESS; +} + +long AXIS2_CALL +axis2_xml_schema_particle_get_min_occurs(void *particle, + axis2_env_t **env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return INTF_TO_IMPL(particle)->min_occurs; +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_particle_set_min_occurs(void *particle, + axis2_env_t **env, + long min_occurs) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + INTF_TO_IMPL(particle)->min_occurs = min_occurs; + return AXIS2_SUCCESS; +} +
Added: webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_sequence.c URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_sequence.c?rev=394660&view=auto ============================================================================== --- webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_sequence.c (added) +++ webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_sequence.c Mon Apr 17 05:15:47 2006 @@ -0,0 +1,177 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_xml_schema_sequence.h> +#include <axis2_xml_schema_group_base.h> + +typedef struct axis2_xml_schema_sequence_impl axis2_xml_schema_sequence_impl_t; + +/** + * @brief Other Extension Struct Impl + * Axis2 Other Extension + */ +struct axis2_xml_schema_sequence_impl +{ + axis2_xml_schema_sequence_t sequence; + axis2_xml_schema_group_base_t *base; + axis2_hash_t *methods; + axis2_xml_schema_obj_collection_t *items; +}; + +#define INTF_TO_IMPL(sequence) ((axis2_xml_schema_sequence_impl_t *) sequence) + +axis2_status_t AXIS2_CALL +axis2_xml_schema_sequence_free(void *sequence, + axis2_env_t **env); + +axis2_xml_schema_group_base_t *AXIS2_CALL +axis2_xml_schema_sequence_get_base_impl(void *sequence, + axis2_env_t **env); + +axis2_xml_schema_obj_collection_t *AXIS2_CALL +axis2_xml_schema_sequence_get_items(void *sequence, + axis2_env_t **env); + + +AXIS2_DECLARE(axis2_xml_schema_sequence_t *) +axis2_xml_schema_sequence_create(axis2_env_t **env) +{ + axis2_xml_schema_sequence_impl_t *sequence_impl = NULL; + axis2_status_t status = AXIS2_FAILURE; + + sequence_impl = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_sequence_impl_t)); + + sequence_impl->base = NULL; + sequence_impl->methods = NULL; + sequence_impl->items = NULL; + sequence_impl->sequence.ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_sequence_ops_t)); + + sequence_impl->sequence.ops->free = axis2_xml_schema_sequence_free; + sequence_impl->sequence.ops->get_base_impl = + axis2_xml_schema_sequence_get_base_impl; + sequence_impl->sequence.ops->get_items = + axis2_xml_schema_sequence_get_items; + + sequence_impl->methods = axis2_hash_make(env); + if(!sequence_impl->methods) + { + AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + axis2_hash_set(sequence_impl->methods, "free", AXIS2_HASH_KEY_STRING, + axis2_xml_schema_sequence_free); + axis2_hash_set(sequence_impl->methods, "get_items", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_sequence_get_items); + + sequence_impl->base = axis2_xml_schema_group_base_create(env); + status = axis2_xml_schema_group_base_resolve_methods( + &(sequence_impl->sequence.base), env, sequence_impl->base, + sequence_impl->methods); + + return &(sequence_impl->sequence); +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_sequence_free(void *sequence, + axis2_env_t **env) +{ + axis2_xml_schema_sequence_impl_t *sequence_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + sequence_impl = INTF_TO_IMPL(sequence); + + if(sequence_impl->items) + { + AXIS2_XML_SCHEMA_OBJ_COLLECTION_FREE(sequence_impl->items, env); + sequence_impl->items = NULL; + } + + if(sequence_impl->methods) + { + axis2_hash_free(sequence_impl->methods, env); + sequence_impl->methods = NULL; + } + + if(sequence_impl->base) + { + AXIS2_XML_SCHEMA_GROUP_BASE_FREE(sequence_impl->base, env); + sequence_impl->base = NULL; + } + + if((&(sequence_impl->sequence))->ops) + { + AXIS2_FREE((*env)->allocator, (&(sequence_impl->sequence))->ops); + (&(sequence_impl->sequence))->ops = NULL; + } + + if(sequence_impl) + { + AXIS2_FREE((*env)->allocator, sequence_impl); + sequence_impl = NULL; + } + return AXIS2_SUCCESS; +} + +axis2_xml_schema_group_base_t *AXIS2_CALL +axis2_xml_schema_sequence_get_base_impl(void *sequence, + axis2_env_t **env) +{ + axis2_xml_schema_sequence_impl_t *sequence_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + sequence_impl = INTF_TO_IMPL(sequence); + + return sequence_impl->base; +} + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_schema_sequence_resolve_methods( + axis2_xml_schema_sequence_t *sequence, + axis2_env_t **env, + axis2_xml_schema_sequence_t *sequence_impl, + axis2_hash_t *methods) +{ + axis2_xml_schema_sequence_impl_t *sequence_impl_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, sequence_impl, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, methods, AXIS2_FAILURE); + + sequence_impl_l = (axis2_xml_schema_sequence_impl_t *) sequence_impl; + + sequence->ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_sequence_ops_t)); + sequence->ops->free = axis2_hash_get(methods, "free", + AXIS2_HASH_KEY_STRING); + sequence->ops->get_base_impl = + sequence_impl_l->sequence.ops->get_base_impl; + sequence->ops->get_items = + sequence_impl_l->sequence.ops->get_items; + + return axis2_xml_schema_group_base_resolve_methods(&(sequence->base), + env, sequence_impl_l->base, methods); +} + +axis2_xml_schema_obj_collection_t *AXIS2_CALL +axis2_xml_schema_sequence_get_items(void *sequence, + axis2_env_t **env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return INTF_TO_IMPL(sequence)->items; +} + Added: webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_type.c URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_type.c?rev=394660&view=auto ============================================================================== --- webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_type.c (added) +++ webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_type.c Mon Apr 17 05:15:47 2006 @@ -0,0 +1,364 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_xml_schema_type.h> +#include <axis2_xml_schema_data_type.h> +#include <axis2_xml_schema_derivation_method.h> +#include <axis2_xml_schema.h> + +typedef struct axis2_xml_schema_type_impl axis2_xml_schema_type_impl_t; + +/** + * @brief Other Extension Struct Impl + * Axis2 Other Extension + */ +struct axis2_xml_schema_type_impl +{ + axis2_xml_schema_type_t type; + axis2_xml_schema_annotated_t *annotated; + axis2_hash_t *methods; + axis2_xml_schema_data_type_t *data_type; + axis2_xml_schema_derivation_method_t *derive_by; + axis2_xml_schema_derivation_method_t *final_derivation; + axis2_xml_schema_derivation_method_t *final_resolved; + axis2_bool_t is_mixed; + /* Name of the type */ + axis2_char_t *name; + axis2_xml_schema_t *schema; +}; + +#define INTF_TO_IMPL(type) ((axis2_xml_schema_type_impl_t *) type) + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_free(void *type, + axis2_env_t **env); + +axis2_xml_schema_annotated_t *AXIS2_CALL +axis2_xml_schema_type_get_base_impl(void *type, + axis2_env_t **env); + +void *AXIS2_CALL +axis2_xml_schema_type_get_base_schema_type(void *type, + axis2_env_t **env); + +axis2_xml_schema_data_type_t *AXIS2_CALL +axis2_xml_schema_type_get_data_type(void *type, + axis2_env_t **env); + +axis2_xml_schema_derivation_method_t *AXIS2_CALL +axis2_xml_schema_type_get_derive_by(void *type, + axis2_env_t **env); + +axis2_xml_schema_derivation_method_t *AXIS2_CALL +axis2_xml_schema_type_get_final(void *type, + axis2_env_t **env); + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_set_final(void *type, + axis2_env_t **env, + axis2_xml_schema_derivation_method_t *final_derivation); + +axis2_xml_schema_derivation_method_t *AXIS2_CALL +axis2_xml_schema_type_get_final_resolved(void *type, + axis2_env_t **env); + +axis2_bool_t AXIS2_CALL +axis2_xml_schema_type_is_mixed(void *type, + axis2_env_t **env); + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_set_mixed(void *type, + axis2_env_t **env, + axis2_bool_t is_mixed); + +axis2_char_t *AXIS2_CALL +axis2_xml_schema_type_get_name(void *type, + axis2_env_t **env); + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_set_name(void *type, + axis2_env_t **env, + axis2_char_t *name); + +axis2_qname_t *AXIS2_CALL +axis2_xml_schema_type_get_qname(void *type, + axis2_env_t **env); + +AXIS2_DECLARE(axis2_xml_schema_type_t *) +axis2_xml_schema_type_create(axis2_env_t **env, + axis2_xml_schema_t *schema) +{ + axis2_xml_schema_type_impl_t *type_impl = NULL; + axis2_status_t status = AXIS2_FAILURE; + + type_impl = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_type_impl_t)); + + type_impl->annotated = NULL; + type_impl->methods = NULL; + type_impl->schema = schema; + type_impl->type.ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_type_ops_t)); + + type_impl->type.ops->free = axis2_xml_schema_type_free; + type_impl->type.ops->get_base_impl = + axis2_xml_schema_type_get_base_impl; + type_impl->type.ops->get_base_schema_type = + axis2_xml_schema_type_get_base_schema_type; + type_impl->type.ops->get_data_type = + axis2_xml_schema_type_get_data_type; + type_impl->type.ops->get_derive_by = + axis2_xml_schema_type_get_derive_by; + type_impl->type.ops->get_final = + axis2_xml_schema_type_get_final; + type_impl->type.ops->set_final = + axis2_xml_schema_type_set_final; + type_impl->type.ops->get_final_resolved = + axis2_xml_schema_type_get_final_resolved; + type_impl->type.ops->is_mixed = + axis2_xml_schema_type_is_mixed; + type_impl->type.ops->set_mixed = + axis2_xml_schema_type_set_mixed; + type_impl->type.ops->get_name = + axis2_xml_schema_type_get_name; + type_impl->type.ops->set_name = + axis2_xml_schema_type_set_name; + type_impl->type.ops->get_qname = + axis2_xml_schema_type_get_qname; + + type_impl->methods = axis2_hash_make(env); + if(!type_impl->methods) + { + AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + type_impl->final_derivation = axis2_xml_schema_derivation_method_create(env, + "None"); + + axis2_hash_set(type_impl->methods, "free", AXIS2_HASH_KEY_STRING, + axis2_xml_schema_type_free); + axis2_hash_set(type_impl->methods, "get_base_schema_type", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_get_base_schema_type); + axis2_hash_set(type_impl->methods, "get_data_type", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_get_data_type); + axis2_hash_set(type_impl->methods, "get_derive_by", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_get_derive_by); + axis2_hash_set(type_impl->methods, "get_final", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_get_final); + axis2_hash_set(type_impl->methods, "set_final", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_set_final); + axis2_hash_set(type_impl->methods, "get_final_resolved", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_get_final_resolved); + axis2_hash_set(type_impl->methods, "is_mixed", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_is_mixed); + axis2_hash_set(type_impl->methods, "set_mixed", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_set_mixed); + axis2_hash_set(type_impl->methods, "get_name", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_get_name); + axis2_hash_set(type_impl->methods, "set_name", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_set_name); + axis2_hash_set(type_impl->methods, "get_qname", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_type_get_qname); + + type_impl->annotated = axis2_xml_schema_annotated_create(env); + status = axis2_xml_schema_annotated_resolve_methods( + &(type_impl->type.base), env, type_impl->annotated, + type_impl->methods); + + return &(type_impl->type); +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_free(void *type, + axis2_env_t **env) +{ + axis2_xml_schema_type_impl_t *type_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + type_impl = INTF_TO_IMPL(type); + + if(type_impl->methods) + { + axis2_hash_free(type_impl->methods, env); + type_impl->methods = NULL; + } + + if(type_impl->annotated) + { + AXIS2_XML_SCHEMA_OBJ_FREE(type_impl->annotated, env); + type_impl->annotated = NULL; + } + + if((&(type_impl->type))->ops) + { + AXIS2_FREE((*env)->allocator, (&(type_impl->type))->ops); + (&(type_impl->type))->ops = NULL; + } + + if(type_impl) + { + AXIS2_FREE((*env)->allocator, type_impl); + type_impl = NULL; + } + return AXIS2_SUCCESS; +} + +axis2_xml_schema_annotated_t *AXIS2_CALL +axis2_xml_schema_type_get_base_impl(void *type, + axis2_env_t **env) +{ + axis2_xml_schema_type_impl_t *type_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + type_impl = INTF_TO_IMPL(type); + + return type_impl->annotated; +} + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_schema_type_resolve_methods( + axis2_xml_schema_type_t *type, + axis2_env_t **env, + axis2_xml_schema_type_t *type_impl, + axis2_hash_t *methods) +{ + axis2_xml_schema_type_impl_t *type_impl_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, type_impl, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, methods, AXIS2_FAILURE); + + type_impl_l = (axis2_xml_schema_type_impl_t *) type_impl; + + type->ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_type_ops_t)); + type->ops->free = axis2_hash_get(methods, "free", + AXIS2_HASH_KEY_STRING); + type->ops->get_base_impl = + type_impl_l->type.ops->get_base_impl; + type->ops->get_base_schema_type = + type_impl_l->type.ops->get_base_schema_type; + type->ops->get_data_type = + type_impl_l->type.ops->get_data_type; + type->ops->get_derive_by = + type_impl_l->type.ops->get_derive_by; + type->ops->get_final = + type_impl_l->type.ops->get_final; + type->ops->set_final = + type_impl_l->type.ops->set_final; + type->ops->get_final_resolved = + type_impl_l->type.ops->get_final_resolved; + type->ops->is_mixed = + type_impl_l->type.ops->is_mixed; + type->ops->set_mixed = + type_impl_l->type.ops->set_mixed; + type->ops->get_name = + type_impl_l->type.ops->get_name; + type->ops->set_name = + type_impl_l->type.ops->set_name; + type->ops->get_qname = + type_impl_l->type.ops->get_qname; + + return axis2_xml_schema_annotated_resolve_methods(&(type->base), + env, type_impl_l->annotated, methods); +} + +void *AXIS2_CALL +axis2_xml_schema_type_get_base_schema_type(void *type, + axis2_env_t **env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return NULL; +} + +axis2_xml_schema_data_type_t *AXIS2_CALL +axis2_xml_schema_type_get_data_type(void *type, + axis2_env_t **env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return NULL; +} + +axis2_xml_schema_derivation_method_t *AXIS2_CALL +axis2_xml_schema_type_get_derive_by(void *type, + axis2_env_t **env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return NULL; +} + +axis2_xml_schema_derivation_method_t *AXIS2_CALL +axis2_xml_schema_type_get_final(void *type, + axis2_env_t **env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return NULL; +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_set_final(void *type, + axis2_env_t **env, + axis2_xml_schema_derivation_method_t *final_derivation) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return AXIS2_SUCCESS; +} + +axis2_xml_schema_derivation_method_t *AXIS2_CALL +axis2_xml_schema_type_get_final_resolved(void *type, + axis2_env_t **env) +{ + return NULL; +} + +axis2_bool_t AXIS2_CALL +axis2_xml_schema_type_is_mixed(void *type, + axis2_env_t **env) +{ + return AXIS2_TRUE; +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_set_mixed(void *type, + axis2_env_t **env, + axis2_bool_t is_mixed) +{ + return AXIS2_SUCCESS; +} + +axis2_char_t *AXIS2_CALL +axis2_xml_schema_type_get_name(void *type, + axis2_env_t **env) +{ + return NULL; +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_set_name(void *type, + axis2_env_t **env, + axis2_char_t *name) +{ + return AXIS2_SUCCESS; +} + +axis2_qname_t *AXIS2_CALL +axis2_xml_schema_type_get_qname(void *type, + axis2_env_t **env) +{ + return NULL; +} + Added: webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_type_receiver.c URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_type_receiver.c?rev=394660&view=auto ============================================================================== --- webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_type_receiver.c (added) +++ webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_type_receiver.c Mon Apr 17 05:15:47 2006 @@ -0,0 +1,121 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_xml_schema_type_receiver.h> +#include <axis2_xml_schema_type.h> +#include <axis2_hash.h> + +typedef struct axis2_xml_schema_type_receiver_impl axis2_xml_schema_type_receiver_impl_t; + +/** + * @brief Xml Schema Type Receiver Struct Impl + * Axis2 Xml Schema Type Receiver + */ +struct axis2_xml_schema_type_receiver_impl +{ + axis2_xml_schema_type_receiver_t type_receiver; +}; + +#define INTF_TO_IMPL(type_receiver) ((axis2_xml_schema_type_receiver_impl_t *) type_receiver) + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_receiver_free(void *type_receiver, + axis2_env_t **env); + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_receiver_set_type(void *type_receiver, + axis2_env_t **env, + axis2_xml_schema_type_t *type); + +AXIS2_DECLARE(axis2_xml_schema_type_receiver_t *) +axis2_xml_schema_type_receiver_create(axis2_env_t **env) +{ + axis2_xml_schema_type_receiver_impl_t *type_receiver_impl = NULL; + + type_receiver_impl = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_type_receiver_impl_t)); + + type_receiver_impl->type_receiver.ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_type_receiver_ops_t)); + + + type_receiver_impl->type_receiver.ops->free = axis2_xml_schema_type_receiver_free; + type_receiver_impl->type_receiver.ops->set_type = axis2_xml_schema_type_receiver_set_type; + + return &(type_receiver_impl->type_receiver); +} + + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_receiver_free(void *type_receiver, + axis2_env_t **env) +{ + axis2_xml_schema_type_receiver_impl_t *type_receiver_impl = NULL; + + type_receiver_impl = INTF_TO_IMPL(type_receiver); + + if((&(type_receiver_impl->type_receiver))->ops) + { + free((&(type_receiver_impl->type_receiver))->ops); + (&(type_receiver_impl->type_receiver))->ops = NULL; + } + + if(type_receiver_impl) + { + free(type_receiver_impl); + type_receiver_impl = NULL; + } + return AXIS2_SUCCESS; +} + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_schema_type_receiver_resolve_methods(axis2_xml_schema_type_receiver_t *type_receiver, + axis2_env_t **env, + axis2_xml_schema_type_receiver_t *type_receiver_impl, + axis2_hash_t *methods) +{ + axis2_xml_schema_type_receiver_impl_t *type_receiver_impl_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, type_receiver_impl, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, methods, AXIS2_FAILURE); + + type_receiver_impl_l = (axis2_xml_schema_type_receiver_impl_t *) type_receiver_impl; + + type_receiver->ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_type_receiver_ops_t)); + type_receiver->ops->free = axis2_hash_get(methods, "free", + AXIS2_HASH_KEY_STRING); + type_receiver->ops->free = axis2_hash_get(methods, "set_type", + AXIS2_HASH_KEY_STRING); + return AXIS2_SUCCESS; + +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_type_receiver_set_type(void *type_receiver, + axis2_env_t **env, + axis2_xml_schema_type_t *type) +{ + axis2_xml_schema_type_receiver_impl_t *type_receiver_impl = NULL; + + type_receiver_impl = INTF_TO_IMPL(type_receiver); + + type_receiver_impl->type = type; + + return AXIS2_SUCCESS; +} + Added: webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_use.c URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_use.c?rev=394660&view=auto ============================================================================== --- webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_use.c (added) +++ webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_use.c Mon Apr 17 05:15:47 2006 @@ -0,0 +1,186 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_xml_schema_use.h> + +typedef struct axis2_xml_schema_use_impl axis2_xml_schema_use_impl_t; + +/** + * @brief Other Extension Struct Impl + * Axis2 Other Extension + */ +struct axis2_xml_schema_use_impl +{ + axis2_xml_schema_use_t use; + axis2_xml_schema_enum_t *schema_enum; + axis2_hash_t *methods; + axis2_array_list_t *members; +}; + +#define INTF_TO_IMPL(use) ((axis2_xml_schema_use_impl_t *) use) + +axis2_status_t AXIS2_CALL +axis2_xml_schema_use_free(void *use, + axis2_env_t **env); + +axis2_xml_schema_enum_t *AXIS2_CALL +axis2_xml_schema_use_get_base_impl(void *use, + axis2_env_t **env); + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_schema_use_resolve_methods( + axis2_xml_schema_use_t *use, + axis2_env_t **env, + axis2_xml_schema_use_t *use_impl, + axis2_hash_t *methods); + +axis2_array_list_t * +axis2_xml_schema_use_get_values(void *use, + axis2_env_t **env); + + +AXIS2_DECLARE(axis2_xml_schema_use_t *) +axis2_xml_schema_use_create(axis2_env_t **env, + axis2_char_t *value) +{ + axis2_xml_schema_use_impl_t *use_impl = NULL; + axis2_status_t status = AXIS2_FAILURE; + + use_impl = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_use_impl_t)); + + use_impl->schema_enum = NULL; + use_impl->methods = NULL; + use_impl->members = NULL; + use_impl->use.ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_use_ops_t)); + + use_impl->use.ops->free = axis2_xml_schema_use_free; + use_impl->use.ops->get_base_impl = axis2_xml_schema_use_get_base_impl; + use_impl->use.ops->get_values = + axis2_xml_schema_use_get_values; + + if(!use_impl->members) + { + use_impl->members = axis2_array_list_create(env, 0); + if(!use_impl->members) + return NULL; + AXIS2_ARRAY_LIST_ADD(use_impl->members, env, "None"); + AXIS2_ARRAY_LIST_ADD(use_impl->members, env, "Optional"); + AXIS2_ARRAY_LIST_ADD(use_impl->members, env, "Prohibited"); + AXIS2_ARRAY_LIST_ADD(use_impl->members, env, "Required"); + } + use_impl->methods = axis2_hash_make(env); + if(!use_impl->methods) + { + AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + axis2_hash_set(use_impl->methods, "free", AXIS2_HASH_KEY_STRING, + axis2_xml_schema_use_free); + axis2_hash_set(use_impl->methods, "get_values", AXIS2_HASH_KEY_STRING, + axis2_xml_schema_use_get_values); + + use_impl->schema_enum = axis2_xml_schema_enum_create(env, value); + status = axis2_xml_schema_enum_resolve_methods( + &(use_impl->use.base), env, use_impl->schema_enum, + use_impl->methods); + + return &(use_impl->use); +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_use_free(void *use, + axis2_env_t **env) +{ + axis2_xml_schema_use_impl_t *use_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + use_impl = INTF_TO_IMPL(use); + + if(use_impl->members) + { + AXIS2_ARRAY_LIST_FREE(use_impl->members, env); + use_impl->members = NULL; + } + + if(use_impl->schema_enum) + { + AXIS2_XML_SCHEMA_ENUM_FREE(use_impl->schema_enum, env); + use_impl->schema_enum = NULL; + } + + if((&(use_impl->use))->ops) + { + AXIS2_FREE((*env)->allocator, (&(use_impl->use))->ops); + (&(use_impl->use))->ops = NULL; + } + + if(use_impl) + { + AXIS2_FREE((*env)->allocator, use_impl); + use_impl = NULL; + } + return AXIS2_SUCCESS; +} + +axis2_xml_schema_enum_t *AXIS2_CALL +axis2_xml_schema_use_get_base_impl(void *use, + axis2_env_t **env) +{ + axis2_xml_schema_use_impl_t *use_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + use_impl = INTF_TO_IMPL(use); + + return use_impl->schema_enum; +} + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_schema_use_resolve_methods( + axis2_xml_schema_use_t *use, + axis2_env_t **env, + axis2_xml_schema_use_t *use_impl, + axis2_hash_t *methods) +{ + axis2_xml_schema_use_impl_t *use_impl_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, use_impl, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, methods, AXIS2_FAILURE); + + use_impl_l = (axis2_xml_schema_use_impl_t *) use_impl; + + use->ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_use_ops_t)); + use->ops->free = axis2_hash_get(methods, "free", + AXIS2_HASH_KEY_STRING); + use->ops->get_base_impl = + use_impl_l->use.ops->get_base_impl; + use->ops->get_values = + use_impl_l->use.ops->get_values; + + return axis2_xml_schema_enum_resolve_methods(&(use->base), + env, use_impl_l->schema_enum, methods); +} + +axis2_array_list_t *AXIS2_CALL +axis2_xml_schema_use_get_values(void *use, + axis2_env_t **env) +{ + return INTF_TO_IMPL(use)->members; +} + Added: webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_xpath.c URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_xpath.c?rev=394660&view=auto ============================================================================== --- webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_xpath.c (added) +++ webservices/axis2/trunk/c/modules/xml/xml_schema/xml_schema_xpath.c Mon Apr 17 05:15:47 2006 @@ -0,0 +1,214 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_xml_schema_xpath.h> + +typedef struct axis2_xml_schema_xpath_impl axis2_xml_schema_xpath_impl_t; + +/** + * @brief Other Extension Struct Impl + * Axis2 Other Extension + */ +struct axis2_xml_schema_xpath_impl +{ + axis2_xml_schema_xpath_t xpath; + axis2_xml_schema_annotated_t *annotated; + axis2_hash_t *methods; + axis2_char_t *x_path; +}; + +#define INTF_TO_IMPL(xpath) ((axis2_xml_schema_xpath_impl_t *) xpath) + +axis2_status_t AXIS2_CALL +axis2_xml_schema_xpath_free(void *xpath, + axis2_env_t **env); + +axis2_xml_schema_annotated_t *AXIS2_CALL +axis2_xml_schema_xpath_get_base_impl(void *xpath, + axis2_env_t **env); + +axis2_char_t *AXIS2_CALL +axis2_xml_schema_xpath_get_xpath(void *xpath, + axis2_env_t **env); + +axis2_status_t AXIS2_CALL +axis2_xml_schema_xpath_set_xpath(void *xpath, + axis2_env_t **env, + axis2_char_t *x_path); + +AXIS2_DECLARE(axis2_xml_schema_xpath_t *) +axis2_xml_schema_xpath_create(axis2_env_t **env, + void *value, + axis2_bool_t fixed) +{ + axis2_xml_schema_xpath_impl_t *xpath_impl = NULL; + axis2_status_t status = AXIS2_FAILURE; + + xpath_impl = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_xpath_impl_t)); + + xpath_impl->annotated = NULL; + xpath_impl->methods = NULL; + xpath_impl->x_path = NULL; + xpath_impl->xpath.ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_xpath_ops_t)); + + xpath_impl->xpath.ops->free = axis2_xml_schema_xpath_free; + xpath_impl->xpath.ops->get_base_impl = + axis2_xml_schema_xpath_get_base_impl; + xpath_impl->xpath.ops->get_xpath = + axis2_xml_schema_xpath_get_xpath; + xpath_impl->xpath.ops->set_xpath = + axis2_xml_schema_xpath_set_xpath; + + xpath_impl->methods = axis2_hash_make(env); + if(!xpath_impl->methods) + { + AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + axis2_hash_set(xpath_impl->methods, "free", AXIS2_HASH_KEY_STRING, + axis2_xml_schema_xpath_free); + axis2_hash_set(xpath_impl->methods, "get_xpath", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_xpath_get_xpath); + axis2_hash_set(xpath_impl->methods, "set_xpath", + AXIS2_HASH_KEY_STRING, axis2_xml_schema_xpath_set_xpath); + + xpath_impl->annotated = axis2_xml_schema_annotated_create(env); + status = axis2_xml_schema_annotated_resolve_methods( + &(xpath_impl->xpath.base), env, xpath_impl->annotated, + xpath_impl->methods); + + return &(xpath_impl->xpath); +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_xpath_free(void *xpath, + axis2_env_t **env) +{ + axis2_xml_schema_xpath_impl_t *xpath_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + xpath_impl = INTF_TO_IMPL(xpath); + + if(xpath_impl->x_path) + { + AXIS2_FREE((*env)->allocator, xpath_impl->x_path); + xpath_impl->x_path = NULL; + } + + if(xpath_impl->methods) + { + axis2_hash_free(xpath_impl->methods, env); + xpath_impl->methods = NULL; + } + + if(xpath_impl->annotated) + { + AXIS2_XML_SCHEMA_OBJ_FREE(xpath_impl->annotated, env); + xpath_impl->annotated = NULL; + } + + if((&(xpath_impl->xpath))->ops) + { + AXIS2_FREE((*env)->allocator, (&(xpath_impl->xpath))->ops); + (&(xpath_impl->xpath))->ops = NULL; + } + + if(xpath_impl) + { + AXIS2_FREE((*env)->allocator, xpath_impl); + xpath_impl = NULL; + } + return AXIS2_SUCCESS; +} + +axis2_xml_schema_annotated_t *AXIS2_CALL +axis2_xml_schema_xpath_get_base_impl(void *xpath, + axis2_env_t **env) +{ + axis2_xml_schema_xpath_impl_t *xpath_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + xpath_impl = INTF_TO_IMPL(xpath); + + return xpath_impl->annotated; +} + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_schema_xpath_resolve_methods( + axis2_xml_schema_xpath_t *xpath, + axis2_env_t **env, + axis2_xml_schema_xpath_t *xpath_impl, + axis2_hash_t *methods) +{ + axis2_xml_schema_xpath_impl_t *xpath_impl_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, xpath_impl, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, methods, AXIS2_FAILURE); + + xpath_impl_l = (axis2_xml_schema_xpath_impl_t *) xpath_impl; + + xpath->ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_schema_xpath_ops_t)); + xpath->ops->free = axis2_hash_get(methods, "free", + AXIS2_HASH_KEY_STRING); + xpath->ops->get_base_impl = + xpath_impl_l->xpath.ops->get_base_impl; + xpath->ops->get_xpath = + xpath_impl_l->xpath.ops->get_xpath; + xpath->ops->set_xpath = + xpath_impl_l->xpath.ops->set_xpath; + + return axis2_xml_schema_annotated_resolve_methods(&(xpath->base), + env, xpath_impl_l->annotated, methods); +} + +axis2_char_t *AXIS2_CALL +axis2_xml_schema_xpath_get_xpath(void *xpath, + axis2_env_t **env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return INTF_TO_IMPL(xpath)->x_path; +} + +axis2_status_t AXIS2_CALL +axis2_xml_schema_xpath_set_xpath(void *xpath, + axis2_env_t **env, + axis2_char_t *x_path) +{ + axis2_xml_schema_xpath_impl_t *xpath_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, xpath, AXIS2_FAILURE); + xpath_impl = INTF_TO_IMPL(xpath); + + if(xpath_impl->x_path) + { + AXIS2_FREE((*env)->allocator, xpath_impl->x_path); + xpath_impl->x_path = NULL; + } + xpath_impl->x_path = AXIS2_STRDUP(x_path, env); + if(!xpath_impl->x_path) + { + AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + Added: webservices/axis2/trunk/c/modules/xml/xml_schema/xml_tokenized_type.c URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/xml_schema/xml_tokenized_type.c?rev=394660&view=auto ============================================================================== --- webservices/axis2/trunk/c/modules/xml/xml_schema/xml_tokenized_type.c (added) +++ webservices/axis2/trunk/c/modules/xml/xml_schema/xml_tokenized_type.c Mon Apr 17 05:15:47 2006 @@ -0,0 +1,195 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <axis2_xml_tokenized_type.h> + +typedef struct axis2_xml_tokenized_type_impl axis2_xml_tokenized_type_impl_t; + +/** + * @brief Other Extension Struct Impl + * Axis2 Other Extension + */ +struct axis2_xml_tokenized_type_impl +{ + axis2_xml_tokenized_type_t tokenized_type; + axis2_xml_schema_enum_t *schema_enum; + axis2_hash_t *methods; + axis2_array_list_t *members; +}; + +#define INTF_TO_IMPL(tokenized_type) ((axis2_xml_tokenized_type_impl_t *) tokenized_type) + +axis2_status_t AXIS2_CALL +axis2_xml_tokenized_type_free(void *tokenized_type, + axis2_env_t **env); + +axis2_xml_schema_enum_t *AXIS2_CALL +axis2_xml_tokenized_type_get_base_impl(void *tokenized_type, + axis2_env_t **env); + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_tokenized_type_resolve_methods( + axis2_xml_tokenized_type_t *tokenized_type, + axis2_env_t **env, + axis2_xml_tokenized_type_t *tokenized_type_impl, + axis2_hash_t *methods); + +axis2_array_list_t * +axis2_xml_tokenized_type_get_values(void *tokenized_type, + axis2_env_t **env); + + +AXIS2_DECLARE(axis2_xml_tokenized_type_t *) +axis2_xml_tokenized_type_create(axis2_env_t **env, + axis2_char_t *value) +{ + axis2_xml_tokenized_type_impl_t *tokenized_type_impl = NULL; + axis2_status_t status = AXIS2_FAILURE; + + tokenized_type_impl = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_tokenized_type_impl_t)); + + tokenized_type_impl->schema_enum = NULL; + tokenized_type_impl->methods = NULL; + tokenized_type_impl->members = NULL; + tokenized_type_impl->tokenized_type.ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_tokenized_type_ops_t)); + + tokenized_type_impl->tokenized_type.ops->free = axis2_xml_tokenized_type_free; + tokenized_type_impl->tokenized_type.ops->get_base_impl = axis2_xml_tokenized_type_get_base_impl; + tokenized_type_impl->tokenized_type.ops->get_values = + axis2_xml_tokenized_type_get_values; + + if(!tokenized_type_impl->members) + { + tokenized_type_impl->members = axis2_array_list_create(env, 0); + if(!tokenized_type_impl->members) + return NULL; + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "CDATA"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "IDREF"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "IDREFS"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "ENTITY"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "ENTITIES"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "NMTOKEN"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "NMTOKENS"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "NOTATION"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "ENUMERATION"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "QName"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "NCName"); + AXIS2_ARRAY_LIST_ADD(tokenized_type_impl->members, env, "None"); + } + tokenized_type_impl->methods = axis2_hash_make(env); + if(!tokenized_type_impl->methods) + { + AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + axis2_hash_set(tokenized_type_impl->methods, "free", AXIS2_HASH_KEY_STRING, + axis2_xml_tokenized_type_free); + axis2_hash_set(tokenized_type_impl->methods, "get_values", AXIS2_HASH_KEY_STRING, + axis2_xml_tokenized_type_get_values); + + tokenized_type_impl->schema_enum = axis2_xml_schema_enum_create(env, value); + status = axis2_xml_schema_enum_resolve_methods( + &(tokenized_type_impl->tokenized_type.base), env, tokenized_type_impl->schema_enum, + tokenized_type_impl->methods); + + return &(tokenized_type_impl->tokenized_type); +} + +axis2_status_t AXIS2_CALL +axis2_xml_tokenized_type_free(void *tokenized_type, + axis2_env_t **env) +{ + axis2_xml_tokenized_type_impl_t *tokenized_type_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + tokenized_type_impl = INTF_TO_IMPL(tokenized_type); + + if(tokenized_type_impl->members) + { + AXIS2_ARRAY_LIST_FREE(tokenized_type_impl->members, env); + tokenized_type_impl->members = NULL; + } + + if(tokenized_type_impl->schema_enum) + { + AXIS2_XML_SCHEMA_ENUM_FREE(tokenized_type_impl->schema_enum, env); + tokenized_type_impl->schema_enum = NULL; + } + + if((&(tokenized_type_impl->tokenized_type))->ops) + { + AXIS2_FREE((*env)->allocator, (&(tokenized_type_impl->tokenized_type))->ops); + (&(tokenized_type_impl->tokenized_type))->ops = NULL; + } + + if(tokenized_type_impl) + { + AXIS2_FREE((*env)->allocator, tokenized_type_impl); + tokenized_type_impl = NULL; + } + return AXIS2_SUCCESS; +} + +axis2_xml_schema_enum_t *AXIS2_CALL +axis2_xml_tokenized_type_get_base_impl(void *tokenized_type, + axis2_env_t **env) +{ + axis2_xml_tokenized_type_impl_t *tokenized_type_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + tokenized_type_impl = INTF_TO_IMPL(tokenized_type); + + return tokenized_type_impl->schema_enum; +} + +AXIS2_DECLARE(axis2_status_t) +axis2_xml_tokenized_type_resolve_methods( + axis2_xml_tokenized_type_t *tokenized_type, + axis2_env_t **env, + axis2_xml_tokenized_type_t *tokenized_type_impl, + axis2_hash_t *methods) +{ + axis2_xml_tokenized_type_impl_t *tokenized_type_impl_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, tokenized_type_impl, AXIS2_FAILURE); + AXIS2_PARAM_CHECK((*env)->error, methods, AXIS2_FAILURE); + + tokenized_type_impl_l = (axis2_xml_tokenized_type_impl_t *) + tokenized_type_impl; + + tokenized_type->ops = AXIS2_MALLOC((*env)->allocator, + sizeof(axis2_xml_tokenized_type_ops_t)); + tokenized_type->ops->free = axis2_hash_get(methods, "free", + AXIS2_HASH_KEY_STRING); + tokenized_type->ops->get_base_impl = + tokenized_type_impl_l->tokenized_type.ops->get_base_impl; + tokenized_type->ops->get_values = + tokenized_type_impl_l->tokenized_type.ops->get_values; + + return axis2_xml_schema_enum_resolve_methods(&(tokenized_type->base), + env, tokenized_type_impl_l->schema_enum, methods); +} + +axis2_array_list_t *AXIS2_CALL +axis2_xml_tokenized_type_get_values(void *tokenized_type, + axis2_env_t **env) +{ + return INTF_TO_IMPL(tokenized_type)->members; +} +
