{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Postprocessing and preprocessing\n", "\n", "## Header preprocessing\n", "\n", "If you need to preprocess header code before the generation, you can create a function that transforms the source code, and store it inside `options.srcmlcpp_options.code_preprocess_function`\n", "\n", "For example:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
int add(int, int b);\n",
"
def add(param_0: Int32, b: Int32) -> Int32:\n",
" pass\n",
"
m.def("add",\n",
" add, py::arg("param_0"), py::arg("b"));\n",
"
int AnswerToTheUltimateQuestionOfLife_TheUniverse_AndEverything() { return 42; }\n",
"
# Copyright(c) 2023 - Pascal Thomet\n",
"# Yes, I claim the copyright on this magnificent function.\n",
"# ...At least, I tried...\n",
"\n",
"def answer_to_the_ultimate_question_of_life_the_universe_and_everything() -> int:\n",
" pass\n",
"
// Copyright(c) 2023 - Pascal Thomet\n",
"// Yes, I claim the copyright on this magnificent function.\n",
"// ...At least, I tried...\n",
"m.def("answer_to_the_ultimate_question_of_life_the_universe_and_everything",\n",
" AnswerToTheUltimateQuestionOfLife_TheUniverse_AndEverything);\n",
"