[MOAB-dev] Re: On type correctness
Jed Brown
jed at 59A2.org
Thu Sep 11 05:48:22 CDT 2008
I just ran into one more iMesh.h declaration that mixes EntityHandle
with EntitySetHandle. My complete patch (superseding the last one) is
attached.
What is the reason for separate functions operating on EntitySets from
Entities? Are there implementations which cannot tell the difference?
Jed
-------------- next part --------------
Index: tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- tools/iMesh/iMesh_MOAB.cpp (revision 2059)
+++ tools/iMesh/iMesh_MOAB.cpp (working copy)
@@ -302,7 +302,7 @@
}
void iMesh_load(iMesh_Instance instance,
- const iBase_EntityHandle handle,
+ const iBase_EntitySetHandle handle,
const char *name, const char *options,
int *err, int name_len, int options_len)
{
@@ -337,7 +337,7 @@
}
void iMesh_save(iMesh_Instance instance,
- const iBase_EntityHandle handle,
+ const iBase_EntitySetHandle handle,
const char *name, const char *options,
int *err, const int name_len, int options_len)
{
@@ -378,7 +378,7 @@
void iMesh_getDfltStorage(iMesh_Instance instance,
int *order, int *err)
{
- *order = iBase_BLOCKED;
+ *order = iBase_INTERLEAVED;
RETURN(iBase_SUCCESS);
}
@@ -830,13 +830,13 @@
/*in*/ const int requested_entity_type,
/*in*/ const int requested_entity_topology,
/*in*/ const int requested_array_size,
- /*out*/ iMesh_EntityIterator* entArr_iterator,
+ /*out*/ iMesh_EntityArrIterator* entArr_iterator,
int *err)
{
MBEntityType req_type = mb_topology_table[requested_entity_topology];
int req_dimension = (req_type == MBMAXTYPE ? (int) requested_entity_type : -1);
RangeIterator *new_it = new RangeIterator;
- *entArr_iterator = reinterpret_cast<iMesh_EntityIterator>(new_it);
+ *entArr_iterator = reinterpret_cast<iMesh_EntityArrIterator>(new_it);
new_it->requestedSize = requested_array_size;
MBErrorCode result;
@@ -874,7 +874,7 @@
* Method: getEntArrNextIter[]
*/
void iMesh_getNextEntArrIter (iMesh_Instance instance,
- /*in*/ iMesh_EntityIterator entArr_iterator,
+ /*in*/ iMesh_EntityArrIterator entArr_iterator,
/*inout*/ iBase_EntityHandle** entity_handles,
/*inout*/ int* entity_handles_allocated,
/*out*/ int* entity_handles_size,
@@ -910,7 +910,7 @@
* Method: resetEntArrIter[]
*/
void iMesh_resetEntArrIter (iMesh_Instance instance,
- /*in*/ iMesh_EntityIterator entArr_iterator, int *err)
+ /*in*/ iMesh_EntityArrIterator entArr_iterator, int *err)
{
RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
@@ -920,7 +920,7 @@
}
void iMesh_endEntArrIter (iMesh_Instance instance,
- /*in*/ iMesh_EntityIterator entArr_iterator, int *err)
+ /*in*/ iMesh_EntityArrIterator entArr_iterator, int *err)
{
RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
@@ -1095,7 +1095,7 @@
}
// return EntitySet_Handle
- *entity_set_created = (iBase_EntityHandle)meshset;
+ *entity_set_created = (iBase_EntitySetHandle)meshset;
RETURN(iBase_ERROR_MAP[result]);
}
@@ -1178,7 +1178,7 @@
int k = 0;
for (; iter != end_iter; iter++)
- (*contained_entset_handles)[k++] = (iBase_EntityHandle)*iter;
+ (*contained_entset_handles)[k++] = (iBase_EntitySetHandle)*iter;
*contained_entset_handles_size = sets.size();
RETURN(iBase_SUCCESS);
@@ -1273,7 +1273,7 @@
void iMesh_isEntContained (iMesh_Instance instance,
/*in*/ const iBase_EntitySetHandle containing_entity_set,
- /*in*/ const iBase_EntitySetHandle contained_entity,
+ /*in*/ const iBase_EntityHandle contained_entity,
int *is_contained, int *err)
{
MBRange all_ents;
@@ -1300,7 +1300,7 @@
/*in*/ const iBase_EntitySetHandle contained_entity_set,
int *is_contained, int *err)
{
- iMesh_isEntContained(instance, containing_entity_set, contained_entity_set,
+ iMesh_isEntContained(instance, containing_entity_set, (iBase_EntityHandle)contained_entity_set,
is_contained, err);
}
@@ -2431,7 +2431,7 @@
int *err)
{
iMesh_initEntArrIter(instance, entity_set_handle, requested_entity_type,
- requested_entity_topology, 1, entity_iterator,
+ requested_entity_topology, 1, (iMesh_EntityArrIterator*)entity_iterator,
err);
}
@@ -2442,20 +2442,20 @@
{
int eh_size = 1;
iMesh_getNextEntArrIter(instance,
- entity_iterator, &entity_handle, &eh_size, &eh_size, is_end, err);
+ (iMesh_EntityArrIterator)entity_iterator, &entity_handle, &eh_size, &eh_size, is_end, err);
}
void iMesh_resetEntIter (iMesh_Instance instance,
/*in*/ iMesh_EntityIterator entity_iterator, int *err)
{
- iMesh_resetEntArrIter(instance, entity_iterator, err);
+ iMesh_resetEntArrIter(instance, (iMesh_EntityArrIterator)entity_iterator, err);
}
void iMesh_endEntIter (iMesh_Instance instance,
/*in*/ iMesh_EntityIterator entity_iterator, int *err)
{
- iMesh_endEntArrIter(instance, entity_iterator, err);
+ iMesh_endEntArrIter(instance, (iMesh_EntityArrIterator)entity_iterator, err);
}
void iMesh_getEntTopo (iMesh_Instance instance,
Index: tools/iMesh/iMesh.h
===================================================================
--- tools/iMesh/iMesh.h (revision 2059)
+++ tools/iMesh/iMesh.h (working copy)
@@ -76,19 +76,19 @@
*
* Type used to store iMesh interface handle
*/
- typedef void* iMesh_Instance;
+ typedef struct iMesh_Instance_private *iMesh_Instance;
/**\brief Type used to store an iterator returned by iMesh
*
* Type used to store an iterator returned by iMesh
*/
- typedef void* iMesh_EntityIterator;
+ typedef struct iMesh_EntityIterator_private *iMesh_EntityIterator;
/**\brief Type used to store an array iterator returned by iMesh
*
* Type used to store an array iterator returned by iMesh
*/
- typedef void* iMesh_EntityArrIterator;
+ typedef struct iMesh_EntityArrIterator_private *iMesh_EntityArrIterator;
/**\brief Enumerator specifying entity topology
*
@@ -514,7 +514,7 @@
* \param *err Pointer to error type returned from function
*/
void iMesh_getAdjEntities(iMesh_Instance instance,
- /*in*/ const iBase_EntityHandle entity_set_handle,
+ /*in*/ const iBase_EntitySetHandle entity_set_handle,
/*in*/ const int entity_type_requestor,
/*in*/ const int entity_topology_requestor,
/*in*/ const int entity_type_requested,
@@ -870,7 +870,7 @@
* \param *err Pointer to error type returned from function
*/
void iMesh_addEntSet(iMesh_Instance instance,
- /*in*/ const iBase_EntityHandle entity_set_to_add,
+ /*in*/ const iBase_EntitySetHandle entity_set_to_add,
/*inout*/ iBase_EntitySetHandle* entity_set_handle,
/*out*/ int *err);
@@ -901,7 +901,7 @@
*/
void iMesh_isEntContained(iMesh_Instance instance,
/*in*/ const iBase_EntitySetHandle containing_entity_set,
- /*in*/ const iBase_EntitySetHandle contained_entity,
+ /*in*/ const iBase_EntityHandle contained_entity,
/*out*/ int *is_contained,
/*out*/ int *err);
Index: tools/iMesh/testc_cbind.c
===================================================================
--- tools/iMesh/testc_cbind.c (revision 2059)
+++ tools/iMesh/testc_cbind.c (working copy)
@@ -796,7 +796,7 @@
}
// check if parent is really added
- iBase_EntityHandle *parents = NULL;
+ iBase_EntitySetHandle *parents = NULL;
int parents_alloc = 0, parents_size;
iMesh_getPrnts(mesh, parent_child, 0,
&parents, &parents_alloc, &parents_size, &result);
@@ -1636,7 +1636,7 @@
}
int entityset_struct_tag_test(iMesh_Instance mesh,
- iBase_EntityHandle *sets, int sets_size,
+ iBase_EntitySetHandle *sets, int sets_size,
iBase_TagHandle *struct_tag)
{
int result;
@@ -1692,7 +1692,7 @@
}
int entityset_tag_delete_test(iMesh_Instance mesh,
- iBase_EntityHandle *sets, int sets_size)
+ iBase_EntitySetHandle *sets, int sets_size)
{
// test forced, unforced deletion of tags from entities
int result;
@@ -1700,7 +1700,7 @@
// test getAlliBase_TagHandles for first entity
iBase_TagHandle *all_tags = NULL;
- iBase_EntityHandle dum_entity = sets[0];
+ iBase_EntitySetHandle dum_entity = sets[0];
int all_tags_alloc = 0, all_tags_size;
iMesh_getAllEntSetTags(mesh, sets[0], &all_tags, &all_tags_alloc,
&all_tags_size, &result);
Index: tools/iMesh/iMeshP_MOAB.cpp
===================================================================
--- tools/iMesh/iMeshP_MOAB.cpp (revision 2059)
+++ tools/iMesh/iMeshP_MOAB.cpp (working copy)
@@ -51,6 +51,8 @@
#define CONST_ENTITY_HANDLE(handle) reinterpret_cast<const MBEntityHandle>(handle)
#define RANGE_ITERATOR(it) reinterpret_cast<RangeIterator*>(it)
#define CAST_TO_VOID(ptr) reinterpret_cast<void*>(ptr)
+#define CAST_TO_PART_HANDLE(ptr) reinterpret_cast<iMeshP_PartHandle>(ptr)
+#define CAST_TO_ENTITY_HANDLE(ptr) reinterpret_cast<iBase_EntityHandle>(ptr)
const iBase_ErrorType iBase_ERROR_MAP[] =
{
@@ -150,7 +152,7 @@
int i;
for (i = 0, rit = pc->partition_sets().begin();
rit != pc->partition_sets().end(); rit++, i++)
- (*part_handles)[i] = CAST_TO_VOID(*rit);
+ (*part_handles)[i] = CAST_TO_PART_HANDLE(*rit);
RETURN(iBase_SUCCESS);
}
@@ -304,7 +306,7 @@
CHECK_SIZE(*copies_entity_handles, *copies_entity_handles_allocated,
*copies_entity_handles_size, iBase_EntityHandle, );
(*part_handles)[0] = 0;
- (*copies_entity_handles)[0] = CAST_TO_VOID(shared_handle);
+ (*copies_entity_handles)[0] = CAST_TO_ENTITY_HANDLE(shared_handle);
RETURN(iBase_SUCCESS);
}
@@ -331,10 +333,10 @@
CHECK_SIZE(*part_handles, *part_handles_allocated, *part_handles_size,
iMeshP_PartHandle, );
CHECK_SIZE(*copies_entity_handles, *copies_entity_handles_allocated,
- *copies_entity_handles_size, iMeshP_PartHandle, );
+ *copies_entity_handles_size, iBase_EntityHandle, );
std::copy(&shared_handles[0], &shared_handles[index],
HANDLE_ARRAY_PTR(*copies_entity_handles));
- std::fill(*part_handles, *part_handles+index, CAST_TO_VOID(0));
+ std::fill(*part_handles, *part_handles+index, CAST_TO_PART_HANDLE(0));
RETURN(iBase_SUCCESS);
}
Index: tools/iMesh/iBase.h
===================================================================
--- tools/iMesh/iBase.h (revision 2059)
+++ tools/iMesh/iBase.h (working copy)
@@ -15,10 +15,10 @@
* TYPEDEF'S
*==========================================================
*/
- typedef void* iBase_Instance;
- typedef void* iBase_EntityHandle;
- typedef void* iBase_EntitySetHandle;
- typedef void* iBase_TagHandle;
+ typedef struct iBase_Instance_private *iBase_Instance;
+ typedef struct iBase_EntityHandle_private *iBase_EntityHandle;
+ typedef struct iBase_EntitySetHandle_private *iBase_EntitySetHandle;
+ typedef struct iBase_TagHandle_private *iBase_TagHandle;
/*==========================================================
* ENTITYTYPE ENUMERATION
Index: tools/iMesh/iMeshP.h
===================================================================
--- tools/iMesh/iMeshP.h (revision 2059)
+++ tools/iMesh/iMeshP.h (working copy)
@@ -20,13 +20,13 @@
*
* Type used to store a part handle
*/
- typedef void* iMeshP_PartHandle;
+ typedef struct iMeshP_PartHandle_private *iMeshP_PartHandle;
/**\brief Type used to store a partition handle
*
* Type used to store a partition handle
*/
- typedef void* iMeshP_PartitionHandle;
+ typedef struct iMeshP_PartitionHandle_private *iMeshP_PartitionHandle;
const int iMeshP_INTERNAL = 0;
const int iMeshP_BOUNDARY = 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <https://lists.mcs.anl.gov/mailman/private/moab-dev/attachments/20080911/ac81ff79/attachment.pgp>
More information about the moab-dev
mailing list