Home | History | Annotate | Download | only in runtime
      1 #include "rs_core.rsh"
      2 #include "rs_graphics.rsh"
      3 #include "rs_structs.h"
      4 
      5 /**
      6 * Element
      7 */
      8 extern uint32_t __attribute__((overloadable))
      9         rsElementGetSubElementCount(rs_element e) {
     10     Element_t *element = (Element_t *)e.p;
     11     if (element == NULL) {
     12         return 0;
     13     }
     14     return element->mHal.state.fieldsCount;
     15 }
     16 
     17 extern rs_element __attribute__((overloadable))
     18         rsElementGetSubElement(rs_element e, uint32_t index) {
     19     Element_t *element = (Element_t *)e.p;
     20     if (element == NULL || index >= element->mHal.state.fieldsCount) {
     21         rs_element nullElem = {0};
     22         return nullElem;
     23     }
     24     rs_element returnElem = {element->mHal.state.fields[index]};
     25     return returnElem;
     26 }
     27 
     28 extern uint32_t __attribute__((overloadable))
     29         rsElementGetSubElementNameLength(rs_element e, uint32_t index) {
     30     Element_t *element = (Element_t *)e.p;
     31     if (element == NULL || index >= element->mHal.state.fieldsCount) {
     32         return 0;
     33     }
     34     return element->mHal.state.fieldNameLengths[index];
     35 }
     36 
     37 extern uint32_t __attribute__((overloadable))
     38         rsElementGetSubElementName(rs_element e, uint32_t index, char *name, uint32_t nameLength) {
     39     Element_t *element = (Element_t *)e.p;
     40     if (element == NULL || index >= element->mHal.state.fieldsCount ||
     41         nameLength == 0 || name == 0) {
     42         return 0;
     43     }
     44 
     45     uint32_t numToCopy = element->mHal.state.fieldNameLengths[index];
     46     if (nameLength < numToCopy) {
     47         numToCopy = nameLength;
     48     }
     49     // Place the null terminator manually, in case of partial string
     50     numToCopy --;
     51     name[numToCopy] = '\0';
     52     const char *nameSource = element->mHal.state.fieldNames[index];
     53     for (uint32_t i = 0; i < numToCopy; i ++) {
     54         name[i] = nameSource[i];
     55     }
     56     return numToCopy;
     57 }
     58 
     59 extern uint32_t __attribute__((overloadable))
     60         rsElementGetSubElementArraySize(rs_element e, uint32_t index) {
     61     Element_t *element = (Element_t *)e.p;
     62     if (element == NULL || index >= element->mHal.state.fieldsCount) {
     63         return 0;
     64     }
     65     return element->mHal.state.fieldArraySizes[index];
     66 }
     67 
     68 extern uint32_t __attribute__((overloadable))
     69         rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index) {
     70     Element_t *element = (Element_t *)e.p;
     71     if (element == NULL || index >= element->mHal.state.fieldsCount) {
     72         return 0;
     73     }
     74     return element->mHal.state.fieldOffsetBytes[index];
     75 }
     76 
     77 extern uint32_t __attribute__((overloadable))
     78         rsElementGetBytesSize(rs_element e) {
     79     Element_t *element = (Element_t *)e.p;
     80     if (element == NULL) {
     81         return 0;
     82     }
     83     return element->mHal.state.elementSizeBytes;
     84 }
     85 
     86 extern rs_data_type __attribute__((overloadable))
     87         rsElementGetDataType(rs_element e) {
     88     Element_t *element = (Element_t *)e.p;
     89     if (element == NULL) {
     90         return RS_TYPE_INVALID;
     91     }
     92     return element->mHal.state.dataType;
     93 }
     94 
     95 extern rs_data_kind __attribute__((overloadable))
     96         rsElementGetDataKind(rs_element e) {
     97     Element_t *element = (Element_t *)e.p;
     98     if (element == NULL) {
     99         return RS_KIND_INVALID;
    100     }
    101     return element->mHal.state.dataKind;
    102 }
    103 
    104 extern uint32_t __attribute__((overloadable))
    105         rsElementGetVectorSize(rs_element e) {
    106     Element_t *element = (Element_t *)e.p;
    107     if (element == NULL) {
    108         return 0;
    109     }
    110     return element->mHal.state.vectorSize;
    111 }
    112