Changeset 2340de6 in buchla-68k for misc


Ignore:
Timestamp:
07/10/2017 09:06:56 PM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
4aa78b2
Parents:
526a993
Message:

Keep macros in external declarations.

Location:
misc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • misc/gen-x.py

    r526a993 r2340de6  
    33from sys import stdout
    44from pycparser import c_ast, parse_file, c_generator
     5from re import escape, subn, search
    56
    67cross_gcc = "/opt/cross-m68k/bin/m68k-none-elf-gcc"
     
    7778    def get_typs(self):
    7879        return self.typs
     80
     81def fix(text, path):
     82    with open(path, "r") as f:
     83        cont = f.read()
     84
     85    (pat, n) = subn(r"\[[0-9]+\]", "[@]", text[7:])
     86
     87    if n == 0:
     88        return text
     89
     90    rex = escape(pat). \
     91         replace("\@", "([0-9A-Z_]+)"). \
     92         replace("\ ", "[\t\n ]+")
     93
     94    m = search(rex, cont)
     95
     96    if not m:
     97        raise Exception("error while matching {}".format(re))
     98
     99    pats = pat.split("@")
     100    vals = m.groups()
     101
     102    if len(pats) != len(vals) + 1:
     103        raise Exception("length mismatch: {} vs. {}". \
     104                        format(len(pats), len(vals)))
     105
     106    out = pats[0]
     107    pats = pats[1:]
     108
     109    while len(pats) > 0:
     110        out += vals[0] + pats[0]
     111        vals = vals[1:]
     112        pats = pats[1:]
     113
     114    return "extern " + out
    79115
    80116gen = c_generator.CGenerator()
     
    130166            decl.init = None
    131167
    132             toks = gen.visit(decl).split(" ")
     168            text = gen.visit(decl)
     169            text = fix(text, decl.coord.file)
     170
     171            toks = text.split(" ")
    133172            alig = ""
    134173
  • misc/proto.x

    r526a993 r2340de6  
    1111#include "slice.h"
    1212#include "stdint.h"
     13#include "timers.h"
    1314#include "vsdd.h"
    1415
     
    4243extern  void            (*pulse1)(void);
    4344extern  void            (*pulse2)(void);
    44 extern  int16_t         timers[8];
     45extern  int16_t         timers[NTIMERS];
    4546extern  int32_t         uldivr;
    4647extern  uint16_t        vi_sadr;
Note: See TracChangeset for help on using the changeset viewer.