Skip to content

Commit

Permalink
ignore ifdefs in source
Browse files Browse the repository at this point in the history
  • Loading branch information
lacraig2 committed Oct 21, 2024
1 parent e4cec3d commit cc777c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions panda/python/core/create_panda_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def copy_ppp_header(filename):
subcontents = trim_pypanda(contents)
for line in subcontents.split("\n"):
# now add void ppp_add_cb_{cb_name}({cb_name}_t);
forbidden = ["#if", "#endif", "#define "]
if any(i in line for i in forbidden):
continue
m = reg.match(line)
if m:
ret_type = m.groups(1)[0]
Expand Down Expand Up @@ -203,6 +206,8 @@ def define_clean_header(ffi, fname):
r = open(fname).read()
for line in r.split("\n"):
assert("extern \"C\" {" not in line), "Externs unsupported by CFFI. Change {} to a single line without braces".format(r)
forbidden = ["#if", "#endif"]
r = "\n".join([l for l in r.split("\n") if any(f in l for f in forbidden)])
r = r.replace("extern \"C\" ", "") # This allows inline externs like 'extern "C" void foo(...)'

reg = ppp_cb_typedef_regex()
Expand All @@ -229,6 +234,7 @@ def expand_ppp_def(line):
ffi.cdef("typedef int target_pid_t;")

ffi.cdef("typedef uint"+str(bits)+"_t target_ulong;")
ffi.cdef("typedef uint"+str(bits)+"_t target_ptr_t;")
ffi.cdef("typedef int"+str(bits)+"_t target_long;")

# PPP Headers
Expand Down

0 comments on commit cc777c8

Please sign in to comment.