Skip to content

Commit

Permalink
Fixed extract script for newer icsnVC40.h.
Browse files Browse the repository at this point in the history
Signed-off-by: David Rebbe <drebbe@intrepidcs.com>
  • Loading branch information
drebbe-intrepid committed May 7, 2019
1 parent 105a038 commit d10d0ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
8 changes: 6 additions & 2 deletions extract_icsneo40_defines.py
Expand Up @@ -25,7 +25,7 @@
print("\nint setup_module_auto_defines(PyObject * module);\n", file=f)
print("#endif // __SETUP_MODULE_AUTO_DEFINES_H__", file=f)

ignores = ('(', '#endif', '#define', 'icscm_', 'GCC_MODIFIER', 'VS_MODIFIER', '{', 'ICSNVC40_H', 'ICSNVC40INTERNAL__H_', 'SYellowSettings_SIZE')
ignores = ('(', '#endif', '#define', 'icscm_', 'GCC_MODIFIER', 'VS_MODIFIER', '{', 'ICSNVC40_H', 'ICSNVC40INTERNAL__H_', 'SYellowSettings_SIZE', 'IS_64BIT_SYSTEM')
use_enums = True
with open('src/setup_module_auto_defines.cpp', 'w') as f:
print(boiler_plate, file=f)
Expand Down Expand Up @@ -74,13 +74,17 @@
print('\tresult += PyModule_AddIntMacro(module, %s);' % sline[0].replace(',', ''), file=f)
continue
if '#define' in line:
sline = line.split()
sline = line.split('//')[0].split()
# DEBUG: print('\t\t' + str(line_number) + '\t' + str(sline))
if any(x in sline[1] for x in ignores):
continue
if len(sline) >= 3 and re.match("^\d+?\.\d+?$", sline[2]) is not None:
# Value is a float
print('\tresult += PyModule_AddObject(module, "{0}", PyFloat_FromDouble({0}));'.format(sline[1]), file=f)
elif len(sline) == 2:
# There is no value, this is used for preprocessor only
# and really shouldn't care about it in python. Going to set it as 0 "just in case"
print('\tresult += PyModule_AddObject(module, "{}", PyLong_FromLong(0));'.format(sline[1]), file=f)
else:
print('\tresult += PyModule_AddIntMacro(module, %s);' % sline[1], file=f)

Expand Down
25 changes: 12 additions & 13 deletions src/setup_module_auto_defines.cpp
Expand Up @@ -12,7 +12,6 @@ int setup_module_auto_defines(PyObject * module)
{
int result = 0;

result += PyModule_AddIntMacro(module, IS_64BIT_SYSTEM);
result += PyModule_AddIntMacro(module, NEOVI_COMMTYPE_RS232);
result += PyModule_AddIntMacro(module, NEOVI_COMMTYPE_USB_BULK);
result += PyModule_AddIntMacro(module, NEOVI_COMMTYPE_TCPIP);
Expand Down Expand Up @@ -531,18 +530,18 @@ int setup_module_auto_defines(PyObject * module)
result += PyModule_AddIntMacro(module, ECU_AVBSettings_SIZE);
result += PyModule_AddIntMacro(module, SJA1105_NUM_PRIORITY);
result += PyModule_AddIntMacro(module, SJA1105_NUM_PORTS);
result += PyModule_AddIntMacro(module, SJA1105_PORT_ENABLE_INGRESS//allow);
result += PyModule_AddIntMacro(module, SJA1105_PORT_ENABLE_EGRESS//allow);
result += PyModule_AddIntMacro(module, SJA1105_PORT_DYN_LEARN//enable);
result += PyModule_AddIntMacro(module, SJA1105_PORT_RETAG//retag);
result += PyModule_AddIntMacro(module, SJA1105_PORT_ING_MIRR//forward);
result += PyModule_AddIntMacro(module, SJA1105_PORT_EGR_MIRR//forward);
result += PyModule_AddIntMacro(module, SJA1105_PORT_DROP_UNTAGGED//drop);
result += PyModule_AddIntMacro(module, SJA1105_PORT_DROP_DOUBLE_TAG//drop);
result += PyModule_AddIntMacro(module, SJA1105_PORT_DROPA664//only);
result += PyModule_AddIntMacro(module, SJA1105_GEN_IGNORE_2_STEP);
result += PyModule_AddIntMacro(module, SJA1105_GEN_MIRROR_PORT_DYNAMIC//if);
result += PyModule_AddIntMacro(module, SJA1105_GEN_VLLUPFORMAT);
result += PyModule_AddObject(module, "SJA1105_PORT_ENABLE_INGRESS", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_PORT_ENABLE_EGRESS", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_PORT_DYN_LEARN", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_PORT_RETAG", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_PORT_ING_MIRR", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_PORT_EGR_MIRR", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_PORT_DROP_UNTAGGED", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_PORT_DROP_DOUBLE_TAG", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_PORT_DROPA664", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_GEN_IGNORE_2_STEP", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_GEN_MIRROR_PORT_DYNAMIC", PyLong_FromLong(0));
result += PyModule_AddObject(module, "SJA1105_GEN_VLLUPFORMAT", PyLong_FromLong(0));
result += PyModule_AddIntMacro(module, SRADPlutoSettings_SIZE);
result += PyModule_AddIntMacro(module, CANHubSettings_SIZE);
result += PyModule_AddIntMacro(module, SFlexVnetzSettings_Size);
Expand Down

0 comments on commit d10d0ce

Please sign in to comment.