ソースを参照

small documentation improvements

Julius Pfrommer 9 年 前
コミット
88cc9a3da2
共有3 個のファイルを変更した44 個の追加38 個の削除を含む
  1. 1 1
      doc/Doxyfile.in
  2. 20 14
      include/ua_types.h
  3. 23 23
      src/ua_types.c

+ 1 - 1
doc/Doxyfile.in

@@ -1943,7 +1943,7 @@ INCLUDE_FILE_PATTERNS  =
 # recursively expanded use the := operator instead of the = operator.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-PREDEFINED             = UA_EXPORT= UA_BITFIELD=
+PREDEFINED             = UA_EXPORT= UA_BITFIELD(SIZE)=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The

+ 20 - 14
include/ua_types.h

@@ -405,11 +405,11 @@ UA_StatusCode UA_EXPORT UA_Variant_setScalarCopy(UA_Variant *v, const void *p, c
  *
  * @param v The variant
  * @param array A pointer to the array data
- * @param noElements The size of the array
+ * @param elements The size of the array
  * @param type The datatype of the array
  * @return Indicates whether the operation succeeded or returns an error code
  */
-UA_StatusCode UA_EXPORT UA_Variant_setArray(UA_Variant *v, void *array, UA_Int32 noElements,
+UA_StatusCode UA_EXPORT UA_Variant_setArray(UA_Variant *v, void *array, UA_Int32 elements,
                                             const UA_DataType *type);
 
 /**
@@ -417,11 +417,11 @@ UA_StatusCode UA_EXPORT UA_Variant_setArray(UA_Variant *v, void *array, UA_Int32
  *
  * @param v The variant
  * @param array A pointer to the array data
- * @param noElements The size of the array
+ * @param elements The size of the array
  * @param type The datatype of the array
  * @return Indicates whether the operation succeeded or returns an error code
  */
-UA_StatusCode UA_EXPORT UA_Variant_setArrayCopy(UA_Variant *v, const void *array, UA_Int32 noElements,
+UA_StatusCode UA_EXPORT UA_Variant_setArrayCopy(UA_Variant *v, const void *array, UA_Int32 elements,
                                                 const UA_DataType *type);
 
 /** @brief NumericRanges are used select a subset in a (multidimensional)
@@ -440,6 +440,11 @@ typedef struct {
 /**
  * Copy the variant, but use only a subset of the (multidimensional) array into a variant. Returns
  * an error code if the variant is not an array or if the indicated range does not fit.
+ *
+ * @param src The source variant
+ * @param dst The target variant
+ * @param range The range of the copied data
+ * @return Returns UA_STATUSCODE_GOOD or an error code
  */
 UA_StatusCode UA_EXPORT UA_Variant_copyRange(const UA_Variant *src, UA_Variant *dst, UA_NumericRange range);
 
@@ -450,9 +455,9 @@ UA_StatusCode UA_EXPORT UA_Variant_copyRange(const UA_Variant *src, UA_Variant *
  *
  * @param v The variant
  * @param dataArray The data array. The type must match the variant
- * @param dataarraySize The length of the data array. This is checked to match the range size.
+ * @param dataArraySize The length of the data array. This is checked to match the range size.
  * @param range The range of where the new data is inserted
- * @return Indicates whether the operation succeeded or returns an error code
+ * @return Returns UA_STATUSCODE_GOOD or an error code
  */
 UA_StatusCode UA_EXPORT UA_Variant_setRange(UA_Variant *v, void *dataArray, UA_Int32 dataArraySize,
                                             const UA_NumericRange range);
@@ -462,9 +467,9 @@ UA_StatusCode UA_EXPORT UA_Variant_setRange(UA_Variant *v, void *dataArray, UA_I
  *
  * @param v The variant
  * @param dataArray The data array. The type must match the variant
- * @param dataarraySize The length of the data array. This is checked to match the range size.
+ * @param dataArraySize The length of the data array. This is checked to match the range size.
  * @param range The range of where the new data is inserted
- * @return Indicates whether the operation succeeded or returns an error code
+ * @return Returns UA_STATUSCODE_GOOD or an error code
  */
 UA_StatusCode UA_EXPORT UA_Variant_setRangeCopy(UA_Variant *v, const void *dataArray, UA_Int32 dataArraySize,
                                                 const UA_NumericRange range);
@@ -564,9 +569,10 @@ void UA_EXPORT UA_delete(void *p, const UA_DataType *dataType);
  * Allocates and initializes an array of variables of a specific type
  *
  * @param dataType The datatype description
+ * @param elements The number of elements in the array
  * @return Returns the memory location of the variable or (void*)0 if no memory could be allocated
  */
-void UA_EXPORT * UA_Array_new(const UA_DataType *dataType, UA_Int32 noElements);
+void UA_EXPORT * UA_Array_new(const UA_DataType *dataType, UA_Int32 elements);
 
 /**
  * Allocates and copies an array. dst is set to (void*)0 if not enough memory is available.
@@ -574,19 +580,19 @@ void UA_EXPORT * UA_Array_new(const UA_DataType *dataType, UA_Int32 noElements);
  * @param src The memory location of the source array
  * @param dst The memory location where the pointer to the destination array is written
  * @param dataType The datatype of the array members
- * @param noElements The size of the array
+ * @param elements The size of the array
  * @return Indicates whether the operation succeeded or returns an error code
  */
-UA_StatusCode UA_EXPORT UA_Array_copy(const void *src, void **dst, const UA_DataType *dataType, UA_Int32 noElements);
+UA_StatusCode UA_EXPORT UA_Array_copy(const void *src, void **dst, const UA_DataType *dataType, UA_Int32 elements);
 
 /**
  * Deletes an array.
  *
- * @param src The memory location of the array
+ * @param p The memory location of the array
  * @param dataType The datatype of the array members
- * @param noElements The size of the array
+ * @param elements The size of the array
  */
-void UA_EXPORT UA_Array_delete(void *p, const UA_DataType *dataType, UA_Int32 noElements);
+void UA_EXPORT UA_Array_delete(void *p, const UA_DataType *dataType, UA_Int32 elements);
 
 /* These are not generated from XML. Server *and* client need them. */
 typedef enum {

+ 23 - 23
src/ua_types.c

@@ -838,21 +838,21 @@ UA_StatusCode UA_Variant_setScalarCopy(UA_Variant *v, const void *p, const UA_Da
     return UA_Variant_setArray(v, new, -1, type);
 }
 
-UA_StatusCode UA_Variant_setArray(UA_Variant *v, void *array, UA_Int32 noElements,
+UA_StatusCode UA_Variant_setArray(UA_Variant *v, void *array, UA_Int32 elements,
                                   const UA_DataType *type) {
     v->type = type;
-    v->arrayLength = noElements;
+    v->arrayLength = elements;
     v->data = array;
     return UA_STATUSCODE_GOOD;
 }
 
-UA_StatusCode UA_Variant_setArrayCopy(UA_Variant *v, const void *array, UA_Int32 noElements,
+UA_StatusCode UA_Variant_setArrayCopy(UA_Variant *v, const void *array, UA_Int32 elements,
                                       const UA_DataType *type) {
     void *new;
-    UA_StatusCode retval = UA_Array_copy(array, &new, type, noElements);
+    UA_StatusCode retval = UA_Array_copy(array, &new, type, elements);
     if(retval != UA_STATUSCODE_GOOD)
         return retval;
-    return UA_Variant_setArray(v, new, noElements, type);
+    return UA_Variant_setArray(v, new, elements, type);
 }
 
 /* DiagnosticInfo */
@@ -1022,16 +1022,16 @@ UA_StatusCode UA_copy(const void *src, void *dst, const UA_DataType *dataType) {
             ptrs += (member->padding >> 3);
             ptrd += (member->padding >> 3);
             UA_Int32 *dstNoElements = (UA_Int32*)ptrd;
-            const UA_Int32 noElements = *((const UA_Int32*)ptrs);
+            const UA_Int32 elements = *((const UA_Int32*)ptrs);
             ptrs += sizeof(UA_Int32) + (member->padding & 0x07);
             ptrd += sizeof(UA_Int32) + (member->padding & 0x07);
-            retval = UA_Array_copy(*(void* const*)ptrs, (void**)ptrd, memberType, noElements);
+            retval = UA_Array_copy(*(void* const*)ptrs, (void**)ptrd, memberType, elements);
             if(retval != UA_STATUSCODE_GOOD) {
                 UA_deleteMembers(dst, dataType);
                 UA_init(dst, dataType);
                 return retval;
             }
-            *dstNoElements = noElements;
+            *dstNoElements = elements;
             ptrs += sizeof(void*);
             ptrd += sizeof(void*);
             continue;
@@ -1133,9 +1133,9 @@ void UA_deleteMembersUntil(void *p, const UA_DataType *dataType, UA_Int32 lastMe
 
         if(member->isArray) {
             ptr += (member->padding >> 3);
-            UA_Int32 noElements = *((UA_Int32*)ptr);
+            UA_Int32 elements = *((UA_Int32*)ptr);
             ptr += sizeof(UA_Int32) + (member->padding & 0x07);
-            UA_Array_delete(*(void**)ptr, memberType, noElements);
+            UA_Array_delete(*(void**)ptr, memberType, elements);
             *(void**)ptr = UA_NULL;
             ptr += sizeof(void*);
             continue;
@@ -1206,58 +1206,58 @@ void UA_delete(void *p, const UA_DataType *dataType) {
 /* Array Handling */
 /******************/
 
-void* UA_Array_new(const UA_DataType *dataType, UA_Int32 noElements) {
-    if((UA_Int32)dataType->memSize * noElements < 0 || dataType->memSize * noElements > MAX_ARRAY_SIZE )
+void* UA_Array_new(const UA_DataType *dataType, UA_Int32 elements) {
+    if((UA_Int32)dataType->memSize * elements < 0 || dataType->memSize * elements > MAX_ARRAY_SIZE )
         return UA_NULL;
 
     if(dataType->fixedSize)
-        return UA_calloc(noElements, dataType->memSize);
+        return UA_calloc(elements, dataType->memSize);
 
-    void *p = UA_malloc(dataType->memSize * (size_t)noElements);
+    void *p = UA_malloc(dataType->memSize * (size_t)elements);
     if(!p)
         return p;
 
     uintptr_t ptr = (uintptr_t)p;
-    for(int i = 0; i<noElements; i++) {
+    for(int i = 0; i<elements; i++) {
         UA_init((void*)ptr, dataType);
         ptr += dataType->memSize;
     }
     return p;
 }
 
-UA_StatusCode UA_Array_copy(const void *src, void **dst, const UA_DataType *dataType, UA_Int32 noElements) {
-    if(noElements <= 0) {
+UA_StatusCode UA_Array_copy(const void *src, void **dst, const UA_DataType *dataType, UA_Int32 elements) {
+    if(elements <= 0) {
         *dst = UA_NULL;
         return UA_STATUSCODE_GOOD;
     }
 
-    if(!(*dst = UA_malloc((size_t)noElements * dataType->memSize)))
+    if(!(*dst = UA_malloc((size_t)elements * dataType->memSize)))
         return UA_STATUSCODE_BADOUTOFMEMORY;
 
     if(dataType->fixedSize) {
-        memcpy(*dst, src, dataType->memSize * (size_t)noElements);
+        memcpy(*dst, src, dataType->memSize * (size_t)elements);
         return UA_STATUSCODE_GOOD;
     }
 
     uintptr_t ptrs = (uintptr_t)src;
     uintptr_t ptrd = (uintptr_t)*dst;
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
-    for(int i = 0; i < noElements; i++) {
+    for(int i = 0; i < elements; i++) {
         retval |= UA_copy((void*)ptrs, (void*)ptrd, dataType);
         ptrs += dataType->memSize;
         ptrd += dataType->memSize;
     }
 
     if(retval != UA_STATUSCODE_GOOD)
-        UA_Array_delete(*dst, dataType, noElements);
+        UA_Array_delete(*dst, dataType, elements);
 
     return retval;
 }
 
-void UA_Array_delete(void *p, const UA_DataType *dataType, UA_Int32 noElements) {
+void UA_Array_delete(void *p, const UA_DataType *dataType, UA_Int32 elements) {
     if(!dataType->fixedSize) {
         uintptr_t ptr = (uintptr_t)p;
-        for(UA_Int32 i = 0; i<noElements; i++) {
+        for(UA_Int32 i = 0; i < elements; i++) {
             UA_deleteMembers((void*)ptr, dataType);
             ptr += dataType->memSize;
         }