| 32 | |
| 33 | |
| 34 | class CLanguage(Language): |
| 35 | |
| 36 | body_prefix = "#" |
| 37 | language = 'C' |
| 38 | start_line = "/*[{dsl_name} input]" |
| 39 | body_prefix = "" |
| 40 | stop_line = "[{dsl_name} start generated code]*/" |
| 41 | checksum_line = "/*[{dsl_name} end generated code: {arguments}]*/" |
| 42 | |
| 43 | COMPILER_DEPRECATION_WARNING_PROTOTYPE: Final[str] = r""" |
| 44 | // Emit compiler warnings when we get to Python {major}.{minor}. |
| 45 | #if PY_VERSION_HEX >= 0x{major:02x}{minor:02x}00C0 |
| 46 | # error {message} |
| 47 | #elif PY_VERSION_HEX >= 0x{major:02x}{minor:02x}00A0 |
| 48 | # ifdef _MSC_VER |
| 49 | # pragma message ({message}) |
| 50 | # else |
| 51 | # warning {message} |
| 52 | # endif |
| 53 | #endif |
| 54 | """ |
| 55 | DEPRECATION_WARNING_PROTOTYPE: Final[str] = r""" |
| 56 | if ({condition}) {{{{{errcheck} |
| 57 | if (PyErr_WarnEx(PyExc_DeprecationWarning, |
| 58 | {message}, 1)) |
| 59 | {{{{ |
| 60 | goto exit; |
| 61 | }}}} |
| 62 | }}}} |
| 63 | """ |
| 64 | |
| 65 | def __init__(self, filename: str) -> None: |
| 66 | super().__init__(filename) |
| 67 | self.cpp = libclinic.cpp.Monitor(filename) |
| 68 | |
| 69 | def parse_line(self, line: str) -> None: |
| 70 | self.cpp.writeline(line) |
| 71 | |
| 72 | def render( |
| 73 | self, |
| 74 | clinic: Clinic, |
| 75 | signatures: Iterable[Module | Class | Function] |
| 76 | ) -> str: |
| 77 | function = None |
| 78 | for o in signatures: |
| 79 | if isinstance(o, Function): |
| 80 | if function: |
| 81 | fail("You may specify at most one function per block.\nFound a block containing at least two:\n\t" + repr(function) + " and " + repr(o)) |
| 82 | function = o |
| 83 | return self.render_function(clinic, function) |
| 84 | |
| 85 | def compiler_deprecated_warning( |
| 86 | self, |
| 87 | func: Function, |
| 88 | parameters: list[Parameter], |
| 89 | ) -> str | None: |
| 90 | minversion: VersionTuple | None = None |
| 91 | for p in parameters: |
no outgoing calls
searching dependent graphs…