- detect arrays and save size in structure
- static variables not in stub
This commit is contained in:
@@ -91,7 +91,7 @@ void cfile_print(cfile_t *aCfile)
|
|||||||
|
|
||||||
while (work)
|
while (work)
|
||||||
{
|
{
|
||||||
printf("[ cva]%d:<%s> (%s) %s\n", work->type, work->prefix, work->dataType, work->name);
|
printf("[ cva]%d:<%s> (%s) %s %s\n", work->type, work->prefix, work->dataType, work->name, work->array);
|
||||||
work = work->next;
|
work = work->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@ typedef struct _CFILE_VARIABLE_T
|
|||||||
char* prefix; /*!< @brief variable prefix (e.g. static) */
|
char* prefix; /*!< @brief variable prefix (e.g. static) */
|
||||||
char* dataType; /*!< @brief data type */
|
char* dataType; /*!< @brief data type */
|
||||||
char* name; /*!< @brief name */
|
char* name; /*!< @brief name */
|
||||||
|
char* array; /*!< @brief array information (e.g. [10] or [DEF_MAX]) */
|
||||||
struct _CFILE_VARIABLE_T *next;
|
struct _CFILE_VARIABLE_T *next;
|
||||||
} cfile_variable_t;
|
} cfile_variable_t;
|
||||||
|
|
||||||
|
@@ -129,7 +129,8 @@ STATIC void checkFunctionType(cfunction_t *aFunction, char *aExpression)
|
|||||||
{
|
{
|
||||||
aFunction->type = CFUNCTION_TYPE_EXTERN;
|
aFunction->type = CFUNCTION_TYPE_EXTERN;
|
||||||
}
|
}
|
||||||
else if (NULL != strstr(aFunction->prefix, CPARS_PREFIX_STATIC_S) && CFUNCTION_TYPE_PROTO != aFunction->type)
|
else if ((NULL != strstr(aFunction->prefix, CPARS_PREFIX_STATIC_S) || NULL != strstr(aFunction->prefix, CPARS_PREFIX_STATIC2_S))
|
||||||
|
&& CFUNCTION_TYPE_PROTO != aFunction->type)
|
||||||
{
|
{
|
||||||
aFunction->type = CFUNCTION_TYPE_STATIC;
|
aFunction->type = CFUNCTION_TYPE_STATIC;
|
||||||
}
|
}
|
||||||
@@ -208,7 +209,7 @@ STATIC int8_t matchPrefix(void *aElement, celement_type_t aElementType, char *aS
|
|||||||
{
|
{
|
||||||
((cfunction_t*) aElement)->type = CFUNCTION_TYPE_EXTERN;
|
((cfunction_t*) aElement)->type = CFUNCTION_TYPE_EXTERN;
|
||||||
}
|
}
|
||||||
else if (*prefix && NULL != strstr(*prefix, CPARS_PREFIX_STATIC_S))
|
else if (*prefix && (NULL != strstr(*prefix, CPARS_PREFIX_STATIC_S) || NULL != strstr(*prefix, CPARS_PREFIX_STATIC2_S)))
|
||||||
{
|
{
|
||||||
((cfunction_t*) aElement)->type = CFUNCTION_TYPE_STATIC;
|
((cfunction_t*) aElement)->type = CFUNCTION_TYPE_STATIC;
|
||||||
}
|
}
|
||||||
@@ -549,6 +550,11 @@ STATIC int8_t cfile_parser_evaluateExpression(char *aExpression, cfile_t *aCfile
|
|||||||
{
|
{
|
||||||
(void) matchPrefix(variable, CELEMENT_TYPE_VARIABLE, &aExpression[matchGroup[1].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 1));
|
(void) matchPrefix(variable, CELEMENT_TYPE_VARIABLE, &aExpression[matchGroup[1].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 1));
|
||||||
xmallocStrlcpy(&variable->name, &aExpression[matchGroup[2].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 2));
|
xmallocStrlcpy(&variable->name, &aExpression[matchGroup[2].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 2));
|
||||||
|
// contains array information if available "[10]"
|
||||||
|
if (XREGEX_IS_MATCHGROUP(matchGroup, 3))
|
||||||
|
{
|
||||||
|
xmallocStrlcpy(&variable->array, &aExpression[matchGroup[3].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 3));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,13 +23,14 @@
|
|||||||
|
|
||||||
#define CPARS_PROTOTYPE_END_C ';'
|
#define CPARS_PROTOTYPE_END_C ';'
|
||||||
#define CPARS_PREFIX_STATIC_S "static"
|
#define CPARS_PREFIX_STATIC_S "static"
|
||||||
|
#define CPARS_PREFIX_STATIC2_S "STATIC"
|
||||||
#define CPARS_PREFIX_EXTERN_S "extern"
|
#define CPARS_PREFIX_EXTERN_S "extern"
|
||||||
|
|
||||||
#define CPARS_EXPRESSION_BASE "^[[:blank:]]*([ _\\*[:alnum:]]* +\\**)([_\\*[:alnum:]\\[\\]]+)"
|
#define CPARS_EXPRESSION_BASE "^[[:blank:]]*([ _\\*[:alnum:]]* +\\**)([_\\*[:alnum:]]+)"
|
||||||
|
|
||||||
#define FUNCTION_BASE CPARS_EXPRESSION_BASE "[[:blank:]]*\\([[:blank:]]*"
|
#define FUNCTION_BASE CPARS_EXPRESSION_BASE "[[:blank:]]*\\([[:blank:]]*"
|
||||||
#define CPARS_REGEX_FUNCTION FUNCTION_BASE "(.*)\\)[[:blank:]\\{\\};]+[[:blank:]]*"
|
#define CPARS_REGEX_FUNCTION FUNCTION_BASE "(.*)\\)[[:blank:]\\{\\};]+[[:blank:]]*"
|
||||||
#define CPARS_REGEX_VARIABLE CPARS_EXPRESSION_BASE "[[:blank:]]*[;=]"
|
#define CPARS_REGEX_VARIABLE CPARS_EXPRESSION_BASE "[[:blank:]]*(\\[*[^;=]*)[[:blank:]]*[;=]"
|
||||||
#define CPARS_REGEX_PARAMETER "[[:blank:]]*([ _\\*[:alnum:]]* +\\**)([_\\*[:alnum:]]+)[[:blank:]]*"
|
#define CPARS_REGEX_PARAMETER "[[:blank:]]*([ _\\*[:alnum:]]* +\\**)([_\\*[:alnum:]]+)[[:blank:]]*"
|
||||||
#define CPARS_REGEX_PREFIX "("CPARS_PREFIX_EXTERN_S"|EXTERN|"CPARS_PREFIX_STATIC_S"|STATIC|volatile|near|far)[[:blank:]]*(.*)"
|
#define CPARS_REGEX_PREFIX "("CPARS_PREFIX_EXTERN_S"|EXTERN|"CPARS_PREFIX_STATIC_S"|STATIC|volatile|near|far)[[:blank:]]*(.*)"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user