|
|
|
@@ -183,6 +183,11 @@ STATIC void createVariableSpecificCheck(FILE *aFile, cfile_variable_t *aVariable
|
|
|
|
|
|
|
|
|
|
STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cfunction_parameter_t *aParameter, char aParameterIndex)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == aParameter->dataType)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (CPARAMETER_TYPE_FUNCPTR == aParameter->type)
|
|
|
|
|
{
|
|
|
|
|
// function pointer
|
|
|
|
@@ -193,7 +198,7 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf
|
|
|
|
|
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_POINTER_S";" NEWLINES, aFunction->name,
|
|
|
|
|
aFunction->name, aParameterIndex, aParameter->dataType);
|
|
|
|
|
}
|
|
|
|
|
else if (NULL != strstr(aParameter->dataType, "*") && NULL != strstr(aParameter->dataType, "char"))
|
|
|
|
|
else if (NULL != strstr(aParameter->dataType, "*") && NULL != strstr(aParameter->dataType, "char")) // TODO how to handle uchar (-> signed warning for strlen)
|
|
|
|
|
{
|
|
|
|
|
// char array with string comparison
|
|
|
|
|
fprintf(aFile, "\tif (" //
|
|
|
|
@@ -407,19 +412,9 @@ STATIC int8_t createStubCheck(char *aNoSuffix, FILE *aFile, FILE *aHeader, cfile
|
|
|
|
|
STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *aFunction)
|
|
|
|
|
{
|
|
|
|
|
cfunction_parameter_t *parameter = NULL;
|
|
|
|
|
char parameterIndex = 'a';
|
|
|
|
|
char parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
bool pointerAvailable = false;
|
|
|
|
|
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
if (NULL != strstr(parameter->dataType, "*") || parameter->array)
|
|
|
|
|
{
|
|
|
|
|
pointerAvailable = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
}
|
|
|
|
|
bool variableParameterAvailable = false;
|
|
|
|
|
|
|
|
|
|
if (NULL == aFile || NULL == aHeader || NULL == aFunction)
|
|
|
|
|
{
|
|
|
|
@@ -430,6 +425,21 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
if (NULL != strstr(NCHECK(parameter->dataType), "*") || parameter->array)
|
|
|
|
|
{
|
|
|
|
|
pointerAvailable = true;
|
|
|
|
|
}
|
|
|
|
|
if (CPARAMETER_TYPE_VARIABLE == parameter->type)
|
|
|
|
|
{
|
|
|
|
|
variableParameterAvailable = true;
|
|
|
|
|
}
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// start comments
|
|
|
|
|
fprintf(aFile, STUB_START_S1 NEWLINES, aFunction->name);
|
|
|
|
|
|
|
|
|
@@ -438,6 +448,12 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
fprintf(aFile, "#define "STUBINSTANCE_AMOUNT_S1" %d" NEWLINES, aFunction->name, STUB_INSTANCES_AMOUNT);
|
|
|
|
|
NEWLINE(aFile);
|
|
|
|
|
|
|
|
|
|
// TODO variable parameter structure
|
|
|
|
|
if (variableParameterAvailable)
|
|
|
|
|
{
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// parameter structure
|
|
|
|
|
fprintf(aFile, "// Expected parameter and return value structures" NEWLINES);
|
|
|
|
|
fprintf(aFile, "typedef struct _STUBPARAMETER_%s" NEWLINES, aFunction->name);
|
|
|
|
@@ -452,9 +468,16 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
fprintf(aFile, "\t%s "STUBPARAMETER_RETURN_S"; /*!< @brief return value */" NEWLINES, aFunction->dataType);
|
|
|
|
|
}
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
// TODO remove "const" from expected structure
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (CPARAMETER_TYPE_FUNCPTR == parameter->type)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aFile, "\t%s (*"STUBPARAMETER_PARAM_S1")%s; /*!< @brief \"%s\" */" NEWLINES, NCHECK(parameter->dataType), parameterIndex++,
|
|
|
|
@@ -497,11 +520,17 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
// pointer address check by default
|
|
|
|
|
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// initialize _size parameter to 1 (default to check addresses)
|
|
|
|
|
if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*")))
|
|
|
|
|
if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*"))) // TODO cast array parameter to be pointer
|
|
|
|
|
{
|
|
|
|
|
fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_POINTER_S"," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex,
|
|
|
|
|
parameter->dataType);
|
|
|
|
@@ -543,9 +572,15 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
fprintf(aHeader, " * @param " STUBINIT_PARAM_RETURN_S " Return value to inject" NEWLINES);
|
|
|
|
|
}
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (NULL != strstr(parameter->dataType, "*") || parameter->array)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aHeader,
|
|
|
|
@@ -568,13 +603,24 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
fprintf(aHeader, ", %s "STUBINIT_PARAM_RETURN_S, aFunction->dataType);
|
|
|
|
|
}
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType && CPARAMETER_TYPE_VARIABLE != parameter->type)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (CPARAMETER_TYPE_FUNCPTR == parameter->type)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aHeader, ", %s (*"STUBINIT_PARAM_PARAMETER_S1")%s", NCHECK(parameter->dataType), parameterIndex++, NCHECK(parameter->array));
|
|
|
|
|
}
|
|
|
|
|
else if (CPARAMETER_TYPE_VARIABLE == parameter->type)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aHeader, ", %s", NCHECK(parameter->name));
|
|
|
|
|
++parameterIndex;
|
|
|
|
|
}
|
|
|
|
|
else if (NULL != strstr(parameter->dataType, "*") || parameter->array)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aHeader, ", %s "STUBINIT_PARAM_PARAMETER_S1"%s", NCHECK(parameter->dataType), parameterIndex, NCHECK(parameter->array));
|
|
|
|
@@ -599,13 +645,24 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
fprintf(aFile, ", %s "STUBINIT_PARAM_RETURN_S, aFunction->dataType);
|
|
|
|
|
}
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType && CPARAMETER_TYPE_VARIABLE != parameter->type)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (CPARAMETER_TYPE_FUNCPTR == parameter->type)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aFile, ", %s (*"STUBINIT_PARAM_PARAMETER_S1")%s", NCHECK(parameter->dataType), parameterIndex++, NCHECK(parameter->array));
|
|
|
|
|
}
|
|
|
|
|
else if (CPARAMETER_TYPE_VARIABLE == parameter->type)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aFile, ", %s", NCHECK(parameter->name));
|
|
|
|
|
++parameterIndex;
|
|
|
|
|
}
|
|
|
|
|
else if (NULL != strstr(parameter->dataType, "*") || parameter->array)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aFile, ", %s "STUBINIT_PARAM_PARAMETER_S1"%s", NCHECK(parameter->dataType), parameterIndex, NCHECK(parameter->array));
|
|
|
|
@@ -642,9 +699,15 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
aFunction->name);
|
|
|
|
|
}
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
fprintf(aFile, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1" = "STUBINIT_PARAM_PARAMETER_S1";" NEWLINES,
|
|
|
|
|
aFunction->name, parameterIndex, parameterIndex);
|
|
|
|
|
if ((NULL != strstr(parameter->dataType, "*") || parameter->array) && CPARAMETER_TYPE_FUNCPTR != parameter->type)
|
|
|
|
@@ -666,9 +729,15 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
aFunction->name);
|
|
|
|
|
}
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// initialize _size parameter to 1 (default to check addresses)
|
|
|
|
|
if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*")))
|
|
|
|
|
{
|
|
|
|
@@ -695,14 +764,25 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
// stub function
|
|
|
|
|
fprintf(aFile, "%s %s %s(", NCHECK(aFunction->prefix), NCHECK(aFunction->dataType), NCHECK(aFunction->name)); // todo remove leading " " when prefix is missing
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType && CPARAMETER_TYPE_VARIABLE != parameter->type)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (CPARAMETER_TYPE_FUNCPTR == parameter->type)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aFile, "%s (*"STUBINIT_PARAM_PARAMETER_S1")%s%s", NCHECK(parameter->dataType), parameterIndex++, NCHECK(parameter->array),
|
|
|
|
|
(NULL != parameter->next ? ", " : ""));
|
|
|
|
|
}
|
|
|
|
|
else if (CPARAMETER_TYPE_VARIABLE == parameter->type)
|
|
|
|
|
{
|
|
|
|
|
fprintf(aFile, "%s%s",NCHECK(parameter->name),(NULL != parameter->next ? ", " : ""));
|
|
|
|
|
++parameterIndex;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf(aFile, "%s "STUBINIT_PARAM_PARAMETER_S1"%s%s", NCHECK(parameter->dataType), parameterIndex++, NCHECK(parameter->array),
|
|
|
|
@@ -727,9 +807,15 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|
|
|
|
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_CALLTEST_S" = STUB_CALL_FAIL;" NEWLINES, aFunction->name, aFunction->name);
|
|
|
|
|
|
|
|
|
|
parameter = aFunction->parameter.head;
|
|
|
|
|
parameterIndex = 'a';
|
|
|
|
|
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
|
|
|
|
|
while (parameter)
|
|
|
|
|
{
|
|
|
|
|
// skip parameter without dataType
|
|
|
|
|
if (NULL == parameter->dataType)
|
|
|
|
|
{
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
createParameterSpecificCheck(aFile, aFunction, parameter, parameterIndex);
|
|
|
|
|
++parameterIndex;
|
|
|
|
|
parameter = parameter->next;
|
|
|
|
|