aboutsummaryrefslogtreecommitdiffstats
path: root/src/prop_info.c
blob: 95d4f58fe8789972ffbbb602d9c7883be33eca28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdint.h>

#include "prop_info.h"
#include "af-steering-wheel-binding.h"

#define ENABLE1_TYPENAME "ENABLE-1"	/* spec. type1.json original type name */

static const char *vartype_strings[] = {
/* 0 */	"void",
/* 1 */	"int8_t",
/* 2 */	"int16_t",
/* 3 */	"int",
/* 4 */	"int32_t",
/* 5 */	"int64_t",
/* 6 */	"uint8_t",
/* 7 */	"uint16_t",
/* 8 */	"uint",
/* 9 */	"uint32_t",
/* 10 */"uint64_t",
/* 11 */	"string",
/* 12 */	"bool",
/* 13 */	"LIST",
/* 14 */ ENABLE1_TYPENAME
};

int string2vartype(const char *varname)
{
	unsigned int i;
	if (varname == NULL)
	{
		return -1;
	}

	for(i=0; i < (sizeof(vartype_strings)/sizeof(char *)); i++)
	{
		if (strcmp(varname, vartype_strings[i]) == 0)
			return (int)i;
	}

	return -1;
};

int propertyValue_int(struct prop_info_t *property_info)
{
	int x = -1;
	switch(property_info->var_type) {
	case INT8_T:
		x = (int)property_info->curValue.int8_val;
		break;
	case INT16_T:
		x =	(int)property_info->curValue.int16_val;
		break;
	case VOID_T:/* FALLTHROGH */
	case INT_T:	/* FALLTHROGH */
	case INT32_T:/* FALLTHROGH */
		x =	(int)property_info->curValue.int32_val;
		break;
	case UINT8_T:
		x =	(int)property_info->curValue.uint8_val;
		break;
	case UINT16_T:
		x =	(int)property_info->curValue.uint16_val;
		break;
	case UINT_T:
	case UINT32_T:
		x = (int)property_info->curValue.uint32_val;
		break;
	case BOOL_T:
		x = (int)property_info->curValue.bool_val;
		break;
	case ENABLE1_T:
		x = (int)property_info->curValue.int32_val;
		break;

	default:
	case STRING_T:
	case ARRAY_T:
	case UINT64_T:
	case INT64_T:
		ERRMSG("Getting property Value:NOT SUPPORT vartype contents:%s %d", property_info->name, property_info->var_type);
		break;
	}
	return x;
}